From 4e60ba038a1fbd0808a4cadd83e04606e6865bd4 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 14 十一月 2023 10:14:47 +0800
Subject: [PATCH] 工艺信息的更新按钮加载更换方式

---
 src/stores/tasks.ts |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts
index e115738..971a627 100644
--- a/src/stores/tasks.ts
+++ b/src/stores/tasks.ts
@@ -28,15 +28,14 @@
     return getTaskList(params)
       .then((res) => {
         channels.value = res.data
-
-        // 棣栨鑾峰彇閫氶亾鏁版嵁鏃惰嚜鍔ㄩ�変腑绗竴涓换鍔�
-        if (!activeTask?.value) {
-          selectFirstTask(channels.value)
-        }
       })
       .catch((err) => {
         console.error(err)
         channels.value = []
+      })
+      .finally(() => {
+        // 棣栨鑾峰彇閫氶亾鏁版嵁鏃惰嚜鍔ㄩ�変腑绗竴涓换鍔�
+        selectFirstTask(channels.value)
       })
   }
 
@@ -44,12 +43,15 @@
     const firstNotEmptyChannel = Object.entries(channels).find((ele) => {
       const taskList = (ele[1] as TasksResponse)?.Tasks
 
-      return !!taskList.length
+      return !!taskList?.length
     })
 
     if (firstNotEmptyChannel) {
       const channelNumber = +firstNotEmptyChannel[0]
       activeTask.value = channels[channelNumber].Tasks[0]
+    } else {
+      // 濡傛灉娌℃湁浠诲姟灏辨竻绌哄綋鍓嶉�変腑鐨勪换鍔�
+      activeTask.value = undefined
     }
   }
 

--
Gitblit v1.8.0