Commit 756b7d6c968bf8b8a16d8970d05968394937daeb
Merge branch 'fix/DEFECT-2118' into 'main_dev'
fix: 修复设备填写设备地址 See merge request yunteng/thingskit-front!1384
Showing
2 changed files
with
23 additions
and
6 deletions
| @@ -202,6 +202,13 @@ export const step1Schemas: FormSchema[] = [ | @@ -202,6 +202,13 @@ export const step1Schemas: FormSchema[] = [ | ||
| 202 | }, | 202 | }, |
| 203 | }, | 203 | }, |
| 204 | { | 204 | { |
| 205 | + field: 'addressType', | ||
| 206 | + label: '', | ||
| 207 | + component: 'Input', | ||
| 208 | + show: false, | ||
| 209 | + defaultValue: 'HEX', | ||
| 210 | + }, | ||
| 211 | + { | ||
| 205 | field: 'addressCode', | 212 | field: 'addressCode', |
| 206 | label: '地址码', | 213 | label: '地址码', |
| 207 | dynamicRules({ values }) { | 214 | dynamicRules({ values }) { |
| @@ -211,7 +218,7 @@ export const step1Schemas: FormSchema[] = [ | @@ -211,7 +218,7 @@ export const step1Schemas: FormSchema[] = [ | ||
| 211 | values?.transportType === TransportTypeEnum.TCP && | 218 | values?.transportType === TransportTypeEnum.TCP && |
| 212 | values?.tcpDeviceProtocol === TCPProtocolTypeEnum.MODBUS_RTU, | 219 | values?.tcpDeviceProtocol === TCPProtocolTypeEnum.MODBUS_RTU, |
| 213 | message: '地址码范围为00~FF', | 220 | message: '地址码范围为00~FF', |
| 214 | - pattern: /^[0-9A-Fa-f]{1,2}$/, | 221 | + pattern: values?.addressType === 'HEX' ? /^[0-9A-Fa-f]{2}$/ : /^[0-9A-Fa-f]{1,2}$/, |
| 215 | }, | 222 | }, |
| 216 | ]; | 223 | ]; |
| 217 | }, | 224 | }, |
| @@ -219,10 +226,15 @@ export const step1Schemas: FormSchema[] = [ | @@ -219,10 +226,15 @@ export const step1Schemas: FormSchema[] = [ | ||
| 219 | component: 'HexInput', | 226 | component: 'HexInput', |
| 220 | changeEvent: 'update:value', | 227 | changeEvent: 'update:value', |
| 221 | valueField: 'value', | 228 | valueField: 'value', |
| 222 | - componentProps: { | ||
| 223 | - type: InputTypeEnum.HEX, | ||
| 224 | - maxValue: parseInt('FF', 16), | ||
| 225 | - placeholder: '请输入寄存器地址', | 229 | + componentProps: ({ formModel }) => { |
| 230 | + return { | ||
| 231 | + type: InputTypeEnum.HEX, | ||
| 232 | + maxValue: parseInt('FF', 16), | ||
| 233 | + placeholder: '请输入寄存器地址', | ||
| 234 | + onHexChange: (e) => { | ||
| 235 | + formModel.addressType = e; | ||
| 236 | + }, | ||
| 237 | + }; | ||
| 226 | }, | 238 | }, |
| 227 | ifShow: ({ values }) => { | 239 | ifShow: ({ values }) => { |
| 228 | return ( | 240 | return ( |
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | } | 23 | } |
| 24 | ); | 24 | ); |
| 25 | 25 | ||
| 26 | - const emits = defineEmits(['update:value', 'change']); | 26 | + const emits = defineEmits(['update:value', 'change', 'hexChange']); |
| 27 | 27 | ||
| 28 | const typOptions = Object.values(InputTypeEnum).map((value) => ({ label: value, value })); | 28 | const typOptions = Object.values(InputTypeEnum).map((value) => ({ label: value, value })); |
| 29 | 29 | ||
| @@ -114,6 +114,10 @@ | @@ -114,6 +114,10 @@ | ||
| 114 | ? getHexToDec(unref(getInputValue)!) | 114 | ? getHexToDec(unref(getInputValue)!) |
| 115 | : `${hexWithPrefix ? '0x' : ''}${Number(unref(getInputValue)).toString(16).toUpperCase()}`; | 115 | : `${hexWithPrefix ? '0x' : ''}${Number(unref(getInputValue)).toString(16).toUpperCase()}`; |
| 116 | }); | 116 | }); |
| 117 | + | ||
| 118 | + const handleInputTypeChange = (e) => { | ||
| 119 | + emits('hexChange', e); | ||
| 120 | + }; | ||
| 117 | </script> | 121 | </script> |
| 118 | 122 | ||
| 119 | <template> | 123 | <template> |
| @@ -124,6 +128,7 @@ | @@ -124,6 +128,7 @@ | ||
| 124 | class="min-w-20" | 128 | class="min-w-20" |
| 125 | :options="typOptions" | 129 | :options="typOptions" |
| 126 | :disabled="disabled" | 130 | :disabled="disabled" |
| 131 | + @change="handleInputTypeChange" | ||
| 127 | /> | 132 | /> |
| 128 | <Input v-bind="$attrs" v-model:value="getInputValue" class="!w-full" :disabled="disabled" /> | 133 | <Input v-bind="$attrs" v-model:value="getInputValue" class="!w-full" :disabled="disabled" /> |
| 129 | <div class="min-w-14 h-full px-2 flex-grow flex-shrink-0 text-center leading-8 bg-gray-200"> | 134 | <div class="min-w-14 h-full px-2 flex-grow flex-shrink-0 text-center leading-8 bg-gray-200"> |