|
@@ -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>
|