|
@ -6,16 +6,26 @@ |
|
|
<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 :disabled="disabled" style="margin: 10px" type="primary" @click="addApartment" |
|
|
<ns-button type="primary" @click="addApartmentSon">新增子部门</ns-button> |
|
|
>新增部门</ns-button |
|
|
<ns-button style="margin: 10px" type="primary" @click="deleteApartment">删除</ns-button> |
|
|
> |
|
|
|
|
|
<ns-button :disabled="disabled" type="primary" @click="addApartmentSon" |
|
|
|
|
|
>新增子部门</ns-button |
|
|
|
|
|
> |
|
|
|
|
|
<ns-button |
|
|
|
|
|
:disabled="disabled" |
|
|
|
|
|
style="margin: 10px" |
|
|
|
|
|
type="primary" |
|
|
|
|
|
@click="deleteApartment" |
|
|
|
|
|
>删除</ns-button |
|
|
|
|
|
> |
|
|
<a-tree |
|
|
<a-tree |
|
|
v-if="apartmentTreeData?.length" |
|
|
v-if="apartmentTreeData?.length" |
|
|
:tree-data="apartmentTreeData" |
|
|
:tree-data="apartmentTreeData" |
|
|
defaultExpandAll |
|
|
defaultExpandAll |
|
|
@select="SelectApartmentTree"> |
|
|
@select="SelectApartmentTree"> |
|
|
<template #title="data"> |
|
|
<template #title="data"> |
|
|
{{ data.deptInfo.deptName }} |
|
|
{{ data.deptInfo?.deptName }} |
|
|
</template> |
|
|
</template> |
|
|
</a-tree> |
|
|
</a-tree> |
|
|
</a-col> |
|
|
</a-col> |
|
@ -51,12 +61,20 @@ |
|
|
<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="addUser">新增角色</ns-button> |
|
|
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="addUser" |
|
|
<ns-button type="primary" @click="addUserSon">新增子角色</ns-button> |
|
|
>新增角色</ns-button |
|
|
<ns-button style="margin: 10px" type="primary" @click="deleteUser">删除</ns-button> |
|
|
> |
|
|
<a-tree :tree-data="userTreeData" defaultExpandAll @select="SelectUserTree"> |
|
|
<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 |
|
|
|
|
|
v-if="userTreeData.length" |
|
|
|
|
|
:tree-data="userTreeData" |
|
|
|
|
|
defaultExpandAll |
|
|
|
|
|
@select="SelectUserTree"> |
|
|
<template #title="data"> |
|
|
<template #title="data"> |
|
|
{{ data }} |
|
|
{{ data.zhName }} |
|
|
</template> |
|
|
</template> |
|
|
</a-tree> |
|
|
</a-tree> |
|
|
</a-col> |
|
|
</a-col> |
|
@ -94,10 +112,11 @@ |
|
|
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'; |
|
|
import { uuid } from '@antv/x6/lib/util/string/uuid'; |
|
|
|
|
|
import { cloneDeep } from 'lodash-es'; |
|
|
import { cloneDeep } from 'lodash-es'; |
|
|
import { formConfig, formConfig2 } from './config'; |
|
|
import { formConfig, formConfig2 } from './config'; |
|
|
import { department } from '/@/api/origanizemanage'; |
|
|
import { department } from '/@/api/origanizemanage'; |
|
|
|
|
|
import { permission } from '/@/api/origanizemanage'; |
|
|
|
|
|
import { NsMessage } from '/nerv-lib/component'; |
|
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
export default defineComponent({ |
|
|
name: 'AuthorityManageIndex', |
|
|
name: 'AuthorityManageIndex', |
|
@ -119,39 +138,10 @@ |
|
|
const formSchema2 = formConfig2(disabled2 as any); |
|
|
const formSchema2 = formConfig2(disabled2 as any); |
|
|
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId; |
|
|
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId; |
|
|
const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId; |
|
|
const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId; |
|
|
|
|
|
const userAdminTreeData = ref([]); |
|
|
watch(ApartcheckedKeys, () => { |
|
|
|
|
|
console.log('checkedKeys', ApartcheckedKeys.value); |
|
|
|
|
|
}); |
|
|
|
|
|
watch(UsercheckedKeys, () => { |
|
|
|
|
|
console.log('checkedKeys', UsercheckedKeys.value); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 部门树 |
|
|
|
|
|
const getDepartList = (params) => { |
|
|
|
|
|
return http.post(department.dartList, params); |
|
|
|
|
|
}; |
|
|
|
|
|
getDepartList({ orgId: 1 }).then((res) => { |
|
|
|
|
|
apartmentTreeData.value = res.data; |
|
|
|
|
|
}); |
|
|
|
|
|
const opMap: any = { |
|
|
|
|
|
type: 'add', |
|
|
|
|
|
fuc: () => {}, |
|
|
|
|
|
record: {}, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const apartmentTreeData = ref([]); |
|
|
const apartmentTreeData = ref([]); |
|
|
|
|
|
|
|
|
const userTreeData = ref([ |
|
|
const userTreeData = ref([]); |
|
|
{ |
|
|
|
|
|
title: '产品总监', |
|
|
|
|
|
key: '0-0', |
|
|
|
|
|
children: [ |
|
|
|
|
|
{ title: '产品经理', key: '0-0-0', info: { departname: '产品经理' } }, |
|
|
|
|
|
{ title: '产品助理', key: '0-0-1', info: { departname: '产品助理' } }, |
|
|
|
|
|
], |
|
|
|
|
|
}, |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
const apartmentAdminTreeData = [ |
|
|
const apartmentAdminTreeData = [ |
|
|
{ |
|
|
{ |
|
@ -174,17 +164,40 @@ |
|
|
], |
|
|
], |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
|
|
|
|
watch(ApartcheckedKeys, () => { |
|
|
|
|
|
console.log('checkedKeys', ApartcheckedKeys.value); |
|
|
|
|
|
}); |
|
|
|
|
|
watch(UsercheckedKeys, () => { |
|
|
|
|
|
console.log('checkedKeys', UsercheckedKeys.value); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const userAdminTreeData = ref([ |
|
|
// 部门树 |
|
|
{ |
|
|
const getDepartList = (params) => { |
|
|
title: '产品总监', |
|
|
return http.post(department.dartList, params); |
|
|
key: '0-0', |
|
|
}; |
|
|
children: [ |
|
|
getDepartList({ orgId }).then((res) => { |
|
|
{ title: '产品经理1', key: '0-0-0' }, |
|
|
apartmentTreeData.value = res.data; |
|
|
{ title: '产品经理2', key: '0-0-1' }, |
|
|
}); |
|
|
], |
|
|
|
|
|
}, |
|
|
const getTree = () => { |
|
|
]); |
|
|
getDepartList({ orgId }).then((res) => { |
|
|
|
|
|
apartmentTreeData.value = res.data; |
|
|
|
|
|
NsMessage.success('操作成功'); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getUserTree = (params = { deptId: 2 }) => { |
|
|
|
|
|
http.post(department.queryRoleTree, params).then((res) => { |
|
|
|
|
|
userTreeData.value = res.data; |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
getUserTree({ deptId: 2 }); |
|
|
|
|
|
const opMap: any = { |
|
|
|
|
|
type: 'add', |
|
|
|
|
|
fuc: () => {}, |
|
|
|
|
|
record: {}, |
|
|
|
|
|
callback: null, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
function fetch(api, params) { |
|
|
function fetch(api, params) { |
|
|
return http.post(api, params); |
|
|
return http.post(api, params); |
|
@ -192,9 +205,14 @@ |
|
|
|
|
|
|
|
|
const addApartment = () => { |
|
|
const addApartment = () => { |
|
|
disabled.value = false; |
|
|
disabled.value = false; |
|
|
opMap.type = 'add'; |
|
|
opMap.type = 'addDept'; |
|
|
|
|
|
formData.value = {}; |
|
|
opMap.fuc = (params) => { |
|
|
opMap.fuc = (params) => { |
|
|
fetch(department.deptSave, { ...params, orgId, projectId }); |
|
|
return http.post(department.deptSave, { |
|
|
|
|
|
...params, |
|
|
|
|
|
orgId, |
|
|
|
|
|
projectId, |
|
|
|
|
|
}); |
|
|
}; |
|
|
}; |
|
|
return; |
|
|
return; |
|
|
}; |
|
|
}; |
|
@ -204,7 +222,7 @@ |
|
|
opMap.type = 'addson'; |
|
|
opMap.type = 'addson'; |
|
|
formData.value = {}; |
|
|
formData.value = {}; |
|
|
opMap.fuc = (params) => { |
|
|
opMap.fuc = (params) => { |
|
|
fetch(department.deptSave, { |
|
|
return http.post(department.deptSave, { |
|
|
...params, |
|
|
...params, |
|
|
orgId, |
|
|
orgId, |
|
|
projectId, |
|
|
projectId, |
|
@ -215,30 +233,58 @@ |
|
|
|
|
|
|
|
|
const addUser = () => { |
|
|
const addUser = () => { |
|
|
disabled2.value = false; |
|
|
disabled2.value = false; |
|
|
|
|
|
opMap.type = 'addUser'; |
|
|
|
|
|
formData.value = {}; |
|
|
|
|
|
opMap.fuc = (params) => { |
|
|
|
|
|
delete params.roleId; |
|
|
|
|
|
return http.post(department.addRole, { |
|
|
|
|
|
...params, |
|
|
|
|
|
orgId, |
|
|
|
|
|
projectId, |
|
|
|
|
|
enName: 'leader', |
|
|
|
|
|
roleNote: 'wqe', |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const addUserSon = () => { |
|
|
const addUserSon = () => { |
|
|
disabled.value = false; |
|
|
disabled.value = false; |
|
|
opMap.type = 'addson'; |
|
|
opMap.type = 'addUserSon'; |
|
|
|
|
|
formData.value = {}; |
|
|
|
|
|
opMap.fuc = (params) => { |
|
|
|
|
|
delete params.roleId; |
|
|
|
|
|
delete params.proleId; |
|
|
|
|
|
return http.post(department.addRole, { |
|
|
|
|
|
...params, |
|
|
|
|
|
proleId: 4, |
|
|
|
|
|
orgId, |
|
|
|
|
|
projectId, |
|
|
|
|
|
enName: 'leader', |
|
|
|
|
|
roleNote: 'wqe', |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
}; |
|
|
}; |
|
|
const deleteApartment = () => { |
|
|
const deleteApartment = () => { |
|
|
|
|
|
// 删除逻辑 |
|
|
|
|
|
// 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), |
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
onOk() { |
|
|
onOk() { |
|
|
function deepDel(data = apartmentTreeData.value[0].children) { |
|
|
http.post(department.deptDel, { deptId: selectRef.value.deptInfo.deptId }).then(() => { |
|
|
data.map((item, index) => { |
|
|
getTree(); |
|
|
if (item.key === selectKey.value) data.splice(index, 1); |
|
|
clearData(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
deepDel(); |
|
|
|
|
|
console.log(selectKey.value); |
|
|
|
|
|
}, |
|
|
}, |
|
|
onCancel() { |
|
|
onCancel() { |
|
|
console.log('Cancel'); |
|
|
console.log('Cancel'); |
|
|
}, |
|
|
}, |
|
|
class: 'test', |
|
|
|
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -248,38 +294,46 @@ |
|
|
icon: createVNode(ExclamationCircleOutlined), |
|
|
icon: createVNode(ExclamationCircleOutlined), |
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
onOk() { |
|
|
onOk() { |
|
|
function deepDel(data = userTreeData.value[0].children) { |
|
|
http.post(department.delRole, { roleId: selectRef2.value.roleId }).then(() => { |
|
|
data.map((item, index) => { |
|
|
getUserTree(); |
|
|
if (item.key === selectKey2.value) data.splice(index, 1); |
|
|
}); |
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
deepDel(); |
|
|
|
|
|
console.log(selectKey2.value); |
|
|
|
|
|
}, |
|
|
|
|
|
onCancel() { |
|
|
|
|
|
console.log('Cancel'); |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
class: 'test', |
|
|
class: 'test', |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
const clearData = () => { |
|
|
|
|
|
selectRef.value = {}; |
|
|
|
|
|
formData.value = {}; |
|
|
|
|
|
opMap.type = ''; |
|
|
|
|
|
opMap.fuc = ''; |
|
|
|
|
|
selectKey.value = ''; |
|
|
|
|
|
}; |
|
|
|
|
|
// 部门选择 |
|
|
const SelectApartmentTree = (selectedKeys: any, info: any) => { |
|
|
const SelectApartmentTree = (selectedKeys: any, info: any) => { |
|
|
console.log(selectedKeys, info); |
|
|
const { selected } = info; |
|
|
|
|
|
disabled.value = !selected; |
|
|
disabled.value = false; |
|
|
console.log(info, 'info'); |
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
|
|
|
console.log(info.node.dataRef, 'info'); |
|
|
|
|
|
selectKey.value = selectedKeys[0]; |
|
|
selectKey.value = selectedKeys[0]; |
|
|
selectRef.value = info.node.dataRef; |
|
|
selectRef.value = info.node.dataRef; |
|
|
formData.value = info.node.dataRef.deptInfo; |
|
|
formData.value = cloneDeep(info.node.dataRef.deptInfo); |
|
|
|
|
|
opMap.type = 'editDpet'; |
|
|
|
|
|
opMap.fuc = (params) => { |
|
|
|
|
|
return http.post(department.deptEdit, params); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 角色选择 |
|
|
const SelectUserTree = (selectedKeys: any, info: any) => { |
|
|
const SelectUserTree = (selectedKeys: any, info: any) => { |
|
|
disabled2.value = false; |
|
|
const { selected } = info; |
|
|
|
|
|
disabled2.value = !selected; |
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
console.log(info.node.dataRef.info, 'info'); |
|
|
console.log(info, 'info'); |
|
|
selectKey2.value = selectedKeys[0]; |
|
|
selectKey2.value = selectedKeys[0]; |
|
|
selectRef2.value = info.node.dataRef; |
|
|
selectRef2.value = info.node.dataRef; |
|
|
formData2.value = info.node.dataRef.info; |
|
|
formData2.value = cloneDeep(info.node.dataRef); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const CancelApartment = () => { |
|
|
const CancelApartment = () => { |
|
@ -305,27 +359,27 @@ |
|
|
|
|
|
|
|
|
// disabled.value = !disabled.value; |
|
|
// disabled.value = !disabled.value; |
|
|
// console.log(formData.value.name, 'formData'); |
|
|
// console.log(formData.value.name, 'formData'); |
|
|
console.log(opMap.type, 'opMap.type'); |
|
|
console.log(opMap.type, 'ApartmentSure'); |
|
|
if (opMap.type === 'add') { |
|
|
const opArr = ['addDept', 'editDpet']; |
|
|
|
|
|
if (opArr.includes(opMap.type)) { |
|
|
console.log(formRef.value, formData); |
|
|
console.log(formRef.value, formData); |
|
|
opMap.fuc && opMap.fuc(formData.value); |
|
|
opMap.fuc && |
|
|
|
|
|
opMap.fuc(formData.value).then(() => { |
|
|
|
|
|
getTree(); |
|
|
|
|
|
}); |
|
|
} else if (selectRef.value && opMap.type === 'addson') |
|
|
} else if (selectRef.value && opMap.type === 'addson') |
|
|
opMap.fuc && opMap.fuc(formData.value); |
|
|
opMap.fuc && opMap.fuc(formData.value); |
|
|
else { |
|
|
else if (opMap.type === 'deptDelete') { |
|
|
console.log('ss'); |
|
|
opMap.fuc && opMap.fuc({ ...formData.value, selectRef: selectRef.value }); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
const UserSure = () => { |
|
|
const UserSure = () => { |
|
|
disabled2.value = !disabled2.value; |
|
|
disabled2.value = !disabled2.value; |
|
|
opMap.fuc && opMap.fuc(formData2.value); |
|
|
|
|
|
console.log(formData2.value, 'formData2'); |
|
|
console.log(formData2.value, 'formData2'); |
|
|
console.log(opMap.type, 'opMap.type'); |
|
|
console.log(opMap.type, 'opMap.type'); |
|
|
if (opMap.type === 'add') { |
|
|
const typeArr = ['addUserSon', 'addUser']; |
|
|
userTreeData.value[0].children.push({ |
|
|
if (typeArr.includes(opMap.type)) { |
|
|
title: formData2.value.departname, |
|
|
opMap.fuc && opMap.fuc(formData2.value); |
|
|
key: 'a2', |
|
|
|
|
|
info: { ...formData2.value }, |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (selectRef2.value && opMap.type === 'addson') |
|
|
} else if (selectRef2.value && opMap.type === 'addson') |
|
|
selectRef2.value['children'] = [ |
|
|
selectRef2.value['children'] = [ |
|
|
{ |
|
|
{ |
|
@ -379,16 +433,19 @@ |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex: 1; |
|
|
flex: 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.left { |
|
|
.left { |
|
|
width: 50%; |
|
|
width: 50%; |
|
|
height: calc(100vh-50px); |
|
|
height: calc(100vh-50px); |
|
|
border-right: 5px solid rgb(229, 235, 240); |
|
|
border-right: 5px solid rgb(229, 235, 240); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.tree { |
|
|
.tree { |
|
|
width: 400px; |
|
|
width: 400px; |
|
|
height: 89vh; |
|
|
height: 89vh; |
|
|
border-right: 2px solid rgb(229, 235, 240); |
|
|
border-right: 2px solid rgb(229, 235, 240); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.right { |
|
|
.right { |
|
|
width: 50%; |
|
|
width: 50%; |
|
|
} |
|
|
} |
|
@ -397,6 +454,7 @@ |
|
|
height: 50vh; |
|
|
height: 50vh; |
|
|
border-bottom: 5px solid rgb(229, 235, 240); |
|
|
border-bottom: 5px solid rgb(229, 235, 240); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.ns-table-title { |
|
|
.ns-table-title { |
|
|
text-align: left; |
|
|
text-align: left; |
|
|
height: 46px; |
|
|
height: 46px; |
|
@ -408,9 +466,11 @@ |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
border-bottom: 2px solid rgb(229, 235, 240); |
|
|
border-bottom: 2px solid rgb(229, 235, 240); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.table { |
|
|
.table { |
|
|
width: 2000px; |
|
|
width: 2000px; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.admin { |
|
|
.admin { |
|
|
text-align: left; |
|
|
text-align: left; |
|
|
height: 42px; |
|
|
height: 42px; |
|
@ -421,6 +481,7 @@ |
|
|
padding-left: 16px; |
|
|
padding-left: 16px; |
|
|
width: calc(100% + 32px); |
|
|
width: calc(100% + 32px); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.form { |
|
|
.form { |
|
|
margin: 20px; |
|
|
margin: 20px; |
|
|
} |
|
|
} |
|
|