Sfoglia il codice sorgente

[Feat 0000]分站管理编辑功能优化

bobo04052021@163.com 1 giorno fa
parent
commit
7f70389219

+ 95 - 35
src/views/vent/deviceManager/substationTabel/substation.data.ts

@@ -102,40 +102,14 @@ export const formSchema: FormSchema[] = [
     component: 'Input',
     required: true,
   },
-
   {
     label: '读取数据方式',
     field: 'strtype',
     component: 'JDictSelectTag',
     required: true,
-    componentProps: ({ formModel, formActionType, schema }) => {
-      return {
-        dictCode: 'getdatatype',
-        placeholder: '请选择分站用途',
-        onChange: (e: any) => {
-          const { updateSchema } = formActionType;
-          if (e == 'plc' || e == 'modbus') {
-            updateSchema({
-              field: 'plcType',
-              show: true,
-            });
-          } else {
-            updateSchema({
-              field: 'plcType',
-              show: false,
-            });
-            if (e == 'http') {
-              updateSchema({
-                label: '请求参数或读取文件名',
-                field: 'reqparam',
-                component: 'Input',
-                required: false,
-                show: true,
-              });
-            }
-          }
-        },
-      };
+    componentProps: {
+      dictCode: 'getdatatype',
+      placeholder: '请选择读取数据方式',
     },
   },
   {
@@ -161,7 +135,7 @@ export const formSchema: FormSchema[] = [
     label: 'PLC类型',
     field: 'plcType',
     component: 'JDictSelectTag',
-    show: true,
+    ifShow: ({ values }) => values.strtype === 'plc',
     componentProps: {
       dictCode: 'plcType',
       placeholder: '请选择PLC类型',
@@ -171,17 +145,20 @@ export const formSchema: FormSchema[] = [
     label: '分站站号',
     field: 'code',
     component: 'InputNumber',
+    ifShow: ({ values }) => ['modbus', 'modbusRtu'].includes(values.strtype),
   },
   {
-    label: '系统缓存点表下标',
-    field: 'plcTable',
+    label: '节点码',
+    field: 'code',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype === 'opc_ua',
   },
   {
     label: '是否从0开始',
     field: 'isZeroStart',
     component: 'RadioGroup',
     defaultValue: 1,
+    ifShow: ({ values }) => ['modbus', 'modbusRtu'].includes(values.strtype),
     componentProps: () => {
       return {
         options: [
@@ -191,10 +168,20 @@ export const formSchema: FormSchema[] = [
       };
     },
   },
+  {
+    label: '分站类型',
+    field: 'reqparam',
+    component: 'Input',
+    ifShow: ({ values }) => ['modbus', 'modbusRtu'].includes(values.strtype),
+    componentProps: {
+      placeholder: '请填写158/130/235',
+    },
+  },
   {
     label: '请求方式',
     field: 'reqtype',
     component: 'JDictSelectTag',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
     componentProps: {
       dictCode: 'reqtype',
       placeholder: '请选择请求方式',
@@ -204,56 +191,110 @@ export const formSchema: FormSchema[] = [
     label: 'reqHeader请求头',
     field: 'reqHeader',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        !['plc', 'modbus', 'modbusRtu', 'opc_ua', 'txt'].some((type) => values.strtype && values.strtype.startsWith(type))),
+  },
+  {
+    label: '请求参数',
+    field: 'reqparam',
+    component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
+  },
+  {
+    label: '读取文件名',
+    field: 'reqparam',
+    component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('txt'),
   },
   {
     label: '请求参数或读取文件名',
     field: 'reqparam',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      !['plc', 'modbus', 'modbusRtu', 'opc_ua', 'txt', 'http'].some((type) => values.strtype && values.strtype.startsWith(type)) &&
+      !values.strtype?.startsWith('http') &&
+      !values.strtype?.startsWith('txt'),
   },
   {
-    label: '数据属性字段(json中数据列表的字段-)',
+    label: '返回数据解析',
     field: 'dataproperty',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype && (values.strtype.startsWith('http') || values.strtype.startsWith('txt')),
   },
   {
     label: 'ID字段',
     field: 'idcode',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        values.strtype.startsWith('txt') ||
+        !['plc', 'modbus', 'modbusRtu', 'opc_ua'].some((type) => values.strtype && values.strtype.startsWith(type))),
   },
   {
     label: '名称code',
     field: 'namecode',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        values.strtype.startsWith('txt') ||
+        !['plc', 'modbus', 'modbusRtu', 'opc_ua'].some((type) => values.strtype && values.strtype.startsWith(type))),
   },
   {
     label: '连接用户名',
     field: 'remoteUser',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        values.strtype === 'opc_ua' ||
+        !['plc', 'modbus', 'modbusRtu', 'txt'].some((type) => values.strtype && values.strtype.startsWith(type))),
   },
   {
     label: '连接密码',
     field: 'remotePass',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        values.strtype === 'opc_ua' ||
+        !['plc', 'modbus', 'modbusRtu', 'txt'].some((type) => values.strtype && values.strtype.startsWith(type))),
   },
   {
     label: '数据格式化',
     field: 'dataformat',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        values.strtype.startsWith('txt') ||
+        !['plc', 'modbus', 'modbusRtu', 'opc_ua'].some((type) => values.strtype && values.strtype.startsWith(type))),
   },
   {
-    label: '字符串分割符',
+    label: '字符串分符',
     field: 'splitchar',
     component: 'Input',
+    ifShow: ({ values }) =>
+      values.strtype &&
+      (values.strtype.startsWith('http') ||
+        values.strtype.startsWith('txt') ||
+        !['plc', 'modbus', 'modbusRtu', 'opc_ua'].some((type) => values.strtype && values.strtype.startsWith(type))),
   },
   {
     label: '控制请求地址',
     field: 'controlStrip',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
   },
   {
     label: '控制请求类型',
     field: 'controlReqtype',
     component: 'JDictSelectTag',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
     componentProps: {
       dictCode: 'reqtype',
       placeholder: '请选择控制请求方式',
@@ -263,21 +304,40 @@ export const formSchema: FormSchema[] = [
     label: '控制请求Header',
     field: 'controlHeader',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
   },
   {
     label: '控制请求参数',
     field: 'controlReqparam',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
   },
   {
     label: '登录地址',
     field: 'loginUrl',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
   },
   {
-    label: '登录结果解析(返回的token读取字段)',
+    label: '登录结果解析',
     field: 'loginResult',
     component: 'Input',
+    ifShow: ({ values }) => values.strtype && values.strtype.startsWith('http'),
+  },
+  {
+    label: '是否自动同步设备',
+    field: 'isAutoSyn',
+    component: 'RadioGroup',
+    defaultValue: 0,
+    ifShow: ({ values }) => values.strtype && (values.strtype.startsWith('http') || values.strtype.startsWith('txt')),
+    componentProps: () => {
+      return {
+        options: [
+          { label: '否', value: 0, key: '0' },
+          { label: '是', value: 1, key: '1' },
+        ],
+      };
+    },
   },
   {
     label: '备注',