Commit ba365d861313c9302eb6ac07ee0a268ede554d09

Authored by ww
1 parent ced7badb

fix: 多个线圈寄存器值修改为必填

... ... @@ -2,18 +2,19 @@
2 2 import { Button, Spin } from 'ant-design-vue';
3 3 import { BasicForm, useForm } from '/@/components/Form';
4 4 import { BasicModal, useModal } from '/@/components/Modal';
5   - import { formSchemas } from './config';
  5 + import { formSchemas, FormFieldsEnum } from './config';
6 6 import { ref } from 'vue';
7 7 import { unref } from 'vue';
8 8 import { composeModbusModalData } from './util';
9 9 import { ModbusCommandValueType } from './type';
10 10 import { genModbusCommand } from '/@/api/task';
  11 + import { isNullOrUnDef } from '/@/utils/is';
11 12
12 13 const emit = defineEmits(['update:value']);
13 14
14 15 const [registerModal] = useModal();
15 16
16   - const [registerForm, { getFieldsValue }] = useForm({
  17 + const [registerForm, { getFieldsValue, validate }] = useForm({
17 18 schemas: formSchemas,
18 19 showActionButtonGroup: false,
19 20 rowProps: { gutter: 10 },
... ... @@ -25,8 +26,12 @@
25 26 const loading = ref(false);
26 27 const handleGetValue = async () => {
27 28 try {
  29 + await validate();
28 30 const value = getFieldsValue();
29 31 const record = composeModbusModalData(value as ModbusCommandValueType);
  32 +
  33 + if (record[FormFieldsEnum.REGISTER_VALUES]?.some((item) => isNullOrUnDef(item))) return;
  34 +
30 35 loading.value = true;
31 36 const result = await genModbusCommand(record);
32 37 commandValue.value = result;
... ... @@ -46,7 +51,7 @@
46 51 return arr.reduce((prev, next) => `${prev} ${next.join('')}`, '');
47 52 };
48 53
49   - const handleOk = () => {
  54 + const handleOk = async () => {
50 55 emit('update:value', unref(commandValue));
51 56 };
52 57 </script>
... ...
... ... @@ -212,6 +212,7 @@ export const formSchemas: FormSchema[] = [
212 212 showTotalControl: false,
213 213 itemProps: () => {
214 214 return {
  215 + required: true,
215 216 valueField: 'value',
216 217 changeEvent: 'update:value',
217 218 } as FormSchema;
... ...