首页调试工作流管理
This commit is contained in:
@@ -190,6 +190,7 @@ import { computed, reactive, ref, watch } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import PatchTemplateEditor from '/@/components/patchTemplate/PatchTemplateEditor.vue';
|
||||
import { uploadFile } from '/@/api/common/upload';
|
||||
import { collectHomeFormFields } from '../utils/flowDsl';
|
||||
|
||||
interface Props {
|
||||
activeMenu: string;
|
||||
@@ -205,42 +206,12 @@ const fieldFiles = reactive<Record<string, { name: string; url: string }[]>>({})
|
||||
const uploadingFields = reactive<Record<string, boolean>>({});
|
||||
const templates = ref<any[]>([]);
|
||||
const getFieldKey = (node: any, field: any): string => {
|
||||
if (field?.__isHttpBodyChild) {
|
||||
return `${node.id}_body_${field.bodyKey}`;
|
||||
}
|
||||
return (node.id || node.nodeCode) + '_' + (field.field || field.label);
|
||||
const id = node.id || node.nodeCode;
|
||||
return `${id}|${field.path || field.field || field.label}`;
|
||||
};
|
||||
|
||||
const getVisibleFields = (node: any): any[] => {
|
||||
const fields = Array.isArray(node?.formConfig) ? node.formConfig : [];
|
||||
const result: any[] = [];
|
||||
fields.forEach((field: any) => {
|
||||
if (!field) return;
|
||||
if (field.expand && typeof field.expand === 'object' && field.expand.editable === false) return;
|
||||
|
||||
if (String(node?.nodeCode || '').toLowerCase() === 'http') {
|
||||
if (field.field !== 'body') return;
|
||||
const bodyVal = field.value;
|
||||
if (!bodyVal || typeof bodyVal !== 'object' || Array.isArray(bodyVal)) return;
|
||||
Object.entries(bodyVal).forEach(([bodyKey, bodyItem]: [string, any]) => {
|
||||
if (!bodyItem || bodyItem.showInForm !== true) return;
|
||||
result.push({
|
||||
__isHttpBodyChild: true,
|
||||
bodyKey,
|
||||
field: `body.${bodyKey}`,
|
||||
label: bodyItem.key || bodyKey,
|
||||
required: false,
|
||||
type: bodyItem.fieldType || 'input',
|
||||
fieldType: bodyItem.fieldType || 'string',
|
||||
fieldConstraint: bodyItem.fieldConstraint || {},
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
result.push(field);
|
||||
});
|
||||
return result;
|
||||
return collectHomeFormFields(node);
|
||||
};
|
||||
|
||||
const isFileField = (field: any): boolean => {
|
||||
@@ -355,13 +326,13 @@ const currentWorkflowHasPatchLayout = computed(() => {
|
||||
});
|
||||
|
||||
const hasFormConfig = (node: any): boolean => {
|
||||
return node.nodeCode !== '__start__' && node.formConfig && node.formConfig.length > 0;
|
||||
return node.nodeCode !== '__start__' && collectHomeFormFields(node).length > 0;
|
||||
};
|
||||
|
||||
const hasFormFields = computed(() => {
|
||||
if (!props.workflowDetail?.nodeInputParams) return false;
|
||||
return props.workflowDetail.nodeInputParams.some(
|
||||
(node: any) => node.nodeCode !== '__start__' && node.formConfig?.length > 0
|
||||
(node: any) => node.nodeCode !== '__start__' && collectHomeFormFields(node).length > 0
|
||||
);
|
||||
});
|
||||
|
||||
@@ -396,43 +367,42 @@ watch(
|
||||
templates.value = Array.isArray(restoredTemplates) ? restoredTemplates : [];
|
||||
|
||||
if (!detail?.nodeInputParams) return;
|
||||
detail.nodeInputParams.forEach((node: any) => {
|
||||
if (!node.formConfig) return;
|
||||
node.formConfig.forEach((field: any) => {
|
||||
if (String(node.nodeCode || '').toLowerCase() === 'http' && field.field === 'body' && field.value && typeof field.value === 'object') {
|
||||
Object.entries(field.value).forEach(([bodyKey, bodyItem]: [string, any]) => {
|
||||
if (!bodyItem || bodyItem.showInForm !== true) return;
|
||||
const bodyFieldKey = `${node.id}_body_${bodyKey}`;
|
||||
if (bodyItem.fieldType === 'number') {
|
||||
formValues[bodyFieldKey] = (bodyItem.value !== undefined && bodyItem.value !== null && bodyItem.value !== '')
|
||||
? Number(bodyItem.value) : null;
|
||||
} else if (bodyItem.fieldType === 'fileUpload') {
|
||||
formValues[bodyFieldKey] = Array.isArray(bodyItem.value) ? bodyItem.value
|
||||
: bodyItem.value ? [bodyItem.value] : [];
|
||||
} else {
|
||||
formValues[bodyFieldKey] = bodyItem.value || '';
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
const nodes = detail.nodeInputParams as any[];
|
||||
|
||||
// 1) 初始化表单值(model → modelRequestParams runtimeShow;form → outputConfig;旧数据 → formConfig)
|
||||
nodes.forEach((node) => {
|
||||
collectHomeFormFields(node).forEach((field) => {
|
||||
const key = getFieldKey(node, field);
|
||||
const hasValue = field.value !== undefined && field.value !== null;
|
||||
const hasValue = field.value !== undefined && field.value !== null && field.value !== '';
|
||||
if (field.type === 'number' || field.type === 'inputNumber') {
|
||||
formValues[key] = hasValue ? Number(field.value) : (field.default ?? null);
|
||||
} else if (field.type === 'switch') {
|
||||
formValues[key] = hasValue ? Boolean(field.value) : (field.default ?? false);
|
||||
} else if (field.type === 'upload' || field.type === 'uploadMultiple' || field.type === 'fileUpload') {
|
||||
formValues[key] = hasValue ? field.value : (field.default ?? (field.type === 'upload' ? '' : []));
|
||||
if (field.type === 'fileUpload') {
|
||||
formValues[key] = hasValue
|
||||
? Array.isArray(field.value)
|
||||
? field.value
|
||||
: field.value
|
||||
? [field.value]
|
||||
: []
|
||||
: Array.isArray(field.default)
|
||||
? field.default
|
||||
: field.default
|
||||
? [field.default]
|
||||
: [];
|
||||
} else {
|
||||
formValues[key] = hasValue ? field.value : (field.default ?? (field.type === 'upload' ? '' : []));
|
||||
}
|
||||
} else {
|
||||
formValues[key] = hasValue ? field.value : (field.default ?? '');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
detail.nodeInputParams.forEach((node: any) => {
|
||||
if (!node.formConfig) return;
|
||||
node.formConfig.forEach((field: any) => {
|
||||
// 2) 文件字段回填已上传文件列表
|
||||
nodes.forEach((node) => {
|
||||
collectHomeFormFields(node).forEach((field) => {
|
||||
if (!isFileField(field)) return;
|
||||
const key = getFieldKey(node, field);
|
||||
const rawValue = formValues[key];
|
||||
|
||||
Reference in New Issue
Block a user