|
|
@@ -18,7 +18,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="top-r yes-events">
|
|
|
- <div class="data-box" @click="toggleBox('面积')" :class="{ active: activeBoxName === '面积' }">
|
|
|
+ <div class="data-box" :class="{ active: activeBoxName === '面积' }">
|
|
|
<div class="data-value">
|
|
|
<span>{{ areaVal.includes("3186") ? 31.2 : 419.89 }}</span
|
|
|
>万亩
|
|
|
@@ -28,13 +28,12 @@
|
|
|
<div
|
|
|
class="data-box"
|
|
|
v-if="areaVal.includes('3186')"
|
|
|
- @click="toggleBox('从化荔枝')"
|
|
|
:class="{ active: activeBoxName === '从化荔枝' }"
|
|
|
>
|
|
|
<div class="data-value"><span>11.9</span>万亩</div>
|
|
|
<div class="data-name">疑似失管面积</div>
|
|
|
</div>
|
|
|
- <div class="data-box" @click="toggleBox('产量')" :class="{ active: activeBoxName === '产量' }">
|
|
|
+ <div class="data-box" :class="{ active: activeBoxName === '产量' }">
|
|
|
<div class="data-value">
|
|
|
<span>{{ areaVal.includes("3186") ? 10.4 : 192.12 }}</span
|
|
|
>万吨
|
|
|
@@ -506,7 +505,7 @@ onMounted(async () => {
|
|
|
distributionLayer = new DistributionLayer(warningMap.kmap);
|
|
|
await getSpeciesListData();
|
|
|
// 作物分布默认选中
|
|
|
- await handleDistributionTreeDefault()
|
|
|
+ handleDistributionTreeDefault()
|
|
|
await handleDistributionLayer();
|
|
|
|
|
|
eventBus.emit("warningMap:init", warningMap.kmap);
|
|
|
@@ -560,10 +559,32 @@ onUnmounted(() => {
|
|
|
|
|
|
// 作物分布默认选中并展开第一个节点,在地图上显示对应分布图层
|
|
|
const handleDistributionLayer = async () => {
|
|
|
- // 默认选中并展开第一个“果类”节点,在地图上显示对应分布图层
|
|
|
+ // 默认选中并展开第一个"果类"节点,在地图上显示对应分布图层
|
|
|
const firstCategory = treeActionData.value[0];
|
|
|
if (firstCategory) {
|
|
|
- await getDistributionData(firstCategory.id);
|
|
|
+ // 递归查找最后一层的节点(没有子节点的叶子节点)
|
|
|
+ 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);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -699,7 +720,6 @@ const handleTabClick = (item) => {
|
|
|
staticMapLayers && staticMapLayers.hideAll();
|
|
|
// 通知预警列表组件清空默认选中项
|
|
|
eventBus.emit("warningHome:clearAlarm");
|
|
|
- treeActionData.value = originTreeData;
|
|
|
// 使用 nextTick 确保树组件数据更新后再设置选中状态
|
|
|
nextTick(() => {
|
|
|
if (treeRef.value) {
|