You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.0 KiB
80 lines
2.0 KiB
import { getApprovalList } from '@/api/task/task'
|
|
import { store } from '@/store'
|
|
import { defineStore } from 'pinia'
|
|
import type { TaskState } from '/#/task'
|
|
|
|
export const useTaskStore = defineStore({
|
|
id: 'task-store',
|
|
state: (): TaskState => ({
|
|
currentIndex: -1,
|
|
activeId: '',
|
|
approvalList: [],
|
|
packageid: '',
|
|
immersion: false,
|
|
inFile: false, // 是否进入文件夹
|
|
inFileId:"",
|
|
}),
|
|
getters: {
|
|
getActiveId: (state: TaskState) => state.activeId,
|
|
getPackageid: (state: TaskState) => state.packageid,
|
|
getCurrentIndex: (state: TaskState) => state.currentIndex,
|
|
getApprovalList: (state: TaskState) => state.approvalList,
|
|
getInFile: (state: TaskState) => state.inFile,
|
|
getInFileId: (state: TaskState) => state.inFileId,
|
|
},
|
|
actions: {
|
|
setApprovalList(list: any[]) {
|
|
this.approvalList = list
|
|
},
|
|
setInFile(flag: any) {
|
|
this.inFile = flag
|
|
},
|
|
setInFileId(id: any) {
|
|
this.inFileId = id
|
|
},
|
|
setActive(index: number, taskId?: string) {
|
|
this.currentIndex = index
|
|
const task = this.approvalList[index]
|
|
this.activeId = taskId || task?.id
|
|
this.packageid = task.packageid
|
|
},
|
|
forward() {
|
|
const len = this.approvalList.length
|
|
|
|
if (this.currentIndex === len - 1)
|
|
return
|
|
|
|
this.setActive(++this.currentIndex)
|
|
},
|
|
back() {
|
|
if (this.currentIndex === 0)
|
|
return
|
|
|
|
this.setActive(--this.currentIndex)
|
|
},
|
|
async fetchApprovalList(pagination) {
|
|
const res = await getApprovalList(pagination)
|
|
if (res.data.length > 0) {
|
|
this.approvalList.push(...res.data)
|
|
if (!this.activeId)
|
|
this.setActive(0)
|
|
}
|
|
|
|
return res
|
|
},
|
|
updateImmersion() {
|
|
this.immersion = !this.immersion
|
|
},
|
|
reset() {
|
|
this.currentIndex = -1
|
|
this.activeId = ''
|
|
this.packageid = ''
|
|
this.approvalList = []
|
|
},
|
|
},
|
|
})
|
|
|
|
export function useTask() {
|
|
return useTaskStore(store)
|
|
}
|