72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import apiClient from './client'
|
|
import type { ApprovalFlowNode, ApiResponse } from '@/types/api'
|
|
|
|
export interface CreateFlowNodeRequest {
|
|
topic_id: number
|
|
parent_id?: number | null
|
|
key: string
|
|
label: string
|
|
data_key?: string | null
|
|
data_value?: string | null
|
|
is_input?: boolean
|
|
input_key?: string | null
|
|
input_hint?: string | null
|
|
is_multi_select?: boolean
|
|
multi_select_key?: string | null
|
|
multi_select_value?: string | null
|
|
topic_code?: string | null
|
|
sort_order?: number
|
|
}
|
|
|
|
export interface UpdateFlowNodeRequest {
|
|
id: number
|
|
topic_id?: number
|
|
parent_id?: number | null
|
|
key?: string
|
|
label?: string
|
|
data_key?: string | null
|
|
data_value?: string | null
|
|
is_input?: boolean
|
|
input_key?: string | null
|
|
input_hint?: string | null
|
|
is_multi_select?: boolean
|
|
multi_select_key?: string | null
|
|
multi_select_value?: string | null
|
|
topic_code?: string | null
|
|
sort_order?: number
|
|
}
|
|
|
|
export interface MoveFlowNodeRequest {
|
|
new_parent_id?: number | null
|
|
new_sort_order?: number
|
|
}
|
|
|
|
export interface SaveTreeRequest {
|
|
nodes: ApprovalFlowNode[]
|
|
}
|
|
|
|
export const flowNodesApi = {
|
|
getTree: (topicId: number) =>
|
|
apiClient.get<ApiResponse<ApprovalFlowNode[]>>(`/flow-nodes/topic/${topicId}`),
|
|
|
|
getById: (id: number) =>
|
|
apiClient.get<ApprovalFlowNode>(`/flow-nodes/${id}`),
|
|
|
|
create: (data: CreateFlowNodeRequest) =>
|
|
apiClient.post<ApprovalFlowNode>('/flow-nodes/', data),
|
|
|
|
update: (data: UpdateFlowNodeRequest) =>
|
|
apiClient.put<ApprovalFlowNode>('/flow-nodes/', data),
|
|
|
|
delete: (id: number) =>
|
|
apiClient.delete<boolean>('/flow-nodes/', { data: { id } }),
|
|
|
|
saveTree: (topicId: number, data: SaveTreeRequest) =>
|
|
apiClient.post<boolean>(`/flow-nodes/topic/${topicId}/tree`, data),
|
|
|
|
move: (id: number, data: MoveFlowNodeRequest) =>
|
|
apiClient.post<ApprovalFlowNode>(`/flow-nodes/${id}/move`, data),
|
|
|
|
duplicate: (id: number) =>
|
|
apiClient.post<ApprovalFlowNode>(`/flow-nodes/${id}/duplicate`, {}),
|
|
} |