Commit a0b21cb2a10bc290dc121df67421dc4a899ef749
Merge branch 'fix/task-center-gen-modbus' into 'main_dev'
fix: 多个线圈寄存器值修改为必填 See merge request yunteng/thingskit-front!912
Showing
2 changed files
with
9 additions
and
3 deletions
... | ... | @@ -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> | ... | ... |