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