sozsoft-platform/ui/src/services/workflow.service.ts

84 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-05-22 09:40:35 +00:00
import apiService from './api.service'
export interface WorkflowConditionDto {
2026-05-22 20:41:36 +00:00
compareColumn: string
compareOperator: string
2026-05-22 09:40:35 +00:00
compareValue: number
}
export interface CompareOutcomeDto {
label: string
targetId?: string | null
conditions: WorkflowConditionDto[]
}
export interface WorkflowCriteriaDto {
id: string
listFormCode: string
nodeId: string
kind: string
title: string
2026-05-22 20:41:36 +00:00
compareColumn: string
compareOperator: string
2026-05-22 09:40:35 +00:00
compareValue: number
approver: string
nextOnStart?: string | null
nextOnTrue?: string | null
nextOnFalse?: string | null
nextOnApprove?: string | null
nextOnReject?: string | null
positionX: number
positionY: number
compareOutcomes: CompareOutcomeDto[]
}
export interface WorkflowStateDto {
criteria: WorkflowCriteriaDto[]
}
2026-05-22 11:50:09 +00:00
export type SaveCriteriaInput = Omit<Partial<WorkflowCriteriaDto>, 'id'> & {
id?: string | null
2026-05-22 20:41:36 +00:00
listFormCode: string
2026-05-22 09:40:35 +00:00
}
const baseUrl = '/api/app/list-form-workflow'
export const workflowService = {
async getState(listFormCode?: string) {
const response = await apiService.fetchData<WorkflowStateDto>({
method: 'GET',
url: `${baseUrl}/state`,
params: { listFormCode },
})
return response.data
},
async saveCriteria(payload: SaveCriteriaInput) {
const response = await apiService.fetchData<WorkflowCriteriaDto>({
method: 'POST',
url: `${baseUrl}/criteria`,
data: payload,
})
return response.data
},
async deleteCriteria(id: string) {
await apiService.fetchData<void>({
method: 'DELETE',
url: `${baseUrl}/criteria/${id}`,
})
},
async resetDemo(listFormCode?: string) {
const response = await apiService.fetchData<WorkflowStateDto>({
method: 'POST',
url: `${baseUrl}/reset-demo`,
params: { listFormCode },
})
return response.data
},
}