Browse Source

fix: 设备详情判读opc和modbus

wzyyy 4 years atrás
parent
commit
5b567b1227
1 changed files with 15 additions and 10 deletions
  1. 15 10
      src/pages/device/Instance/Detail/index.tsx

+ 15 - 10
src/pages/device/Instance/Detail/index.tsx

@@ -149,24 +149,29 @@ const InstanceDetail = observer(() => {
       tab: '物模型映射',
       component: <MetadataMap type="device" />,
     },
-    {
-      key: 'opcua',
-      tab: 'OPC UA',
-      component: <Opcua />,
-    },
-    {
-      key: 'modbus',
-      tab: 'Modbus',
-      component: <Modbus />,
-    },
   ];
   const [list, setList] =
     useState<{ key: string; tab: string | ReactNode; component: ReactNode }[]>(baseList);
 
   const getDetail = (id: string) => {
     service.detail(id).then((response) => {
+      console.log(response.result);
       InstanceModel.detail = response?.result;
       const datalist = [...baseList];
+      if (response.result.protocol === 'modbus-tcp') {
+        datalist.push({
+          key: 'modbus',
+          tab: 'Modbus',
+          component: <Modbus />,
+        });
+      }
+      if (response.result.protocol === 'opc-ua') {
+        datalist.push({
+          key: 'opcua',
+          tab: 'OPC UA',
+          component: <Opcua />,
+        });
+      }
       if (response.result.deviceType?.value === 'gateway') {
         // 产品类型为网关的情况下才显示此模块
         datalist.push({