|
@@ -12,6 +12,7 @@
|
|
|
:renderContent="renderContent"
|
|
|
:props="defaultPropsValue"
|
|
|
@check="handleCheck"
|
|
|
+ @checkChange="handleCheckChange"
|
|
|
>
|
|
|
</el-tree>
|
|
|
</div>
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
QueryIotEquipment,
|
|
|
} from "../../../service/iotService";
|
|
|
import { addDataPoint } from "@/unit/map/addLayer";
|
|
|
-
|
|
|
+import { getMapToken } from "../../../service/map.js";
|
|
|
const treeTabSecondRef = ref(null);
|
|
|
let treeDataTabSecond = ref([]);
|
|
|
|
|
@@ -45,32 +46,54 @@ const defaultPropsValue = ref({
|
|
|
label: "name",
|
|
|
});
|
|
|
const checkNameData = ref([]);
|
|
|
-//树表单选择
|
|
|
-const handleCheck = (node, checkKeys) => {
|
|
|
- // if (checkNameData.value.includes(node.name)) {
|
|
|
- // //取消选中操作
|
|
|
- // //根据是否有child判断当前是否是叶子节点
|
|
|
- // if(!node.child || node?.child.length == 0){
|
|
|
- // //是子节点
|
|
|
- // }else{
|
|
|
+//树表单选择,做打点操作
|
|
|
+const handleCheck = async (node, checkKeys) => {
|
|
|
+ try {
|
|
|
+ if(checkNameData.value.includes(node.name)){
|
|
|
+ checkNameData.value = checkNameData.value.filter(name => name != node.name)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const res = await getMapToken();
|
|
|
+ const token = res?.data.msg[0].Rows[0].token;
|
|
|
+ if (token) {
|
|
|
+ checkKeys.checkedNodes.forEach((node) => {
|
|
|
+ if (node?.child?.length > 0) return;
|
|
|
+ queryPointList(node.name, token);
|
|
|
+ checkNameData.value.push(node.name)
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("map:token:error");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
- // }
|
|
|
- // 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 handleCheckChange = async (node, isCheck, halfCheckKeys) => {
|
|
|
+ if (node?.child?.length > 0 || isCheck) return;
|
|
|
+ try {
|
|
|
+ debugger
|
|
|
+ const res = await getMapToken();
|
|
|
+ const token = res?.data.msg[0].Rows[0].token;
|
|
|
+ if (!token) {
|
|
|
+ console.log("map:token:error");
|
|
|
+ }else{
|
|
|
+ addDataPoint(
|
|
|
+ {
|
|
|
+ id: node.name,
|
|
|
+ token: token
|
|
|
+ },
|
|
|
+ false
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (error) {}
|
|
|
};
|
|
|
|
|
|
//获取点位数据
|
|
|
-const queryPointList = async (terminal) => {
|
|
|
+const queryPointList = async (terminal, token) => {
|
|
|
try {
|
|
|
const equipmengRes = await QueryListEquipment({ terminal: terminal });
|
|
|
if (equipmengRes?.data?.code == 200) {
|
|
@@ -98,6 +121,7 @@ const queryPointList = async (terminal) => {
|
|
|
.then((resArr) => {
|
|
|
let data = [];
|
|
|
let keyArr = [];
|
|
|
+ //遍历并发请求返回结果
|
|
|
resArr.forEach((result) => {
|
|
|
if (result.status == "fulfilled") {
|
|
|
const detailRes = result.value;
|
|
@@ -119,24 +143,29 @@ const queryPointList = async (terminal) => {
|
|
|
x: detailRes?.item?.lng,
|
|
|
y: detailRes?.item?.lat,
|
|
|
attributes: obj,
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
let params = {
|
|
|
id: terminal,
|
|
|
title: terminal,
|
|
|
data: data,
|
|
|
showLableInfo: "{terminal}:{serialNumber}",
|
|
|
+ token: token,
|
|
|
fields: [
|
|
|
{
|
|
|
- name: 'terminal',
|
|
|
- type: 'string'
|
|
|
+ name: "OBJECTID",
|
|
|
+ type: "oid"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "terminal",
|
|
|
+ type: "string",
|
|
|
},
|
|
|
{
|
|
|
- name: 'serialNumber',
|
|
|
- type: 'string'
|
|
|
+ name: "serialNumber",
|
|
|
+ type: "string",
|
|
|
},
|
|
|
...keyArr.map((key) => {
|
|
|
return {
|
|
@@ -144,10 +173,10 @@ const queryPointList = async (terminal) => {
|
|
|
type: "string",
|
|
|
};
|
|
|
}),
|
|
|
- ]
|
|
|
-
|
|
|
+ ],
|
|
|
};
|
|
|
console.log(params);
|
|
|
+
|
|
|
addDataPoint(params);
|
|
|
})
|
|
|
.catch((error) => {
|