|
|
|
@ -14,6 +14,7 @@ |
|
|
|
class="menu-item" |
|
|
|
v-for="(btn, index) in buttons" |
|
|
|
:key="index" |
|
|
|
v-site-auth="btn.siteAuth || '*'" |
|
|
|
:class="{ 'disabled': btn.disabled }" |
|
|
|
@click="handleButtonClick(btn)" |
|
|
|
> |
|
|
|
@ -31,12 +32,69 @@ export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
buttons: [ |
|
|
|
{ icon: 'scan', label: '直接退料', iconClass: 'direct', to: 'productionReturnPicking', disabled: false }, |
|
|
|
{ icon: 'records', label: '申请单退料', iconClass: 'request', to: 'productionReturnPDA', disabled: false }, |
|
|
|
{ icon: 'scan', label: '直接退料', iconClass: 'direct', to: 'productionReturnPicking', disabled: false, siteAuth: '*' }, |
|
|
|
{ icon: 'records', label: '申请单退料', iconClass: 'request', to: 'productionReturnPDA', disabled: false, siteAuth: '55' }, |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
directives: { |
|
|
|
// 与 main.vue 的 v-site-auth 一致:* 或命中当前 site 才显示 |
|
|
|
siteAuth: { |
|
|
|
inserted(el, binding, vnode) { |
|
|
|
if (vnode.context && vnode.context.applySiteAuthForElement) { |
|
|
|
vnode.context.applySiteAuthForElement(el, binding); |
|
|
|
} |
|
|
|
}, |
|
|
|
componentUpdated(el, binding, vnode) { |
|
|
|
if (vnode.context && vnode.context.applySiteAuthForElement) { |
|
|
|
vnode.context.applySiteAuthForElement(el, binding); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
currentSite() { |
|
|
|
const storeSite = this.$store.state.user.site; |
|
|
|
const normalizedStoreSite = |
|
|
|
storeSite === null || storeSite === undefined |
|
|
|
? '' |
|
|
|
: String(storeSite).trim(); |
|
|
|
if (normalizedStoreSite && normalizedStoreSite !== '0') { |
|
|
|
return normalizedStoreSite; |
|
|
|
} |
|
|
|
return (localStorage.getItem('site') || '').trim(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
normalizeMenuSiteAuthValue(siteAuthValue) { |
|
|
|
const rawValue = |
|
|
|
siteAuthValue === null || siteAuthValue === undefined |
|
|
|
? '*' |
|
|
|
: String(siteAuthValue).trim(); |
|
|
|
return rawValue === '' ? '*' : rawValue; |
|
|
|
}, |
|
|
|
isMenuVisibleForCurrentSite(siteAuthValue) { |
|
|
|
const normalizedAuthValue = this.normalizeMenuSiteAuthValue(siteAuthValue); |
|
|
|
if (normalizedAuthValue === '*') { |
|
|
|
return true; |
|
|
|
} |
|
|
|
const currentSite = this.currentSite; |
|
|
|
if (!currentSite) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
const authSiteList = normalizedAuthValue |
|
|
|
.split(',') |
|
|
|
.map((item) => item.trim()) |
|
|
|
.filter((item) => item !== ''); |
|
|
|
return ( |
|
|
|
authSiteList.includes('*') || |
|
|
|
authSiteList.includes(String(currentSite).trim()) |
|
|
|
); |
|
|
|
}, |
|
|
|
applySiteAuthForElement(el, binding) { |
|
|
|
const isVisible = this.isMenuVisibleForCurrentSite(binding.value); |
|
|
|
el.style.display = isVisible ? '' : 'none'; |
|
|
|
}, |
|
|
|
handleButtonClick(btn) { |
|
|
|
if (btn.disabled) { |
|
|
|
this.$message.warning('正在开发中,敬请期待...'); |
|
|
|
|