From c9cfcbda7fb7c8b62b27d623feb0418790396740 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 18 九月 2026 11:09:07 +0800
Subject: [PATCH] 天津融邦环保app 1.部署修改

---
 src/pages/oa/_utils/approvalModuleListSearch.js |  365 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 204 insertions(+), 161 deletions(-)

diff --git a/src/pages/oa/_utils/approvalModuleListSearch.js b/src/pages/oa/_utils/approvalModuleListSearch.js
index a81b174..b8d06a5 100644
--- a/src/pages/oa/_utils/approvalModuleListSearch.js
+++ b/src/pages/oa/_utils/approvalModuleListSearch.js
@@ -1,3 +1,4 @@
+import dayjs from "dayjs";
 import {
   APPROVAL_MODULE_KEYS,
   APPROVAL_MODULE_REGISTRY,
@@ -178,61 +179,151 @@
   return hit?.value ?? hit?.defaultValue ?? "";
 }
 
-function pickDateRange(searchForm) {
-  const range =
-    searchForm?.createTimeRange ??
-    searchForm?.applyDateRange ??
-    searchForm?.transferDateRange;
-  if (!Array.isArray(range) || !range[0]) return {};
-  const out = { createTimeStart: range[0] };
-  if (range[1]) out.createTimeEnd = range[1];
+/** 鎵佸钩鍖栦负 Spring GET 鍙粦瀹氱殑 query锛坅pprovalInstanceDto.xxx锛屽嬁鐢ㄦ柟鎷彿锛� */
+export function appendDotNotationQuery(target, prefix, fields) {
+  if (!fields || typeof fields !== "object") return;
+  for (const [key, value] of Object.entries(fields)) {
+    if (value == null || value === "") continue;
+    target[`${prefix}.${key}`] = value;
+  }
+}
+
+function pickApplicantFromSearchForm(searchForm = {}) {
+  const out = {};
+  const sf = searchForm || {};
+  const name = (sf.applicantName || "").trim();
+  const kw = (sf.applicantKeyword || "").trim();
+  const id = sf.applicantId;
+
+  if (name) out.applicantName = name;
+  if (kw) {
+    out.applicantName = kw;
+    if (/^\d+$/.test(kw)) out.applicantId = Number(kw);
+  }
+  if (id != null && id !== "") {
+    out.applicantId = typeof id === "number" ? id : Number(id) || id;
+  }
   return out;
 }
 
-/** 鍚勬ā鍧楅粯璁ゆ煡璇㈣〃鍗曪紙涓� Web searchForm 瀛楁涓�鑷达級 */
-export function createModuleSearchForm(moduleKey) {
-  switch (moduleKey) {
-    case APPROVAL_MODULE_KEYS.REGULAR:
-      return { applicantName: "", applyDateRange: null };
-    case APPROVAL_MODULE_KEYS.TRANSFER:
-      return { applicantId: "", transferDateRange: null };
-    case APPROVAL_MODULE_KEYS.WORK_HANDOVER:
-      return { applicantId: "", handoverStatus: "", handoverType: "" };
-    case APPROVAL_MODULE_KEYS.LEAVE:
-      return { applicantKeyword: "", leaveType: "" };
-    case APPROVAL_MODULE_KEYS.OVERTIME:
-      return { applicantKeyword: "", overtimeType: "" };
-    case APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE:
-    case APPROVAL_MODULE_KEYS.COST_REIMBURSE:
-    case APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS:
-      return { applicantKeyword: "" };
-    default:
-      return {};
-  }
+function pickInstanceNoFromSearchForm(searchForm = {}) {
+  const no = (searchForm?.instanceNo || "").trim();
+  return no ? { instanceNo: no } : {};
 }
 
-/** 鏈嶅姟绔� listPage DTO 鐗囨锛堜笌 Web buildExtraListParams + buildApprovalInstanceListParams 涓�鑷达級 */
-export function buildModuleListDto(moduleKey, searchForm = {}) {
-  const sf = searchForm || {};
-  const dto = { ...pickDateRange(sf) };
+/** 鏀寔瀹℃壒鍗曞彿鏌ヨ鐨勫鎵圭敵璇锋ā鍧� */
+export const INSTANCE_NO_SEARCH_MODULE_KEYS = new Set([
+  APPROVAL_MODULE_KEYS.REGULAR,
+  APPROVAL_MODULE_KEYS.TRANSFER,
+  APPROVAL_MODULE_KEYS.WORK_HANDOVER,
+  APPROVAL_MODULE_KEYS.LEAVE,
+  APPROVAL_MODULE_KEYS.OVERTIME,
+]);
 
-  switch (moduleKey) {
-    case APPROVAL_MODULE_KEYS.REGULAR: {
-      const name = (sf.applicantName || "").trim();
-      if (name) dto.applicantName = name;
-      break;
-    }
-    case APPROVAL_MODULE_KEYS.TRANSFER:
-      break;
-    case APPROVAL_MODULE_KEYS.WORK_HANDOVER:
-      break;
-    case APPROVAL_MODULE_KEYS.LEAVE:
-    case APPROVAL_MODULE_KEYS.OVERTIME:
-      break;
-    default:
-      break;
+const INSTANCE_NO_SEARCH_FIELD = {
+  key: "instanceNo",
+  type: "input",
+  label: "瀹℃壒鍗曞彿",
+  placeholder: "璇疯緭鍏ュ鎵瑰崟鍙�",
+};
+
+/** 缁勮 approvalInstanceDto 鏌ヨ鐗囨锛堢敵璇蜂汉 + 瀹℃壒鍗曞彿 + 鐘舵�� + 鏃堕棿鑼冨洿锛屼笌 Web 涓�鑷达級 */
+export function buildApprovalInstanceSearchDto(searchForm = {}, extraParams = {}) {
+  const dto = {
+    ...(extraParams && typeof extraParams === "object" ? extraParams : {}),
+  };
+  Object.assign(dto, pickApplicantFromSearchForm(searchForm));
+  Object.assign(dto, pickInstanceNoFromSearchForm(searchForm));
+
+  if (searchForm?.status) {
+    dto.status = searchForm.status;
   }
+
+  const range = searchForm?.createTimeRange;
+  if (Array.isArray(range) && range[0]) {
+    dto.createTimeStart = range[0] + (range[0].includes(":") ? "" : " 00:00:00");
+  }
+  if (Array.isArray(range) && range[1]) {
+    dto.createTimeEnd = range[1] + (range[1].includes(":") ? "" : " 23:59:59");
+  }
+
+  delete dto.createTime;
   return dto;
+}
+
+function pickDateRange(searchForm) {
+  return buildApprovalInstanceSearchDto(searchForm);
+}
+
+/** 鍚勬ā鍧楅粯璁ゆ煡璇㈣〃鍗曪紙涓� Web searchForm 瀛楁涓�鑷达級 */
+const APPLICANT_ONLY_MODULE_KEYS = new Set([
+  APPROVAL_MODULE_KEYS.REGULAR,
+  APPROVAL_MODULE_KEYS.TRANSFER,
+  APPROVAL_MODULE_KEYS.WORK_HANDOVER,
+  APPROVAL_MODULE_KEYS.LEAVE,
+  APPROVAL_MODULE_KEYS.OVERTIME,
+  APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE,
+  APPROVAL_MODULE_KEYS.COST_REIMBURSE,
+]);
+
+function withInstanceNoSearch(moduleKey, base) {
+  if (INSTANCE_NO_SEARCH_MODULE_KEYS.has(moduleKey)) {
+    return { instanceNo: "", ...base };
+  }
+  return base;
+}
+
+function applicantOnlySearchForm(moduleKey) {
+  if (moduleKey === APPROVAL_MODULE_KEYS.REGULAR) {
+    return withInstanceNoSearch(moduleKey, { applicantName: "" });
+  }
+  if (
+    moduleKey === APPROVAL_MODULE_KEYS.TRANSFER ||
+    moduleKey === APPROVAL_MODULE_KEYS.WORK_HANDOVER
+  ) {
+    return withInstanceNoSearch(moduleKey, { applicantId: "" });
+  }
+  if (APPLICANT_ONLY_MODULE_KEYS.has(moduleKey)) {
+    return withInstanceNoSearch(moduleKey, { applicantKeyword: "" });
+  }
+  return {};
+}
+
+export function createModuleSearchForm(moduleKey) {
+  if (APPLICANT_ONLY_MODULE_KEYS.has(moduleKey)) {
+    return applicantOnlySearchForm(moduleKey);
+  }
+  if (moduleKey === APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS) {
+    return { applicantKeyword: "" };
+  }
+  return {};
+}
+
+/** 鏈嶅姟绔� listPage DTO 鐗囨锛堜笌 Web buildApprovalInstanceListParams 涓�鑷达級 */
+export function buildModuleListDto(moduleKey, searchForm = {}) {
+  return buildApprovalInstanceSearchDto(searchForm);
+}
+
+function matchInstanceNo(row, instanceNo) {
+  const kw = (instanceNo || "").trim().toLowerCase();
+  if (!kw) return true;
+  const parts = [row?.instanceNo, row?.bizId]
+    .filter(v => v != null && v !== "")
+    .map(v => String(v).toLowerCase());
+  return parts.some(p => p.includes(kw));
+}
+
+export function hasActiveModuleSearch(moduleKey, searchForm = {}) {
+  const sf = searchForm || {};
+  if ((sf.instanceNo || "").trim()) return true;
+  if ((sf.applicantKeyword || "").trim()) return true;
+  if ((sf.applicantName || "").trim()) return true;
+  if (sf.applicantId != null && sf.applicantId !== "") return true;
+  if (sf.status) return true;
+  if (Array.isArray(sf.createTimeRange) && sf.createTimeRange.length === 2) {
+    return true;
+  }
+  return false;
 }
 
 function matchApplicantKeyword(row, keyword) {
@@ -298,131 +389,83 @@
   });
 }
 
-/** 鍓嶇绛涢�夛紙Web 鏈笅鍙戞帴鍙g殑瀛楁涓� Web 琛屼负涓�鑷达級 */
+/** 鎸夌敵璇蜂汉銆佸鎵瑰崟鍙枫�佺姸鎬併�佹椂闂磋寖鍥村仛鍓嶇鍏滃簳绛涢�� */
 export function filterRowsByModuleSearch(moduleKey, rows, searchForm = {}) {
   const sf = searchForm || {};
   const list = Array.isArray(rows) ? rows : [];
+  if (!hasActiveModuleSearch(moduleKey, sf)) return list;
 
-  switch (moduleKey) {
-    case APPROVAL_MODULE_KEYS.TRANSFER:
-      return list.filter(
-        row =>
-          matchApplicantId(row, sf.applicantId) &&
-          matchApplicantKeyword(row, sf.applicantKeyword)
-      );
-    case APPROVAL_MODULE_KEYS.WORK_HANDOVER:
-      return list.filter(
-        row =>
-          matchApplicantId(row, sf.applicantId) &&
-          matchSelectValue(row, ["handoverStatus", "浜ゆ帴鐘舵��"], sf.handoverStatus) &&
-          matchSelectValue(row, ["handoverType", "浜ゆ帴绫诲瀷"], sf.handoverType)
-      );
-    case APPROVAL_MODULE_KEYS.LEAVE:
-      return list.filter(
-        row =>
-          matchApplicantKeyword(row, sf.applicantKeyword) &&
-          matchSelectValue(row, ["leaveType", "璇峰亣绫诲瀷"], sf.leaveType)
-      );
-    case APPROVAL_MODULE_KEYS.OVERTIME:
-      return list.filter(
-        row =>
-          matchApplicantKeyword(row, sf.applicantKeyword) &&
-          matchSelectValue(row, ["overtimeType", "鍔犵彮绫诲瀷"], sf.overtimeType)
-      );
-    case APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE:
-    case APPROVAL_MODULE_KEYS.COST_REIMBURSE:
-    case APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS:
-      return list.filter(row => matchApplicantKeyword(row, sf.applicantKeyword));
-    default:
-      return list;
-  }
+  return list.filter(row => {
+    if (!matchInstanceNo(row, sf.instanceNo)) return false;
+    if (!matchApplicantId(row, sf.applicantId)) return false;
+    if (!matchApplicantKeyword(row, sf.applicantKeyword || sf.applicantName)) {
+      return false;
+    }
+    if (
+      sf.status &&
+      String(row.statusRaw || row.status).toUpperCase() !== String(sf.status).toUpperCase()
+    ) {
+      return false;
+    }
+    if (Array.isArray(sf.createTimeRange) && sf.createTimeRange.length === 2) {
+      const rowTime = row.createTime || row.applyTime;
+      if (rowTime) {
+        const t = dayjs(rowTime);
+        const start = dayjs(sf.createTimeRange[0] + " 00:00:00");
+        const end = dayjs(sf.createTimeRange[1] + " 23:59:59");
+        if (t.isBefore(start) || t.isAfter(end)) return false;
+      }
+    }
+    return true;
+  });
+}
+
+function prependInstanceNoField(fields, moduleKey) {
+  if (!INSTANCE_NO_SEARCH_MODULE_KEYS.has(moduleKey)) return fields;
+  return [INSTANCE_NO_SEARCH_FIELD, ...fields];
 }
 
 /** 妯″潡绛涢�� UI 閰嶇疆 */
 export function getModuleSearchMeta(moduleKey) {
-  switch (moduleKey) {
-    case APPROVAL_MODULE_KEYS.REGULAR:
-      return {
-        fields: [
+  if (moduleKey === APPROVAL_MODULE_KEYS.REGULAR) {
+    return {
+      fields: prependInstanceNoField(
+        [
           { key: "applicantName", type: "input", label: "鐢宠浜�", placeholder: "璇疯緭鍏ョ敵璇蜂汉" },
-          { key: "applyDateRange", type: "daterange", label: "鐢宠鏃ユ湡" },
         ],
-      };
-    case APPROVAL_MODULE_KEYS.TRANSFER:
-      return {
-        fields: [
-          { key: "applicantId", type: "user", label: "鐢宠浜�", placeholder: "璇烽�夋嫨鐢宠浜�" },
-          { key: "transferDateRange", type: "daterange", label: "杞矖鏃堕棿" },
-        ],
-      };
-    case APPROVAL_MODULE_KEYS.WORK_HANDOVER:
-      return {
-        fields: [
-          { key: "applicantId", type: "user", label: "鐢宠浜�", placeholder: "璇烽�夋嫨鐢宠浜�" },
-          {
-            key: "handoverStatus",
-            type: "select",
-            label: "浜ゆ帴鐘舵��",
-            options: HANDOVER_STATUS_OPTIONS,
-          },
-          {
-            key: "handoverType",
-            type: "select",
-            label: "浜ゆ帴绫诲瀷",
-            options: HANDOVER_TYPE_OPTIONS,
-          },
-        ],
-      };
-    case APPROVAL_MODULE_KEYS.LEAVE:
-      return {
-        fields: [
-          {
-            key: "applicantKeyword",
-            type: "input",
-            label: "鐢宠浜�",
-            placeholder: "濮撳悕鎴栫紪鍙�",
-          },
-          {
-            key: "leaveType",
-            type: "select",
-            label: "璇峰亣绫诲瀷",
-            options: LEAVE_TYPE_OPTIONS,
-          },
-        ],
-      };
-    case APPROVAL_MODULE_KEYS.OVERTIME:
-      return {
-        fields: [
-          {
-            key: "applicantKeyword",
-            type: "input",
-            label: "鐢宠浜�",
-            placeholder: "濮撳悕鎴栫紪鍙�",
-          },
-          {
-            key: "overtimeType",
-            type: "select",
-            label: "鍔犵彮绫诲瀷",
-            options: OVERTIME_TYPE_OPTIONS,
-          },
-        ],
-      };
-    case APPROVAL_MODULE_KEYS.TRAVEL_REIMBURSE:
-    case APPROVAL_MODULE_KEYS.COST_REIMBURSE:
-    case APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS:
-      return {
-        fields: [
-          {
-            key: "applicantKeyword",
-            type: "input",
-            label: "鐢宠浜�",
-            placeholder: "濮撳悕鎴栫紪鍙�",
-          },
-        ],
-      };
-    default:
-      return { fields: [] };
+        moduleKey
+      ),
+    };
   }
+  if (
+    moduleKey === APPROVAL_MODULE_KEYS.TRANSFER ||
+    moduleKey === APPROVAL_MODULE_KEYS.WORK_HANDOVER
+  ) {
+    return {
+      fields: prependInstanceNoField(
+        [
+          { key: "applicantId", type: "user", label: "鐢宠浜�", placeholder: "璇烽�夋嫨鐢宠浜�" },
+        ],
+        moduleKey
+      ),
+    };
+  }
+  if (APPLICANT_ONLY_MODULE_KEYS.has(moduleKey)) {
+    return {
+      fields: prependInstanceNoField(
+        [
+          {
+            key: "applicantKeyword",
+            type: "input",
+            label: "鐢宠浜�",
+            placeholder: "濮撳悕鎴栫紪鍙�",
+          },
+        ],
+        moduleKey
+      ),
+    };
+  }
+  return { fields: [] };
 }
 
 export function resetModuleSearchForm(moduleKey, target) {

--
Gitblit v1.9.3