import { defineStore } from 'pinia'; import { ref } from 'vue'; import { fetchGetJobList, fetchGetWorkflowNameList } from '@/service/api'; import { SetupStoreId } from '@/enum'; export const useWorkflowStore = defineStore(SetupStoreId.Workflow, () => { const id = ref(); const type = ref(); const groupName = ref(); const jobList = ref[]>([]); const workflowList = ref[]>([]); function setId(value: string) { id.value = value; } function setType(value: number) { type.value = value; } async function setJobList(value: string) { groupName.value = value; const { data, error } = await fetchGetJobList({ groupName: value }); if (!error) { jobList.value = data.map(item => { return { id: item.id!, jobName: item.jobName }; }); } } async function setWorkflowList(value: string) { groupName.value = value; const { data, error } = await fetchGetWorkflowNameList({ groupName: value }); if (!error) { workflowList.value = data.map(item => { return { id: item.id!, workflowName: item.workflowName }; }); } } function clear() { id.value = undefined; type.value = undefined; groupName.value = undefined; jobList.value = []; } return { id, type, groupName, jobList, workflowList, setJobList, setWorkflowList, setType, setId, clear }; });