From 3acec796e54dc2f5e7d93e8ca72db7da9ec46f60 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 28 四月 2025 17:33:56 +0800
Subject: [PATCH] 2025.04.28

---
 src/stores/subtask.js |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/src/stores/subtask.js b/src/stores/subtask.js
index 8deda39..aaf96cb 100644
--- a/src/stores/subtask.js
+++ b/src/stores/subtask.js
@@ -1,21 +1,49 @@
-import { ref } from 'vue'
+import { ref, unref } from 'vue'
 import { defineStore } from 'pinia'
 import timeUtil from '@/utils/time-util'
+import { useMapStore } from '@/stores/map.js'
+import taskApi from '@/api/fysp/taskApi.js'
+import marks from '@/utils/map/marks.js'
+import mapUtil from '@/utils/map/util.js'
+import scene_1 from '@/assets/icon/scene_1.png'
+
+const mapStore = useMapStore()
 
 // 宸℃煡浠诲姟
 export const useSubtaskStore = defineStore('subtask', () => {
+  // 鎬讳换鍔′俊鎭�
+  const taskInfo = ref(null)
   // 褰撴湡鎵�鏈夊贰鏌ョ粺璁′俊鎭�
   const summaryList = ref([])
+  // 姣忔棩鐨勫贰鏌ョ粺璁′俊鎭�
   const summaryMap = ref(new Map())
   const subtaskLoading = ref(false)
+  const onFetchInfo = []
   const onFetchList = []
   const onFetchMap = []
 
+  function fetchTopTaskProgress(area) {
+    subtaskLoading.value = true
+    taskApi.fetchTopTaskProgress(area).then((res) => {
+      if (res.data.length == 0) return
+      const data = res.data[0]
+      // 瀛樺偍涓哄叏灞�鏁版嵁
+      setSummary(data)
+      subtaskLoading.value = false
+      // 缁樺埗鍦板浘鏍囪
+      marks.createLabelMarks(scene_1, unref(data.subTaskSummary), (v) => {
+        mapStore.focusMarker = v
+      })
+      mapUtil.setFitView()
+    })
+  }
+
   // 璁剧疆鏂扮殑鍊�
   function setSummary(data) {
-    summaryList.value = data
+    taskInfo.value = data
+    summaryList.value = data.subTaskSummary
     summaryMap.value.clear()
-    data.forEach((e) => {
+    data.subTaskSummary.forEach((e) => {
       const tag = timeUtil.formatYMD(e.subtask.planstarttime)
       if (!summaryMap.value.has(tag)) {
         summaryMap.value.set(tag, [])
@@ -35,6 +63,19 @@
       onFetchMap.forEach((e) => {
         e(summaryMap.value)
       })
+    }
+    if (onFetchInfo.length > 0) {
+      onFetchInfo.forEach((e) => {
+        e(taskInfo.value)
+      })
+    }
+  }
+
+  function getTaskInfo(callback) {
+    if (taskInfo.value == null) {
+      onFetchInfo.push(callback)
+    } else {
+      callback(taskInfo.value)
     }
   }
 
@@ -58,5 +99,15 @@
     }
   }
 
-  return { summaryList, summaryMap, subtaskLoading, setSummary, getSummaryList, getSummaryMap }
+  return {
+    // taskInfo,
+    // summaryList,
+    // summaryMap,
+    subtaskLoading,
+    fetchTopTaskProgress,
+    setSummary,
+    getTaskInfo,
+    getSummaryList,
+    getSummaryMap
+  }
 })

--
Gitblit v1.9.3