【modify】使用ESLint格式化代码
This commit is contained in:
@@ -1,131 +1,130 @@
|
||||
import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
|
||||
import { USER_AUTH, SYS_BUTTON_AUTH } from '@/store/mutation-types'
|
||||
|
||||
const hasPermission = {
|
||||
install (Vue, options) {
|
||||
Vue.directive('has', {
|
||||
inserted: (el, binding, vnode)=>{
|
||||
//console.time()
|
||||
//节点权限处理,如果命中则不进行全局权限处理
|
||||
if(!filterNodePermission(el, binding, vnode)){
|
||||
filterGlobalPermission(el, binding, vnode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
install (Vue, options) {
|
||||
Vue.directive('has', {
|
||||
inserted: (el, binding, vnode) => {
|
||||
// console.time()
|
||||
// 节点权限处理,如果命中则不进行全局权限处理
|
||||
if (!filterNodePermission(el, binding, vnode)) {
|
||||
filterGlobalPermission(el, binding, vnode)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程节点权限控制
|
||||
*/
|
||||
export function filterNodePermission(el, binding, vnode) {
|
||||
let permissionList = [];
|
||||
export function filterNodePermission (el, binding, vnode) {
|
||||
const permissionList = []
|
||||
try {
|
||||
let obj = vnode.context.$props.formData;
|
||||
const obj = vnode.context.$props.formData
|
||||
if (obj) {
|
||||
let bpmList = obj.permissionList;
|
||||
for (let bpm of bpmList) {
|
||||
if(bpm.type != '2') {
|
||||
permissionList.push(bpm);
|
||||
const bpmList = obj.permissionList
|
||||
for (const bpm of bpmList) {
|
||||
if (bpm.type != '2') {
|
||||
permissionList.push(bpm)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log("页面权限异常----", e);
|
||||
// console.log("页面权限异常----", e);
|
||||
}
|
||||
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
|
||||
//el.parentNode.removeChild(el)
|
||||
return false;
|
||||
if (permissionList === null || permissionList === '' || permissionList === undefined || permissionList.length <= 0) {
|
||||
// el.parentNode.removeChild(el)
|
||||
return false
|
||||
}
|
||||
|
||||
console.log("流程节点页面权限--NODE--");
|
||||
let permissions = [];
|
||||
for (let item of permissionList) {
|
||||
if(item.type != '2') {
|
||||
permissions.push(item.action);
|
||||
console.log('流程节点页面权限--NODE--')
|
||||
const permissions = []
|
||||
for (const item of permissionList) {
|
||||
if (item.type != '2') {
|
||||
permissions.push(item.action)
|
||||
}
|
||||
}
|
||||
//console.log("页面权限----"+permissions);
|
||||
//console.log("页面权限----"+binding.value);
|
||||
// console.log("页面权限----"+permissions);
|
||||
// console.log("页面权限----"+binding.value);
|
||||
if (!permissions.includes(binding.value)) {
|
||||
//el.parentNode.removeChild(el)
|
||||
return false;
|
||||
}else{
|
||||
for (let item2 of permissionList) {
|
||||
if(binding.value === item2.action){
|
||||
return true;
|
||||
// el.parentNode.removeChild(el)
|
||||
return false
|
||||
} else {
|
||||
for (const item2 of permissionList) {
|
||||
if (binding.value === item2.action) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局权限控制
|
||||
*/
|
||||
export function filterGlobalPermission(el, binding, vnode) {
|
||||
export function filterGlobalPermission (el, binding, vnode) {
|
||||
const permissionList = []
|
||||
const allPermissionList = []
|
||||
|
||||
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 authList = Vue.ls.get(USER_AUTH);
|
||||
const authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
|
||||
for (const auth of authList) {
|
||||
if (auth.type != '2') {
|
||||
permissionList.push(auth)
|
||||
}
|
||||
}
|
||||
//console.log("页面权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
|
||||
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");
|
||||
for (let gauth of allAuthList) {
|
||||
if(gauth.type != '2') {
|
||||
allPermissionList.push(gauth);
|
||||
// console.log("页面权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
|
||||
const allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
|
||||
for (const 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(binding.value === itemG.action){
|
||||
if(itemG.status == '0'){
|
||||
invalidFlag = true;
|
||||
break;
|
||||
// 设置全局配置是否有命中
|
||||
let invalidFlag = false// 无效命中
|
||||
if (allPermissionList != null && allPermissionList != '' && allPermissionList != undefined && allPermissionList.length > 0) {
|
||||
for (const itemG of allPermissionList) {
|
||||
if (binding.value === itemG.action) {
|
||||
if (itemG.status == '0') {
|
||||
invalidFlag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(invalidFlag){
|
||||
return;
|
||||
if (invalidFlag) {
|
||||
return
|
||||
}
|
||||
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
|
||||
el.parentNode.removeChild(el);
|
||||
return;
|
||||
if (permissionList === null || permissionList === '' || permissionList === undefined || permissionList.length <= 0) {
|
||||
el.parentNode.removeChild(el)
|
||||
return
|
||||
}
|
||||
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]);
|
||||
const permissions = []
|
||||
for (const 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(',')) {
|
||||
const 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);
|
||||
} else {
|
||||
permissions.push(item.action)
|
||||
}
|
||||
}
|
||||
//update--end--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU------
|
||||
// update--end--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU------
|
||||
}
|
||||
}
|
||||
if (!permissions.includes(binding.value)) {
|
||||
el.parentNode.removeChild(el);
|
||||
el.parentNode.removeChild(el)
|
||||
}
|
||||
}
|
||||
|
||||
export default hasPermission;
|
||||
export default hasPermission
|
||||
|
||||
Reference in New Issue
Block a user