diff --git a/apps/web-antd/src/api/core/form-management.ts b/apps/web-antd/src/api/core/form-management.ts new file mode 100644 index 0000000..e6e20bd --- /dev/null +++ b/apps/web-antd/src/api/core/form-management.ts @@ -0,0 +1,157 @@ +import { workflowRequestClient } from '#/api/request'; + +// --- Enums --- + +export enum FormStatus { + Draft = 0, + Published = 1, + Disabled = 2, +} + +// --- Types --- + +export interface FormDefinitionDto { + id: string; + name: string; + code: string; + description: string | null; + version: number; + status: FormStatus; +} + +export interface FormDefinitionDetailDto extends FormDefinitionDto { + schemaJson: string | null; +} + +export interface PagedFormResult { + items: FormDefinitionDto[]; + total: number; +} + +export interface FormDataDto { + id: string; + formDefinitionId: string; + instanceId: string; + dataJson: string; +} + +// --- Form Definition CRUD --- + +export function getFormDefinitionsApi(params?: { + pageIndex?: number; + pageSize?: number; + status?: FormStatus; +}) { + return workflowRequestClient.get('/forms', { params }); +} + +export function getFormDefinitionByIdApi(id: string) { + return workflowRequestClient.get(`/forms/${id}`); +} + +export function createFormDefinitionApi(data: { + name: string; + code: string; + description?: string; + schemaJson: string; +}) { + return workflowRequestClient.post('/forms', data); +} + +export function updateFormDefinitionApi( + id: string, + data: { + name: string; + description?: string; + schemaJson: string; + }, +) { + return workflowRequestClient.put(`/forms/${id}`, data); +} + +export function deleteFormDefinitionApi(id: string) { + return workflowRequestClient.delete(`/forms/${id}`); +} + +export function publishFormDefinitionApi(id: string) { + return workflowRequestClient.post(`/forms/${id}/publish`); +} + +export function disableFormDefinitionApi(id: string) { + return workflowRequestClient.post(`/forms/${id}/disable`); +} + +// --- Form Data --- + +export function submitFormDataApi(data: { + formDefinitionId: string; + instanceId: string; + dataJson: string; +}) { + return workflowRequestClient.post('/forms/data', data); +} + +export function getFormDataByInstanceApi(instanceId: string) { + return workflowRequestClient.get( + `/forms/data/${instanceId}`, + ); +} + +// --- Component Registry --- + +export interface FormComponentDto { + id: string; + name: string; + displayName: string; + category: string; + icon: string; + defaultSchema: string; + supportedProps: string; + isActive: boolean; + sortOrder: number; +} + +export function getFormComponentsApi(params?: { + category?: string; + isActive?: boolean; +}) { + return workflowRequestClient.get('/form-components', { + params, + }); +} + +export function getFormComponentByIdApi(id: string) { + return workflowRequestClient.get(`/form-components/${id}`); +} + +export function createFormComponentApi(data: { + name: string; + displayName: string; + category: string; + icon: string; + defaultSchema: string; + supportedProps?: string; +}) { + return workflowRequestClient.post('/form-components', data); +} + +export function updateFormComponentApi( + id: string, + data: { + displayName: string; + category: string; + icon: string; + defaultSchema: string; + supportedProps?: string; + isActive?: boolean; + }, +) { + return workflowRequestClient.put( + `/form-components/${id}`, + data, + ); +} + +export function deleteFormComponentApi(id: string) { + return workflowRequestClient.delete(`/form-components/${id}`); +}