|
@@ -21,7 +21,7 @@
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
- import { getByRyId, userShareAdd } from '/@/api/operate';
|
|
|
|
|
|
+ import { getinnerByRyId, userShareAdd } from '/@/api/operate';
|
|
|
|
|
|
const { t } = useI18n();
|
|
const { t } = useI18n();
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
@@ -43,56 +43,95 @@
|
|
component: 'Input',
|
|
component: 'Input',
|
|
show: false,
|
|
show: false,
|
|
label: 'id',
|
|
label: 'id',
|
|
|
|
+ defaultValue: '111',
|
|
required: false,
|
|
required: false,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
field: 'ryNo',
|
|
field: 'ryNo',
|
|
- component: 'AutoComplete',
|
|
|
|
|
|
+ component: 'Input',
|
|
label: '人员编号',
|
|
label: '人员编号',
|
|
required: true,
|
|
required: true,
|
|
- componentProps: {
|
|
|
|
- filterOption: onFilterOption,
|
|
|
|
- onSearch: onSearch,
|
|
|
|
- onChange: (data) => {
|
|
|
|
- setTimeout(() => {
|
|
|
|
- const item = optionsName.value && optionsName.value.find((ele) => ele.ryNo == data);
|
|
|
|
- setFieldsValue({
|
|
|
|
- ryNickName: item && item.ryNickName ? item.ryNickName : '',
|
|
|
|
- id: item && item.id ? item.id : '',
|
|
|
|
- });
|
|
|
|
- }, 100);
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- colProps: {
|
|
|
|
- span: 20,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- field: 'ryNickName',
|
|
|
|
- component: 'Input',
|
|
|
|
- label: '姓名',
|
|
|
|
rules: [
|
|
rules: [
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
validator: async (rule, value) => {
|
|
validator: async (rule, value) => {
|
|
|
|
+ let myData = await getFieldsValue();
|
|
if (!value) {
|
|
if (!value) {
|
|
- return Promise.reject('请输入正确的人员编号');
|
|
|
|
|
|
+ return Promise.reject('请输入人员编号');
|
|
|
|
+ }
|
|
|
|
+ let res = await getinnerByRyId({ ryNo: value });
|
|
|
|
+ console.log('value', value, res);
|
|
|
|
+ if (res && !res.data) {
|
|
|
|
+ return Promise.reject('人员编号不存在');
|
|
|
|
+ }
|
|
|
|
+ Promise.resolve();
|
|
|
|
+ let id = res && res.data && res.data.id;
|
|
|
|
+ if(myData.id != id || !myData.id){
|
|
|
|
+ setFieldsValue({
|
|
|
|
+ ryNickName: res && res.data ? res.data.ryNickName : '',
|
|
|
|
+ id: res && res.data ? res.data.id : '',
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- return Promise.resolve();
|
|
|
|
},
|
|
},
|
|
- trigger: 'change',
|
|
|
|
|
|
+ trigger: 'blur',
|
|
},
|
|
},
|
|
],
|
|
],
|
|
colProps: {
|
|
colProps: {
|
|
span: 20,
|
|
span: 20,
|
|
},
|
|
},
|
|
|
|
+ },
|
|
|
|
+ // {
|
|
|
|
+ // field: 'ryNo',
|
|
|
|
+ // component: 'AutoComplete',
|
|
|
|
+ // label: '人员编号',
|
|
|
|
+ // required: true,
|
|
|
|
+ // componentProps: {
|
|
|
|
+ // filterOption: onFilterOption,
|
|
|
|
+ // onSearch: onSearch,
|
|
|
|
+ // onChange: (data) => {
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
+ // const item = optionsName.value && optionsName.value.find((ele) => ele.ryNo == data);
|
|
|
|
+ // setFieldsValue({
|
|
|
|
+ // ryNickName: item && item.ryNickName ? item.ryNickName : '',
|
|
|
|
+ // id: item && item.id ? item.id : '',
|
|
|
|
+ // });
|
|
|
|
+ // }, 100);
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
|
|
+ // colProps: {
|
|
|
|
+ // span: 20,
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
|
|
+ {
|
|
|
|
+ field: 'ryNickName',
|
|
|
|
+ component: 'Input',
|
|
|
|
+ label: '姓名',
|
|
|
|
+ // rules: [
|
|
|
|
+ // {
|
|
|
|
+ // required: true,
|
|
|
|
+ // // @ts-ignore
|
|
|
|
+ // validator: async (rule, value) => {
|
|
|
|
+ // if (!value) {
|
|
|
|
+ // return Promise.reject('请输入正确的人员编号');
|
|
|
|
+ // }
|
|
|
|
+ // return Promise.resolve();
|
|
|
|
+ // },
|
|
|
|
+ // trigger: 'change',
|
|
|
|
+ // },
|
|
|
|
+ // ],
|
|
|
|
+ colProps: {
|
|
|
|
+ span: 20,
|
|
|
|
+ },
|
|
componentProps: {
|
|
componentProps: {
|
|
disabled: true,
|
|
disabled: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
];
|
|
];
|
|
- const [registerForm, { validate, resetFields, setFieldsValue, updateSchema }] = useForm({
|
|
|
|
|
|
+ const [
|
|
|
|
+ registerForm,
|
|
|
|
+ { validate, resetFields, setFieldsValue, getFieldsValue, updateSchema },
|
|
|
|
+ ] = useForm({
|
|
labelWidth: 110,
|
|
labelWidth: 110,
|
|
schemas,
|
|
schemas,
|
|
showActionButtonGroup: false,
|
|
showActionButtonGroup: false,
|
|
@@ -114,25 +153,21 @@
|
|
// return option.value.indexOf(inputText.toUpperCase()) >= 0;
|
|
// return option.value.indexOf(inputText.toUpperCase()) >= 0;
|
|
}
|
|
}
|
|
async function onSearch(searchText) {
|
|
async function onSearch(searchText) {
|
|
- if (searchText.length < 7) return;
|
|
|
|
- const list = await getByRyId({ ryNo: searchText });
|
|
|
|
- console.log('onSearch', list);
|
|
|
|
- optionsName.value =
|
|
|
|
- list.map((ele) => {
|
|
|
|
- return { ...ele, value: ele.ryNo };
|
|
|
|
- }) || [];
|
|
|
|
- // console.log('paramList', optionsList);
|
|
|
|
- // optionsName.value = optionsList || [];
|
|
|
|
|
|
+ const res = await getinnerByRyId({ ryNo: searchText });
|
|
|
|
+ console.log('res', res.data);
|
|
|
|
+ if (!res.data) return;
|
|
|
|
+ optionsName.value = res.data || {};
|
|
updateSchema({
|
|
updateSchema({
|
|
field: 'ryNo',
|
|
field: 'ryNo',
|
|
componentProps: {
|
|
componentProps: {
|
|
- options: optionsName.value,
|
|
|
|
|
|
+ options: [optionsName.value],
|
|
},
|
|
},
|
|
});
|
|
});
|
|
}
|
|
}
|
|
const handleSubmit = async () => {
|
|
const handleSubmit = async () => {
|
|
|
|
+ const params = await validate();
|
|
try {
|
|
try {
|
|
- const params = await validate();
|
|
|
|
|
|
+ console.log('params', params);
|
|
await userShareAdd(params);
|
|
await userShareAdd(params);
|
|
closeModal();
|
|
closeModal();
|
|
resetFields();
|
|
resetFields();
|