| | |
| | | import { matchBusinessTypeValue } from "../approve-list/approveListConstants.js"; |
| | | |
| | | /** |
| | | * 各业务模块与审批模板类型的映射(配置化入口) |
| | | * |
| | | * 各业务模块与审批模板类型的映射(配置化入口) * |
| | | * 使用方式: |
| | | * 1. 在业务页引入 ApprovalTemplateBindDialog,传入 moduleKey |
| | | * 2. 或在表单内嵌 ApprovalTemplateFormSection + useApprovalTemplateBinding({ moduleKey }) |
| | |
| | | OVERTIME: "overtime", |
| | | TRAVEL_REIMBURSE: "travel_reimburse", |
| | | COST_REIMBURSE: "cost_reimburse", |
| | | ENTERPRISE_NEWS: "enterprise_news", |
| | | }; |
| | | |
| | | /** @type {Record<string, import('./approvalModuleRegistry.js').ApprovalModuleConfig>} */ |
| | |
| | | approvalType: "cost_reimburse", |
| | | typeLabels: ["费用", "费用报销"], |
| | | }, |
| | | [APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS]: { |
| | | label: "企业新闻", |
| | | approvalType: "enterprise_news", |
| | | typeLabels: ["企业新闻", "新闻", "新闻发布"], |
| | | }, |
| | | }; |
| | | |
| | | /** |
| | |
| | | return APPROVAL_MODULE_REGISTRY[moduleKey] || null; |
| | | } |
| | | |
| | | /** 列表查询默认 businessType(与审批列表 listPage 约定一致) */ |
| | | export function getModuleListBusinessType(moduleKey) { |
| | | const cfg = getApprovalModuleConfig(moduleKey); |
| | | if (!cfg) return ""; |
| | | if (cfg.businessType != null && cfg.businessType !== "") return cfg.businessType; |
| | | return cfg.approvalType || ""; |
| | | } |
| | | |
| | | export function listApprovalModuleEntries() { |
| | | return Object.entries(APPROVAL_MODULE_REGISTRY).map(([moduleKey, cfg]) => ({ |
| | | moduleKey, |
| | |
| | | })); |
| | | } |
| | | |
| | | /** 从 TypeEnums 选项中解析本模块的 businessType */ |
| | | /** 从 TypeEnums 选项中解析本模块的 businessType(与审批列表下拉一致) */ |
| | | export function resolveModuleBusinessType(moduleKey, typeOptions = []) { |
| | | const cfg = getApprovalModuleConfig(moduleKey); |
| | | if (!cfg) return null; |
| | | if (cfg.businessType != null && cfg.businessType !== "") return cfg.businessType; |
| | | |
| | | const labels = [cfg.label, ...(cfg.typeLabels || [])].filter(Boolean); |
| | | const hit = (typeOptions || []).find((opt) => { |
| | | const hitByLabel = (typeOptions || []).find((opt) => { |
| | | const optLabel = String(opt?.label || "").trim(); |
| | | if (!optLabel) return false; |
| | | return labels.some( |
| | | (l) => optLabel === l || optLabel.includes(l) || l.includes(optLabel) |
| | | ); |
| | | }); |
| | | if (hit?.value != null && hit.value !== "") return hit.value; |
| | | if (hitByLabel?.value != null && hitByLabel.value !== "") return hitByLabel.value; |
| | | |
| | | if (cfg.approvalType) { |
| | | const hitByValue = (typeOptions || []).find( |
| | | (opt) => |
| | | matchBusinessTypeValue(opt?.value, cfg.approvalType) || |
| | | matchBusinessTypeValue(opt?.code, cfg.approvalType) |
| | | ); |
| | | if (hitByValue?.value != null && hitByValue.value !== "") return hitByValue.value; |
| | | } |
| | | |
| | | return cfg.approvalType || null; |
| | | } |