|
@@ -45,7 +45,7 @@
|
|
|
|
|
|
<HcDialog bgColor="#ffffff" isToBody isTable :show="authModal" title="权限配置" @save="authModalSave" @close="authModalClose" widths="40rem">
|
|
<HcDialog bgColor="#ffffff" isToBody isTable :show="authModal" title="权限配置" @save="authModalSave" @close="authModalClose" widths="40rem">
|
|
<el-scrollbar>
|
|
<el-scrollbar>
|
|
- <HcDataTree treeKey="id" :h-props="treeProps" :datas="treeMenuNode" :defaultCheckedKeys="treeMenuKeys" showCheckbox @check="treeMenuNodeCheck">
|
|
|
|
|
|
+ <HcDataTree ref="authTreeRef" treeKey="id" :h-props="treeProps" :datas="treeMenuNode" :defaultCheckedKeys="treeMenuKeys" showCheckbox>
|
|
<template #default="{node, data}">
|
|
<template #default="{node, data}">
|
|
<span class="hc-tree-menu-label">{{node.label}}</span>
|
|
<span class="hc-tree-menu-label">{{node.label}}</span>
|
|
<span class="hc-tree-menu-remark">{{data.remark}}</span>
|
|
<span class="hc-tree-menu-remark">{{data.remark}}</span>
|
|
@@ -66,7 +66,7 @@ import menuApi from "~api/system/menu";
|
|
import {delMessage} from "~uti/tools";
|
|
import {delMessage} from "~uti/tools";
|
|
|
|
|
|
//显示模式
|
|
//显示模式
|
|
-const isedit = ref(false)
|
|
|
|
|
|
+const isedit = ref(true)
|
|
|
|
|
|
//页面被激活时
|
|
//页面被激活时
|
|
onActivated(() => {
|
|
onActivated(() => {
|
|
@@ -122,7 +122,9 @@ const formRules = {
|
|
}
|
|
}
|
|
|
|
|
|
//树节点的菜单点击事件
|
|
//树节点的菜单点击事件
|
|
|
|
+const treeInfo = ref({})
|
|
const treeMenuTap = ({key, node, data}) => {
|
|
const treeMenuTap = ({key, node, data}) => {
|
|
|
|
+ treeInfo.value = data
|
|
if (key === 'add') {
|
|
if (key === 'add') {
|
|
formModel.value = {
|
|
formModel.value = {
|
|
parentId: data.id,
|
|
parentId: data.id,
|
|
@@ -191,16 +193,21 @@ const delNodeClick = async (data) => {
|
|
|
|
|
|
//权限配置
|
|
//权限配置
|
|
const authModal = ref(false)
|
|
const authModal = ref(false)
|
|
|
|
+const authTreeRef = ref(null)
|
|
const treeMenuNode = ref([])
|
|
const treeMenuNode = ref([])
|
|
const treeProps = ref({
|
|
const treeProps = ref({
|
|
label: 'name',
|
|
label: 'name',
|
|
children: 'children'
|
|
children: 'children'
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+//默认勾选的节点
|
|
|
|
+const treeMenuKeys = ref([])
|
|
const authModalShow = (data) => {
|
|
const authModalShow = (data) => {
|
|
treeMenuNode.value = []
|
|
treeMenuNode.value = []
|
|
|
|
+ treeMenuKeys.value = []
|
|
authModal.value = true
|
|
authModal.value = true
|
|
getMenuData()
|
|
getMenuData()
|
|
|
|
+ getMenuKeyApi(data.id)
|
|
}
|
|
}
|
|
|
|
|
|
const getMenuData = async () => {
|
|
const getMenuData = async () => {
|
|
@@ -212,18 +219,42 @@ const getMenuData = async () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//默认勾选的节点
|
|
|
|
-const treeMenuKeys = ref([])
|
|
|
|
-
|
|
|
|
-//树节点被选择
|
|
|
|
-const treeMenuNodeCheck = (data, {checkedKeys, halfCheckedKeys}) => {
|
|
|
|
- console.log('全选', checkedKeys) //全选
|
|
|
|
- console.log('半选', halfCheckedKeys) //半选
|
|
|
|
|
|
+//获取已勾选的菜单key
|
|
|
|
+const getMenuKeyApi = async (id) => {
|
|
|
|
+ treeMenuKeys.value = []
|
|
|
|
+ const {error, code, data} = await mainApi.getMenuKeys(id)
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ const arr = getArrValue(data?.usermenu)
|
|
|
|
+ arr.forEach((item)=>{
|
|
|
|
+ let arr = item.split("---");
|
|
|
|
+ if(arr[1] === 'all'){
|
|
|
|
+ treeMenuKeys.value.push(arr[0])
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ treeMenuKeys.value = []
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//权限配置弹窗保存
|
|
//权限配置弹窗保存
|
|
-const authModalSave = () => {
|
|
|
|
-
|
|
|
|
|
|
+const authModalSave = async () => {
|
|
|
|
+ let id = treeInfo.value?.id, menuAll = [];
|
|
|
|
+ const menuList = authTreeRef.value?.treeRef.getCheckedKeys() // 全选节点
|
|
|
|
+ const menuHalf = authTreeRef.value?.treeRef.getHalfCheckedKeys() // 半选
|
|
|
|
+ menuList.forEach((id)=>{
|
|
|
|
+ menuAll.push(id + '---all')
|
|
|
|
+ })
|
|
|
|
+ menuHalf.forEach((id)=>{
|
|
|
|
+ menuAll.push(id + '---hanlf')
|
|
|
|
+ })
|
|
|
|
+ //发起请求
|
|
|
|
+ const {error, code, msg} = await mainApi.setMenuGrant(id, menuAll)
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ window?.$message?.success(msg)
|
|
|
|
+ authModal.value = false
|
|
|
|
+ } else {
|
|
|
|
+ window?.$message?.error(msg)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//权限配置弹窗关闭
|
|
//权限配置弹窗关闭
|