| | |
| | | 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 = [ |
| | |
| | | { value: "cancelled", label: "已撤销" }, |
| | | ]; |
| | | |
| | | export const LEGACY_APPROVE_LIST_STORAGE_KEY = "oa_unified_approve_list_v1"; |
| | | |
| | | export function clearLegacyApproveListStorage() { |
| | | try { |
| | | localStorage.removeItem(LEGACY_APPROVE_LIST_STORAGE_KEY); |
| | | } catch { |
| | | /* ignore */ |
| | | } |
| | | } |
| | | |
| | | /** 提交弹窗:模板卡片(来自后端列表) */ |
| | | export function mapSubmitTemplateCard(row) { |
| | | const cfg = parseFormConfigToData(row?.formConfig); |
| | | return { |
| | | id: row?.id, |
| | | key: String(row?.id ?? ""), |
| | | businessType: row?.businessType ?? cfg.approvalType ?? row?.approvalType ?? "", |
| | | approvalType: cfg.approvalType || row?.approvalType || "", |
| | | label: row?.templateName || "—", |
| | | summaryPlaceholder: (row?.description || "").trim() || cfg.summaryPlaceholder || "点击填写并提交", |
| | | }; |
| | | } |
| | | |
| | | export function matchBusinessTypeValue(a, b) { |
| | | if (a == null || a === "" || b == null || b === "") return false; |
| | | return a === b || a === Number(b) || Number(a) === b || String(a) === String(b); |
| | | } |
| | | |
| | | /** 审批记录 approveAction → 页面 result */ |
| | |
| | | /** 单字段展示值(详情只读) */ |
| | | 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); |
| | |
| | | const dto = { |
| | | templateId, |
| | | templateName: submitForm?.templateName || tpl.label || "", |
| | | businessType: tpl.businessType ?? submitForm?.businessType ?? "", |
| | | title, |
| | | 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; |
| | |
| | | templateName: row.templateName || "", |
| | | businessId: row.businessId, |
| | | businessType: row.businessType, |
| | | businessName: row.businessName || "", |
| | | applicantId: row.applicantId, |
| | | applicantNo: row.applicantId != null ? String(row.applicantId) : "", |
| | | applicantName: row.applicantName || "", |
| | |
| | | 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)) : []; |
| | | } |