refactor: 刷新

bak
elseif 2 years ago
parent f1691d506c
commit f9335c4011

@ -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
},

@ -85,7 +85,7 @@ async function refreshHandler() {
<SvgIcon style="margin-left: 10px;" size="18" name="filter" />
</div>
</div>
<TaskList style="height: calc(100vh - 146px);" class="work-sheet-list" :data="data" :active-id="taskStore.getActiveId" />
<TaskList style="height: calc(100vh - 146px);" class="work-sheet-list" :data="data" :active-id="taskStore.getActiveId!" />
</div>
</template>

@ -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 })

1
types/task.d.ts vendored

@ -10,6 +10,7 @@ export interface TaskState {
packageid: string
currentIndex: number
approvalList: any[]
refresh: boolean
}
export interface TaskEntity {

Loading…
Cancel
Save