|
|
@@ -27,17 +27,38 @@
|
|
|
@press-enter="deviceMapping"
|
|
|
>
|
|
|
<template #addonBefore>
|
|
|
- <a-button size="small" type="link" @click="handleMinusDevice">
|
|
|
+ <a-button
|
|
|
+ :disabled="modelRef.mappingLength == 0"
|
|
|
+ size="small"
|
|
|
+ type="link"
|
|
|
+ @click="handleMinusDevice"
|
|
|
+ >
|
|
|
<Icon icon="ic:baseline-minus" :size="20" />
|
|
|
</a-button>
|
|
|
</template>
|
|
|
<template #addonAfter>
|
|
|
- <a-button size="small" type="link" @click="handlePlusDevice">
|
|
|
+ <a-button
|
|
|
+ :disabled="modelRef.mappingLength == 20"
|
|
|
+ size="small"
|
|
|
+ type="link"
|
|
|
+ @click="handlePlusDevice"
|
|
|
+ >
|
|
|
<Icon icon="ic:round-plus" :size="20" />
|
|
|
</a-button>
|
|
|
</template>
|
|
|
</input-number>
|
|
|
</template>
|
|
|
+ <template #IDInput="{ model, field }">
|
|
|
+ <Input v-model:value="model[field]" />
|
|
|
+ <a-button
|
|
|
+ :disabled="modelRef.mappingLength == 0"
|
|
|
+ size="small"
|
|
|
+ type="link"
|
|
|
+ @click="handleMinusDevice"
|
|
|
+ >
|
|
|
+ <Icon icon="ic:baseline-minus" :size="20" />
|
|
|
+ </a-button>
|
|
|
+ </template>
|
|
|
</BasicForm>
|
|
|
</div>
|
|
|
</BasicModal>
|
|
|
@@ -47,7 +68,7 @@
|
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import { InputNumber } from 'ant-design-vue';
|
|
|
+ import { InputNumber, Input } from 'ant-design-vue';
|
|
|
// AddDevice
|
|
|
import { checkDevice, AddDevice } from '/@/api/corporation/modal';
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
@@ -55,7 +76,7 @@
|
|
|
import { clamp, range } from 'lodash-es';
|
|
|
|
|
|
export default defineComponent({
|
|
|
- components: { BasicModal, BasicForm, InputNumber, Icon },
|
|
|
+ components: { BasicModal, BasicForm, InputNumber, Icon, Input },
|
|
|
props: {
|
|
|
userData: { type: Object },
|
|
|
},
|
|
|
@@ -74,8 +95,19 @@
|
|
|
data && onDataReceive(data);
|
|
|
});
|
|
|
|
|
|
- const handlevalidator = async (_, value) => {
|
|
|
- console.log('handlevalidator', value);
|
|
|
+ const handlevalidator = async (item, value) => {
|
|
|
+ let values = getFieldsValue();
|
|
|
+ console.log('handlevalidator', value, item, values);
|
|
|
+ let childNameList: string[] = [];
|
|
|
+ Object.keys(values).map((ele) => {
|
|
|
+ if (ele.includes('ID') && item.field !== ele) {
|
|
|
+ childNameList.push(values[ele]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const issort = childNameList.some((element) => element == value);
|
|
|
+ if (issort) {
|
|
|
+ return Promise.reject(t('routes.devices.deviceCode'));
|
|
|
+ }
|
|
|
if (!value) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
@@ -158,42 +190,6 @@
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- // async function submitModal() {
|
|
|
- // let formData = {
|
|
|
- // ...getFieldsValue(),
|
|
|
- // };
|
|
|
- // let validate = false;
|
|
|
- // try {
|
|
|
- // const res = await validateFields();
|
|
|
- // validate = true;
|
|
|
- // console.log('passing', res, formData);
|
|
|
- // } catch (error: unknown) {
|
|
|
- // console.log('not passing', error);
|
|
|
- // }
|
|
|
- // if (validate) {
|
|
|
- // const { subNum, id, userName } = modelRef.value;
|
|
|
- // let childNameList = [];
|
|
|
- // Object.keys(formData).map((ele) => {
|
|
|
- // if (ele.includes('ID')) {
|
|
|
- // childNameList.push(formData[ele]);
|
|
|
- // }
|
|
|
- // });
|
|
|
- // console.log('modelRef.value', Object.keys(formData), childNameList);
|
|
|
- // try {
|
|
|
- // const res = await AddDevice({
|
|
|
- // childNames: childNameList as any as string[],
|
|
|
- // companyId: id,
|
|
|
- // subNum: String(subNum),
|
|
|
- // userName,
|
|
|
- // });
|
|
|
- // success(res);
|
|
|
- // closeModal();
|
|
|
- // } catch (errors) {
|
|
|
- // // error('errors');
|
|
|
- // // console.log('not passing', error);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
async function submitModal() {
|
|
|
try {
|
|
|
const values = await validate();
|
|
|
@@ -227,62 +223,6 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- // function numOnChange(data) {
|
|
|
- // const value = Number(data);
|
|
|
- // if (num.value > value) {
|
|
|
- // //减
|
|
|
- // let delList = Array.from(new Array(num.value)).map((_, index) => {
|
|
|
- // console.log(index, value, num.value);
|
|
|
- // if (index >= value) {
|
|
|
- // return `ID${index}`;
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
- // removeSchemaByFiled(delList as any as string[]);
|
|
|
- // console.log('schemasList减', value, num.value, delList);
|
|
|
- // // value,num.value,schemasList.filter((_,index) => {return !(index<num.value)}).map((_,index) => `ID${index}`))
|
|
|
- // } else {
|
|
|
- // //增
|
|
|
- // let device = t('routes.corporation.device');
|
|
|
- // let schemasList: FormSchema[] = Array.from(new Array(value)).map((_, index) => {
|
|
|
- // return {
|
|
|
- // field: `ID${index}`,
|
|
|
- // component: 'Input',
|
|
|
- // label: device + 'ID' + index,
|
|
|
- // helpMessage: [t('common.checkTips'), `${device} ${t('common.unusual')}`],
|
|
|
- // itemProps: {
|
|
|
- // validateTrigger: 'blur',
|
|
|
- // },
|
|
|
- // colProps: {
|
|
|
- // span: 24,
|
|
|
- // },
|
|
|
- // rules: [
|
|
|
- // {
|
|
|
- // required: true,
|
|
|
- // message: `${t('common.inputText')} ${device} ID`,
|
|
|
- // },
|
|
|
- // {
|
|
|
- // validator: handlevalidator,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // };
|
|
|
- // });
|
|
|
- // console.log(
|
|
|
- // 'schemasList增',
|
|
|
- // num.value,
|
|
|
- // schemasList.filter((_, index) => {
|
|
|
- // return index >= num.value;
|
|
|
- // }),
|
|
|
- // );
|
|
|
- // schemasList
|
|
|
- // .filter((_, index) => {
|
|
|
- // return index >= num.value;
|
|
|
- // })
|
|
|
- // .forEach((item) => appendSchemaByField(item, ''));
|
|
|
- // }
|
|
|
- // num.value = value;
|
|
|
- // }
|
|
|
-
|
|
|
function handleVisibleChange(v) {
|
|
|
v && props.userData && nextTick(() => onDataReceive(props.userData));
|
|
|
}
|
|
|
@@ -302,13 +242,14 @@
|
|
|
field: `ID${startIndex}`,
|
|
|
component: 'Input',
|
|
|
label: `${t('routes.corporation.device')} ID ${startIndex}`,
|
|
|
- helpMessage: [
|
|
|
- t('common.checkTips'),
|
|
|
- `${t('routes.corporation.device')} ${t('common.unusual')}`,
|
|
|
- ],
|
|
|
+ // helpMessage: [
|
|
|
+ // t('common.checkTips'),
|
|
|
+ // `${t('routes.corporation.device')} ${t('common.unusual')}`,
|
|
|
+ // ],
|
|
|
itemProps: {
|
|
|
validateTrigger: 'blur',
|
|
|
},
|
|
|
+ // slot: 'IDInput',
|
|
|
colProps: {
|
|
|
span: 24,
|
|
|
},
|