common.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import store from '@/store/index'
export const Common = {
setAuthBtn(resData) {
let data = resData || store.getters.curMenuAuth.data
const authBtnEl = document.getElementsByTagName('button')
const authStringArr = ['新增', '编辑', '删除', '导出', '导入', '修改', '解绑']
if (authBtnEl && authBtnEl.length > 0) {
if (data && data.length > 0) {
authBtnEl.forEach(elItem => {
let flag = true
let authFlag = false
const elText = elItem.innerText
authStringArr.forEach(authItem => {
if (elText.includes(authItem)) {
authFlag = true
return
}
})
if (authFlag) {
data.forEach(labelItem => {
if (flag) {
elItem.style.display = 'none'
if (elText.includes(labelItem.label)) {
elItem.style.display = 'inline-block'
flag = false
}
}
})
}
})
}
}
},
getAuthData() {
return store.getters.curMenuAuth.data
}
}