Commit 9a4df2219e7408a342e85b5ce633b4c54665baf3

Authored by loveumiko
1 parent 444d7d51

fix: 修改物模型属性下发

@@ -28,7 +28,8 @@ @@ -28,7 +28,8 @@
28 const keys = ref<string[]>([]); 28 const keys = ref<string[]>([]);
29 29
30 const modBUSForm = ref<any>({}); 30 const modBUSForm = ref<any>({});
31 - const isShowModBUS = ref<Boolean>(false); 31 + const isShowModBUS = ref<Boolean>(false); //用于判断标识符类型是否时自定义还是modBUS
  32 + const isShowActionType = ref<Boolean>(true); //判断设备属性标识符为modBus时没有填写扩展描述
32 const formField = ref(''); 33 const formField = ref('');
33 34
34 const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => { 35 const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => {
@@ -45,6 +46,14 @@ @@ -45,6 +46,14 @@
45 if (type === DataTypeEnum.IS_STRUCT) { 46 if (type === DataTypeEnum.IS_STRUCT) {
46 schemas = dataType?.specs as StructJSON[]; 47 schemas = dataType?.specs as StructJSON[];
47 } 48 }
  49 +
  50 + keys.value = schemas.map((item) => {
  51 + return item.identifier!;
  52 + });
  53 + isShowActionType.value = actionType ? true : false; //判断modBUS类型时 物模型是否填写扩展描述
  54 +
  55 + //是modBUS类型的就用另外的表单
  56 + //判断是否是modBus的下发命令
48 if (codeType == TaskTypeEnum.MODBUS) { 57 if (codeType == TaskTypeEnum.MODBUS) {
49 isShowModBUS.value = true; 58 isShowModBUS.value = true;
50 modBUSForm.value = { 59 modBUSForm.value = {
@@ -59,9 +68,6 @@ @@ -59,9 +68,6 @@
59 } else { 68 } else {
60 isShowModBUS.value = false; 69 isShowModBUS.value = false;
61 const formSchemas = genForm(schemas); 70 const formSchemas = genForm(schemas);
62 - keys.value = schemas.map((item) => {  
63 - return item.identifier!;  
64 - });  
65 setProps({ schemas: formSchemas }); 71 setProps({ schemas: formSchemas });
66 } 72 }
67 73
@@ -85,15 +91,23 @@ @@ -85,15 +91,23 @@
85 try { 91 try {
86 loading.value = true; 92 loading.value = true;
87 if (!props.deviceId) return; 93 if (!props.deviceId) return;
  94 + if (!unref(isShowActionType)) {
  95 + createMessage.warning('当前物模型扩展描述没有填写');
  96 + return;
  97 + }
88 const sendValue = ref({}); 98 const sendValue = ref({});
  99 + //判断tcp类型 标识符是自定义还是ModBus
89 if (unref(isShowModBUS)) { 100 if (unref(isShowModBUS)) {
90 - //判断tcp类型 标识符是自定义还是ModBus  
91 const oldValue = getFieldsValue()[unref(formField)]; 101 const oldValue = getFieldsValue()[unref(formField)];
92 - const newValue = getArray(SingleToHex(oldValue));  
93 -  
94 - modBUSForm.value.registerValues =  
95 - unref(modBUSForm).method != '16' ? [newValue[0]] : newValue;  
96 - modBUSForm.value.registerNumber = unref(modBUSForm).method != '16' ? 1 : 2; 102 + modBUSForm.value.registerValues = [oldValue];
  103 + modBUSForm.value.registerNumber = 1;
  104 + // 只有
  105 + if (unref(modBUSForm).method == '16') {
  106 + const newValue = getArray(SingleToHex(oldValue));
  107 + modBUSForm.value.registerValues = newValue;
  108 + modBUSForm.value.registerNumber = 2;
  109 + modBUSForm.value.method = '10';
  110 + }
97 111
98 sendValue.value = await genModbusCommand(unref(modBUSForm)); 112 sendValue.value = await genModbusCommand(unref(modBUSForm));
99 } else { 113 } else {