|
|
@@ -585,31 +585,7 @@ onUnmounted(() => {
|
|
|
const handleDistributionLayer = async () => {
|
|
|
// 默认选中并展开第一个"果类"节点,在地图上显示对应分布图层
|
|
|
const firstCategory = treeActionData.value[0];
|
|
|
- if (firstCategory) {
|
|
|
- // 递归查找最后一层的节点(没有子节点的叶子节点)
|
|
|
- const getLastLevelNodes = (node) => {
|
|
|
- const lastLevelNodes = [];
|
|
|
- if ((!node.items || node.items.length === 0) && (!node.children || node.children.length === 0)) {
|
|
|
- lastLevelNodes.push(node);
|
|
|
- } else {
|
|
|
- const children = node.items || node.children || [];
|
|
|
- children.forEach((child) => {
|
|
|
- lastLevelNodes.push(...getLastLevelNodes(child));
|
|
|
- });
|
|
|
- }
|
|
|
- return lastLevelNodes;
|
|
|
- };
|
|
|
-
|
|
|
- const lastLevelNodes = getLastLevelNodes(firstCategory);
|
|
|
- const lastLevelIds = lastLevelNodes.map((n) => n.id);
|
|
|
-
|
|
|
- // 并发请求所有数据
|
|
|
- const promises = lastLevelIds.map((id) => getDistributionData(id));
|
|
|
- const results = await Promise.all(promises);
|
|
|
- const finalMapData = results.flat();
|
|
|
-
|
|
|
- distributionLayer.initData(finalMapData);
|
|
|
- }
|
|
|
+ getCommonMapData(firstCategory);
|
|
|
};
|
|
|
|
|
|
// 作物分布树形结构默认展开与默认选中
|
|
|
@@ -624,31 +600,7 @@ const handleDistributionTreeDefault = () => {
|
|
|
// 物候期分布默认选中并展开第一个节点,在地图上显示对应分布图层
|
|
|
const handlePhenologyLayer = async () => {
|
|
|
const firstCategory = treeActionData.value[0].children[0];
|
|
|
- if (firstCategory) {
|
|
|
- // 递归查找最后一层的节点(没有子节点的叶子节点)
|
|
|
- const getLastLevelNodes = (node) => {
|
|
|
- const lastLevelNodes = [];
|
|
|
- if ((!node.items || node.items.length === 0) && (!node.children || node.children.length === 0)) {
|
|
|
- lastLevelNodes.push(node);
|
|
|
- } else {
|
|
|
- const children = node.items || node.children || [];
|
|
|
- children.forEach((child) => {
|
|
|
- lastLevelNodes.push(...getLastLevelNodes(child));
|
|
|
- });
|
|
|
- }
|
|
|
- return lastLevelNodes;
|
|
|
- };
|
|
|
-
|
|
|
- const lastLevelNodes = getLastLevelNodes(firstCategory);
|
|
|
- const lastLevelIds = lastLevelNodes.map((n) => n.id);
|
|
|
-
|
|
|
- // 并发请求所有数据
|
|
|
- const promises = lastLevelIds.map((id) => getDistributionData(id));
|
|
|
- const results = await Promise.all(promises);
|
|
|
- const finalMapData = results.flat();
|
|
|
-
|
|
|
- distributionLayer.initData(finalMapData);
|
|
|
- }
|
|
|
+ getCommonMapData(firstCategory);
|
|
|
};
|
|
|
|
|
|
// 物候期分布树形结构默认展开与默认选中
|
|
|
@@ -663,6 +615,19 @@ const handlePhenologyTreeDefault = () => {
|
|
|
// 预警分布默认选中并展开第一个节点,在地图上显示对应分布图层
|
|
|
const handleAlarmLayer = async () => {
|
|
|
const firstCategory = treeActionData.value[0].children[0];
|
|
|
+ getCommonMapData(firstCategory);
|
|
|
+};
|
|
|
+
|
|
|
+// 预警分布树形结构默认展开与默认选中
|
|
|
+const handleAlarmTreeDefault = () => {
|
|
|
+ defaultCheckedKeys.value = [
|
|
|
+ treeActionData.value[0]?.children[0]?.id
|
|
|
+ ];
|
|
|
+ defaultExpandedKeys.value = [treeActionData.value[0]?.id];
|
|
|
+};
|
|
|
+
|
|
|
+// 处理公共获取最后一级的节点数据
|
|
|
+const getCommonMapData = async (firstCategory) => {
|
|
|
if (firstCategory) {
|
|
|
// 递归查找最后一层的节点(没有子节点的叶子节点)
|
|
|
const getLastLevelNodes = (node) => {
|
|
|
@@ -688,15 +653,7 @@ const handleAlarmLayer = async () => {
|
|
|
|
|
|
distributionLayer.initData(finalMapData);
|
|
|
}
|
|
|
-};
|
|
|
-
|
|
|
-// 预警分布树形结构默认展开与默认选中
|
|
|
-const handleAlarmTreeDefault = () => {
|
|
|
- defaultCheckedKeys.value = [
|
|
|
- treeActionData.value[0]?.children[0]?.id
|
|
|
- ];
|
|
|
- defaultExpandedKeys.value = [treeActionData.value[0]?.id];
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
// ai与地图交互
|
|
|
const hideChatMapLayer = ref(true);
|