|
|
@ -39,21 +39,28 @@ |
|
|
|
formLayout="vertical" |
|
|
|
class="form" /> |
|
|
|
</a-tab-pane> |
|
|
|
<a-tab-pane key="2" tab="部门权限"> |
|
|
|
<a-tab-pane key="2" :disabled="disabled" tab="部门权限"> |
|
|
|
<a-tree |
|
|
|
:tree-data="apartmentAdminTreeData" |
|
|
|
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }" |
|
|
|
v-model:checkedKeys="ApartcheckedKeys" |
|
|
|
checkable |
|
|
|
:selectable="false" |
|
|
|
defaultExpandAll |
|
|
|
@select="ApartmentSelect"> |
|
|
|
<template #title="{ title }"> |
|
|
|
{{ title }} |
|
|
|
</template> |
|
|
|
<template #title="data"> {{ data.label }}</template> |
|
|
|
</a-tree> |
|
|
|
</a-tab-pane> |
|
|
|
</a-tabs> |
|
|
|
<ns-button style="margin: 20px" type="primary" @click="CancelApartment">取消</ns-button> |
|
|
|
<ns-button type="primary" @click="ApartmentSure">确定</ns-button> |
|
|
|
<div v-show="activeKey === '1'"> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="CancelApartment">取消</ns-button> |
|
|
|
<ns-button type="primary" :disabled="disabled" @click="ApartmentSure">确定</ns-button> |
|
|
|
</div> |
|
|
|
<div v-show="activeKey === '2'"> |
|
|
|
<ns-button style="margin-left: 16px" type="primary" @click="apartmentPermission" |
|
|
|
>确定</ns-button |
|
|
|
> |
|
|
|
</div> |
|
|
|
</a-col> |
|
|
|
</a-row> |
|
|
|
</div> |
|
|
@ -61,9 +68,7 @@ |
|
|
|
<div class="ns-table-title">角色管理</div> |
|
|
|
<a-row> |
|
|
|
<a-col :span="12" class="tree"> |
|
|
|
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="addUser" |
|
|
|
>新增角色</ns-button |
|
|
|
> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="addUser">新增角色</ns-button> |
|
|
|
<ns-button :disabled="disabled2" type="primary" @click="addUserSon">新增子角色</ns-button> |
|
|
|
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="deleteUser" |
|
|
|
>删除</ns-button |
|
|
@ -87,21 +92,25 @@ |
|
|
|
formLayout="vertical" |
|
|
|
class="form" /> |
|
|
|
</a-tab-pane> |
|
|
|
<a-tab-pane key="2" tab="角色权限"> |
|
|
|
<a-tab-pane key="2" :disabled="disabled2" tab="角色权限"> |
|
|
|
<a-tree |
|
|
|
v-if="userAdminTreeData?.length" |
|
|
|
:tree-data="userAdminTreeData" |
|
|
|
v-model:checkedKeys="UsercheckedKeys" |
|
|
|
defaultExpandAll |
|
|
|
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }" |
|
|
|
:selectable="false" |
|
|
|
checkable |
|
|
|
@select="UserSelect"> |
|
|
|
<template #title="{ title }"> |
|
|
|
{{ title }} |
|
|
|
</template> |
|
|
|
</a-tree> |
|
|
|
@select="UserSelect" /> |
|
|
|
</a-tab-pane> |
|
|
|
</a-tabs> |
|
|
|
<ns-button style="margin: 20px" type="primary" @click="CancelUser">取消</ns-button> |
|
|
|
<ns-button type="primary" @click="UserSure"> 确定</ns-button> |
|
|
|
<div v-show="activeKey2 === '1'"> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button> |
|
|
|
<ns-button type="primary" :disabled="disabled2" @click="UserSure"> 确定</ns-button> |
|
|
|
</div> |
|
|
|
<div v-show="activeKey2 === '2'"> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="rolePermission"> 确定</ns-button> |
|
|
|
</div> |
|
|
|
</a-col> |
|
|
|
</a-row> |
|
|
|
</div> |
|
|
@ -112,7 +121,7 @@ |
|
|
|
import { Modal } from 'ant-design-vue'; |
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; |
|
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
|
import { cloneDeep } from 'lodash-es'; |
|
|
|
import { cloneDeep, get } from 'lodash-es'; |
|
|
|
import { formConfig, formConfig2 } from './config'; |
|
|
|
import { department } from '/@/api/origanizemanage'; |
|
|
|
import { permission } from '/@/api/origanizemanage'; |
|
|
@ -140,34 +149,18 @@ |
|
|
|
const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId; |
|
|
|
const userAdminTreeData = ref([]); |
|
|
|
const apartmentTreeData = ref([]); |
|
|
|
const apartmentAdminTreeData = ref([]); |
|
|
|
|
|
|
|
const userTreeData = ref([]); |
|
|
|
const getPermissionTree = (params) => { |
|
|
|
return http.post(permission.permissionTree, params); |
|
|
|
return http.post(permission.permissionTree, params).then((res) => { |
|
|
|
apartmentAdminTreeData.value = get(res, 'data.data'); |
|
|
|
userAdminTreeData.value = get(res, 'data.data'); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
getPermissionTree({ projectId }); |
|
|
|
|
|
|
|
const apartmentAdminTreeData = [ |
|
|
|
{ |
|
|
|
title: '首页', |
|
|
|
key: '0-0', |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
title: '控制台', |
|
|
|
key: '0-0-0', |
|
|
|
children: [ |
|
|
|
{ title: 'leaf', key: '0-0-0-0' }, |
|
|
|
{ title: 'leaf', key: '0-0-0-1' }, |
|
|
|
], |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '用户管理', |
|
|
|
key: '0-0-1', |
|
|
|
children: [{ key: '0-0-1-0', title: 'sss' }], |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
]; |
|
|
|
watch(ApartcheckedKeys, () => { |
|
|
|
console.log('checkedKeys', ApartcheckedKeys.value); |
|
|
|
}); |
|
|
@ -183,6 +176,7 @@ |
|
|
|
apartmentTreeData.value = res.data; |
|
|
|
}); |
|
|
|
|
|
|
|
// 获取部门树 |
|
|
|
const getTree = () => { |
|
|
|
getDepartList({ orgId }).then((res) => { |
|
|
|
apartmentTreeData.value = res.data; |
|
|
@ -190,14 +184,17 @@ |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const getUserTree = (params = { deptId: selectRef.value.deptInfo.deptId }) => { |
|
|
|
// 获取角色树 |
|
|
|
const getUserTree = (params = { deptId: selectRef.value?.deptInfo?.deptId }) => { |
|
|
|
http.post(department.queryRoleTree, params).then((res) => { |
|
|
|
userTreeData.value = res.data; |
|
|
|
}); |
|
|
|
}; |
|
|
|
// 根据依赖刷新角色树 |
|
|
|
watchEffect(() => { |
|
|
|
if (selectRef.value) getUserTree(); |
|
|
|
if (selectRef.value) { |
|
|
|
getUserTree(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
const opMap: any = { |
|
|
@ -284,7 +281,7 @@ |
|
|
|
onOk() { |
|
|
|
http.post(department.deptDel, { deptId: selectRef.value.deptInfo.deptId }).then(() => { |
|
|
|
getTree(); |
|
|
|
clearData(); |
|
|
|
clearApartData(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
onCancel() { |
|
|
@ -307,13 +304,78 @@ |
|
|
|
class: 'test', |
|
|
|
}); |
|
|
|
}; |
|
|
|
const clearData = () => { |
|
|
|
|
|
|
|
const clearApartData = () => { |
|
|
|
selectRef.value = {}; |
|
|
|
formData.value = {}; |
|
|
|
opMap.type = ''; |
|
|
|
opMap.fuc = ''; |
|
|
|
selectKey.value = ''; |
|
|
|
}; |
|
|
|
|
|
|
|
// 保存部门权限 |
|
|
|
const apartmentPermission = () => { |
|
|
|
http |
|
|
|
.post(department.addPermission, { |
|
|
|
deptId: selectRef.value?.deptInfo.deptId, |
|
|
|
projectId, |
|
|
|
permissionVoList: ApartcheckedKeys.value.map((item) => { |
|
|
|
return { permissionId: item }; |
|
|
|
}), |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
NsMessage.success('保存成功'); |
|
|
|
}); |
|
|
|
}; |
|
|
|
// 保存角色权限 |
|
|
|
const rolePermission = () => { |
|
|
|
http |
|
|
|
.post(department.addRolePermission, { |
|
|
|
// deptId: selectRef.value?.deptInfo.deptId, |
|
|
|
roleId: selectRef2.value?.roleId, |
|
|
|
projectId, |
|
|
|
permissionVoList: UsercheckedKeys.value.map((item) => { |
|
|
|
return { permissionId: item }; |
|
|
|
}), |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
NsMessage.success('保存成功'); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 获取部门拥有的权限 |
|
|
|
const getDeptPermission = () => { |
|
|
|
http |
|
|
|
.post(department.queryDeptPermission, { deptId: selectRef.value?.deptInfo.deptId }) |
|
|
|
.then((res) => { |
|
|
|
ApartcheckedKeys.value = res.data.map((item) => { |
|
|
|
return item.permissionId; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 获取角色拥有的权限 |
|
|
|
const getRolePermission = () => { |
|
|
|
http |
|
|
|
.post(department.queryRolePermission, { roleId: selectRef2.value?.roleId }) |
|
|
|
.then((res) => { |
|
|
|
UsercheckedKeys.value = res.data.map((item) => { |
|
|
|
return item.permissionId; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* 默认选中视为编辑部门 |
|
|
|
* type editDpet |
|
|
|
*/ |
|
|
|
const apartmentChoose = () => { |
|
|
|
opMap.type = 'editDpet'; |
|
|
|
opMap.fuc = (params) => { |
|
|
|
return http.post(department.deptEdit, params); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
// 部门选择 |
|
|
|
const SelectApartmentTree = (selectedKeys: any, info: any) => { |
|
|
|
const { selected } = info; |
|
|
@ -322,12 +384,21 @@ |
|
|
|
selectKey.value = selectedKeys[0]; |
|
|
|
selectRef.value = info.node.dataRef; |
|
|
|
formData.value = cloneDeep(info.node.dataRef.deptInfo); |
|
|
|
apartmentChoose(); |
|
|
|
ApartcheckedKeys.value.splice(0); |
|
|
|
getDeptPermission(); |
|
|
|
// getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* 默认选中视为编辑角色 |
|
|
|
* type editDpet |
|
|
|
*/ |
|
|
|
const roleChoose = () => { |
|
|
|
opMap.type = 'editDpet'; |
|
|
|
opMap.fuc = (params) => { |
|
|
|
return http.post(department.deptEdit, params); |
|
|
|
}; |
|
|
|
|
|
|
|
// getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
|
}; |
|
|
|
|
|
|
|
// 角色选择 |
|
|
@ -339,14 +410,15 @@ |
|
|
|
selectKey2.value = selectedKeys[0]; |
|
|
|
selectRef2.value = info.node.dataRef; |
|
|
|
formData2.value = cloneDeep(info.node.dataRef); |
|
|
|
opMap.type = 'editRole'; |
|
|
|
opMap.fuc = (params) => { |
|
|
|
return http.post(department.editRole, params); |
|
|
|
}; |
|
|
|
roleChoose(); |
|
|
|
UsercheckedKeys.value.splice(0); |
|
|
|
getRolePermission(); |
|
|
|
}; |
|
|
|
|
|
|
|
const CancelApartment = () => { |
|
|
|
disabled.value = true; |
|
|
|
// 取消视为转入编辑状态 |
|
|
|
// clearApartData(); |
|
|
|
}; |
|
|
|
|
|
|
|
const CancelUser = () => { |
|
|
@ -382,10 +454,9 @@ |
|
|
|
opMap.fuc && opMap.fuc({ ...formData.value, selectRef: selectRef.value }); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const UserSure = () => { |
|
|
|
disabled2.value = !disabled2.value; |
|
|
|
console.log(formData2.value, 'formData2'); |
|
|
|
console.log(opMap.type, 'opMap.type'); |
|
|
|
const typeArr = ['addUserSon', 'addUser', 'editRole']; |
|
|
|
if (typeArr.includes(opMap.type)) { |
|
|
|
opMap.fuc && |
|
|
@ -403,7 +474,6 @@ |
|
|
|
else { |
|
|
|
console.log('ss'); |
|
|
|
} |
|
|
|
formData2.value = {}; |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
@ -436,6 +506,8 @@ |
|
|
|
UsercheckedKeys, |
|
|
|
UserSelect, |
|
|
|
formRef, |
|
|
|
apartmentPermission, |
|
|
|
rolePermission, |
|
|
|
}; |
|
|
|
}, |
|
|
|
}); |
|
|
|