| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { computed } from "vue"; |
| | | import { businessApprovalStatusLabel, businessApprovalStatusTagType, formatFieldDisplayValue, resolveInstanceFormFields } from "../approve-list/approveListConstants.js"; |
| | | import { INSTANCE_NO_SEARCH_MODULE_KEYS, INSTANCE_NO_TABLE_COLUMN } from "./approvalInstanceListSearch.js"; |
| | | |
| | | /** å表/详æ
ä¸åæ¾ä¸ºç¬ç«åçå¡«æ¥é¡¹ keyï¼é¿å
è¦çå®ä¾ç³»ç»åæ®µï¼ */ |
| | | const DEFAULT_EXCLUDE_KEYS = new Set(["summary", "status", "approvalStatus", "approvalstatus", "instanceStatus", "publishStatus", "newsStatus"]); |
| | | |
| | | /** enrich åå¿
é¡»ä¿ççå®ä¾å段ï¼ä¸è¢« formConfig éºå¹³è¦çï¼ */ |
| | | const PRESERVE_INSTANCE_FIELDS = [ |
| | | "id", |
| | | "approvalStatus", |
| | | "statusRaw", |
| | | "status", |
| | | "instanceNo", |
| | | "templateId", |
| | | "templateName", |
| | | "businessType", |
| | | "businessId", |
| | | "businessName", |
| | | "applicantId", |
| | | "applicantNo", |
| | | "applicantName", |
| | | "createTime", |
| | | "applyTime", |
| | | "finishTime", |
| | | "title", |
| | | "isApprove", |
| | | "unread", |
| | | "currentLevel", |
| | | "newsStatus", |
| | | "storageBlobVOList", |
| | | "storageBlobDTOs", |
| | | ]; |
| | | |
| | | /** |
| | | * ä»è¡æ°æ® formConfig è§£æå段å®ä¹ä¸å¡«æ¥å¼ï¼å¹¶éºå¹³å°è¡ä¸ä¾ä¸»è¡¨ prop ç»å®ï¼å±ç¤ºç¨æ ¼å¼åå¼ï¼ |
| | | */ |
| | | export function enrichInstanceRowFromFormConfig(row, caches) { |
| | | const { fields, formPayload, templateSnapshot } = resolveInstanceFormFields(row); |
| | | const formDisplay = {}; |
| | | const displayRow = { |
| | | ...row, |
| | | formFieldDefs: fields, |
| | | formPayload, |
| | | templateSnapshot: row.templateSnapshot || templateSnapshot, |
| | | formDisplay, |
| | | }; |
| | | |
| | | for (const f of fields) { |
| | | if (!f?.key || DEFAULT_EXCLUDE_KEYS.has(f.key)) continue; |
| | | const val = formPayload[f.key]; |
| | | let text = formatFieldDisplayValue(f, val, caches); |
| | | if (text === String(val) && row?.applicantName && (f.label === "ç³è¯·äºº" || f.key === "applicant" || f.key === "applicantName")) { |
| | | const idMatch = String(val) === String(row.applicantId) || String(val) === String(row.applicantNo); |
| | | if (idMatch) text = row.applicantName; |
| | | } |
| | | formDisplay[f.key] = text; |
| | | displayRow[f.key] = text; |
| | | } |
| | | |
| | | for (const key of PRESERVE_INSTANCE_FIELDS) { |
| | | if (row[key] !== undefined) displayRow[key] = row[key]; |
| | | } |
| | | |
| | | return displayRow; |
| | | } |
| | | |
| | | /** |
| | | * ä»å表é¦è¡ formConfig çæä¸»è¡¨å¨æåï¼label åèªæ¨¡æ¿å段 labelï¼ |
| | | */ |
| | | export function getFormConfigFieldColumns(firstRow, { excludeKeys = DEFAULT_EXCLUDE_KEYS } = {}) { |
| | | const fields = (firstRow?.formFieldDefs || []).filter(f => f?.key && !excludeKeys.has(f.key)); |
| | | return fields.map(f => ({ |
| | | label: f.label || f.key, |
| | | prop: f.key, |
| | | minWidth: f.type === "textarea" ? 200 : f.type === "datetimerange" ? 160 : 120, |
| | | showOverflowTooltip: true, |
| | | })); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡ç³è¯·ä¸»è¡¨åï¼åºå®å + formConfig 卿å + 审æ¹ç¶æ + æä½ |
| | | */ |
| | | export function buildInstanceTableColumns(tableDataRef, buildTableActions, options = {}) { |
| | | const { moduleKey, excludeKeys = DEFAULT_EXCLUDE_KEYS, beforeFormColumns = [], extraColumns = [], afterFormColumns = [], actionWidth = 260 } = options; |
| | | |
| | | const leadingCols = moduleKey && INSTANCE_NO_SEARCH_MODULE_KEYS.has(moduleKey) ? [INSTANCE_NO_TABLE_COLUMN] : []; |
| | | |
| | | return computed(() => { |
| | | const formCols = getFormConfigFieldColumns(tableDataRef.value?.[0], { excludeKeys }); |
| | | return [ |
| | | ...leadingCols, |
| | | ...beforeFormColumns, |
| | | ...formCols, |
| | | ...extraColumns, |
| | | ...afterFormColumns, |
| | | { label: "å建æ¶é´", prop: "createTime", width: 170 }, |
| | | { |
| | | label: "审æ¹ç¶æ", |
| | | prop: "approvalStatus", |
| | | width: 110, |
| | | dataType: "tag", |
| | | formatData: v => businessApprovalStatusLabel(v), |
| | | formatType: v => businessApprovalStatusTagType(v), |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "æä½", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: actionWidth, |
| | | operation: buildTableActions(), |
| | | }, |
| | | ]; |
| | | }); |
| | | } |