| | |
| | | nodeSignModeLabel, |
| | | } from "../approve-template/approveTemplateConstants.js"; |
| | | import { buildFormPayloadFromFields, parseFormConfigToData } from "../approve-template/formConfigUtils.js"; |
| | | import { isDynamicOptionSource, selectOptionSourceLabel } from "../approve-template/selectOptionSource.js"; |
| | | |
| | | /** 审批类型(与后端字段 approvalType 对齐,后期可同步) */ |
| | | export const APPROVAL_TYPE_OPTIONS = [ |
| | |
| | | /** 单字段展示值(详情只读) */ |
| | | export function formatFieldDisplayValue(field, val) { |
| | | if (val == null || val === "" || (Array.isArray(val) && !val.length)) return "—"; |
| | | if (field?.type === "select" && isDynamicOptionSource(field.optionSource)) { |
| | | return `${selectOptionSourceLabel(field.optionSource)}:${String(val)}`; |
| | | } |
| | | if (field?.type === "select" && field.options?.length) { |
| | | const hit = field.options.find((o) => String(o.value) === String(val)); |
| | | return hit?.label || String(val); |
| | |
| | | formConfig: buildInstanceFormConfigJson({ ...tpl, fields: tpl.fields || submitForm?.formFieldDefs }, payload), |
| | | tasks: taskList, |
| | | }; |
| | | |
| | | const attachments = |
| | | (Array.isArray(submitForm?.storageBlobDTOs) && submitForm.storageBlobDTOs.length |
| | | ? submitForm.storageBlobDTOs |
| | | : null) || tpl.storageBlobDTOs; |
| | | if (attachments?.length) dto.storageBlobDTOs = attachments; |
| | | |
| | | if (isUpdate) { |
| | | dto.id = existingRow?.id ?? submitForm?.instanceId; |
| | |
| | | formFieldDefs: fields, |
| | | formPayload, |
| | | flowNodes, |
| | | templateAttachments: initTemplateAttachmentsFromSnapshot(templateSnapshot), |
| | | storageBlobDTOs: row?.storageBlobDTOs?.length |
| | | ? JSON.parse(JSON.stringify(row.storageBlobDTOs)) |
| | | : [], |
| | | }; |
| | | } |
| | | |
| | |
| | | formFieldDefs: tpl?.fields || [], |
| | | formPayload: payload, |
| | | flowNodes, |
| | | templateAttachments: tpl?.storageBlobDTOs |
| | | ? JSON.parse(JSON.stringify(tpl.storageBlobDTOs)) |
| | | : [], |
| | | storageBlobDTOs: [], |
| | | }; |
| | | } |
| | | |
| | | export function initTemplateAttachmentsFromSnapshot(templateSnapshot) { |
| | | const list = templateSnapshot?.storageBlobDTOs; |
| | | return list?.length ? JSON.parse(JSON.stringify(list)) : []; |
| | | } |