|
|
@ -12,7 +12,7 @@ |
|
|
|
<a-tree |
|
|
|
v-if="apartmentTreeData?.length" |
|
|
|
:tree-data="apartmentTreeData" |
|
|
|
:checkedKeys="['0-0']" |
|
|
|
v-model:checkedKeys="deptTreeCheckedKeys" |
|
|
|
defaultExpandAll |
|
|
|
@select="SelectApartmentTree"> |
|
|
|
<template #title="data"> |
|
|
@ -29,8 +29,13 @@ |
|
|
|
:model="formData" |
|
|
|
formLayout="vertical" |
|
|
|
class="form" /> |
|
|
|
<!-- <ns-button style="margin: 16px" type="primary" @click="CancelApartment" |
|
|
|
>取消 |
|
|
|
</ns-button> |
|
|
|
<ns-button v-show="disabled" type="primary" @click="deptEdit">编辑</ns-button> |
|
|
|
<ns-button v-show="!disabled" type="primary" @click="ApartmentSure">确定</ns-button> --> |
|
|
|
</a-tab-pane> |
|
|
|
<a-tab-pane key="2" :disabled="disabled" tab="部门权限"> |
|
|
|
<a-tab-pane key="2" :disabled="!selectKey?.length" tab="部门权限"> |
|
|
|
<a-tree |
|
|
|
:tree-data="apartmentAdminTreeData" |
|
|
|
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }" |
|
|
@ -38,21 +43,18 @@ |
|
|
|
checkable |
|
|
|
:selectable="false" |
|
|
|
defaultExpandAll |
|
|
|
@check="deptCheck" |
|
|
|
@select="ApartmentSelect"> |
|
|
|
<template #title="data"> {{ data.label }}</template> |
|
|
|
</a-tree> |
|
|
|
<ns-button style="margin-left: 16px" type="primary" @click="apartmentPermission" |
|
|
|
>确定 |
|
|
|
</ns-button> |
|
|
|
</a-tab-pane> |
|
|
|
</a-tabs> |
|
|
|
<div v-show="activeKey === '1'"> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="CancelApartment">取消 </ns-button> |
|
|
|
<ns-button v-show="disabled" type="primary" @click="deptEdit">编辑</ns-button> |
|
|
|
<ns-button v-show="!disabled" type="primary" @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> |
|
|
@ -60,7 +62,13 @@ |
|
|
|
<div class="ns-table-title">角色管理</div> |
|
|
|
<a-row> |
|
|
|
<a-col :span="12" class="tree"> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="addUser">新增角色</ns-button> |
|
|
|
<ns-button |
|
|
|
:disabled="!selectKey?.length" |
|
|
|
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 |
|
|
@ -83,31 +91,25 @@ |
|
|
|
:model="formData2" |
|
|
|
formLayout="vertical" |
|
|
|
class="form" /> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button> |
|
|
|
<ns-button v-show="disabled2" type="primary" @click="roleEdit"> 编辑 </ns-button> |
|
|
|
<ns-button v-show="!disabled2" type="primary" @click="UserSure"> 确定 </ns-button> |
|
|
|
</a-tab-pane> |
|
|
|
<a-tab-pane key="2" :disabled="disabled2" tab="角色权限"> |
|
|
|
<a-tab-pane key="2" :disabled="!selectKey2?.length" 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 |
|
|
|
@check="roleCheck" |
|
|
|
@select="UserSelect" /> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="rolePermission"> |
|
|
|
确定 |
|
|
|
</ns-button> |
|
|
|
</a-tab-pane> |
|
|
|
</a-tabs> |
|
|
|
<div v-show="activeKey2 === '1'"> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button> |
|
|
|
<ns-button v-show="disabled2" type="primary" :disabled="disabled2" @click="UserSure"> |
|
|
|
确定</ns-button |
|
|
|
> |
|
|
|
<ns-button v-show="!disabled2" 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> |
|
|
@ -134,6 +136,7 @@ |
|
|
|
const activeKey2 = ref('1'); |
|
|
|
const disabled = ref(true); |
|
|
|
const disabled2 = ref(true); |
|
|
|
const deptTreeCheckedKeys = ref(['0-0-0']); |
|
|
|
const ApartcheckedKeys = ref<string[]>([]); |
|
|
|
const UsercheckedKeys = ref<string[]>([]); |
|
|
|
const selectKey = ref(); |
|
|
@ -148,9 +151,13 @@ |
|
|
|
const apartmentAdminTreeData = ref([]); |
|
|
|
const userTreeData = ref([]); |
|
|
|
const getPermissionTree = (params) => { |
|
|
|
return http.post(permission.permissionTree, params).then((res) => { |
|
|
|
apartmentAdminTreeData.value = get(res, 'data.data'); |
|
|
|
userAdminTreeData.value = get(res, 'data.data'); |
|
|
|
return http.post(permission.queryOrgPermission, params).then((res) => { |
|
|
|
apartmentAdminTreeData.value = get(res, 'data'); |
|
|
|
}); |
|
|
|
}; |
|
|
|
const getRolePermissionTree = (params) => { |
|
|
|
return http.post(permission.queryFilterDeptPermission, params).then((res) => { |
|
|
|
userAdminTreeData.value = get(res, 'data'); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
@ -165,16 +172,27 @@ |
|
|
|
|
|
|
|
// 部门树 |
|
|
|
const getDepartList = (params) => { |
|
|
|
return http.post(department.dartList, params); |
|
|
|
return http.post(department.queryDeptTree, params).then((res) => { |
|
|
|
const result = res.data.map((item, index) => { |
|
|
|
item['deptInfo'] = item.orgInfo; |
|
|
|
item['deptInfo'] = item.orgInfo; |
|
|
|
item['deptInfo']['deptName'] = item?.orgInfo?.orgName; |
|
|
|
item['own'] = !index; |
|
|
|
item['children'] = item.deptTrees; |
|
|
|
return item; |
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
}); |
|
|
|
}; |
|
|
|
getDepartList({ orgId }).then((res) => { |
|
|
|
apartmentTreeData.value = res.data; |
|
|
|
apartmentTreeData.value = res; |
|
|
|
}); |
|
|
|
|
|
|
|
// 获取部门树 |
|
|
|
const getTree = () => { |
|
|
|
getDepartList({ orgId }).then((res) => { |
|
|
|
apartmentTreeData.value = res.data; |
|
|
|
apartmentTreeData.value = res; |
|
|
|
NsMessage.success('操作成功'); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -199,18 +217,19 @@ |
|
|
|
callback: null, |
|
|
|
}; |
|
|
|
|
|
|
|
function fetch(api, params) { |
|
|
|
return http.post(api, params); |
|
|
|
} |
|
|
|
|
|
|
|
const addApartment = () => { |
|
|
|
disabled.value = false; |
|
|
|
opMap.type = 'addDept'; |
|
|
|
formData.value = {}; |
|
|
|
let sourceOrgId = ''; |
|
|
|
if (!selectRef.value.own) { |
|
|
|
sourceOrgId = orgId; |
|
|
|
} |
|
|
|
opMap.fuc = (params) => { |
|
|
|
return http.post(department.deptSave, { |
|
|
|
...params, |
|
|
|
orgId, |
|
|
|
orgId: selectRef.value.deptInfo?.orgId, |
|
|
|
sourceOrgId, |
|
|
|
projectId, |
|
|
|
orgName, |
|
|
|
}); |
|
|
@ -222,13 +241,22 @@ |
|
|
|
disabled.value = false; |
|
|
|
opMap.type = 'addson'; |
|
|
|
formData.value = {}; |
|
|
|
let sourceOrgId = ''; |
|
|
|
if (!selectRef.value.own) { |
|
|
|
sourceOrgId = orgId; |
|
|
|
} |
|
|
|
opMap.fuc = (params) => { |
|
|
|
if (!selectRef.value?.deptInfo?.deptId) { |
|
|
|
NsMessage.warn('请选择部门'); |
|
|
|
return; |
|
|
|
} |
|
|
|
return http.post(department.deptSave, { |
|
|
|
...params, |
|
|
|
orgId, |
|
|
|
projectId, |
|
|
|
pdeptId: selectRef.value.deptInfo.deptId, |
|
|
|
deptName: selectRef.value.deptInfo.deptName, |
|
|
|
sourceOrgId, |
|
|
|
// deptName: selectRef.value.deptInfo.deptName, |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -311,6 +339,58 @@ |
|
|
|
opMap.fuc = ''; |
|
|
|
selectKey.value = ''; |
|
|
|
}; |
|
|
|
const clearRoleData = () => { |
|
|
|
selectRef2.value = {}; |
|
|
|
formData2.value = {}; |
|
|
|
opMap.type = ''; |
|
|
|
opMap.fuc = ''; |
|
|
|
selectKey2.value = ''; |
|
|
|
}; |
|
|
|
|
|
|
|
const deptTotalCheckedKeys = ref([]); |
|
|
|
const roleTotalCheckedKeys = ref([]); |
|
|
|
// 部门权限选择 |
|
|
|
const deptCheck = (checked, { halfCheckedKeys }) => { |
|
|
|
console.log(checked, halfCheckedKeys); |
|
|
|
|
|
|
|
const result = checked.map((item) => { |
|
|
|
return { |
|
|
|
halfCheck: false, |
|
|
|
permissionId: item, |
|
|
|
}; |
|
|
|
}); |
|
|
|
const finalResult = halfCheckedKeys |
|
|
|
.map((item) => { |
|
|
|
return { |
|
|
|
halfCheck: true, |
|
|
|
permissionId: item, |
|
|
|
}; |
|
|
|
}) |
|
|
|
.concat(result); |
|
|
|
|
|
|
|
deptTotalCheckedKeys.value = finalResult; |
|
|
|
}; |
|
|
|
|
|
|
|
// 角色权限选择 |
|
|
|
const roleCheck = (checked, { halfCheckedKeys }) => { |
|
|
|
console.log(checked, halfCheckedKeys); |
|
|
|
|
|
|
|
const result = checked.map((item) => { |
|
|
|
return { |
|
|
|
halfCheck: false, |
|
|
|
permissionId: item, |
|
|
|
}; |
|
|
|
}); |
|
|
|
const finalResult = halfCheckedKeys |
|
|
|
.map((item) => { |
|
|
|
return { |
|
|
|
halfCheck: true, |
|
|
|
permissionId: item, |
|
|
|
}; |
|
|
|
}) |
|
|
|
.concat(result); |
|
|
|
roleTotalCheckedKeys.value = finalResult; |
|
|
|
}; |
|
|
|
|
|
|
|
// 保存部门权限 |
|
|
|
const apartmentPermission = () => { |
|
|
@ -318,9 +398,7 @@ |
|
|
|
.post(department.addPermission, { |
|
|
|
deptId: selectRef.value?.deptInfo.deptId, |
|
|
|
projectId, |
|
|
|
permissionVoList: ApartcheckedKeys.value.map((item) => { |
|
|
|
return { permissionId: item }; |
|
|
|
}), |
|
|
|
permissionVoList: deptTotalCheckedKeys.value, |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
NsMessage.success('保存成功'); |
|
|
@ -333,9 +411,7 @@ |
|
|
|
// deptId: selectRef.value?.deptInfo.deptId, |
|
|
|
roleId: selectRef2.value?.roleId, |
|
|
|
projectId, |
|
|
|
permissionVoList: UsercheckedKeys.value.map((item) => { |
|
|
|
return { permissionId: item }; |
|
|
|
}), |
|
|
|
permissionVoList: roleTotalCheckedKeys.value, |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
NsMessage.success('保存成功'); |
|
|
@ -345,22 +421,28 @@ |
|
|
|
// 获取部门拥有的权限 |
|
|
|
const getDeptPermission = () => { |
|
|
|
http |
|
|
|
.post(department.queryDeptPermission, { deptId: selectRef.value?.deptInfo.deptId }) |
|
|
|
.post(permission.queryDeptPermission, { deptId: selectRef.value?.deptInfo.deptId }) |
|
|
|
.then((res) => { |
|
|
|
ApartcheckedKeys.value = res.data.map((item) => { |
|
|
|
ApartcheckedKeys.value = res.data |
|
|
|
?.filter((item) => !item.halfCheck) |
|
|
|
.map((item) => { |
|
|
|
return item.permissionId; |
|
|
|
}); |
|
|
|
deptTotalCheckedKeys.value = res.data; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 获取角色拥有的权限 |
|
|
|
const getRolePermission = () => { |
|
|
|
http |
|
|
|
.post(department.queryRolePermission, { roleId: selectRef2.value?.roleId }) |
|
|
|
.post(permission.queryRolePermission, { roleId: selectRef2.value?.roleId }) |
|
|
|
.then((res) => { |
|
|
|
UsercheckedKeys.value = res.data.map((item) => { |
|
|
|
UsercheckedKeys.value = res.data |
|
|
|
?.filter((item) => !item.halfCheck) |
|
|
|
.map((item) => { |
|
|
|
return item.permissionId; |
|
|
|
}); |
|
|
|
roleTotalCheckedKeys.value = res.data; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
@ -377,6 +459,7 @@ |
|
|
|
|
|
|
|
// 部门编辑 |
|
|
|
const deptEdit = () => { |
|
|
|
disabledTree(); |
|
|
|
disabled.value = false; |
|
|
|
apartmentChoose(); |
|
|
|
}; |
|
|
@ -404,24 +487,27 @@ |
|
|
|
* type editDpet |
|
|
|
*/ |
|
|
|
const roleChoose = () => { |
|
|
|
opMap.type = 'editDpet'; |
|
|
|
opMap.type = 'editRole'; |
|
|
|
opMap.fuc = (params) => { |
|
|
|
return http.post(department.deptEdit, params); |
|
|
|
return http.post(department.editRole, params); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
const roleEdit = () => { |
|
|
|
disabled2.value = false; |
|
|
|
roleChoose(); |
|
|
|
}; |
|
|
|
// 角色选择 |
|
|
|
const SelectUserTree = (selectedKeys: any, info: any) => { |
|
|
|
const { selected } = info; |
|
|
|
disabled2.value = !selected; |
|
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
|
console.log(info, 'info'); |
|
|
|
// disabled2.value = !selected; |
|
|
|
|
|
|
|
if (!selectedKeys?.length) return; |
|
|
|
selectKey2.value = selectedKeys[0]; |
|
|
|
selectRef2.value = info.node.dataRef; |
|
|
|
formData2.value = cloneDeep(info.node.dataRef); |
|
|
|
roleChoose(); |
|
|
|
UsercheckedKeys.value.splice(0); |
|
|
|
getRolePermission(); |
|
|
|
getRolePermissionTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
|
}; |
|
|
|
|
|
|
|
const CancelApartment = () => { |
|
|
@ -452,6 +538,7 @@ |
|
|
|
opMap.fuc && |
|
|
|
opMap.fuc(formData.value).then(() => { |
|
|
|
getTree(); |
|
|
|
clearApartData(); |
|
|
|
disabled.value = true; |
|
|
|
}); |
|
|
|
} else if (opMap.type === 'deptDelete') { |
|
|
@ -466,6 +553,7 @@ |
|
|
|
opMap.fuc && |
|
|
|
opMap.fuc(formData2.value).then(() => { |
|
|
|
getUserTree(); |
|
|
|
clearRoleData(); |
|
|
|
}); |
|
|
|
} else if (selectRef2.value && opMap.type === 'addson') |
|
|
|
selectRef2.value['children'] = [ |
|
|
@ -480,6 +568,13 @@ |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const disabledTree = (data, disabled) => { |
|
|
|
console.log(userAdminTreeData.value, 'userAdminTreeData.value'); |
|
|
|
userAdminTreeData.value.map((item) => { |
|
|
|
item['disabled'] = disabled; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
|
disabled, |
|
|
|
disabled2, |
|
|
@ -513,6 +608,12 @@ |
|
|
|
apartmentPermission, |
|
|
|
rolePermission, |
|
|
|
deptEdit, |
|
|
|
selectKey, |
|
|
|
selectKey2, |
|
|
|
deptTreeCheckedKeys, |
|
|
|
deptCheck, |
|
|
|
roleCheck, |
|
|
|
roleEdit, |
|
|
|
}; |
|
|
|
}, |
|
|
|
}); |
|
|
|