|
|
@ -94,7 +94,7 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import {searchSysLanguage} from "@/api/sysLanguage.js" |
|
|
import {searchSysLanguage} from "@/api/sysLanguage.js" |
|
|
import {getUserAuthorizedSites} from "@/api/factory/accessSite.js" |
|
|
|
|
|
|
|
|
import {getUserAuthorizedSites, getUserAuthorizedSubSiteCodes} from "@/api/factory/accessSite.js" |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
@ -170,6 +170,26 @@ export default { |
|
|
this.$message.error('获取工厂列表失败'); |
|
|
this.$message.error('获取工厂列表失败'); |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 登录后缓存用户子site编码集合,供后续页面按需使用 |
|
|
|
|
|
cacheUserAuthorizedSubSiteCodes(userName, site) { |
|
|
|
|
|
if (!userName || !userName.trim() || !site) { |
|
|
|
|
|
this.$store.commit('user/updateSubSiteCodeList', []) |
|
|
|
|
|
localStorage.setItem('userSubSiteCodeList', JSON.stringify([])) |
|
|
|
|
|
return Promise.resolve([]) |
|
|
|
|
|
} |
|
|
|
|
|
return getUserAuthorizedSubSiteCodes({ userName: userName.trim(), site: site }).then(({data}) => { |
|
|
|
|
|
const sourceList = (data && data.code === 0) ? (data.data || []) : [] |
|
|
|
|
|
const subSiteCodeList = Array.from(new Set((sourceList || []).filter(item => !!item))) |
|
|
|
|
|
this.$store.commit('user/updateSubSiteCodeList', subSiteCodeList) |
|
|
|
|
|
localStorage.setItem('userSubSiteCodeList', JSON.stringify(subSiteCodeList)) |
|
|
|
|
|
return subSiteCodeList |
|
|
|
|
|
}).catch(error => { |
|
|
|
|
|
console.error('缓存子site编码失败:', error) |
|
|
|
|
|
this.$store.commit('user/updateSubSiteCodeList', []) |
|
|
|
|
|
localStorage.setItem('userSubSiteCodeList', JSON.stringify([])) |
|
|
|
|
|
return [] |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
dataFormSubmit() { |
|
|
dataFormSubmit() { |
|
|
if (!this.selectedSite) { |
|
|
if (!this.selectedSite) { |
|
|
this.$message.error('请选择工厂'); |
|
|
this.$message.error('请选择工厂'); |
|
|
@ -194,8 +214,9 @@ export default { |
|
|
localStorage.setItem('site', this.selectedSite); |
|
|
localStorage.setItem('site', this.selectedSite); |
|
|
|
|
|
|
|
|
this.$store.commit('user/updateSite', this.selectedSite); |
|
|
this.$store.commit('user/updateSite', this.selectedSite); |
|
|
|
|
|
|
|
|
|
|
|
this.cacheUserAuthorizedSubSiteCodes(this.dataForm.userName, this.selectedSite).finally(() => { |
|
|
this.$router.replace({ name: 'home' }); |
|
|
this.$router.replace({ name: 'home' }); |
|
|
|
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
this.$alert(data.msg, '错误', { |
|
|
this.$alert(data.msg, '错误', { |
|
|
confirmButtonText: '确定' |
|
|
confirmButtonText: '确定' |
|
|
|