|
@ -65,10 +65,10 @@ |
|
|
</a-tabs> |
|
|
</a-tabs> |
|
|
<a-space v-if="activeKey === 1 || deptPermissionTreeData?.length"> |
|
|
<a-space v-if="activeKey === 1 || deptPermissionTreeData?.length"> |
|
|
<ns-button type="primary" @click="CancelApartment">取消 </ns-button> |
|
|
<ns-button type="primary" @click="CancelApartment">取消 </ns-button> |
|
|
<ns-button v-show="disabled" type="primary" @click="pipe(deptEdit, true, false)"> |
|
|
<ns-button v-if="disabled" type="primary" @click="pipe(deptEdit, true, false)"> |
|
|
编辑 |
|
|
编辑 |
|
|
</ns-button> |
|
|
</ns-button> |
|
|
<ns-button v-show="!disabled" type="primary" @click="deptSure">确定</ns-button> |
|
|
<ns-button v-else type="primary" @click="deptSure">确定</ns-button> |
|
|
</a-space> |
|
|
</a-space> |
|
|
</div> |
|
|
</div> |
|
|
</a-col> |
|
|
</a-col> |
|
@ -79,11 +79,11 @@ |
|
|
<a-row> |
|
|
<a-row> |
|
|
<a-col :span="8" class="tree"> |
|
|
<a-col :span="8" class="tree"> |
|
|
<a-space wrap style="margin-bottom: 16px; justify-content: flex-start"> |
|
|
<a-space wrap style="margin-bottom: 16px; justify-content: flex-start"> |
|
|
<ns-button v-auth="'userAdd'" type="primary" @click="rolePipe(addUser, true)"> |
|
|
<!-- <ns-button v-auth="'userAdd'" type="primary" @click="rolePipe(addUser, true)"> |
|
|
新增角色 |
|
|
新增角色 |
|
|
</ns-button> |
|
|
</ns-button> |
|
|
<ns-button type="primary" @click="rolePipe(addUserSon)">新增子角色</ns-button> |
|
|
<ns-button type="primary" @click="rolePipe(addUserSon)">新增子角色</ns-button> |
|
|
<ns-button type="primary" @click="rolePipe(deleteUser)"> 删除 </ns-button> |
|
|
<ns-button type="primary" @click="rolePipe(deleteUser)"> 删除 </ns-button> --> |
|
|
</a-space> |
|
|
</a-space> |
|
|
<a-tree |
|
|
<a-tree |
|
|
v-if="roleTreeData.length" |
|
|
v-if="roleTreeData.length" |
|
@ -95,19 +95,19 @@ |
|
|
<template #title="data"> |
|
|
<template #title="data"> |
|
|
<div style="display: flex; justify-content: space-between; align-items: center"> |
|
|
<div style="display: flex; justify-content: space-between; align-items: center"> |
|
|
<span> {{ data.zhName }}</span> |
|
|
<span> {{ data.zhName }}</span> |
|
|
<!-- <a-dropdown> |
|
|
<a-dropdown> |
|
|
<ns-icon name="actionMore" size="14" class="actionMore" /> |
|
|
<ns-icon name="actionMore" size="14" class="actionMore" /> |
|
|
<template #overlay> |
|
|
<template #overlay> |
|
|
<a-menu> |
|
|
<a-menu> |
|
|
<a-menu-item |
|
|
<a-menu-item |
|
|
v-for="(action, index) in dropRoleActions" |
|
|
v-for="(action, index) in filterAction(data, dropRoleActions, 'addUser')" |
|
|
:key="index" |
|
|
:key="index" |
|
|
@click="action.func(data)"> |
|
|
@click="action.func(data)"> |
|
|
<span>{{ action.title }}</span> |
|
|
<span>{{ action.title }}</span> |
|
|
</a-menu-item> |
|
|
</a-menu-item> |
|
|
</a-menu> |
|
|
</a-menu> |
|
|
</template> |
|
|
</template> |
|
|
</a-dropdown> --> |
|
|
</a-dropdown> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
</a-tree> |
|
|
</a-tree> |
|
@ -139,20 +139,16 @@ |
|
|
<a-empty style="margin-top: 120px" v-else /> |
|
|
<a-empty style="margin-top: 120px" v-else /> |
|
|
</a-tab-pane> |
|
|
</a-tab-pane> |
|
|
</a-tabs> |
|
|
</a-tabs> |
|
|
<a-space> |
|
|
<a-space v-if="roleActiveKey === 1 || rolePermissionTreeData?.length"> |
|
|
<ns-button type="primary" @click="CancelUser">取消</ns-button> |
|
|
<ns-button type="primary" @click="CancelUser">取消</ns-button> |
|
|
<ns-button |
|
|
<ns-button |
|
|
v-show="roleDisabled" |
|
|
v-if="roleDisabled" |
|
|
:disabled="!roleTreeData?.length" |
|
|
:disabled="!roleTreeData?.length" |
|
|
type="primary" |
|
|
type="primary" |
|
|
@click="rolePipe(roleEdit, false, false)"> |
|
|
@click="rolePipe(roleEdit, false, false)"> |
|
|
编辑 |
|
|
编辑 |
|
|
</ns-button> |
|
|
</ns-button> |
|
|
<ns-button |
|
|
<ns-button v-else :disabled="!roleTreeData?.length" type="primary" @click="roleSure"> |
|
|
v-show="!roleDisabled" |
|
|
|
|
|
:disabled="!roleTreeData?.length" |
|
|
|
|
|
type="primary" |
|
|
|
|
|
@click="roleSure"> |
|
|
|
|
|
确定 |
|
|
确定 |
|
|
</ns-button> |
|
|
</ns-button> |
|
|
</a-space> |
|
|
</a-space> |
|
@ -167,7 +163,7 @@ |
|
|
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 { cloneDeep, get } from 'lodash-es'; |
|
|
import { cloneDeep, get, isEmpty } 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 { permission } from '/@/api/origanizemanage'; |
|
@ -180,7 +176,7 @@ |
|
|
const formRef = ref(); |
|
|
const formRef = ref(); |
|
|
const formRoleRef = ref(); |
|
|
const formRoleRef = ref(); |
|
|
let formData = ref({}); |
|
|
let formData = ref({}); |
|
|
let roleFormData = ref({}); |
|
|
let roleFormData = ref({ isLeader: 1 }); |
|
|
const activeKey = ref(1); |
|
|
const activeKey = ref(1); |
|
|
const roleActiveKey = ref(1); |
|
|
const roleActiveKey = ref(1); |
|
|
const disabled = ref(true); |
|
|
const disabled = ref(true); |
|
@ -224,7 +220,7 @@ |
|
|
|
|
|
|
|
|
/**操作拦截 */ |
|
|
/**操作拦截 */ |
|
|
const pipe = (func: Function, flag = false, toggle = true) => { |
|
|
const pipe = (func: Function, flag = false, toggle = true) => { |
|
|
if (toggle) activeKey.value = 1; |
|
|
// if (toggle) activeKey.value = 1; |
|
|
if (flag) { |
|
|
if (flag) { |
|
|
// 只有部门的操作 |
|
|
// 只有部门的操作 |
|
|
if (selectRef.value?.hasOwnProperty('orgInfo') || !selectRef.value?.deptInfo) { |
|
|
if (selectRef.value?.hasOwnProperty('orgInfo') || !selectRef.value?.deptInfo) { |
|
@ -243,13 +239,15 @@ |
|
|
|
|
|
|
|
|
const rolePipe = (func: Function, linkDept = false, toggle = true) => { |
|
|
const rolePipe = (func: Function, linkDept = false, toggle = true) => { |
|
|
console.log(selectRoleRef.value); |
|
|
console.log(selectRoleRef.value); |
|
|
if (toggle) roleActiveKey.value = 1; |
|
|
// if (toggle) roleActiveKey.value = 1; |
|
|
// 需要先选择部门 |
|
|
// 需要先选择部门 |
|
|
if ((linkDept && !selectRef.value?.deptInfo) || selectRef.value?.hasOwnProperty('own')) { |
|
|
if ((linkDept && !selectRef.value?.deptInfo) || selectRef.value?.hasOwnProperty('own')) { |
|
|
NsMessage.error('请先选择相关部门'); |
|
|
NsMessage.error('请先选择相关部门'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (!linkDept && !selectRoleRef.value) { |
|
|
console.log(123); |
|
|
|
|
|
|
|
|
|
|
|
if (!linkDept && isEmpty(selectRoleRef.value)) { |
|
|
NsMessage.error('请先选择相关角色'); |
|
|
NsMessage.error('请先选择相关角色'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -302,6 +300,7 @@ |
|
|
item['deptInfo'] = item.orgInfo; |
|
|
item['deptInfo'] = item.orgInfo; |
|
|
item['deptInfo']['deptName'] = item?.orgInfo?.orgName; |
|
|
item['deptInfo']['deptName'] = item?.orgInfo?.orgName; |
|
|
item['own'] = !index; |
|
|
item['own'] = !index; |
|
|
|
|
|
item['selectable'] = false; |
|
|
item['children'] = item.deptTrees; |
|
|
item['children'] = item.deptTrees; |
|
|
return item; |
|
|
return item; |
|
|
}); |
|
|
}); |
|
@ -325,7 +324,7 @@ |
|
|
// 获取角色树 |
|
|
// 获取角色树 |
|
|
const getUserTree = (params = { deptId: selectRef.value?.deptInfo?.deptId }) => { |
|
|
const getUserTree = (params = { deptId: selectRef.value?.deptInfo?.deptId }) => { |
|
|
return http.post(department.queryRoleTree, params).then((res) => { |
|
|
return http.post(department.queryRoleTree, params).then((res) => { |
|
|
roleTreeData.value = res.data; |
|
|
roleTreeData.value = [{ zhName: '全部', selectable: false, orgInfo: {}, children: res.data }]; |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
// 根据依赖刷新角色树 |
|
|
// 根据依赖刷新角色树 |
|
@ -334,12 +333,12 @@ |
|
|
getUserTree().then(() => { |
|
|
getUserTree().then(() => { |
|
|
if (!roleTreeData.value?.length) { |
|
|
if (!roleTreeData.value?.length) { |
|
|
selectRoleRef.value = {}; |
|
|
selectRoleRef.value = {}; |
|
|
roleFormData.value = {}; |
|
|
roleFormData.value = { isLeader: 1 }; |
|
|
} |
|
|
} |
|
|
const info = { |
|
|
const info = { |
|
|
node: { key: '0-0', dataRef: { ...roleTreeData.value[0] } }, |
|
|
node: { key: '0-0-0', dataRef: { ...roleTreeData.value[0].children[0] } }, |
|
|
}; |
|
|
}; |
|
|
SelectUserTree(['0-0'], info); |
|
|
SelectUserTree([''], info); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -351,8 +350,10 @@ |
|
|
callback: null, |
|
|
callback: null, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 添加部门 |
|
|
const addApartment = (data) => { |
|
|
const addApartment = (data) => { |
|
|
const { deptInfo } = data; |
|
|
const { deptInfo } = data; |
|
|
|
|
|
activeKey.value = 1; |
|
|
|
|
|
|
|
|
disabled.value = false; |
|
|
disabled.value = false; |
|
|
opMap.type = 'addDept'; |
|
|
opMap.type = 'addDept'; |
|
@ -369,23 +370,17 @@ |
|
|
orgId: deptInfo?.orgId, |
|
|
orgId: deptInfo?.orgId, |
|
|
sourceOrgId, |
|
|
sourceOrgId, |
|
|
projectId, |
|
|
projectId, |
|
|
|
|
|
pdeptId: deptInfo.pdeptId || '', |
|
|
orgName, |
|
|
orgName, |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const getParent = (data) => { |
|
|
// 添加子部门 |
|
|
if (data?.parent) { |
|
|
|
|
|
getParent(data.parent); |
|
|
|
|
|
} else { |
|
|
|
|
|
data; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const addApartmentSon = (data) => { |
|
|
const addApartmentSon = (data) => { |
|
|
const { deptInfo } = data; |
|
|
const { deptInfo } = data; |
|
|
|
|
|
activeKey.value = 1; |
|
|
disabled.value = false; |
|
|
disabled.value = false; |
|
|
opMap.type = 'addson'; |
|
|
opMap.type = 'addson'; |
|
|
formData.value = {}; |
|
|
formData.value = {}; |
|
@ -407,10 +402,11 @@ |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const addUser = () => { |
|
|
const addUser = (data) => { |
|
|
roleDisabled.value = false; |
|
|
roleDisabled.value = false; |
|
|
opMap.type = 'addUser'; |
|
|
opMap.type = 'addUser'; |
|
|
roleFormData.value = {}; |
|
|
roleFormData.value = { isLeader: 1 }; |
|
|
|
|
|
roleActiveKey.value = 1; |
|
|
opMap.fuc = (params) => { |
|
|
opMap.fuc = (params) => { |
|
|
delete params.roleId; |
|
|
delete params.roleId; |
|
|
return formRoleRef.value.triggerSubmit().then(() => { |
|
|
return formRoleRef.value.triggerSubmit().then(() => { |
|
@ -418,6 +414,7 @@ |
|
|
...params, |
|
|
...params, |
|
|
orgId, |
|
|
orgId, |
|
|
projectId, |
|
|
projectId, |
|
|
|
|
|
proleId: data.proleId || '', |
|
|
deptId: selectRef.value.deptInfo.deptId, |
|
|
deptId: selectRef.value.deptInfo.deptId, |
|
|
deptName: selectRef.value.deptInfo.deptName, |
|
|
deptName: selectRef.value.deptInfo.deptName, |
|
|
}); |
|
|
}); |
|
@ -425,10 +422,11 @@ |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const addUserSon = () => { |
|
|
const addUserSon = (data) => { |
|
|
roleDisabled.value = false; |
|
|
roleDisabled.value = false; |
|
|
opMap.type = 'addUserSon'; |
|
|
opMap.type = 'addUserSon'; |
|
|
roleFormData.value = {}; |
|
|
roleActiveKey.value = 1; |
|
|
|
|
|
roleFormData.value = { isLeader: 1 }; |
|
|
opMap.fuc = (params) => { |
|
|
opMap.fuc = (params) => { |
|
|
delete params.roleId; |
|
|
delete params.roleId; |
|
|
return formRoleRef.value.triggerSubmit().then(() => { |
|
|
return formRoleRef.value.triggerSubmit().then(() => { |
|
@ -436,7 +434,7 @@ |
|
|
...params, |
|
|
...params, |
|
|
orgId, |
|
|
orgId, |
|
|
projectId, |
|
|
projectId, |
|
|
proleId: selectRoleRef.value.roleId, |
|
|
proleId: data.roleId, |
|
|
deptId: selectRef.value.deptInfo.deptId, |
|
|
deptId: selectRef.value.deptInfo.deptId, |
|
|
deptName: selectRef.value.deptInfo.deptName, |
|
|
deptName: selectRef.value.deptInfo.deptName, |
|
|
}); |
|
|
}); |
|
@ -444,8 +442,6 @@ |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
const deleteDept = (data) => { |
|
|
const deleteDept = (data) => { |
|
|
console.log(data); |
|
|
|
|
|
|
|
|
|
|
|
// 删除逻辑 |
|
|
// 删除逻辑 |
|
|
Modal.confirm({ |
|
|
Modal.confirm({ |
|
|
title: '是否确认删除', |
|
|
title: '是否确认删除', |
|
@ -458,6 +454,7 @@ |
|
|
// 删除选中的数据需要清空 |
|
|
// 删除选中的数据需要清空 |
|
|
deptTreeSelectedKeys.value = []; |
|
|
deptTreeSelectedKeys.value = []; |
|
|
selectRef.value = ''; |
|
|
selectRef.value = ''; |
|
|
|
|
|
roleTreeData.value = [{ zhName: '全部', selectable: false, orgInfo: {}, children: [] }]; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -467,16 +464,20 @@ |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const deleteUser = () => { |
|
|
const deleteUser = (data) => { |
|
|
Modal.confirm({ |
|
|
Modal.confirm({ |
|
|
title: '是否确认删除', |
|
|
title: '是否确认删除', |
|
|
onOk() { |
|
|
onOk() { |
|
|
http.post(department.delRole, { roleId: selectRoleRef.value.roleId }).then(() => { |
|
|
http.post(department.delRole, { roleId: data.roleId }).then(() => { |
|
|
getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
getUserTree({ deptId: selectRef.value.deptInfo.deptId }); |
|
|
clearRoleData(); |
|
|
clearRoleData(); |
|
|
// 清空select树 |
|
|
// 清空select树 |
|
|
roleTreeSelectedKeys.value = []; |
|
|
if (data.selected) { |
|
|
selectRoleRef.value = ''; |
|
|
// 删除选中的数据需要清空 |
|
|
|
|
|
roleTreeSelectedKeys.value = []; |
|
|
|
|
|
selectRoleRef.value = ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
NsMessage.success('操作成功'); |
|
|
NsMessage.success('操作成功'); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -554,6 +555,7 @@ |
|
|
}; |
|
|
}; |
|
|
// 保存角色权限 |
|
|
// 保存角色权限 |
|
|
const rolePermission = () => { |
|
|
const rolePermission = () => { |
|
|
|
|
|
if (!roleTotalCheckedKeys.value?.length) return; |
|
|
http |
|
|
http |
|
|
.post(department.addRolePermission, { |
|
|
.post(department.addRolePermission, { |
|
|
// deptId: selectRef.value?.deptInfo.deptId, |
|
|
// deptId: selectRef.value?.deptInfo.deptId, |
|
@ -645,6 +647,7 @@ |
|
|
rolePermissionTreeData.value = []; |
|
|
rolePermissionTreeData.value = []; |
|
|
roleCheckedKeys.value = []; |
|
|
roleCheckedKeys.value = []; |
|
|
roleTreeSelectedKeys.value = []; |
|
|
roleTreeSelectedKeys.value = []; |
|
|
|
|
|
roleDisabled.value = true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -739,10 +742,10 @@ |
|
|
// { title: '新增角色', func: addUser, key: 'addUser' }, |
|
|
// { title: '新增角色', func: addUser, key: 'addUser' }, |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
const filterAction = (data, actions) => { |
|
|
const filterAction = (data, actions, keyV = 'addDept') => { |
|
|
if (data.hasOwnProperty('orgInfo')) { |
|
|
if (data.hasOwnProperty('orgInfo')) { |
|
|
// 企业节点 |
|
|
// 企业节点 |
|
|
return actions.filter(({ key }) => key === 'addDept'); |
|
|
return actions.filter(({ key }) => key === keyV); |
|
|
} |
|
|
} |
|
|
return actions; |
|
|
return actions; |
|
|
}; |
|
|
}; |
|
|