|
@@ -1,5 +1,43 @@
|
|
|
import axiosInstance from '../utils/axios';
|
|
import axiosInstance from '../utils/axios';
|
|
|
|
|
|
|
|
|
|
+function toCommaString(value: unknown): string {
|
|
|
|
|
+ if (Array.isArray(value)) {
|
|
|
|
|
+ return value
|
|
|
|
|
+ .map((item) => String(item).trim())
|
|
|
|
|
+ .filter((item) => item !== '')
|
|
|
|
|
+ .join(',');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (value === undefined || value === null || value === '') {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ }
|
|
|
|
|
+ return String(value).trim();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function normalizeWorkflowContentCopyIds(content: string): string {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const parsed = JSON.parse(content);
|
|
|
|
|
+ if (parsed && Array.isArray(parsed.nodes)) {
|
|
|
|
|
+ parsed.nodes = parsed.nodes.map((node: any) => {
|
|
|
|
|
+ const nodeData = node?.data && typeof node.data === 'object' ? { ...node.data } : undefined;
|
|
|
|
|
+ if (!nodeData) return node;
|
|
|
|
|
+ if ('copyDeptIds' in nodeData) {
|
|
|
|
|
+ nodeData.copyDeptIds = toCommaString(nodeData.copyDeptIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ('copyUserIds' in nodeData) {
|
|
|
|
|
+ nodeData.copyUserIds = toCommaString(nodeData.copyUserIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...node,
|
|
|
|
|
+ data: nodeData,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return JSON.stringify(parsed, null, 2);
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ return content;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 流程设计 VO
|
|
// 流程设计 VO
|
|
|
export interface WorkflowDesignVO {
|
|
export interface WorkflowDesignVO {
|
|
|
id?: number;
|
|
id?: number;
|
|
@@ -70,7 +108,11 @@ export const workflowDesignApi = {
|
|
|
|
|
|
|
|
// 更新流程设计
|
|
// 更新流程设计
|
|
|
updateWorkflowDesign: (data: UpdateWorkflowDesignParam) => {
|
|
updateWorkflowDesign: (data: UpdateWorkflowDesignParam) => {
|
|
|
- return axiosInstance.put<WorkflowDesignVO>('/iscs/workflow-design/updateWorkflowDesign', data);
|
|
|
|
|
|
|
+ const payload: UpdateWorkflowDesignParam = { ...data };
|
|
|
|
|
+ if (typeof payload.content === 'string' && payload.content.trim() !== '') {
|
|
|
|
|
+ payload.content = normalizeWorkflowContentCopyIds(payload.content);
|
|
|
|
|
+ }
|
|
|
|
|
+ return axiosInstance.put<WorkflowDesignVO>('/iscs/workflow-design/updateWorkflowDesign', payload);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 删除流程设计
|
|
// 删除流程设计
|