From a1df9699594b0a0e46d26a0394eafb1eb030c68b Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 17:42:09 +0800
Subject: [PATCH] 企业新闻

---
 src/views/officeProcessAutomation/ApproveManage/approve-list/approveListConstants.js |  262 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 205 insertions(+), 57 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/approveListConstants.js b/src/views/officeProcessAutomation/ApproveManage/approve-list/approveListConstants.js
index acbed98..4aa3c61 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/approveListConstants.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/approveListConstants.js
@@ -8,7 +8,10 @@
   nodeSignModeLabel,
 } from "../approve-template/approveTemplateConstants.js";
 import { buildFormPayloadFromFields, parseFormConfigToData } from "../approve-template/formConfigUtils.js";
-import { isDynamicOptionSource, selectOptionSourceLabel } from "../approve-template/selectOptionSource.js";
+import {
+  isDynamicOptionSource,
+  resolveSelectDisplayLabel,
+} from "../approve-template/selectOptionSource.js";
 
 /** 瀹℃壒绫诲瀷锛堜笌鍚庣瀛楁 approvalType 瀵归綈锛屽悗鏈熷彲鍚屾锛� */
 export const APPROVAL_TYPE_OPTIONS = [
@@ -25,15 +28,119 @@
   { value: "procurement", label: "閲囪喘瀹℃壒", cellBg: "#f4f4f5", cellColor: "#909399" },
   { value: "quotation", label: "鎶ヤ环瀹℃壒", cellBg: "#f4ecfc", cellColor: "#9b59b6" },
   { value: "shipment", label: "鍙戣揣瀹℃壒", cellBg: "#e8faf6", cellColor: "#1abc9c" },
+  { value: "enterprise_news", label: "浼佷笟鏂伴椈", cellBg: "#ecf5ff", cellColor: "#409eff" },
 ];
 
-/** 瀹℃壒鐘舵�� approvalStatus */
-export const APPROVAL_STATUS_OPTIONS = [
-  { value: "pending", label: "瀹℃牳涓�" },
-  { value: "approved", label: "宸查�氳繃" },
-  { value: "rejected", label: "宸查┏鍥�" },
-  { value: "cancelled", label: "宸叉挙閿�" },
+/** 鍒楄〃鏌ヨ锛氬鎵圭姸鎬侊紙涓庡悗绔� status 鏋氫妇涓�鑷达級 */
+export const APPROVAL_STATUS_SEARCH_OPTIONS = [
+  { value: "DRAFT", label: "鑽夌" },
+  { value: "PENDING", label: "寰呭鎵�" },
+  { value: "APPROVED", label: "宸查�氳繃" },
+  { value: "REJECTED", label: "宸查┏鍥�" },
 ];
+
+/**
+ * 瀹℃壒鐘舵�佸睍绀猴紙涓庡悗绔� status 鏋氫妇涓�鑷达級
+ * DRAFT鈫掕崏绋� PENDING鈫掑緟瀹℃壒/杩涜涓� APPROVED鈫掑凡閫氳繃/宸插畬鎴� REJECTED鈫掑凡椹冲洖
+ */
+export const APPROVAL_STATUS_OPTIONS = [
+  { value: "draft", api: "DRAFT", label: "鑽夌" },
+  { value: "pending", api: "PENDING", label: "寰呭鎵�" },
+  { value: "approved", api: "APPROVED", label: "宸查�氳繃" },
+  { value: "rejected", api: "REJECTED", label: "宸查┏鍥�" },
+  { value: "cancelled", api: "CANCELLED", label: "宸叉挙閿�" },
+];
+
+/** 鏁板瓧鐘舵�佺爜锛堥儴鍒嗗悗绔敤 0/1/2锛� */
+const STATUS_NUMERIC_MAP = {
+  0: "pending",
+  1: "approved",
+  2: "rejected",
+  3: "cancelled",
+  4: "cancelled",
+};
+
+/** 鍚庣 status / 椤甸潰 approvalStatus 鈫� 缁熶竴椤甸潰 key锛坧ending | approved | rejected | cancelled锛� */
+export function normalizeApprovalStatusKey(v) {
+  if (v == null || v === "") return "pending";
+  if (typeof v === "number" || (typeof v === "string" && /^\d+$/.test(v.trim()))) {
+    const numKey = STATUS_NUMERIC_MAP[Number(v)];
+    if (numKey) return numKey;
+  }
+  const s = String(v).trim();
+  if (!s) return "pending";
+  const upper = s.toUpperCase();
+  if (upper === "DRAFT") return "draft";
+  if (upper === "PUBLISHED") return "approved";
+  if (upper === "OFFLINE") return "cancelled";
+  if (upper === "APPROVED" || upper === "APPROVE" || upper === "PASS" || upper === "AGREE") {
+    return "approved";
+  }
+  if (
+    upper === "REJECTED" ||
+    upper === "REJECT" ||
+    upper === "REFUSE" ||
+    upper === "REFUSED" ||
+    upper === "DENIED"
+  ) {
+    return "rejected";
+  }
+  if (upper === "CANCELLED" || upper === "CANCEL" || upper === "REVOKED") return "cancelled";
+  if (
+    upper === "PENDING" ||
+    upper === "IN_PROGRESS" ||
+    upper === "PROCESSING" ||
+    upper === "RUNNING" ||
+    upper === "WAIT" ||
+    upper === "WAITING"
+  ) {
+    return "pending";
+  }
+  if (s.includes("鑽夌")) return "draft";
+  if (s.includes("椹冲洖") || s.includes("鎷掔粷")) return "rejected";
+  if (s.includes("涓嬬嚎")) return "cancelled";
+  if (s.includes("鎾ら攢")) return "cancelled";
+  if (s.includes("鍙戝竷") || s.includes("閫氳繃") || s.includes("瀹屾垚")) return "approved";
+  if (s.includes("寰呭") || s.includes("杩涜涓�") || s.includes("瀹℃壒涓�")) return "pending";
+  const lower = s.toLowerCase();
+  if (["draft", "pending", "approved", "rejected", "cancelled"].includes(lower)) return lower;
+  return "pending";
+}
+
+/** 浠庡垪琛�/璇︽儏琛岃В鏋愬悗绔師濮嬬姸鎬侊紙鍏煎澶氬瓧娈靛懡鍚嶏級 */
+export function resolveInstanceStatusRaw(row) {
+  if (!row || typeof row !== "object") return "";
+  const candidates = [
+    row.status,
+    row.statusRaw,
+    row.approvalStatus,
+    row.statusName,
+    row.statusLabel,
+    row.approvalStatusName,
+    row.statusDesc,
+    row.instanceStatus,
+    row.approvalInstanceStatus,
+    row.approveStatus,
+    row.auditStatus,
+    row.approvalInstance?.status,
+    row.approvalInstanceVo?.status,
+  ];
+  for (const c of candidates) {
+    if (c != null && c !== "") return c;
+  }
+  const tasks = row.tasks;
+  if (Array.isArray(tasks) && tasks.length) {
+    const rejected = tasks.some((t) =>
+      normalizeApprovalStatusKey(t?.status ?? t?.taskStatus) === "rejected"
+    );
+    if (rejected) return "REJECTED";
+    const allApproved = tasks.every((t) =>
+      normalizeApprovalStatusKey(t?.status ?? t?.taskStatus) === "approved"
+    );
+    if (allApproved) return "APPROVED";
+  }
+  return "";
+}
 
 /** 鎻愪氦寮圭獥锛氭ā鏉垮崱鐗囷紙鏉ヨ嚜鍚庣鍒楄〃锛� */
 export function mapSubmitTemplateCard(row) {
@@ -75,20 +182,11 @@
 }
 
 export function mapTaskStatusLabel(status) {
-  const s = String(status || "").toUpperCase();
-  if (s === "APPROVED") return "宸查�氳繃";
-  if (s === "REJECTED") return "宸查┏鍥�";
-  if (s === "PENDING") return "寰呭鎵�";
-  if (s === "CANCELLED") return "宸叉挙閿�";
-  return status || "鈥�";
+  return approvalStatusLabel(status);
 }
 
 export function mapTaskStatusTagType(status) {
-  const s = String(status || "").toUpperCase();
-  if (s === "APPROVED") return "success";
-  if (s === "REJECTED") return "danger";
-  if (s === "CANCELLED") return "info";
-  return "warning";
+  return approvalStatusTagType(status);
 }
 
 /** 鍚庣 tasks 鈫� 椤甸潰 flowNodes锛堟寜 levelNo 鍒嗙粍锛屼緵娴佺▼缂栬緫/灞曠ず锛� */
@@ -164,11 +262,16 @@
   return "text";
 }
 
-/** 鍗曞瓧娈靛睍绀哄�硷紙璇︽儏鍙锛� */
-export function formatFieldDisplayValue(field, val) {
+/**
+ * 鍗曞瓧娈靛睍绀哄�硷紙璇︽儏鍙銆佸垪琛ㄤ富琛級
+ * @param {object} [caches] 浜哄憳/閮ㄩ棬涓嬫媺缂撳瓨锛岀敤浜庤В鏋愩�屼汉鍛樺垪琛ㄣ�嶇被瀛楁涓哄鍚�
+ */
+export function formatFieldDisplayValue(field, val, caches) {
   if (val == null || val === "" || (Array.isArray(val) && !val.length)) return "鈥�";
   if (field?.type === "select" && isDynamicOptionSource(field.optionSource)) {
-    return `${selectOptionSourceLabel(field.optionSource)}锛�${String(val)}`;
+    const label = resolveSelectDisplayLabel(field, val, caches || {});
+    if (label && label !== "鈥�") return label;
+    return String(val);
   }
   if (field?.type === "select" && field.options?.length) {
     const hit = field.options.find((o) => String(o.value) === String(val));
@@ -291,22 +394,20 @@
     dto.id = existingRow?.id ?? submitForm?.instanceId;
     dto.instanceNo = existingRow?.instanceNo ?? submitForm?.instanceNo ?? "";
     dto.status =
-      existingRow?.statusRaw || mapInstanceStatusToApi(existingRow?.approvalStatus) || "PENDING";
+      submitForm?.saveStatusApi ||
+      existingRow?.statusRaw ||
+      mapInstanceStatusToApi(existingRow?.approvalStatus) ||
+      "PENDING";
     dto.currentLevel = existingRow?.currentLevel ?? submitForm?.currentLevel ?? 1;
     dto.applicantId = existingRow?.applicantId ?? existingRow?.applicantNo;
     dto.applicantName = existingRow?.applicantName || "";
   } else {
-    dto.status = "PENDING";
+    dto.status = submitForm?.saveStatusApi || "PENDING";
     dto.currentLevel = 1;
     dto.applicantId = userStore?.id;
     dto.applicantName = userStore?.nickName || userStore?.name || "";
   }
   return dto;
-}
-
-/** @deprecated 浣跨敤 buildInstanceDto */
-export function buildSaveInstanceDto(params) {
-  return buildInstanceDto(params);
 }
 
 /** 鏍¢獙鎻愪氦瀹℃壒娴佺▼锛堜笌妯℃澘椤佃鍒欎竴鑷达級 */
@@ -323,20 +424,20 @@
 
 /** 鍚庣 status 鈫� 椤甸潰 approvalStatus */
 export function mapInstanceStatusFromApi(status) {
-  const s = String(status || "").toUpperCase();
-  if (s === "APPROVED") return "approved";
-  if (s === "REJECTED") return "rejected";
-  if (s === "CANCELLED") return "cancelled";
-  return "pending";
+  return normalizeApprovalStatusKey(status);
+}
+
+/** 鍒楄〃/璇︽儏琛� 鈫� 椤甸潰 approvalStatus key */
+export function mapInstanceApprovalStatusFromRow(row) {
+  const raw = resolveInstanceStatusRaw(row);
+  return normalizeApprovalStatusKey(raw);
 }
 
 /** 椤甸潰 approvalStatus 鈫� 鍚庣 status */
 export function mapInstanceStatusToApi(approvalStatus) {
-  const s = String(approvalStatus || "").toLowerCase();
-  if (s === "approved") return "APPROVED";
-  if (s === "rejected") return "REJECTED";
-  if (s === "cancelled") return "CANCELLED";
-  return "PENDING";
+  const key = normalizeApprovalStatusKey(approvalStatus);
+  const hit = APPROVAL_STATUS_OPTIONS.find((x) => x.value === key);
+  return hit?.api || "PENDING";
 }
 
 export function unwrapInstancePage(res) {
@@ -350,7 +451,8 @@
 /** 鍒嗛〉鍒楄〃椤� 鈫� 琛ㄦ牸琛� */
 export function mapInstanceFromApi(row) {
   if (!row) return {};
-  const approvalStatus = mapInstanceStatusFromApi(row.status);
+  const statusRaw = resolveInstanceStatusRaw(row);
+  const approvalStatus = normalizeApprovalStatusKey(statusRaw);
   const createTime = formatDisplayTime(row.createTime ?? row.applyTime ?? "");
   const applyTime = formatDisplayTime(row.applyTime ?? "");
   const finishTime = formatDisplayTime(row.finishTime ?? "");
@@ -377,7 +479,7 @@
     unread: Boolean(row.isApprove) && approvalStatus === "pending",
     isApprove: Boolean(row.isApprove),
     approvalStatus,
-    statusRaw: row.status,
+    statusRaw: statusRaw || row.status,
     createTime,
     applyTime: applyTime === "鈥�" ? "" : applyTime,
     finishTime: finishTime === "鈥�" ? "" : finishTime,
@@ -418,19 +520,35 @@
   };
 }
 
-export function buildApprovalInstanceListParams({ page, searchForm }) {
+export function buildApprovalInstanceListParams({ page, searchForm, businessType, extraParams }) {
+  const extra = { ...(extraParams && typeof extraParams === "object" ? extraParams : {}) };
+  if (extra.createTime != null && extra.createTimeStart == null) {
+    extra.createTimeStart = extra.createTime;
+  }
+  delete extra.createTime;
+
   const params = {
     current: page.current,
     size: page.size,
+    ...extra,
   };
-  const dto = {};
-  const kw = (searchForm?.applicantKeyword || "").trim();
-  if (kw) dto.applicantName = kw;
-  if (searchForm?.approvalType) {
-    const opt = APPROVAL_TYPE_OPTIONS.find((x) => x.value === searchForm.approvalType);
-    if (opt?.label) dto.templateName = opt.label;
+  const bizType = businessType ?? searchForm?.businessType;
+  if (bizType != null && bizType !== "") {
+    params.businessType = bizType;
   }
-  if (Object.keys(dto).length) params.approvalInstanceDto = dto;
+  if (searchForm?.status) {
+    params.status = searchForm.status;
+  }
+  const range =
+    searchForm?.createTimeRange ??
+    searchForm?.applyDateRange ??
+    searchForm?.transferDateRange;
+  if (Array.isArray(range) && range[0]) {
+    params.createTimeStart = range[0];
+  }
+  if (Array.isArray(range) && range[1]) {
+    params.createTimeEnd = range[1];
+  }
   return params;
 }
 
@@ -449,18 +567,48 @@
 }
 
 export function approvalStatusLabel(v) {
-  return APPROVAL_STATUS_OPTIONS.find((x) => x.value === v)?.label || "鈥�";
+  const key = normalizeApprovalStatusKey(v);
+  return APPROVAL_STATUS_OPTIONS.find((x) => x.value === key)?.label || "鈥�";
+}
+
+/** 涓氬姟鐢宠椤电姸鎬佹枃妗堬細PENDING鈫掕繘琛屼腑 APPROVED鈫掑凡瀹屾垚 REJECTED鈫掑凡椹冲洖 */
+export function businessApprovalStatusLabel(v) {
+  const key = normalizeApprovalStatusKey(v);
+  if (key === "draft") return "鑽夌";
+  if (key === "pending") return "杩涜涓�";
+  if (key === "approved") return "宸插畬鎴�";
+  if (key === "rejected") return "宸查┏鍥�";
+  if (key === "cancelled") return "宸叉挙閿�";
+  return "鈥�";
+}
+
+/**
+ * 涓氬姟鐢宠椤垫槸鍚﹀厑璁镐慨鏀癸紙浜斾釜鐢宠椤碉級
+ * 杩涜涓�(PENDING)銆佸凡瀹屾垚(APPROVED) 涓嶅彲淇敼锛涘凡椹冲洖銆佸凡鎾ら攢绛夊彲淇敼
+ */
+export function canEditBusinessInstanceRow(row) {
+  const key = normalizeApprovalStatusKey(
+    row?.approvalStatus ?? row?.statusRaw ?? row?.status
+  );
+  return key !== "pending" && key !== "approved";
+}
+
+export function businessApprovalStatusTagType(v) {
+  const key = normalizeApprovalStatusKey(v);
+  if (key === "draft") return "info";
+  if (key === "approved") return "success";
+  if (key === "rejected") return "danger";
+  if (key === "cancelled") return "info";
+  return "warning";
 }
 
 export function approvalStatusTagType(v) {
-  if (v === "approved") return "success";
-  if (v === "rejected") return "danger";
-  if (v === "cancelled") return "info";
-  return "primary";
-}
-
-export function unreadLabel(v) {
-  return v ? "鏄�" : "鍚�";
+  const key = normalizeApprovalStatusKey(v);
+  if (key === "draft") return "info";
+  if (key === "approved") return "success";
+  if (key === "rejected") return "danger";
+  if (key === "cancelled") return "info";
+  return "warning";
 }
 
 /** 鍒楄〃琛� 鈫� 缂栬緫琛ㄥ崟锛堜粎鐢ㄨ鏁版嵁鍥炴樉锛� */

--
Gitblit v1.9.3