From 97081b89ee45da49b8dbb4173ab45df031fe3c0d Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 16:58:40 +0800
Subject: [PATCH] 删除冗余和无效代码

---
 src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js |   69 +++++++++++++++++++++++++++-------
 1 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js b/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
index 09d68fd..2bdd35a 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
@@ -1,6 +1,7 @@
+import { matchBusinessTypeValue } from "../approve-list/approveListConstants.js";
+
 /**
- * 鍚勪笟鍔℃ā鍧椾笌瀹℃壒妯℃澘绫诲瀷鐨勬槧灏勶紙閰嶇疆鍖栧叆鍙o級
- *
+ * 鍚勪笟鍔℃ā鍧椾笌瀹℃壒妯℃澘绫诲瀷鐨勬槧灏勶紙閰嶇疆鍖栧叆鍙o級 *
  * 浣跨敤鏂瑰紡锛�
  * 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>} */
@@ -33,22 +35,22 @@
   [APPROVAL_MODULE_KEYS.RESIGN]: {
     label: "绂昏亴鐢宠",
     approvalType: "resign",
-    typeLabels: ["绂昏亴", "绂昏亴鐢宠"],
+    typeLabels: ["绂昏亴", "绂昏亴鐢宠", "绂昏亴瀹℃壒"],
   },
   [APPROVAL_MODULE_KEYS.WORK_HANDOVER]: {
     label: "宸ヤ綔浜ゆ帴",
     approvalType: "work_handover",
-    typeLabels: ["宸ヤ綔浜ゆ帴", "浜ゆ帴"],
+    typeLabels: ["宸ヤ綔浜ゆ帴", "浜ゆ帴", "宸ヤ綔浜ゆ帴瀹℃壒"],
   },
   [APPROVAL_MODULE_KEYS.LEAVE]: {
     label: "璇峰亣鐢宠",
     approvalType: "leave",
-    typeLabels: ["璇峰亣", "璇峰亣鐢宠"],
+    typeLabels: ["璇峰亣", "璇峰亣鐢宠", "璇峰亣瀹℃壒"],
   },
   [APPROVAL_MODULE_KEYS.OVERTIME]: {
     label: "鍔犵彮鐢宠",
     approvalType: "overtime",
-    typeLabels: ["鍔犵彮", "鍔犵彮鐢宠"],
+    typeLabels: ["鍔犵彮", "鍔犵彮鐢宠", "鍔犵彮瀹℃壒"],
   },
   [APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE]: {
     label: "宸梾鎶ラ攢",
@@ -59,6 +61,11 @@
     label: "璐圭敤鎶ラ攢",
     approvalType: "cost_reimburse",
     typeLabels: ["璐圭敤", "璐圭敤鎶ラ攢"],
+  },
+  [APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS]: {
+    label: "浼佷笟鏂伴椈",
+    approvalType: "enterprise_news",
+    typeLabels: ["浼佷笟鏂伴椈", "鏂伴椈", "鏂伴椈鍙戝竷"],
   },
 };
 
@@ -75,28 +82,62 @@
   return APPROVAL_MODULE_REGISTRY[moduleKey] || null;
 }
 
-export function listApprovalModuleEntries() {
-  return Object.entries(APPROVAL_MODULE_REGISTRY).map(([moduleKey, cfg]) => ({
-    moduleKey,
-    ...cfg,
-  }));
+/** 鍒楄〃鏌ヨ榛樿 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 || "";
 }
 
-/** 浠� 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;
 }
+
+/** 鏀堕泦涓庢ā鍧楃浉鍏崇殑鍏ㄩ儴 businessType 鍙栧�硷紙鏋氫妇鍊� + approvalType锛夛紝鐢ㄤ簬妯℃澘鍒楄〃杩囨护 */
+export function getModuleMatchingBusinessTypes(moduleKey, typeOptions = []) {
+  const cfg = getApprovalModuleConfig(moduleKey);
+  if (!cfg) return [];
+
+  const values = new Set();
+  const primary = resolveModuleBusinessType(moduleKey, typeOptions);
+  if (primary != null && primary !== "") values.add(primary);
+  if (cfg.approvalType) values.add(cfg.approvalType);
+
+  const labels = [cfg.label, ...(cfg.typeLabels || [])].filter(Boolean);
+  for (const opt of typeOptions || []) {
+    const optLabel = String(opt?.label || "").trim();
+    if (!optLabel) continue;
+    const matched = labels.some(
+      (l) => optLabel === l || optLabel.includes(l) || l.includes(optLabel)
+    );
+    if (matched && opt.value != null && opt.value !== "") {
+      values.add(opt.value);
+    }
+  }
+  return [...values];
+}

--
Gitblit v1.9.3