From f9335c4011e5c2c31d2b3ee096c06162bbdccf72 Mon Sep 17 00:00:00 2001 From: elseif Date: Thu, 14 Mar 2024 10:35:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/task.ts | 8 ++++++-- src/views/task/aside/Aside.vue | 2 +- src/views/task/content/Content.vue | 6 +++++- types/task.d.ts | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/store/modules/task.ts b/src/store/modules/task.ts index 9fad4b4..1891b2b 100644 --- a/src/store/modules/task.ts +++ b/src/store/modules/task.ts @@ -10,6 +10,7 @@ export const useTaskStore = defineStore({ activeId: '', approvalList: [], packageid: '', + refresh: false, }), getters: { getActiveId: (state: TaskState) => state.activeId, @@ -41,12 +42,15 @@ export const useTaskStore = defineStore({ this.setActive(--this.currentIndex) }, - async fetchApprovalList(pagination, id) { + async fetchApprovalList(pagination, id, refresh?: boolean) { const res = await getApprovalList(pagination, id) this.setApprovalList(res.data) - if (res.data.length > 0) + if (res.data.length > 0) { this.setActive(0) + // 审批操作完成后,需要刷新,为防止activeId在刷新后值不变,通过此值刷新 + this.refresh = !this.refresh + } return res.data }, diff --git a/src/views/task/aside/Aside.vue b/src/views/task/aside/Aside.vue index 64e253e..896ddce 100644 --- a/src/views/task/aside/Aside.vue +++ b/src/views/task/aside/Aside.vue @@ -85,7 +85,7 @@ async function refreshHandler() { - + diff --git a/src/views/task/content/Content.vue b/src/views/task/content/Content.vue index 3acd3ff..d49cdcb 100644 --- a/src/views/task/content/Content.vue +++ b/src/views/task/content/Content.vue @@ -190,9 +190,13 @@ function backHandler() { taskStore.back() } -watch(() => taskStore.activeId, async (newValue, oldValue) => { +watch(() => [taskStore.activeId, taskStore.refresh], async (newValue, oldValue) => { const packageid = taskStore.getPackageid const taskId = taskStore.getActiveId + + if (taskId === '' || packageid === '') + return + taskDetailInfo.value = await getTaskDetailInfo(taskId, packageid) const { data, total } = await getTaskDetailPictureList(packageid, taskId, { ...taskpagination, ...sortBy }) diff --git a/types/task.d.ts b/types/task.d.ts index 87fa855..fa55486 100644 --- a/types/task.d.ts +++ b/types/task.d.ts @@ -10,6 +10,7 @@ export interface TaskState { packageid: string currentIndex: number approvalList: any[] + refresh: boolean } export interface TaskEntity {