diff --git a/src/api/approval/flow/index.ts b/src/api/approval/flow/index.ts new file mode 100644 index 0000000..61de416 --- /dev/null +++ b/src/api/approval/flow/index.ts @@ -0,0 +1,52 @@ +import request from '@/utils/request'; +import type { ApiResult } from '@/api'; +import { THINK_API_URL } from '@/config/setting'; +import type { + ApprovalFlow, + ApprovalFlowNode, + ApprovalFlowVersion +} from './model'; + +/** + * 流程定义列表(当前版本与出厂模板) + */ +export async function listFlowConfigs() { + const res = await request.get>( + THINK_API_URL + '/approval/flow' + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 流程定义历史版本 + */ +export async function listFlowHistory(flowCode: string) { + const res = await request.get>( + THINK_API_URL + '/approval/flow/history', + { params: { flowCode } } + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 发布流程定义新版本(保存即发布) + */ +export async function publishFlowConfig(data: { + flowCode: string; + nodes: ApprovalFlowNode[]; +}) { + const res = await request.post>( + THINK_API_URL + '/approval/flow/publish', + data + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} diff --git a/src/api/approval/flow/model/index.ts b/src/api/approval/flow/model/index.ts new file mode 100644 index 0000000..ef2c61a --- /dev/null +++ b/src/api/approval/flow/model/index.ts @@ -0,0 +1,68 @@ +/** + * 流程节点会签组(与后端 ApprovalNode.ApprovalGroup 对应) + */ +export interface ApprovalFlowNodeGroup { + key: string; + name: string; + resolver?: string; + orgCode?: string; +} + +/** + * 流程节点回填字段(与后端 ApprovalNode.WritableField 对应) + */ +export interface ApprovalFlowWritableField { + field: string; + required: boolean; +} + +/** + * 流程节点(与后端 ApprovalNode 对应) + */ +export interface ApprovalFlowNode { + key: string; + type: string; + resolver?: string; + orgCode?: string; + name: string; + groups?: ApprovalFlowNodeGroup[]; + writableFields?: ApprovalFlowWritableField[]; +} + +/** + * 可写字段元数据(与后端 ApprovalFieldSpec 对应) + */ +export interface ApprovalFieldSpec { + key: string; + label: string; + maxLength?: number; + unique?: boolean; + type?: string; +} + +/** + * 流程定义当前版本 + */ +export interface ApprovalFlow { + flowCode: string; + flowName: string; + version?: number; + definitionId?: number; + publishTime?: string; + nodes: ApprovalFlowNode[]; + factoryNodes: ApprovalFlowNode[]; + factoryVersion?: number; + fieldSpecs: ApprovalFieldSpec[]; + resolvers: string[]; +} + +/** + * 流程定义历史版本 + */ +export interface ApprovalFlowVersion { + definitionId: number; + version: number; + name: string; + publishTime?: string; + nodes: ApprovalFlowNode[]; +} diff --git a/src/views/approval/flow/components/node-card.vue b/src/views/approval/flow/components/node-card.vue new file mode 100644 index 0000000..c4d929b --- /dev/null +++ b/src/views/approval/flow/components/node-card.vue @@ -0,0 +1,337 @@ + + + + + + diff --git a/src/views/approval/flow/constants.ts b/src/views/approval/flow/constants.ts new file mode 100644 index 0000000..b8758ae --- /dev/null +++ b/src/views/approval/flow/constants.ts @@ -0,0 +1,22 @@ +/** + * 流程节点类型(与后端 ApprovalConstants 对应) + */ +export const NODE_TYPE_OPTIONS = [ + { value: 'APPROVE', label: '审批(或签)' }, + { value: 'COUNTERSIGN', label: '会签' }, + { value: 'DISPATCH', label: '派单' }, + { value: 'CONFIRM', label: '存档' }, + { value: 'ARCHIVE', label: '归档' } +]; + +/** 需要固定组织编码的解析器 */ +export const ORG_RESOLVERS = ['orgLeaderByCode', 'orgDeputyByCode']; + +/** 可配置回填字段的节点类型 */ +export const WRITABLE_TYPES = ['APPROVE', 'COUNTERSIGN', 'CONFIRM']; + +/** 节点类型显示名 */ +export function nodeTypeLabel(type?: string) { + const item = NODE_TYPE_OPTIONS.find((option) => option.value === type); + return item ? item.label : type || ''; +} diff --git a/src/views/approval/flow/index.vue b/src/views/approval/flow/index.vue new file mode 100644 index 0000000..eea5174 --- /dev/null +++ b/src/views/approval/flow/index.vue @@ -0,0 +1,364 @@ + + + + + +