Commit dc7c6718685980818175d38a726d74622dfc854f

Authored by loveumiko
2 parents 77d15d7c 81d79e11

Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into p…

…erf/add-board-fontsize-field
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 import { Button } from 'ant-design-vue'; 2 import { Button } from 'ant-design-vue';
3 - import { nextTick, ref, unref, watch } from 'vue'; 3 + import { nextTick, ref, watch } from 'vue';
4 import { BasicForm, useForm } from '/@/components/Form'; 4 import { BasicForm, useForm } from '/@/components/Form';
5 import { BasicModal } from '/@/components/Modal'; 5 import { BasicModal } from '/@/components/Modal';
6 import { PlusCircleOutlined } from '@ant-design/icons-vue'; 6 import { PlusCircleOutlined } from '@ant-design/icons-vue';
@@ -19,8 +19,6 @@ @@ -19,8 +19,6 @@
19 } 19 }
20 ); 20 );
21 21
22 - const dataType = ref(props.dataType); //获取数据类型  
23 -  
24 const emit = defineEmits(['update:value']); 22 const emit = defineEmits(['update:value']);
25 23
26 const [ 24 const [
@@ -46,15 +44,17 @@ @@ -46,15 +44,17 @@
46 show.value = false; 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 updateSchema([ 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 watch( 59 watch(
60 () => props.value, 60 () => props.value,
@@ -89,7 +89,9 @@ @@ -89,7 +89,9 @@
89 functionJson: { 89 functionJson: {
90 inputData, 90 inputData,
91 outputData, 91 outputData,
92 - ...(serviceCommand ? { inputData: [{ serviceCommand }] } : {}), 92 + ...(serviceCommand
  93 + ? { inputData: [{ serviceCommand: serviceCommand.replaceAll(/\s/g, '').toUpperCase() }] }
  94 + : {}),
93 }, 95 },
94 } as ModelOfMatterParams; 96 } as ModelOfMatterParams;
95 97
@@ -117,7 +117,18 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { @@ -117,7 +117,18 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => {
117 field: FormField.SERVICE_COMMAND, 117 field: FormField.SERVICE_COMMAND,
118 label: '输入参数', 118 label: '输入参数',
119 component: 'Input', 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 ifShow: tcpDeviceFlag, 132 ifShow: tcpDeviceFlag,
122 componentProps: { 133 componentProps: {
123 placeholder: '请输入ASCII或HEX服务命令', 134 placeholder: '请输入ASCII或HEX服务命令',
@@ -35,6 +35,9 @@ export const getSendValues = async (option, getDesign, checked) => { @@ -35,6 +35,9 @@ export const getSendValues = async (option, getDesign, checked) => {
35 commandType == CommandTypeEnum.SERVICE.toString() 35 commandType == CommandTypeEnum.SERVICE.toString()
36 ) { 36 ) {
37 values.customCommand.command = checked ? openCommand : closeCommand; 37 values.customCommand.command = checked ? openCommand : closeCommand;
  38 + values.customCommand.command = values.customCommand.command
  39 + .replaceAll(/\s/g, '')
  40 + .toUpperCase();
38 } 41 }
39 if ( 42 if (
40 //判断命令下发类型是不是属性 且是modbus 43 //判断命令下发类型是不是属性 且是modbus