From be85a121031530d69865fd30d0dfb2fe0998a6a3 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期四, 21 五月 2026 15:21:40 +0800
Subject: [PATCH] 优化查询条件分类
---
src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js | 74 +++++++++++++++++++++++++-----------
1 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js b/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
index ad85890..a85cf9c 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-shared/approvalModuleRegistry.js
@@ -1,11 +1,8 @@
+import { matchBusinessTypeValue } from "../approve-list/approveListConstants.js";
+
/**
* 鍚勪笟鍔℃ā鍧椾笌瀹℃壒妯℃澘绫诲瀷鐨勬槧灏勶紙閰嶇疆鍖栧叆鍙o級
- *
- * 浣跨敤鏂瑰紡锛�
- * 1. 鍦ㄤ笟鍔¢〉寮曞叆 ApprovalTemplateBindDialog锛屼紶鍏� moduleKey
- * 2. 鎴栧湪琛ㄥ崟鍐呭祵 ApprovalTemplateFormSection + useApprovalTemplateBinding({ moduleKey })
- *
- * businessType锛氳嫢鍚庣 TypeEnums 宸插浐瀹� code锛屽彲鐩存帴鍐欐 value锛涘惁鍒欑敤 typeLabels 鎸夊悕绉板尮閰�
+ * businessType 涓庡悗绔� TypeEnums / listPage 绾﹀畾涓�鑷达紙鍐欐鏋氫妇鍊硷級
*/
export const APPROVAL_MODULE_KEYS = {
REGULAR: "regular",
@@ -16,6 +13,19 @@
OVERTIME: "overtime",
TRAVEL_REIMBURSE: "travel_reimburse",
COST_REIMBURSE: "cost_reimburse",
+ ENTERPRISE_NEWS: "enterprise_news",
+};
+
+/** 瀹℃壒瀹炰緥 listPage / 淇濆瓨 浣跨敤鐨� businessType 鏋氫妇 */
+export const APPROVAL_BUSINESS_TYPE = {
+ [APPROVAL_MODULE_KEYS.REGULAR]: 10,
+ [APPROVAL_MODULE_KEYS.TRANSFER]: 11,
+ [APPROVAL_MODULE_KEYS.WORK_HANDOVER]: 13,
+ [APPROVAL_MODULE_KEYS.LEAVE]: 14,
+ [APPROVAL_MODULE_KEYS.OVERTIME]: 15,
+ [APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE]: 16,
+ [APPROVAL_MODULE_KEYS.COST_REIMBURSE]: 17,
+ [APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS]: 18,
};
/** @type {Record<string, import('./approvalModuleRegistry.js').ApprovalModuleConfig>} */
@@ -23,11 +33,13 @@
[APPROVAL_MODULE_KEYS.REGULAR]: {
label: "杞鐢宠",
approvalType: "regular",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.REGULAR],
typeLabels: ["杞", "杞鐢宠"],
},
[APPROVAL_MODULE_KEYS.TRANSFER]: {
label: "璋冨矖鐢宠",
approvalType: "transfer",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.TRANSFER],
typeLabels: ["璋冨矖", "璋冨姩", "璋冨矖鐢宠", "璋冨姩鐢宠"],
},
[APPROVAL_MODULE_KEYS.RESIGN]: {
@@ -38,36 +50,47 @@
[APPROVAL_MODULE_KEYS.WORK_HANDOVER]: {
label: "宸ヤ綔浜ゆ帴",
approvalType: "work_handover",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.WORK_HANDOVER],
typeLabels: ["宸ヤ綔浜ゆ帴", "浜ゆ帴", "宸ヤ綔浜ゆ帴瀹℃壒"],
},
[APPROVAL_MODULE_KEYS.LEAVE]: {
label: "璇峰亣鐢宠",
approvalType: "leave",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.LEAVE],
typeLabels: ["璇峰亣", "璇峰亣鐢宠", "璇峰亣瀹℃壒"],
},
[APPROVAL_MODULE_KEYS.OVERTIME]: {
label: "鍔犵彮鐢宠",
approvalType: "overtime",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.OVERTIME],
typeLabels: ["鍔犵彮", "鍔犵彮鐢宠", "鍔犵彮瀹℃壒"],
},
[APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE]: {
label: "宸梾鎶ラ攢",
approvalType: "travel_reimburse",
- typeLabels: ["宸梾", "宸梾鎶ラ攢"],
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE],
+ typeLabels: ["宸梾", "宸梾鎶ラ攢", "鍑哄樊鎶ラ攢"],
},
[APPROVAL_MODULE_KEYS.COST_REIMBURSE]: {
label: "璐圭敤鎶ラ攢",
approvalType: "cost_reimburse",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.COST_REIMBURSE],
typeLabels: ["璐圭敤", "璐圭敤鎶ラ攢"],
+ },
+ [APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS]: {
+ label: "浼佷笟鏂伴椈",
+ approvalType: "enterprise_news",
+ businessType: APPROVAL_BUSINESS_TYPE[APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS],
+ typeLabels: ["浼佷笟鏂伴椈", "鏂伴椈", "鏂伴椈鍙戝竷"],
},
};
/**
* @typedef {object} ApprovalModuleConfig
* @property {string} label
- * @property {string} [approvalType] 鍒楄〃鏍峰紡鐢�
- * @property {string|number} [businessType] 涓� TypeEnums value 涓�鑷存椂鍙啓姝�
- * @property {string[]} [typeLabels] 涓� TypeEnums label 妯$硦鍖归厤
+ * @property {string} [approvalType]
+ * @property {string|number} [businessType]
+ * @property {string[]} [typeLabels]
*/
export function getApprovalModuleConfig(moduleKey) {
@@ -75,45 +98,50 @@
return APPROVAL_MODULE_REGISTRY[moduleKey] || null;
}
-export function listApprovalModuleEntries() {
- return Object.entries(APPROVAL_MODULE_REGISTRY).map(([moduleKey, cfg]) => ({
- moduleKey,
- ...cfg,
- }));
+/** 鍒楄〃鏌ヨ businessType锛堜紭鍏堥厤缃灇涓撅紝涓嶅啀鍥為�� approvalType 瀛楃涓诧級 */
+export function getModuleListBusinessType(moduleKey) {
+ const cfg = getApprovalModuleConfig(moduleKey);
+ if (!cfg) return "";
+ if (cfg.businessType != null && cfg.businessType !== "") return cfg.businessType;
+ return APPROVAL_BUSINESS_TYPE[moduleKey] ?? "";
}
-/** 浠� TypeEnums 閫夐」涓В鏋愭湰妯″潡鐨� businessType */
+/** 浠� TypeEnums 瑙f瀽鏈ā鍧� businessType锛涘凡閰嶇疆鏋氫妇鏃剁洿鎺ヨ繑鍥� */
export function resolveModuleBusinessType(moduleKey, typeOptions = []) {
const cfg = getApprovalModuleConfig(moduleKey);
if (!cfg) return null;
- if (cfg.businessType != null && cfg.businessType !== "") return cfg.businessType;
+
+ const fixed = getModuleListBusinessType(moduleKey);
+ if (fixed != null && fixed !== "") return fixed;
const labels = [cfg.label, ...(cfg.typeLabels || [])].filter(Boolean);
- const hit = (typeOptions || []).find((opt) => {
- const optLabel = String(opt?.label || "").trim();
+ const hitByLabel = (typeOptions || []).find((opt) => {
+ const optLabel = String(opt?.label || opt?.name || "").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;
return cfg.approvalType || null;
}
-/** 鏀堕泦涓庢ā鍧楃浉鍏崇殑鍏ㄩ儴 businessType 鍙栧�硷紙鏋氫妇鍊� + approvalType锛夛紝鐢ㄤ簬妯℃澘鍒楄〃杩囨护 */
+/** 鍒楄〃/妯℃澘杩囨护鐢ㄧ殑 businessType 闆嗗悎 */
export function getModuleMatchingBusinessTypes(moduleKey, typeOptions = []) {
const cfg = getApprovalModuleConfig(moduleKey);
if (!cfg) return [];
+ const fixed = getModuleListBusinessType(moduleKey);
+ if (fixed != null && fixed !== "") return [fixed];
+
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();
+ const optLabel = String(opt?.label || opt?.name || "").trim();
if (!optLabel) continue;
const matched = labels.some(
(l) => optLabel === l || optLabel.includes(l) || l.includes(optLabel)
--
Gitblit v1.9.3