Commit dc7c6718685980818175d38a726d74622dfc854f
Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into p…
…erf/add-board-fontsize-field
Showing
4 changed files
with
27 additions
and
11 deletions
| 1 | 1 | <script lang="ts" setup> |
| 2 | 2 | import { Button } from 'ant-design-vue'; |
| 3 | - import { nextTick, ref, unref, watch } from 'vue'; | |
| 3 | + import { nextTick, ref, watch } from 'vue'; | |
| 4 | 4 | import { BasicForm, useForm } from '/@/components/Form'; |
| 5 | 5 | import { BasicModal } from '/@/components/Modal'; |
| 6 | 6 | import { PlusCircleOutlined } from '@ant-design/icons-vue'; |
| ... | ... | @@ -19,8 +19,6 @@ |
| 19 | 19 | } |
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | - const dataType = ref(props.dataType); //获取数据类型 | |
| 23 | - | |
| 24 | 22 | const emit = defineEmits(['update:value']); |
| 25 | 23 | |
| 26 | 24 | const [ |
| ... | ... | @@ -46,15 +44,17 @@ |
| 46 | 44 | show.value = false; |
| 47 | 45 | }; |
| 48 | 46 | |
| 49 | - watch( | |
| 50 | - () => props.dataType, | |
| 51 | - (value) => { | |
| 52 | - dataType.value = value; | |
| 47 | + watch(show, async (value) => { | |
| 48 | + if (value) { | |
| 49 | + await nextTick(); | |
| 53 | 50 | updateSchema([ |
| 54 | - { field: FormFieldsEnum.ZOOM_FACTOR, ifShow: unref(dataType) == 'BOOL' ? false : true }, | |
| 51 | + { | |
| 52 | + field: FormFieldsEnum.ZOOM_FACTOR, | |
| 53 | + ifShow: props.dataType == DataTypeEnum.IS_BOOL ? false : true, | |
| 54 | + }, | |
| 55 | 55 | ]); |
| 56 | 56 | } |
| 57 | - ); | |
| 57 | + }); | |
| 58 | 58 | |
| 59 | 59 | watch( |
| 60 | 60 | () => props.value, | ... | ... |
| ... | ... | @@ -89,7 +89,9 @@ |
| 89 | 89 | functionJson: { |
| 90 | 90 | inputData, |
| 91 | 91 | outputData, |
| 92 | - ...(serviceCommand ? { inputData: [{ serviceCommand }] } : {}), | |
| 92 | + ...(serviceCommand | |
| 93 | + ? { inputData: [{ serviceCommand: serviceCommand.replaceAll(/\s/g, '').toUpperCase() }] } | |
| 94 | + : {}), | |
| 93 | 95 | }, |
| 94 | 96 | } as ModelOfMatterParams; |
| 95 | 97 | ... | ... |
| ... | ... | @@ -117,7 +117,18 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { |
| 117 | 117 | field: FormField.SERVICE_COMMAND, |
| 118 | 118 | label: '输入参数', |
| 119 | 119 | component: 'Input', |
| 120 | - rules: [{ message: '输入参数为必填项', required: true }], | |
| 120 | + rules: [ | |
| 121 | + { message: '输入参数为必填项', required: true }, | |
| 122 | + { | |
| 123 | + message: '请输入ASCII或HEX服务命令(0~9/A~F)', | |
| 124 | + validator(_rule, value, _callback) { | |
| 125 | + const reg = /^[\s0-9a-fA-F]+$/; | |
| 126 | + | |
| 127 | + if (reg.test(value)) return Promise.resolve(); | |
| 128 | + return Promise.reject('请输入ASCII或HEX服务命令(0~9/A~F)'); | |
| 129 | + }, | |
| 130 | + }, | |
| 131 | + ], | |
| 121 | 132 | ifShow: tcpDeviceFlag, |
| 122 | 133 | componentProps: { |
| 123 | 134 | placeholder: '请输入ASCII或HEX服务命令', | ... | ... |
| ... | ... | @@ -35,6 +35,9 @@ export const getSendValues = async (option, getDesign, checked) => { |
| 35 | 35 | commandType == CommandTypeEnum.SERVICE.toString() |
| 36 | 36 | ) { |
| 37 | 37 | values.customCommand.command = checked ? openCommand : closeCommand; |
| 38 | + values.customCommand.command = values.customCommand.command | |
| 39 | + .replaceAll(/\s/g, '') | |
| 40 | + .toUpperCase(); | |
| 38 | 41 | } |
| 39 | 42 | if ( |
| 40 | 43 | //判断命令下发类型是不是属性 且是modbus | ... | ... |