wenhongquan 2 lat temu
rodzic
commit
3dca363c03

+ 41 - 5
ruoyi-ui-vue3/src/views/gateway/pointsetting/index.vue

@@ -65,7 +65,7 @@
               <el-table-column label="操作" fixed="right" >
                 <template #default="scope">
                   <div>
-                    <el-button
+                    <el-button v-if="scope.row.protocalType!=3"
                       link @click="goadd(scope.row)"
                     >
                       <el-tooltip effect="dark" content="查看点表配置">
@@ -104,9 +104,11 @@
 </template>
 
 <script setup  >
-import {ref} from "vue";
+import {ref, watchEffect} from "vue";
 import {useRoute, useRouter} from "vue-router";
 import { listSensor} from "@/api/data/sensor";
+import { listModbusRtu} from "@/api/data/modbusRtu";
+import { listModbusTcp} from "@/api/data/modbusTcp";
 const {proxy} = getCurrentInstance();
 const { protocal_type,sensor_type} = proxy.useDict( "protocal_type","sensor_type");
 
@@ -120,7 +122,8 @@ const cloumdata = ref([
   {label: '传感器编码', prop:'sn',visible:true},
   {label: '传感器名称', prop:'name',visible:true},
   {label: '类型', prop:'sensorType',visible:true},
-  {label: '协议', prop:'pname',visible:true},
+  {label: '协议类型', prop:'pname',visible:true},
+  {label: '协议名称', prop:'sname',visible:true},
   {label: '描述', prop:'sensorDesc',visible:true},
   {label: '备注', prop:'remark',visible:true},
 ]);
@@ -155,12 +158,45 @@ const goadd = (item)=>{
   router.push("/gateway/pointsetting/setting");
 }
 
+const rtudata = ref([]);
+const tcpdata = ref([]);
+const getdata = ()=>{
+  listModbusRtu({pageSize:10000}).then(res=>{
+    const {rows,total,page,size} = res;
+    rtudata.value = rows;
+  })
+
+  listModbusTcp({pageSize:10000}).then(res=>{
+    const {rows,total,page,size} = res;
+    tcpdata.value = rows;
+  })
+}
+getdata();
+
+watchEffect(()=>{
+  tabledata.value = tabledata.value.map(item=>{
+    item["pname"] = (protocal_type.value??[]).find(i=>i.value == item.protocalType).label;
+
+    let protacalname = "自定义协议";
+    try{
+      if(item.protocalType==2){
+        protacalname = rtudata.value.find(i=>i.id == item.protocalId).protocolName;
+      }else if(item.protocalType==1) {
+        protacalname = tcpdata.value.find(i => i.id == item.protocalId).protocolName;
+      }
+    }catch (e){}
+
+    item["sname"] = protacalname;
+    return item;
+  });
+})
+
 const getalldata = () => {
-  listSensor({...searchform.value,pageSize:pagedata.value.size,pageNum:pagedata.value.current}).then(res => {
+  listSensor({...searchform.value,pageSize:pagedata.value.size,pageNum:pagedata.value.current,params:{notypes:"3"}}).then(res => {
     const {rows,total,page,size} = res;
     pagedata.value = {total:total,current:page, size:10};
     tabledata.value = rows.map(item=>{
-      item["pname"] = (protocal_type.value??[]).find(i=>i.value == item.protocalType).label;
+      item["pname"] = (protocal_type.value??[]).find(i=>i.value+"" == item.protocalType).label;
       return item;
     });
   })