You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
5.2 KiB

11 months ago
import { mockData } from './mock';
import { cloneDeep } from 'lodash-es';
import { Modal } from 'ant-design-vue';
import { createVNode, ref } from 'vue';
import { NsMessage } from '/nerv-lib/component';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
11 months ago
import { http } from '/nerv-lib/util';
import { origanizemanage } from '/@/api/origanizemanage';
11 months ago
export const formConfig = [
{
field: 'field111',
component: 'NsChildForm',
componentProps: {
title: '用户信息',
schemas: [
{
label: '账号',
11 months ago
field: 'accountNo',
11 months ago
component: 'NsInput',
componentProps: {
placeholder: '请输入账号',
maxLength: 20,
},
rules: [
{
required: true,
message: '请输入账号',
},
],
},
{
label: '姓名',
11 months ago
field: 'realName',
11 months ago
component: 'NsInput',
componentProps: {
placeholder: '请输入姓名',
maxLength: 20,
},
rules: [
{
required: true,
message: '请输入姓名',
},
],
},
{
label: '性别',
field: 'sex',
component: 'NsRadioGroup',
componentProps: {
radioType: 'radio',
options: [
11 months ago
{ label: '男', value: '男' },
{ label: '女', value: '女' },
11 months ago
],
},
},
{
label: '手机号',
11 months ago
field: 'telephone',
11 months ago
component: 'NsInput',
componentProps: {
placeholder: '请输入手机号',
maxLength: 11,
},
rules: [
{
required: true,
message: '请输入正确手机号格式',
pattern: /^[1][3-9][0-9]{9}$/,
},
],
},
{
label: '邮箱',
field: 'email',
component: 'NsInput',
componentProps: {
placeholder: '请输入邮箱',
maxLength: 30,
},
},
{
label: '组织关系',
11 months ago
field: 'orgName',
11 months ago
component: 'NsInput',
11 months ago
defaultValue: JSON.parse(sessionStorage.getItem('userInfo')).orgName,
11 months ago
componentProps: {
disabled: true,
maxLength: 30,
},
},
],
},
},
];
11 months ago
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;
});
});
};
11 months ago
export const formConfig2 = (casData: any) => {
11 months ago
// 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];
// });
11 months ago
return ref([
{
field: 'information',
component: 'NsCascader',
componentProps: {
placeholder: '请选择',
11 months ago
displayRender: ({ labels, selectedOptions }: any) => {
console.log(labels, selectedOptions);
casData.value = selectedOptions.map(({ label, value }) => {
return { label, value };
});
11 months ago
return labels.join('/');
},
11 months ago
// 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];
});
}
},
11 months ago
},
},
]);
};