feat: 用户联调
This commit is contained in:
@@ -9,7 +9,7 @@ export const formConfig = (disabled: Boolean) => {
|
||||
schemas: [
|
||||
{
|
||||
label: '部门名称',
|
||||
field: 'name',
|
||||
field: 'deptName',
|
||||
component: 'NsInput',
|
||||
componentProps: {
|
||||
disabled: disabled,
|
||||
@@ -23,27 +23,27 @@ export const formConfig = (disabled: Boolean) => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '上级部门',
|
||||
field: 'department',
|
||||
component: 'NsSelect',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: [
|
||||
{
|
||||
label: '部门1',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '部门2',
|
||||
value: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
// {
|
||||
// label: '上级部门',
|
||||
// field: 'department',
|
||||
// component: 'NsSelect',
|
||||
// componentProps: {
|
||||
// disabled: true,
|
||||
// options: [
|
||||
// {
|
||||
// label: '部门1',
|
||||
// value: 1,
|
||||
// },
|
||||
// {
|
||||
// label: '部门2',
|
||||
// value: 2,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
{
|
||||
label: '部门编码',
|
||||
field: 'code',
|
||||
field: 'deptCode',
|
||||
component: 'NsInput',
|
||||
componentProps: {
|
||||
disabled: disabled,
|
||||
|
@@ -9,9 +9,13 @@
|
||||
<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>
|
||||
<a-tree :tree-data="apartmentTreeData" defaultExpandAll @select="SelectApartmentTree">
|
||||
<template #title="{ title }">
|
||||
{{ title }}
|
||||
<a-tree
|
||||
v-if="apartmentTreeData?.length"
|
||||
:tree-data="apartmentTreeData"
|
||||
defaultExpandAll
|
||||
@select="SelectApartmentTree">
|
||||
<template #title="data">
|
||||
{{ data.deptInfo.deptName }}
|
||||
</template>
|
||||
</a-tree>
|
||||
</a-col>
|
||||
@@ -39,9 +43,7 @@
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
<ns-button style="margin: 20px" type="primary" @click="CancelApartment">取消</ns-button>
|
||||
<ns-button type="primary" @click="ApartmentSure">{{
|
||||
disabled ? '编辑' : '确定'
|
||||
}}</ns-button>
|
||||
<ns-button type="primary" @click="ApartmentSure">确定</ns-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
@@ -53,8 +55,8 @@
|
||||
<ns-button type="primary" @click="addUserSon">新增子角色</ns-button>
|
||||
<ns-button style="margin: 10px" type="primary" @click="deleteUser">删除</ns-button>
|
||||
<a-tree :tree-data="userTreeData" defaultExpandAll @select="SelectUserTree">
|
||||
<template #title="{ title }">
|
||||
{{ title }}
|
||||
<template #title="data">
|
||||
{{ data }}
|
||||
</template>
|
||||
</a-tree>
|
||||
</a-col>
|
||||
@@ -95,6 +97,8 @@
|
||||
import { uuid } from '@antv/x6/lib/util/string/uuid';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { formConfig, formConfig2 } from './config';
|
||||
import { department } from '/@/api/origanizemanage';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'AuthorityManageIndex',
|
||||
setup() {
|
||||
@@ -113,6 +117,9 @@
|
||||
const selectRef2 = ref();
|
||||
const formSchema = formConfig(disabled as any);
|
||||
const formSchema2 = formConfig2(disabled2 as any);
|
||||
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId;
|
||||
const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId;
|
||||
|
||||
watch(ApartcheckedKeys, () => {
|
||||
console.log('checkedKeys', ApartcheckedKeys.value);
|
||||
});
|
||||
@@ -120,23 +127,20 @@
|
||||
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([
|
||||
{
|
||||
title: '铁路总局',
|
||||
key: '0-0',
|
||||
info: { name: '铁路总局' },
|
||||
children: [
|
||||
{ title: '济阳站', key: '0-0-0', info: { name: '济阳站' } },
|
||||
{ title: '临沂站', key: '0-0-1', info: { name: '临沂站' } },
|
||||
],
|
||||
},
|
||||
]);
|
||||
const apartmentTreeData = ref([]);
|
||||
|
||||
const userTreeData = ref([
|
||||
{
|
||||
@@ -182,14 +186,31 @@
|
||||
},
|
||||
]);
|
||||
|
||||
function fetch(api, params) {
|
||||
return http.post(api, params);
|
||||
}
|
||||
|
||||
const addApartment = () => {
|
||||
disabled.value = false;
|
||||
opMap.type = 'add';
|
||||
opMap.fuc = (params) => {
|
||||
fetch(department.deptSave, { ...params, orgId, projectId });
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
const addApartmentSon = () => {
|
||||
disabled.value = false;
|
||||
opMap.type = 'addson';
|
||||
formData.value = {};
|
||||
opMap.fuc = (params) => {
|
||||
fetch(department.deptSave, {
|
||||
...params,
|
||||
orgId,
|
||||
projectId,
|
||||
pdeptId: selectRef.value.deptInfo.deptId,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const addUser = () => {
|
||||
@@ -243,12 +264,14 @@
|
||||
};
|
||||
|
||||
const SelectApartmentTree = (selectedKeys: any, info: any) => {
|
||||
console.log(selectedKeys, info);
|
||||
|
||||
disabled.value = false;
|
||||
console.log(selectedKeys, 'selectedKeys');
|
||||
console.log(info.node.dataRef, 'info');
|
||||
selectKey.value = selectedKeys[0];
|
||||
selectRef.value = info.node.dataRef;
|
||||
formData.value = info.node.dataRef.info;
|
||||
formData.value = info.node.dataRef.deptInfo;
|
||||
};
|
||||
const SelectUserTree = (selectedKeys: any, info: any) => {
|
||||
disabled2.value = false;
|
||||
@@ -280,24 +303,17 @@
|
||||
const ApartmentSure = () => {
|
||||
// formRef.value?.triggerSubmit().then(() => {});
|
||||
|
||||
disabled.value = !disabled.value;
|
||||
opMap.fuc && opMap.fuc(formData.value);
|
||||
// disabled.value = !disabled.value;
|
||||
// console.log(formData.value.name, 'formData');
|
||||
console.log(opMap.type, 'opMap.type');
|
||||
if (opMap.type === 'add') {
|
||||
apartmentTreeData.value[0].children.push({
|
||||
title: formData.value.name,
|
||||
key: 'a1',
|
||||
info: { ...formData.value },
|
||||
});
|
||||
console.log(formRef.value, formData);
|
||||
opMap.fuc && opMap.fuc(formData.value);
|
||||
} else if (selectRef.value && opMap.type === 'addson')
|
||||
selectRef.value['children'] = [
|
||||
{ key: '123', title: formData.value.name, info: { ...cloneDeep(formData.value) } },
|
||||
];
|
||||
opMap.fuc && opMap.fuc(formData.value);
|
||||
else {
|
||||
console.log('ss');
|
||||
}
|
||||
formData.value = {};
|
||||
};
|
||||
const UserSure = () => {
|
||||
disabled2.value = !disabled2.value;
|
||||
|
Reference in New Issue
Block a user