gtsoft-snail-job-admin/src/store/modules/workflow/index.ts
csc 06050b976c feat(workflow): 新增子流程节点功能
- 添加子流程节点相关的组件和逻辑
- 实现子流程节点的添加、编辑和删除
- 添加工作流列表获取和展示功能
- 优化工作流节点的渲染和交互
2025-05-09 00:51:22 +08:00

67 lines
1.5 KiB
TypeScript

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<string>();
const type = ref<number>();
const groupName = ref<string>();
const jobList = ref<Pick<Api.Job.Job, 'id' | 'jobName'>[]>([]);
const workflowList = ref<Pick<Api.Workflow.Workflow, 'id' | 'workflowName'>[]>([]);
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
};
});