From 4456a684eea5f644aff6e3ff74dab328a153ec8f Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 18:01:00 +0800
Subject: [PATCH] 对企业新闻状态处理机制进行重构,并移除不再使用的导入项。引入了状态规范化所需的数值与标签映射功能,从而提升了清晰度和可维护性。

---
 src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js   |   30 ++++++++++++++++++++++++++++--
 src/views/officeProcessAutomation/EnterpriseNews/news-manage/index.vue                |    4 ----
 src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsMappers.js |    7 ++-----
 3 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsMappers.js b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsMappers.js
index 5ef1a19..27cb9bc 100644
--- a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsMappers.js
+++ b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsMappers.js
@@ -2,7 +2,7 @@
   createEmptyForm,
   normalizeEnterpriseNewsStatus,
   publishStatusLabel,
-  PUBLISH_STATUS_OPTIONS,
+  publishStatusTag,
 } from "./enterpriseNewsUtils.js";
 
 /** formPayload 涓瓨鏀惧畬鏁翠紒涓氭柊闂讳笟鍔℃暟鎹殑閿紙瀹℃壒瀹炰緥淇濆瓨鐢級 */
@@ -204,10 +204,7 @@
       width: 100,
       dataType: "tag",
       formatData: (v) => publishStatusLabel(v),
-      formatType: (v) => {
-        const hit = PUBLISH_STATUS_OPTIONS.find((x) => x.value === v);
-        return hit?.tag || "info";
-      },
+      formatType: (v) => publishStatusTag(v),
     },
     { label: "鍒涘缓浜�", prop: "publisherName", width: 110 },
     { label: "鍒涘缓鏃堕棿", prop: "createTime", width: 170 },
diff --git a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
index 71ceaba..9bc29c3 100644
--- a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
+++ b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
@@ -27,14 +27,40 @@
   archived: "OFFLINE",
 };
 
+/** 鍚庣鏁板瓧鐘舵�佺爜 鈫� 鏋氫妇锛�0 鑽夌 1 寰呭鎵� 2 宸插彂甯� 3 椹冲洖 4 宸蹭笅绾匡級 */
+const ENTERPRISE_NEWS_STATUS_NUMERIC_MAP = {
+  0: "DRAFT",
+  1: "PENDING",
+  2: "PUBLISHED",
+  3: "REJECTED",
+  4: "OFFLINE",
+};
+
+const ENTERPRISE_NEWS_STATUS_LABEL_MAP = {
+  鑽夌: "DRAFT",
+  寰呭鎵�: "PENDING",
+  宸插彂甯�: "PUBLISHED",
+  椹冲洖: "REJECTED",
+  宸查┏鍥�: "REJECTED",
+  宸蹭笅绾�: "OFFLINE",
+};
+
 /** 缁熶竴涓哄悗绔姸鎬佹灇涓惧�� */
 export function normalizeEnterpriseNewsStatus(v) {
   if (v == null || v === "") return "DRAFT";
-  const upper = String(v).trim().toUpperCase();
+  if (typeof v === "number" || (typeof v === "string" && /^\d+$/.test(v.trim()))) {
+    const numKey = ENTERPRISE_NEWS_STATUS_NUMERIC_MAP[Number(v)];
+    if (numKey) return numKey;
+  }
+  const raw = String(v).trim();
+  if (ENTERPRISE_NEWS_STATUS_LABEL_MAP[raw]) {
+    return ENTERPRISE_NEWS_STATUS_LABEL_MAP[raw];
+  }
+  const upper = raw.toUpperCase();
   if (upper === "APPROVED") return "PUBLISHED";
   const hit = PUBLISH_STATUS_OPTIONS.find((x) => x.value === upper);
   if (hit) return hit.value;
-  const legacy = LEGACY_PUBLISH_STATUS_MAP[String(v).trim().toLowerCase()];
+  const legacy = LEGACY_PUBLISH_STATUS_MAP[raw.toLowerCase()];
   if (legacy) return legacy;
   return upper;
 }
diff --git a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/index.vue b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/index.vue
index 13decff..f263a41 100644
--- a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/index.vue
+++ b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/index.vue
@@ -232,10 +232,6 @@
 } from "../../ApproveManage/approve-shared/approvalTemplateBindingUtils.js";
 import { createEmptySubmitForm } from "../../ApproveManage/approve-list/approveListConstants.js";
 import { APPROVAL_MODULE_KEYS } from "../../ApproveManage/approve-shared/approvalModuleRegistry.js";
-import {
-  applyBindingToForm,
-  validateTemplateBinding,
-} from "../../ApproveManage/approve-shared/approvalTemplateBindingUtils.js";
 import { useFlowUserOptions } from "../../ApproveManage/approve-shared/useFlowUserOptions.js";
 import NewsDetailPanel from "./components/NewsDetailPanel.vue";
 import {

--
Gitblit v1.9.3