From c8cf9f8ba577ce75e8723ff2d4218fffae349c47 Mon Sep 17 00:00:00 2001
From: songshankun <songshankun@foxmail.com>
Date: 星期二, 14 十一月 2023 15:11:09 +0800
Subject: [PATCH] fix: 修复工序步骤条当前工序展示错误的问题

---
 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