feat: 用户联调
This commit is contained in:
@@ -4,6 +4,8 @@ import { Modal } from 'ant-design-vue';
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { NsMessage } from '/nerv-lib/component';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { http } from '/nerv-lib/util';
|
||||
import { origanizemanage } from '/@/api/origanizemanage';
|
||||
export const formConfig = [
|
||||
{
|
||||
field: 'field111',
|
||||
@@ -48,8 +50,8 @@ export const formConfig = [
|
||||
componentProps: {
|
||||
radioType: 'radio',
|
||||
options: [
|
||||
{ label: '男', value: 1 },
|
||||
{ label: '女', value: 2 },
|
||||
{ label: '男', value: '男' },
|
||||
{ label: '女', value: '女' },
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -80,8 +82,9 @@ export const formConfig = [
|
||||
},
|
||||
{
|
||||
label: '组织关系',
|
||||
field: 'relation',
|
||||
field: 'orgName',
|
||||
component: 'NsInput',
|
||||
defaultValue: JSON.parse(sessionStorage.getItem('userInfo')).orgName,
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
maxLength: 30,
|
||||
@@ -91,35 +94,93 @@ export const formConfig = [
|
||||
},
|
||||
},
|
||||
];
|
||||
const options = ref([]);
|
||||
|
||||
const getUserPerList = (transform, params = {}) => {
|
||||
return http.post(origanizemanage.queryUserPerList, { ...params }).then((res) => {
|
||||
return res.data.map((item) => {
|
||||
item = { ...item, ...transform(item) };
|
||||
return item;
|
||||
});
|
||||
});
|
||||
};
|
||||
export const formConfig2 = (casData: any) => {
|
||||
// const transForm = (data) => {
|
||||
// data['label'] = data.orgName;
|
||||
// data['value'] = data.orgId;
|
||||
// data['isLeaf'] = false;
|
||||
// data['level'] = 1;
|
||||
// return data;
|
||||
// };
|
||||
// getUserPerList(transForm).then((res) => {
|
||||
// options.value = [...res];
|
||||
// });
|
||||
return ref([
|
||||
{
|
||||
field: 'information',
|
||||
component: 'NsCascader',
|
||||
componentProps: {
|
||||
placeholder: '请选择',
|
||||
displayRender: ({ labels }: any) => {
|
||||
casData.value = labels;
|
||||
displayRender: ({ labels, selectedOptions }: any) => {
|
||||
console.log(labels, selectedOptions);
|
||||
|
||||
casData.value = selectedOptions.map(({ label, value }) => {
|
||||
return { label, value };
|
||||
});
|
||||
return labels.join('/');
|
||||
},
|
||||
options: [
|
||||
{
|
||||
value: '1',
|
||||
label: '铁路局',
|
||||
children: [
|
||||
{
|
||||
value: '2',
|
||||
label: '产品部',
|
||||
children: [
|
||||
{
|
||||
value: '3',
|
||||
label: '产品总监',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
// defaultValue: [1, 1, 3],
|
||||
// options: options,
|
||||
// changeOnSelect: true,
|
||||
loadData: (selectedOptions, options) => {
|
||||
console.log(selectedOptions, options, 'selectedOptions, options');
|
||||
|
||||
const targetOption = selectedOptions[selectedOptions.length - 1];
|
||||
let transForm, params;
|
||||
// load options lazily
|
||||
if (!selectedOptions.length) {
|
||||
transForm = (data) => {
|
||||
data['label'] = data.orgName;
|
||||
data['value'] = data.orgId;
|
||||
data['isLeaf'] = false;
|
||||
data['level'] = 1;
|
||||
return data;
|
||||
};
|
||||
getUserPerList(transForm).then((res) => {
|
||||
options.value = [...res];
|
||||
});
|
||||
}
|
||||
const id = targetOption?.value;
|
||||
const level = targetOption?.level;
|
||||
if (targetOption) {
|
||||
targetOption.loading = true;
|
||||
}
|
||||
|
||||
if (level === 1) {
|
||||
transForm = (data) => {
|
||||
data['label'] = data.deptName;
|
||||
data['value'] = data.deptId;
|
||||
data['isLeaf'] = false;
|
||||
data['level'] = 2;
|
||||
return data;
|
||||
};
|
||||
params = { orgId: id };
|
||||
} else if (level === 2) {
|
||||
transForm = (data) => {
|
||||
data['label'] = data.roleName;
|
||||
data['value'] = data.roleId;
|
||||
data['level'] = 3;
|
||||
return data;
|
||||
};
|
||||
params = { deptId: id };
|
||||
}
|
||||
if (targetOption) {
|
||||
getUserPerList(transForm, { ...params }).then((res) => {
|
||||
targetOption.loading = false;
|
||||
targetOption.children = [...res];
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
Reference in New Issue
Block a user