[update] - 增加是否是内部企业的权限设置

This commit is contained in:
fengchenchen
2022-04-26 14:05:37 +08:00
parent b4bfed5fa9
commit 3b22191e50
2 changed files with 82 additions and 7 deletions
+66
View File
@@ -134,4 +134,70 @@ export function filterGlobalPermission(el, binding, vnode) {
}
}
/*
* 导出一个可以在js中做是否有权限判断的方法
* */
export function judgeGlobalPermission(bindingValue) {
let permissionList = []
let allPermissionList = []
//let authList = Vue.ls.get(USER_AUTH);
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
for (let auth of authList) {
if(auth.type != '2') {
permissionList.push(auth)
}
}
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
for (let gauth of allAuthList) {
if(gauth.type != '2') {
allPermissionList.push(gauth)
}
}
//设置全局配置是否有命中
let invalidFlag = false//无效命中
if(allPermissionList != null && allPermissionList != '' && allPermissionList != undefined && allPermissionList.length > 0){
for (let itemG of allPermissionList) {
if(bindingValue === itemG.action){
if(itemG.status == '0'){
invalidFlag = true
break
}
}
}
}
if(invalidFlag){
return true
}
if (permissionList === null || permissionList === '' || permissionList === undefined||permissionList.length<=0) {
return false
}
let permissions = []
for (let item of permissionList) {
//权限策略1显示2禁用
if(item.type != '2'){
//update--begin--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU-------
if(item.action){
if(item.action.includes(',')){
let split = item.action.split(',')
for (let i = 0; i <split.length ; i++) {
if(!split[i] ||split[i].length==0){
continue
}
permissions.push(split[i])
}
}else{
permissions.push(item.action)
}
}
//update--end--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU------
}
}
if (!permissions.includes(bindingValue)) {
return false
}
return true
}
export default hasPermission
@@ -88,6 +88,14 @@ import PageHeaderTitle from '@comp/layouts/PageHeaderTitle'
import IconImg from '@/assets/imgs/icon/icon_company_management.png'
import { aduitCompany, checkContactByCompany, updateInternalEnterprise } from '../../api/incomePaymentsApi'
import { getAction } from '../../api/manage'
import { judgeGlobalPermission } from '../../utils/hasPermission'
const otherColumnItem = {
title: '是否是内部企业',
align: 'center',
width: 150,
dataIndex: 'internalEnterprise',
scopedSlots: { customRender: 'switch' }
}
export default {
name: 'BusinessManagement',
@@ -159,12 +167,6 @@ export default {
dataIndex: 'bankAccountName',
scopedSlots: { customRender: 'text' }
}, {
title: '是否是内部企业',
align: 'center',
width: 150,
dataIndex: 'internalEnterprise',
scopedSlots: { customRender: 'switch' }
},{
title: '操作',
dataIndex: 'action',
align: 'center',
@@ -299,7 +301,6 @@ export default {
}
},
onSwitchChange(val, record) {
console.log('---------val, record--------', val, record)
let params = {
id: record.id,
internalEnterprise: val
@@ -310,11 +311,19 @@ export default {
this.$message.success(res.message)
this.loadData()
} else {
this.$message.error(res.message)
this.isLoading = false
}
}, () => {
this.isLoading = false
})
},
// 加载数据字典的方法,此处做其他数据的处理
initDictConfig() {
let hasPermission = judgeGlobalPermission('company:updateInternalEnterprise')
if(hasPermission) {
this.columns.splice(this.columns.length - 1, 0, otherColumnItem)
}
}
}
}