|
@@ -68,6 +68,14 @@
|
|
<div class="font-bold">{{ state.currentMenu.title }}</div>
|
|
<div class="font-bold">{{ state.currentMenu.title }}</div>
|
|
<div class="flex flex-1 flex-col gap-2 overflow-auto">
|
|
<div class="flex flex-1 flex-col gap-2 overflow-auto">
|
|
<template v-if="state.currentMenu.auths?.length > 0">
|
|
<template v-if="state.currentMenu.auths?.length > 0">
|
|
|
|
+ <el-button-group size="small">
|
|
|
|
+ <el-button type="primary" @click="onCheckAll(true)"
|
|
|
|
+ >全选</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button type="info" @click="onCheckAll(false)"
|
|
|
|
+ >取消全选</el-button
|
|
|
|
+ >
|
|
|
|
+ </el-button-group>
|
|
<el-checkbox-group v-model="state.activeAuths">
|
|
<el-checkbox-group v-model="state.activeAuths">
|
|
<template v-for="item in state.currentMenu.auths">
|
|
<template v-for="item in state.currentMenu.auths">
|
|
<el-checkbox :value="item.value">
|
|
<el-checkbox :value="item.value">
|
|
@@ -99,7 +107,7 @@ import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
import { Search } from '@element-plus/icons-vue'
|
|
import { Search } from '@element-plus/icons-vue'
|
|
import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
|
|
import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
|
|
-import { rolesMenus, rolesMenusAdd } from '@/api/modules/center/role'
|
|
|
|
|
|
+import { rolesAuths, rolesAuthsAdd } from '@/api/modules/center/role'
|
|
import bigModelRouter from '@/router/modules/big-model'
|
|
import bigModelRouter from '@/router/modules/big-model'
|
|
|
|
|
|
const DialogStore = useDialogStore()
|
|
const DialogStore = useDialogStore()
|
|
@@ -140,15 +148,15 @@ const initData = () => {
|
|
state.loading = true
|
|
state.loading = true
|
|
state.activeAuths = []
|
|
state.activeAuths = []
|
|
ref_tree.value?.setCheckedKeys([], false)
|
|
ref_tree.value?.setCheckedKeys([], false)
|
|
- rolesMenus(props.transfer.roleId)
|
|
|
|
|
|
+ rolesAuths(props.transfer.roleId)
|
|
.then(({ data }: any) => {
|
|
.then(({ data }: any) => {
|
|
const authArr: any = []
|
|
const authArr: any = []
|
|
const menuArr: any = []
|
|
const menuArr: any = []
|
|
data.forEach((v) => {
|
|
data.forEach((v) => {
|
|
- if (v.includes(AppStore.permission.splitAuth)) {
|
|
|
|
- authArr.push(v)
|
|
|
|
|
|
+ if (v.auth.includes(AppStore.permission.splitAuth)) {
|
|
|
|
+ authArr.push(v.auth)
|
|
} else {
|
|
} else {
|
|
- menuArr.push(v)
|
|
|
|
|
|
+ menuArr.push(v.auth)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
state.activeAuths = authArr
|
|
state.activeAuths = authArr
|
|
@@ -224,11 +232,26 @@ const onNodeClick = (data, node) => {
|
|
state.currentMenu.title = getTitle(node)
|
|
state.currentMenu.title = getTitle(node)
|
|
state.currentMenu.auths = data.auths
|
|
state.currentMenu.auths = data.auths
|
|
}
|
|
}
|
|
|
|
+const onCheckAll = (flag) => {
|
|
|
|
+ if (flag) {
|
|
|
|
+ state.currentMenu.auths.forEach((v) => {
|
|
|
|
+ if (!state.activeAuths.includes(v.value)) {
|
|
|
|
+ state.activeAuths.push(v.value)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ state.activeAuths = state.activeAuths.filter(
|
|
|
|
+ (v) => !state.currentMenu.auths.some((a) => a.value === v),
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+}
|
|
const onSubmit = () => {
|
|
const onSubmit = () => {
|
|
const arr = [...ref_tree.value.getCheckedKeys(), ...state.activeAuths]
|
|
const arr = [...ref_tree.value.getCheckedKeys(), ...state.activeAuths]
|
|
state.loading = true
|
|
state.loading = true
|
|
- rolesMenusAdd(props.transfer.roleId, arr)
|
|
|
|
- .then(({ data }: any) => {})
|
|
|
|
|
|
+ rolesAuthsAdd(props.transfer.roleId, arr)
|
|
|
|
+ .then(({ data }: any) => {
|
|
|
|
+ ElMessage.success('授权成功!')
|
|
|
|
+ })
|
|
.finally(() => {
|
|
.finally(() => {
|
|
state.loading = false
|
|
state.loading = false
|
|
initData()
|
|
initData()
|