Commit 9a4df2219e7408a342e85b5ce633b4c54665baf3

Authored by loveumiko
1 parent 444d7d51

fix: 修改物模型属性下发

... ... @@ -28,7 +28,8 @@
28 28 const keys = ref<string[]>([]);
29 29
30 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 33 const formField = ref('');
33 34
34 35 const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => {
... ... @@ -45,6 +46,14 @@
45 46 if (type === DataTypeEnum.IS_STRUCT) {
46 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 57 if (codeType == TaskTypeEnum.MODBUS) {
49 58 isShowModBUS.value = true;
50 59 modBUSForm.value = {
... ... @@ -59,9 +68,6 @@
59 68 } else {
60 69 isShowModBUS.value = false;
61 70 const formSchemas = genForm(schemas);
62   - keys.value = schemas.map((item) => {
63   - return item.identifier!;
64   - });
65 71 setProps({ schemas: formSchemas });
66 72 }
67 73
... ... @@ -85,15 +91,23 @@
85 91 try {
86 92 loading.value = true;
87 93 if (!props.deviceId) return;
  94 + if (!unref(isShowActionType)) {
  95 + createMessage.warning('当前物模型扩展描述没有填写');
  96 + return;
  97 + }
88 98 const sendValue = ref({});
  99 + //判断tcp类型 标识符是自定义还是ModBus
89 100 if (unref(isShowModBUS)) {
90   - //判断tcp类型 标识符是自定义还是ModBus
91 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 112 sendValue.value = await genModbusCommand(unref(modBUSForm));
99 113 } else {
... ...