|
|
@ -32,7 +32,7 @@ |
|
|
|
v-model:value="searchValue" |
|
|
|
style="margin-bottom: 8px" |
|
|
|
@search="onSearch" /> --> |
|
|
|
<a-tree v-if="treeData?.length" v-model:checkedKeys="checkedKeys" v-bind="serverTree" /> |
|
|
|
<a-tree v-if="treeData?.length" v-model:checkedKeys="checkedKeys" v-bind="serverTree"/> |
|
|
|
</ns-drawer> |
|
|
|
|
|
|
|
<TreeAdd ref="treeAdd" @ok="handleOk" :info="currentBoundaryRecord" /> |
|
|
@ -82,9 +82,10 @@ |
|
|
|
const comApi = computed(() => { |
|
|
|
return calMap[opType.value as keyof typeof calMap]; |
|
|
|
}); |
|
|
|
|
|
|
|
// 公共请求方法,包含tablereload,drawerclose |
|
|
|
const fetch = (params, isReload = true) => { |
|
|
|
console.log(params) |
|
|
|
console.log(comApi.value) |
|
|
|
http.post(comApi.value, params).then(() => { |
|
|
|
NsMessage.success('操作成功'); |
|
|
|
onClose(); |
|
|
@ -197,10 +198,61 @@ |
|
|
|
// 获取服务权限树 |
|
|
|
const getTree = (params) => { |
|
|
|
return http.post(enterPrise.permissionTree, params).then((res) => { |
|
|
|
treeData.value = res.data?.data; |
|
|
|
// treeData.value = res.data?.data; |
|
|
|
let dataTreeList = res.data?.data; |
|
|
|
let getDataTreeList = dataTreeListReply(dataTreeList) |
|
|
|
treeData.value = filterTreeData(getDataTreeList); |
|
|
|
}); |
|
|
|
}; |
|
|
|
getTree({}); |
|
|
|
// 递归处理权限树数据(将子级为空的节点增加“hidden"标识) |
|
|
|
const dataTreeListReply =(data:any)=>{ |
|
|
|
return data.map(item => { |
|
|
|
if (item.menus && item.menus.length > 0) { |
|
|
|
return { |
|
|
|
...item, |
|
|
|
menus: dataTreeListReply(item.menus), |
|
|
|
}; |
|
|
|
} |
|
|
|
if (item.menus && item.menus.length == 0) { |
|
|
|
item.hidden = true; |
|
|
|
} |
|
|
|
return item; |
|
|
|
}); |
|
|
|
} |
|
|
|
//递归处理服务权限树数据(将子级menus为空的节点隐藏) |
|
|
|
const filterTreeData = (data:any) => { |
|
|
|
return data.map(item => { |
|
|
|
//方法一:给子节点menus为空的当前节点增加样式控制显示隐藏 |
|
|
|
if (item.menus && item.menus.length > 0) { |
|
|
|
item.menus.map(itemchild=>{ |
|
|
|
if(itemchild.menus && itemchild.menus.length==0){ |
|
|
|
item.class = 'parentNodeArrowHide'; |
|
|
|
} |
|
|
|
}) |
|
|
|
return { |
|
|
|
...item, |
|
|
|
menus: filterTreeData(item.menus), |
|
|
|
}; |
|
|
|
}else{ |
|
|
|
if(item.hidden){ |
|
|
|
item.class = 'leafNodeHide'; |
|
|
|
} |
|
|
|
} |
|
|
|
return item; |
|
|
|
}) |
|
|
|
//方法二:递归过滤掉滤掉hidden的节点 |
|
|
|
// return data.filter(item => !item.hidden).map(item => { |
|
|
|
// if (item.menus) { |
|
|
|
// return { |
|
|
|
// ...item, |
|
|
|
// menus: filterTreeData(item.menus), |
|
|
|
// }; |
|
|
|
// } |
|
|
|
// return item; |
|
|
|
// }); |
|
|
|
} |
|
|
|
|
|
|
|
getTree({}) |
|
|
|
|
|
|
|
// 获取当前企业拥有的权限数据 |
|
|
|
const getPermissionData = (params) => { |
|
|
@ -354,3 +406,11 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
<style> |
|
|
|
.leafNodeHide{ |
|
|
|
display:none!important; |
|
|
|
} |
|
|
|
.parentNodeArrowHide .ant-tree-switcher{ |
|
|
|
visibility: hidden; |
|
|
|
} |
|
|
|
</style> |
|
|
|