yyb
10 小时以前 352f7bbb74f1b6c57b3d3e576849d0565932fbd4
src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
@@ -1,6 +1,7 @@
import { matchBusinessTypeValue } from "../approve-list/approveListConstants.js";
/**
 * 各业务模块与审批模板类型的映射(配置化入口)
 *
 * 各业务模块与审批模板类型的映射(配置化入口) *
 * 使用方式:
 * 1. 在业务页引入 ApprovalTemplateBindDialog,传入 moduleKey
 * 2. 或在表单内嵌 ApprovalTemplateFormSection + useApprovalTemplateBinding({ moduleKey })
@@ -16,6 +17,7 @@
  OVERTIME: "overtime",
  TRAVEL_REIMBURSE: "travel_reimburse",
  COST_REIMBURSE: "cost_reimburse",
  ENTERPRISE_NEWS: "enterprise_news",
};
/** @type {Record<string, import('./approvalModuleRegistry.js').ApprovalModuleConfig>} */
@@ -60,6 +62,11 @@
    approvalType: "cost_reimburse",
    typeLabels: ["费用", "费用报销"],
  },
  [APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS]: {
    label: "企业新闻",
    approvalType: "enterprise_news",
    typeLabels: ["企业新闻", "新闻", "新闻发布"],
  },
};
/**
@@ -75,6 +82,14 @@
  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,
@@ -82,21 +97,30 @@
  }));
}
/** 从 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;
}