Browse Source

iot列表点查询

lhh 1 month ago
parent
commit
1ca25ce9f6

+ 3 - 2
src/service/iotService.js

@@ -14,9 +14,10 @@ export function QueryIotListTree(){
   })
 }
 
-export function QueryListEquipment(){
+export function QueryListEquipment(params){
   return requestGet({
-    url: '/iot/list/equipment'
+    url: '/iot/list/equipment',
+    params: params
   })
 }
 

+ 4 - 13
src/unit/map/addLayer.js

@@ -277,7 +277,9 @@ export function AddSingleLayer(params) {
 
 //地图洒点
 export async function addDataPoint(params, status = true) {
+  
   try {
+    debugger
     const res = await getMapToken();
     const token = res?.data.msg[0].Rows[0].token
     if(token){
@@ -290,21 +292,10 @@ export async function addDataPoint(params, status = true) {
             name: "OBJECTID",
             type: "oid"
           },
-          {
-            name: "textTitle",
-            type: "string"
-          },
-          {
-            name: "countNum",
-            type: "string"
-          },
-          {
-            name: "type",
-            type: "string"
-          }
+          ...params.fields
         ],
         data: params.data,
-        showLableInfo: "{textTitle}",
+        showLableInfo: params.showLableInfo,
         token: token
       });
     }else{

+ 106 - 76
src/views/IOTDataAnalysis/components/IOTLIstDialog.vue

@@ -7,7 +7,6 @@
         :data="treeDataTabSecond"
         ref="treeTabSecondRef"
         show-checkbox
-        check-strictly
         node-key="id"
         :default-expand-all="false"
         :renderContent="renderContent"
@@ -22,7 +21,11 @@
 
 <script setup>
 import { onMounted, ref } from "vue";
-import { QueryListEquipment, QueryIotListTree, QueryIotEquipment } from "../../../service/iotService";
+import {
+  QueryListEquipment,
+  QueryIotListTree,
+  QueryIotEquipment,
+} from "../../../service/iotService";
 import { addDataPoint } from "@/unit/map/addLayer";
 
 const treeTabSecondRef = ref(null);
@@ -41,91 +44,120 @@ const defaultPropsValue = ref({
   children: "child",
   label: "name",
 });
-const checkNameData = ref([])
+const checkNameData = ref([]);
 //树表单选择
 const handleCheck = (node, checkKeys) => {
-  
+  // if (checkNameData.value.includes(node.name)) {
+  //   //取消选中操作
+  //   //根据是否有child判断当前是否是叶子节点
+  //   if(!node.child || node?.child.length == 0){
+  //     //是子节点
+  //   }else{
 
-  console.log(node)
-  let data;
-  if(checkNameData.value.includes(node.name)){
-    checkNameData.value = checkNameData.value.filter(item => item != node.name)
-    addDataPoint({id: node.name}, false)
-  }else{
-    checkNameData.value.push(node.name)
-    queryPointList(node.name)
-  }
-  
+  //   }
+  //   checkNameData.value = checkNameData.value.filter(
+  //     (item) => item != node.name
+  //   );
+  // } else {
+  //   //选中操作
+  //   checkNameData.value.push(node.name);
+  //   queryPointList(node.name);
+  // }
+  checkKeys.checkedNodes.forEach((node) => {
+    if(node?.child?.length > 0) return
+    queryPointList(node.name);
+  });
 };
 
 //获取点位数据
 const queryPointList = async (terminal) => {
   try {
-    const equipmengRes = await QueryListEquipment({terminal: terminal});
-    if(equipmengRes?.data?.code == 200){
-      const list = equipmengRes?.data?.data?.list || []
-      const allPromise = []
+    const equipmengRes = await QueryListEquipment({ terminal: terminal });
+    if (equipmengRes?.data?.code == 200) {
+      const list = equipmengRes?.data?.data?.list || [];
+      const allPromise = [];
       list.forEach((item, index) => {
-        if(item.serialNumber){
+        if (item?.serialNumber) {
           let promiseItem = new Promise((resolve, reject) => {
-            QueryIotEquipment(item.serialNumber).then(res => {
-              resolve({
-                ...res,
-                item
+            QueryIotEquipment(item?.serialNumber)
+              .then((res) => {
+                resolve({
+                  ...res,
+                  item,
+                });
               })
-            }).catch((error) => {
-              reject(error)
-            })
-          })
-          allPromise.push(promiseItem)
+              .catch((error) => {
+                reject(error);
+              });
+          });
+          allPromise.push(promiseItem);
         }
-      })
+      });
       //处理异步调用
-      Promise.allSettled(allPromise).then(resArr => {
-        let data = [];
-        resArr.forEach(result => {
-          if(result.status == "fulfilled"){
-            const detailRes = result.value;
-            if(detailRes?.data?.code == '200'){
-              let obj = {
-              textTitle: terminal,
-              countNum: 12,
-              type: '数量'
-            }
-            const resData = detailRes?.data?.data || []
-            resData.forEach(el => {
-              if(el.latestValue){
-                obj[el.name] = el.latestValue
+      Promise.allSettled(allPromise)
+        .then((resArr) => {
+          let data = [];
+          let keyArr = [];
+          resArr.forEach((result) => {
+            if (result.status == "fulfilled") {
+              const detailRes = result.value;
+              if (detailRes?.data?.code == "200") {
+                let obj = {
+                  terminal: detailRes?.item?.terminal,
+                  serialNumber: detailRes?.item?.serialNumber,
+                };
+                const resData = detailRes?.data?.data || [];
+                resData.forEach((el) => {
+                  if (el.latestValue) {
+                    obj[el.name] = el.latestValue;
+                    if (!keyArr.includes(el.name)) {
+                      keyArr.push(el.name);
+                    }
+                  }
+                });
+                data.push({
+                  x: detailRes?.item?.lng,
+                  y: detailRes?.item?.lat,
+                  attributes: obj,
+                  
+                });
               }
-            })
-            data.push(
+            }
+          });
+          let params = {
+            id: terminal,
+            title: terminal,
+            data: data,
+            showLableInfo: "{terminal}:{serialNumber}",
+            fields: [
               {
-                x: detailRes?.item?.lng,
-                y: detailRes?.item?.lat,
-                attributes: obj
-              }
-            )
-          }
+                name: 'terminal',
+                type: 'string'
+              },
+              {
+                name: 'serialNumber',
+                type: 'string'
+              },
+              ...keyArr.map((key) => {
+                return {
+                  name: key,
+                  type: "string",
+                };
+              }),
+            ]
             
-        }
-      })
-        let params = {
-          id: terminal,
-          title: terminal,
-          data: data
-        }
-        console.log(params)
-        addDataPoint(params)
-      }).catch((error) => {
-        console.log('allSettled:error', error)
-      })
+          };
+          console.log(params);
+          addDataPoint(params);
+        })
+        .catch((error) => {
+          console.log("allSettled:error", error);
+        });
     }
   } catch (error) {
-    console.log(error)
+    console.log(error);
   }
-  
-}
-
+};
 
 onMounted(() => {
   getListTree();
@@ -293,14 +325,12 @@ const renderContent = (h, { node, data, store }) => {
     background-image: url("@/assets/imgs/IOTImage/header-bottom.png");
     background-size: 100% 100%;
   }
-  
 }
-:deep(.custom-tree-node){
-    .node-label{
-      width: 15ch;
-      display: inline-block;
-      overflow-x: hidden;
-
-    }
+:deep(.custom-tree-node) {
+  .node-label {
+    width: 179px;
+    display: inline-block;
+    overflow-x: hidden;
   }
+}
 </style>

+ 3 - 3
vite.config.js

@@ -17,8 +17,8 @@ export default defineConfig({
             // 代理所有 /api 的请求,该求情将被代理到 target 中
             '/api': {
                 // 代理请求之后的请求地址(你的真实接口地址)
-                target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod-2/',
-                //target: 'http://localhost:9250/',
+                // target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod-2/',
+                target: 'http://192.168.3.60:9250/',
                 secure: false,
                 ws: true,
                 // 跨域
@@ -28,7 +28,7 @@ export default defineConfig({
             '/addressapi': {
                 // 代理请求之后的请求地址(你的真实接口地址)
                 target: 'https://cimweb.zjw.sh.cegn.cn:2008/',
-                //target: 'http://localhost:9250/',
+                // target: 'http://192.168.3.60:9250/',
                 secure: false,
                 ws: true,
                 // 跨域