|
|
@ -6,9 +6,13 @@ |
|
|
|
<div class="ns-table-title">部门管理</div> |
|
|
|
<a-row> |
|
|
|
<a-col :span="12" class="tree"> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="addApartment">新增部门</ns-button> |
|
|
|
<ns-button type="primary" @click="addApartmentSon">新增子部门</ns-button> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="deleteApartment">删除</ns-button> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="pipe(addApartment)"> |
|
|
|
新增部门 |
|
|
|
</ns-button> |
|
|
|
<ns-button type="primary" @click="pipe(addApartmentSon, true)">新增子部门</ns-button> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="pipe(deleteDept)"> |
|
|
|
删除 |
|
|
|
</ns-button> |
|
|
|
<a-tree |
|
|
|
v-if="apartmentTreeData?.length" |
|
|
|
:tree-data="apartmentTreeData" |
|
|
@ -22,20 +26,16 @@ |
|
|
|
</a-col> |
|
|
|
<a-col :span="12" class="list"> |
|
|
|
<a-tabs v-model:activeKey="activeKey"> |
|
|
|
<a-tab-pane key="1" tab="部门信息"> |
|
|
|
<a-tab-pane :key="1" tab="部门信息"> |
|
|
|
<ns-form |
|
|
|
ref="formRef" |
|
|
|
:schemas="formSchema" |
|
|
|
:wrapperCol="{ span: 18 }" |
|
|
|
: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="!selectKey?.length" tab="部门权限"> |
|
|
|
<a-tab-pane :key="2" tab="部门权限"> |
|
|
|
<a-tree |
|
|
|
:tree-data="apartmentAdminTreeData" |
|
|
|
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }" |
|
|
@ -43,18 +43,14 @@ |
|
|
|
checkable |
|
|
|
:selectable="false" |
|
|
|
defaultExpandAll |
|
|
|
@check="deptCheck" |
|
|
|
@select="ApartmentSelect"> |
|
|
|
@check="deptCheck"> |
|
|
|
<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> |
|
|
|
<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> |
|
|
|
<ns-button v-show="disabled" type="primary" @click="pipe(deptEdit)">编辑</ns-button> |
|
|
|
<ns-button v-show="!disabled" type="primary" @click="deptSure">确定</ns-button> |
|
|
|
</a-col> |
|
|
|
</a-row> |
|
|
|
</div> |
|
|
@ -62,17 +58,13 @@ |
|
|
|
<div class="ns-table-title">角色管理</div> |
|
|
|
<a-row> |
|
|
|
<a-col :span="12" class="tree"> |
|
|
|
<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 |
|
|
|
> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="rolePipe(addUser, true)"> |
|
|
|
新增角色 |
|
|
|
</ns-button> |
|
|
|
<ns-button type="primary" @click="rolePipe(addUserSon)">新增子角色</ns-button> |
|
|
|
<ns-button style="margin: 10px" type="primary" @click="rolePipe(deleteUser)"> |
|
|
|
删除 |
|
|
|
</ns-button> |
|
|
|
<a-tree |
|
|
|
v-if="userTreeData.length" |
|
|
|
:tree-data="userTreeData" |
|
|
@ -84,18 +76,17 @@ |
|
|
|
</a-tree> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12" class="list"> |
|
|
|
<a-tabs v-model:activeKey="activeKey2"> |
|
|
|
<a-tab-pane key="1" tab="角色信息"> |
|
|
|
<a-tabs v-model:activeKey="roleActiveKey"> |
|
|
|
<a-tab-pane :key="1" tab="角色信息"> |
|
|
|
<ns-form |
|
|
|
ref="formRoleRef" |
|
|
|
:schemas="formSchema2" |
|
|
|
:model="formData2" |
|
|
|
:model="roleFormData" |
|
|
|
:wrapperCol="{ span: 18 }" |
|
|
|
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="!selectKey2?.length" tab="角色权限"> |
|
|
|
<a-tab-pane :key="2" tab="角色权限"> |
|
|
|
<a-tree |
|
|
|
:tree-data="userAdminTreeData" |
|
|
|
v-model:checkedKeys="UsercheckedKeys" |
|
|
@ -103,20 +94,19 @@ |
|
|
|
: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> |
|
|
|
@check="roleCheck" /> |
|
|
|
</a-tab-pane> |
|
|
|
</a-tabs> |
|
|
|
<ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button> |
|
|
|
<ns-button v-show="roleDisabled" type="primary" @click="roleEdit"> 编辑 </ns-button> |
|
|
|
<ns-button v-show="!roleDisabled" type="primary" @click="UserSure"> 确定 </ns-button> |
|
|
|
</a-col> |
|
|
|
</a-row> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<script lang="ts"> |
|
|
|
import { createVNode, defineComponent, reactive, ref, watch, watchEffect } from 'vue'; |
|
|
|
<script lang="ts" setup> |
|
|
|
import { createVNode, ref, watchEffect } from 'vue'; |
|
|
|
import { Modal } from 'ant-design-vue'; |
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; |
|
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
@ -126,30 +116,84 @@ |
|
|
|
import { permission } from '/@/api/origanizemanage'; |
|
|
|
import { NsMessage } from '/nerv-lib/component'; |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
defineOptions({ |
|
|
|
name: 'AuthorityManageIndex', |
|
|
|
setup() { |
|
|
|
}); |
|
|
|
|
|
|
|
const formRef = ref(); |
|
|
|
const formRoleRef = ref(); |
|
|
|
let formData = ref({}); |
|
|
|
let formData2 = ref({}); |
|
|
|
const activeKey = ref('1'); |
|
|
|
const activeKey2 = ref('1'); |
|
|
|
let roleFormData = ref({}); |
|
|
|
const activeKey = ref(1); |
|
|
|
const roleActiveKey = ref(1); |
|
|
|
const disabled = ref(true); |
|
|
|
const disabled2 = ref(true); |
|
|
|
const roleDisabled = ref(true); |
|
|
|
const deptTreeCheckedKeys = ref(['0-0-0']); |
|
|
|
const ApartcheckedKeys = ref<string[]>([]); |
|
|
|
const UsercheckedKeys = ref<string[]>([]); |
|
|
|
const currentOrgRef = ref(); |
|
|
|
const selectKey = ref(); |
|
|
|
const selectRef = ref(); |
|
|
|
const selectKey2 = ref(); |
|
|
|
const selectRef2 = ref(); |
|
|
|
const selectRoleKey = ref(); |
|
|
|
const selectRoleRef = ref(); |
|
|
|
const formSchema = formConfig(disabled as any); |
|
|
|
const formSchema2 = formConfig2(disabled2 as any); |
|
|
|
const formSchema2 = formConfig2(roleDisabled as any); |
|
|
|
const { orgId, orgName, projectId } = JSON.parse(sessionStorage.getItem('userInfo')); |
|
|
|
const userAdminTreeData = ref([]); |
|
|
|
const apartmentTreeData = ref([]); |
|
|
|
const apartmentAdminTreeData = ref([]); |
|
|
|
const userTreeData = ref([]); |
|
|
|
|
|
|
|
// 包含半选状态的权限数据 |
|
|
|
const deptTotalCheckedKeys = ref([]); |
|
|
|
const roleTotalCheckedKeys = ref([]); |
|
|
|
|
|
|
|
// 禁用权限树 |
|
|
|
const disabledTree = (data, disabled = true) => { |
|
|
|
data.map((item) => { |
|
|
|
item['disabled'] = disabled; |
|
|
|
if (item.menus) { |
|
|
|
disabledTree(item.menus, disabled); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
watchEffect(() => { |
|
|
|
disabledTree(apartmentAdminTreeData.value, disabled.value); |
|
|
|
disabledTree(userAdminTreeData.value, roleDisabled.value); |
|
|
|
}); |
|
|
|
|
|
|
|
/**操作拦截 */ |
|
|
|
const pipe = (func: Function, flag = false) => { |
|
|
|
console.log(selectRef.value); |
|
|
|
|
|
|
|
if (flag && !selectRef.value?.hasOwnProperty('own')) { |
|
|
|
NsMessage.error('请先选择相关部门'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!flag && !selectRef.value?.deptInfo) { |
|
|
|
NsMessage.error('请先选择相关企业'); |
|
|
|
return; |
|
|
|
} |
|
|
|
func && func(); |
|
|
|
}; |
|
|
|
|
|
|
|
const rolePipe = (func: Function, linkDept = false) => { |
|
|
|
console.log(selectRoleRef.value); |
|
|
|
|
|
|
|
// 需要先选择部门 |
|
|
|
if ((linkDept && !selectRef.value?.deptInfo) || selectRef.value?.hasOwnProperty('own')) { |
|
|
|
NsMessage.error('请先选择相关部门'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!linkDept && !selectRoleRef.value) { |
|
|
|
NsMessage.error('请先选择相关角色'); |
|
|
|
return; |
|
|
|
} |
|
|
|
func && func(); |
|
|
|
}; |
|
|
|
/**操作拦截 */ |
|
|
|
|
|
|
|
const getPermissionTree = (params) => { |
|
|
|
return http.post(permission.queryOrgPermission, params).then((res) => { |
|
|
|
apartmentAdminTreeData.value = get(res, 'data'); |
|
|
@ -163,13 +207,6 @@ |
|
|
|
|
|
|
|
getPermissionTree({ projectId, orgId }); |
|
|
|
|
|
|
|
watch(ApartcheckedKeys, () => { |
|
|
|
console.log('checkedKeys', ApartcheckedKeys.value); |
|
|
|
}); |
|
|
|
watch(UsercheckedKeys, () => { |
|
|
|
console.log('checkedKeys', UsercheckedKeys.value); |
|
|
|
}); |
|
|
|
|
|
|
|
// 部门树 |
|
|
|
const getDepartList = (params) => { |
|
|
|
return http.post(department.queryDeptTree, params).then((res) => { |
|
|
@ -222,10 +259,11 @@ |
|
|
|
opMap.type = 'addDept'; |
|
|
|
formData.value = {}; |
|
|
|
let sourceOrgId = ''; |
|
|
|
if (!selectRef.value.own) { |
|
|
|
if (!currentOrgRef.value.own) { |
|
|
|
sourceOrgId = orgId; |
|
|
|
} |
|
|
|
opMap.fuc = (params) => { |
|
|
|
return formRef.value.triggerSubmit().then(() => { |
|
|
|
return http.post(department.deptSave, { |
|
|
|
...params, |
|
|
|
orgId: selectRef.value.deptInfo?.orgId, |
|
|
@ -233,6 +271,7 @@ |
|
|
|
projectId, |
|
|
|
orgName, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
return; |
|
|
|
}; |
|
|
@ -242,14 +281,11 @@ |
|
|
|
opMap.type = 'addson'; |
|
|
|
formData.value = {}; |
|
|
|
let sourceOrgId = ''; |
|
|
|
if (!selectRef.value.own) { |
|
|
|
if (!currentOrgRef.value.own) { |
|
|
|
sourceOrgId = orgId; |
|
|
|
} |
|
|
|
opMap.fuc = (params) => { |
|
|
|
if (!selectRef.value?.deptInfo?.deptId) { |
|
|
|
NsMessage.warn('请选择部门'); |
|
|
|
return; |
|
|
|
} |
|
|
|
return formRef.value.triggerSubmit().then(() => { |
|
|
|
return http.post(department.deptSave, { |
|
|
|
...params, |
|
|
|
orgId, |
|
|
@ -258,13 +294,14 @@ |
|
|
|
sourceOrgId, |
|
|
|
// deptName: selectRef.value.deptInfo.deptName, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
const addUser = () => { |
|
|
|
disabled2.value = false; |
|
|
|
roleDisabled.value = false; |
|
|
|
opMap.type = 'addUser'; |
|
|
|
formData2.value = {}; |
|
|
|
roleFormData.value = {}; |
|
|
|
opMap.fuc = (params) => { |
|
|
|
delete params.roleId; |
|
|
|
return http.post(department.addRole, { |
|
|
@ -278,29 +315,23 @@ |
|
|
|
}; |
|
|
|
|
|
|
|
const addUserSon = () => { |
|
|
|
disabled.value = false; |
|
|
|
roleDisabled.value = false; |
|
|
|
opMap.type = 'addUserSon'; |
|
|
|
formData2.value = {}; |
|
|
|
roleFormData.value = {}; |
|
|
|
opMap.fuc = (params) => { |
|
|
|
delete params.roleId; |
|
|
|
return http.post(department.addRole, { |
|
|
|
...params, |
|
|
|
orgId, |
|
|
|
projectId, |
|
|
|
proleId: selectRef2.value.roleId, |
|
|
|
proleId: selectRoleRef.value.roleId, |
|
|
|
deptId: selectRef.value.deptInfo.deptId, |
|
|
|
deptName: selectRef.value.deptInfo.deptName, |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
const deleteApartment = () => { |
|
|
|
const deleteDept = () => { |
|
|
|
// 删除逻辑 |
|
|
|
// opMap.type = 'deptDelete'; |
|
|
|
// opMap.fuc = (params) => { |
|
|
|
// return http.post(department.deptDel, params).then(() => { |
|
|
|
// NsMessage.success('删除成功'); |
|
|
|
// }); |
|
|
|
// }; |
|
|
|
Modal.confirm({ |
|
|
|
title: '是否确认删除', |
|
|
|
icon: createVNode(ExclamationCircleOutlined), |
|
|
@ -308,7 +339,7 @@ |
|
|
|
onOk() { |
|
|
|
http.post(department.deptDel, { deptId: selectRef.value.deptInfo.deptId }).then(() => { |
|
|
|
getTree(); |
|
|
|
clearApartData(); |
|
|
|
clearDeptData(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
onCancel() { |
|
|
@ -323,7 +354,7 @@ |
|
|
|
icon: createVNode(ExclamationCircleOutlined), |
|
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
|
onOk() { |
|
|
|
http.post(department.delRole, { roleId: selectRef2.value.roleId }).then(() => { |
|
|
|
http.post(department.delRole, { roleId: selectRoleRef.value.roleId }).then(() => { |
|
|
|
getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
|
}); |
|
|
|
}, |
|
|
@ -332,23 +363,17 @@ |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const clearApartData = () => { |
|
|
|
selectRef.value = {}; |
|
|
|
const clearDeptData = () => { |
|
|
|
formData.value = {}; |
|
|
|
opMap.type = ''; |
|
|
|
opMap.fuc = ''; |
|
|
|
selectKey.value = ''; |
|
|
|
}; |
|
|
|
const clearRoleData = () => { |
|
|
|
selectRef2.value = {}; |
|
|
|
formData2.value = {}; |
|
|
|
roleFormData.value = {}; |
|
|
|
opMap.type = ''; |
|
|
|
opMap.fuc = ''; |
|
|
|
selectKey2.value = ''; |
|
|
|
}; |
|
|
|
|
|
|
|
const deptTotalCheckedKeys = ref([]); |
|
|
|
const roleTotalCheckedKeys = ref([]); |
|
|
|
// 部门权限选择 |
|
|
|
const deptCheck = (checked, { halfCheckedKeys }) => { |
|
|
|
console.log(checked, halfCheckedKeys); |
|
|
@ -393,8 +418,8 @@ |
|
|
|
}; |
|
|
|
|
|
|
|
// 保存部门权限 |
|
|
|
const apartmentPermission = () => { |
|
|
|
http |
|
|
|
const deptPermission = () => { |
|
|
|
return http |
|
|
|
.post(department.addPermission, { |
|
|
|
deptId: selectRef.value?.deptInfo.deptId, |
|
|
|
projectId, |
|
|
@ -409,7 +434,7 @@ |
|
|
|
http |
|
|
|
.post(department.addRolePermission, { |
|
|
|
// deptId: selectRef.value?.deptInfo.deptId, |
|
|
|
roleId: selectRef2.value?.roleId, |
|
|
|
roleId: selectRoleRef.value?.roleId, |
|
|
|
projectId, |
|
|
|
permissionVoList: roleTotalCheckedKeys.value, |
|
|
|
}) |
|
|
@ -435,7 +460,7 @@ |
|
|
|
// 获取角色拥有的权限 |
|
|
|
const getRolePermission = () => { |
|
|
|
http |
|
|
|
.post(permission.queryRolePermission, { roleId: selectRef2.value?.roleId }) |
|
|
|
.post(permission.queryRolePermission, { roleId: selectRoleRef.value?.roleId }) |
|
|
|
.then((res) => { |
|
|
|
UsercheckedKeys.value = res.data |
|
|
|
?.filter((item) => !item.halfCheck) |
|
|
@ -459,27 +484,32 @@ |
|
|
|
|
|
|
|
// 部门编辑 |
|
|
|
const deptEdit = () => { |
|
|
|
disabledTree(); |
|
|
|
disabled.value = false; |
|
|
|
apartmentChoose(); |
|
|
|
}; |
|
|
|
|
|
|
|
// 部门选择 |
|
|
|
const SelectApartmentTree = (selectedKeys: any, info: any) => { |
|
|
|
console.log(selectedKeys, info); |
|
|
|
|
|
|
|
const { selected } = info; |
|
|
|
console.log(info); |
|
|
|
|
|
|
|
// disabled.value = !selected; |
|
|
|
// 部门切换需要调整角色tab |
|
|
|
roleActiveKey.value = 1; |
|
|
|
|
|
|
|
const { selected } = info; |
|
|
|
if (!selectedKeys?.length) return; |
|
|
|
|
|
|
|
selectKey.value = [info.node.key]; |
|
|
|
selectRef.value = info.node.dataRef; |
|
|
|
ApartcheckedKeys.value.splice(0); |
|
|
|
getDeptPermission(); |
|
|
|
formData.value = cloneDeep(info.node.dataRef.deptInfo); |
|
|
|
|
|
|
|
// getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
|
// 确定是否是企业 |
|
|
|
if (!selectRef.value.hasOwnProperty('own')) { |
|
|
|
formData.value = cloneDeep(info.node.dataRef.deptInfo); |
|
|
|
} else { |
|
|
|
currentOrgRef.value = selectRef.value; |
|
|
|
formData.value = {}; |
|
|
|
} |
|
|
|
getDeptPermission(); |
|
|
|
ApartcheckedKeys.value = []; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -493,132 +523,77 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
const roleEdit = () => { |
|
|
|
disabled2.value = false; |
|
|
|
roleDisabled.value = false; |
|
|
|
roleChoose(); |
|
|
|
}; |
|
|
|
// 角色选择 |
|
|
|
const SelectUserTree = (selectedKeys: any, info: any) => { |
|
|
|
const { selected } = info; |
|
|
|
// disabled2.value = !selected; |
|
|
|
// roleDisabled.value = !selected; |
|
|
|
|
|
|
|
if (!selectedKeys?.length) return; |
|
|
|
selectKey2.value = selectedKeys[0]; |
|
|
|
selectRef2.value = info.node.dataRef; |
|
|
|
formData2.value = cloneDeep(info.node.dataRef); |
|
|
|
UsercheckedKeys.value.splice(0); |
|
|
|
selectRoleKey.value = selectedKeys[0]; |
|
|
|
selectRoleRef.value = info.node.dataRef; |
|
|
|
roleFormData.value = cloneDeep(info.node.dataRef); |
|
|
|
UsercheckedKeys.value = []; |
|
|
|
getRolePermission(); |
|
|
|
getRolePermissionTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
|
}; |
|
|
|
|
|
|
|
const CancelApartment = () => { |
|
|
|
disabled.value = true; |
|
|
|
// 取消视为转入编辑状态 |
|
|
|
// clearApartData(); |
|
|
|
}; |
|
|
|
|
|
|
|
const CancelUser = () => { |
|
|
|
disabled2.value = true; |
|
|
|
}; |
|
|
|
|
|
|
|
const ApartmentSelect = (selectedKeys: any, info: any) => { |
|
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
|
console.log(info, 'info'); |
|
|
|
roleDisabled.value = true; |
|
|
|
}; |
|
|
|
|
|
|
|
const UserSelect = (selectedKeys: any, info: any) => { |
|
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
|
console.log(info, 'info'); |
|
|
|
}; |
|
|
|
|
|
|
|
const ApartmentSure = () => { |
|
|
|
console.log(opMap.type, 'ApartmentSure'); |
|
|
|
// 部门确定 |
|
|
|
const deptSure = () => { |
|
|
|
const opArr = ['addDept', 'editDpet', 'addson']; |
|
|
|
if (activeKey.value === 1) { |
|
|
|
if (opArr.includes(opMap.type)) { |
|
|
|
console.log(formRef.value, formData); |
|
|
|
opMap.fuc && |
|
|
|
opMap.fuc(formData.value).then(() => { |
|
|
|
getTree(); |
|
|
|
clearApartData(); |
|
|
|
clearDeptData(); |
|
|
|
disabled.value = true; |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
deptPermission().then(() => { |
|
|
|
clearDeptData(); |
|
|
|
disabled.value = true; |
|
|
|
}); |
|
|
|
} else if (opMap.type === 'deptDelete') { |
|
|
|
opMap.fuc && opMap.fuc({ ...formData.value, selectRef: selectRef.value }); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 角色确定 |
|
|
|
const UserSure = () => { |
|
|
|
disabled2.value = !disabled2.value; |
|
|
|
roleDisabled.value = !roleDisabled.value; |
|
|
|
const typeArr = ['addUserSon', 'addUser', 'editRole']; |
|
|
|
if (roleActiveKey.value === 1) { |
|
|
|
if (typeArr.includes(opMap.type)) { |
|
|
|
opMap.fuc && |
|
|
|
opMap.fuc(formData2.value).then(() => { |
|
|
|
opMap.fuc(roleFormData.value).then(() => { |
|
|
|
getUserTree(); |
|
|
|
clearRoleData(); |
|
|
|
}); |
|
|
|
} else if (selectRef2.value && opMap.type === 'addson') |
|
|
|
selectRef2.value['children'] = [ |
|
|
|
{ |
|
|
|
key: '123', |
|
|
|
title: formData2.value.departname, |
|
|
|
info: { ...cloneDeep(formData2.value) }, |
|
|
|
}, |
|
|
|
]; |
|
|
|
else { |
|
|
|
console.log('ss'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
rolePermission(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const disabledTree = (data, disabled) => { |
|
|
|
console.log(userAdminTreeData.value, 'userAdminTreeData.value'); |
|
|
|
userAdminTreeData.value.map((item) => { |
|
|
|
item['disabled'] = disabled; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
|
disabled, |
|
|
|
disabled2, |
|
|
|
formSchema, |
|
|
|
formSchema2, |
|
|
|
formData, |
|
|
|
formData2, |
|
|
|
apartmentTreeData, |
|
|
|
userTreeData, |
|
|
|
SelectApartmentTree, |
|
|
|
SelectUserTree, |
|
|
|
activeKey, |
|
|
|
activeKey2, |
|
|
|
ApartmentSure, |
|
|
|
UserSure, |
|
|
|
addApartment, |
|
|
|
addApartmentSon, |
|
|
|
deleteApartment, |
|
|
|
deleteUser, |
|
|
|
addUser, |
|
|
|
addUserSon, |
|
|
|
CancelApartment, |
|
|
|
CancelUser, |
|
|
|
apartmentAdminTreeData, |
|
|
|
ApartmentSelect, |
|
|
|
ApartcheckedKeys, |
|
|
|
userAdminTreeData, |
|
|
|
UsercheckedKeys, |
|
|
|
UserSelect, |
|
|
|
formRef, |
|
|
|
apartmentPermission, |
|
|
|
rolePermission, |
|
|
|
deptEdit, |
|
|
|
selectKey, |
|
|
|
selectKey2, |
|
|
|
deptTreeCheckedKeys, |
|
|
|
deptCheck, |
|
|
|
roleCheck, |
|
|
|
roleEdit, |
|
|
|
}; |
|
|
|
}, |
|
|
|
}); |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
|
<style lang="less" scoped> |
|
|
|
:deep(.ant-tabs-tabpane) { |
|
|
|
padding: 20px; |
|
|
|
.form { |
|
|
|
margin: 0 !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.main { |
|
|
|
display: flex; |
|
|
|
flex: 1; |
|
|
|