fix: bug修改
This commit is contained in:
@@ -131,6 +131,7 @@ export const formConfig2 = (disabled2: Boolean) => {
|
||||
label: '是否部门领导',
|
||||
field: 'isLeader',
|
||||
component: 'NsRadioGroup',
|
||||
defaultValue: 1,
|
||||
componentProps: {
|
||||
disabled: disabled2,
|
||||
radioType: 'radio',
|
||||
|
@@ -65,10 +65,10 @@
|
||||
</a-tabs>
|
||||
<a-space v-if="activeKey === 1 || deptPermissionTreeData?.length">
|
||||
<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 v-show="!disabled" type="primary" @click="deptSure">确定</ns-button>
|
||||
<ns-button v-else type="primary" @click="deptSure">确定</ns-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</a-col>
|
||||
@@ -79,11 +79,11 @@
|
||||
<a-row>
|
||||
<a-col :span="8" class="tree">
|
||||
<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 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-tree
|
||||
v-if="roleTreeData.length"
|
||||
@@ -95,19 +95,19 @@
|
||||
<template #title="data">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center">
|
||||
<span> {{ data.zhName }}</span>
|
||||
<!-- <a-dropdown>
|
||||
<a-dropdown>
|
||||
<ns-icon name="actionMore" size="14" class="actionMore" />
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item
|
||||
v-for="(action, index) in dropRoleActions"
|
||||
v-for="(action, index) in filterAction(data, dropRoleActions, 'addUser')"
|
||||
:key="index"
|
||||
@click="action.func(data)">
|
||||
<span>{{ action.title }}</span>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown> -->
|
||||
</a-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</a-tree>
|
||||
@@ -139,20 +139,16 @@
|
||||
<a-empty style="margin-top: 120px" v-else />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
<a-space>
|
||||
<a-space v-if="roleActiveKey === 1 || rolePermissionTreeData?.length">
|
||||
<ns-button type="primary" @click="CancelUser">取消</ns-button>
|
||||
<ns-button
|
||||
v-show="roleDisabled"
|
||||
v-if="roleDisabled"
|
||||
:disabled="!roleTreeData?.length"
|
||||
type="primary"
|
||||
@click="rolePipe(roleEdit, false, false)">
|
||||
编辑
|
||||
</ns-button>
|
||||
<ns-button
|
||||
v-show="!roleDisabled"
|
||||
:disabled="!roleTreeData?.length"
|
||||
type="primary"
|
||||
@click="roleSure">
|
||||
<ns-button v-else :disabled="!roleTreeData?.length" type="primary" @click="roleSure">
|
||||
确定
|
||||
</ns-button>
|
||||
</a-space>
|
||||
@@ -167,7 +163,7 @@
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
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 { department } from '/@/api/origanizemanage';
|
||||
import { permission } from '/@/api/origanizemanage';
|
||||
@@ -180,7 +176,7 @@
|
||||
const formRef = ref();
|
||||
const formRoleRef = ref();
|
||||
let formData = ref({});
|
||||
let roleFormData = ref({});
|
||||
let roleFormData = ref({ isLeader: 1 });
|
||||
const activeKey = ref(1);
|
||||
const roleActiveKey = ref(1);
|
||||
const disabled = ref(true);
|
||||
@@ -224,7 +220,7 @@
|
||||
|
||||
/**操作拦截 */
|
||||
const pipe = (func: Function, flag = false, toggle = true) => {
|
||||
if (toggle) activeKey.value = 1;
|
||||
// if (toggle) activeKey.value = 1;
|
||||
if (flag) {
|
||||
// 只有部门的操作
|
||||
if (selectRef.value?.hasOwnProperty('orgInfo') || !selectRef.value?.deptInfo) {
|
||||
@@ -243,13 +239,15 @@
|
||||
|
||||
const rolePipe = (func: Function, linkDept = false, toggle = true) => {
|
||||
console.log(selectRoleRef.value);
|
||||
if (toggle) roleActiveKey.value = 1;
|
||||
// if (toggle) roleActiveKey.value = 1;
|
||||
// 需要先选择部门
|
||||
if ((linkDept && !selectRef.value?.deptInfo) || selectRef.value?.hasOwnProperty('own')) {
|
||||
NsMessage.error('请先选择相关部门');
|
||||
return;
|
||||
}
|
||||
if (!linkDept && !selectRoleRef.value) {
|
||||
console.log(123);
|
||||
|
||||
if (!linkDept && isEmpty(selectRoleRef.value)) {
|
||||
NsMessage.error('请先选择相关角色');
|
||||
return;
|
||||
}
|
||||
@@ -302,6 +300,7 @@
|
||||
item['deptInfo'] = item.orgInfo;
|
||||
item['deptInfo']['deptName'] = item?.orgInfo?.orgName;
|
||||
item['own'] = !index;
|
||||
item['selectable'] = false;
|
||||
item['children'] = item.deptTrees;
|
||||
return item;
|
||||
});
|
||||
@@ -325,7 +324,7 @@
|
||||
// 获取角色树
|
||||
const getUserTree = (params = { deptId: selectRef.value?.deptInfo?.deptId }) => {
|
||||
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(() => {
|
||||
if (!roleTreeData.value?.length) {
|
||||
selectRoleRef.value = {};
|
||||
roleFormData.value = {};
|
||||
roleFormData.value = { isLeader: 1 };
|
||||
}
|
||||
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(['0-0-0'], info);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -351,8 +350,10 @@
|
||||
callback: null,
|
||||
};
|
||||
|
||||
// 添加部门
|
||||
const addApartment = (data) => {
|
||||
const { deptInfo } = data;
|
||||
activeKey.value = 1;
|
||||
|
||||
disabled.value = false;
|
||||
opMap.type = 'addDept';
|
||||
@@ -369,23 +370,17 @@
|
||||
orgId: deptInfo?.orgId,
|
||||
sourceOrgId,
|
||||
projectId,
|
||||
pdeptId: deptInfo.pdeptId || '',
|
||||
orgName,
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const getParent = (data) => {
|
||||
if (data?.parent) {
|
||||
getParent(data.parent);
|
||||
} else {
|
||||
data;
|
||||
}
|
||||
};
|
||||
|
||||
// 添加子部门
|
||||
const addApartmentSon = (data) => {
|
||||
const { deptInfo } = data;
|
||||
|
||||
activeKey.value = 1;
|
||||
disabled.value = false;
|
||||
opMap.type = 'addson';
|
||||
formData.value = {};
|
||||
@@ -410,7 +405,8 @@
|
||||
const addUser = () => {
|
||||
roleDisabled.value = false;
|
||||
opMap.type = 'addUser';
|
||||
roleFormData.value = {};
|
||||
roleFormData.value = { isLeader: 1 };
|
||||
roleActiveKey.value = 1;
|
||||
opMap.fuc = (params) => {
|
||||
delete params.roleId;
|
||||
return formRoleRef.value.triggerSubmit().then(() => {
|
||||
@@ -428,7 +424,8 @@
|
||||
const addUserSon = () => {
|
||||
roleDisabled.value = false;
|
||||
opMap.type = 'addUserSon';
|
||||
roleFormData.value = {};
|
||||
roleActiveKey.value = 1;
|
||||
roleFormData.value = { isLeader: 1 };
|
||||
opMap.fuc = (params) => {
|
||||
delete params.roleId;
|
||||
return formRoleRef.value.triggerSubmit().then(() => {
|
||||
@@ -444,8 +441,6 @@
|
||||
};
|
||||
};
|
||||
const deleteDept = (data) => {
|
||||
console.log(data);
|
||||
|
||||
// 删除逻辑
|
||||
Modal.confirm({
|
||||
title: '是否确认删除',
|
||||
@@ -458,6 +453,7 @@
|
||||
// 删除选中的数据需要清空
|
||||
deptTreeSelectedKeys.value = [];
|
||||
selectRef.value = '';
|
||||
roleTreeData.value = [{ zhName: '全部', selectable: false, orgInfo: {}, children: [] }];
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -467,16 +463,20 @@
|
||||
});
|
||||
};
|
||||
|
||||
const deleteUser = () => {
|
||||
const deleteUser = (data) => {
|
||||
Modal.confirm({
|
||||
title: '是否确认删除',
|
||||
onOk() {
|
||||
http.post(department.delRole, { roleId: selectRoleRef.value.roleId }).then(() => {
|
||||
http.post(department.delRole, { roleId: data.roleId }).then(() => {
|
||||
getUserTree({ deptId: selectRef.value.deptInfo.deptId });
|
||||
clearRoleData();
|
||||
// 清空select树
|
||||
roleTreeSelectedKeys.value = [];
|
||||
selectRoleRef.value = '';
|
||||
if (data.selected) {
|
||||
// 删除选中的数据需要清空
|
||||
roleTreeSelectedKeys.value = [];
|
||||
selectRoleRef.value = '';
|
||||
}
|
||||
|
||||
NsMessage.success('操作成功');
|
||||
});
|
||||
},
|
||||
@@ -554,6 +554,7 @@
|
||||
};
|
||||
// 保存角色权限
|
||||
const rolePermission = () => {
|
||||
if (!roleTotalCheckedKeys.value?.length) return;
|
||||
http
|
||||
.post(department.addRolePermission, {
|
||||
// deptId: selectRef.value?.deptInfo.deptId,
|
||||
@@ -645,6 +646,7 @@
|
||||
rolePermissionTreeData.value = [];
|
||||
roleCheckedKeys.value = [];
|
||||
roleTreeSelectedKeys.value = [];
|
||||
roleDisabled.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -739,10 +741,10 @@
|
||||
// { title: '新增角色', func: addUser, key: 'addUser' },
|
||||
]);
|
||||
|
||||
const filterAction = (data, actions) => {
|
||||
const filterAction = (data, actions, keyV = 'addDept') => {
|
||||
if (data.hasOwnProperty('orgInfo')) {
|
||||
// 企业节点
|
||||
return actions.filter(({ key }) => key === 'addDept');
|
||||
return actions.filter(({ key }) => key === keyV);
|
||||
}
|
||||
return actions;
|
||||
};
|
||||
|
Reference in New Issue
Block a user