From 93b8ceac34e2fbd5c57fe5ab4f5bac32c85408aa Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期五, 22 五月 2026 15:37:09 +0800
Subject: [PATCH] fix(hr): 修正岗位字段映射

---
 src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js |   69 ++++++++++++++++++++++++++++++----
 1 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
index 4ba3085..9bc29c3 100644
--- a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
+++ b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
@@ -8,13 +8,62 @@
   { value: "culture", label: "鏂囧寲娲诲姩", color: "#67c23a" },
 ];
 
-/** 鍙戝竷鐘舵�� */
+/** 浼佷笟鏂伴椈鐘舵�侊紙涓庡悗绔灇涓句竴鑷达級 */
 export const PUBLISH_STATUS_OPTIONS = [
-  { value: "draft", label: "鑽夌", tag: "info" },
-  { value: "pending_review", label: "寰呭鏍�", tag: "warning" },
-  { value: "published", label: "宸插彂甯�", tag: "success" },
-  { value: "archived", label: "宸插綊妗�", tag: "" },
+  { value: "DRAFT", label: "鑽夌", tag: "info" },
+  { value: "PENDING", label: "寰呭鎵�", tag: "warning" },
+  { value: "PUBLISHED", label: "宸插彂甯�", tag: "success" },
+  { value: "REJECTED", label: "椹冲洖", tag: "danger" },
+  { value: "OFFLINE", label: "宸蹭笅绾�", tag: "info" },
 ];
+
+/** 浼佷笟鏂伴椈鍒楄〃绛涢�� */
+export const ENTERPRISE_NEWS_STATUS_SEARCH_OPTIONS = [...PUBLISH_STATUS_OPTIONS];
+
+const LEGACY_PUBLISH_STATUS_MAP = {
+  draft: "DRAFT",
+  pending_review: "PENDING",
+  published: "PUBLISHED",
+  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";
+  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[raw.toLowerCase()];
+  if (legacy) return legacy;
+  return upper;
+}
 
 /** 鎺掔増妯℃澘 */
 export const LAYOUT_TEMPLATE_OPTIONS = [
@@ -63,11 +112,13 @@
 }
 
 export function publishStatusLabel(v) {
-  return PUBLISH_STATUS_OPTIONS.find((x) => x.value === v)?.label || v || "鈥�";
+  const key = normalizeEnterpriseNewsStatus(v);
+  return PUBLISH_STATUS_OPTIONS.find((x) => x.value === key)?.label || v || "鈥�";
 }
 
 export function publishStatusTag(v) {
-  return PUBLISH_STATUS_OPTIONS.find((x) => x.value === v)?.tag || "info";
+  const key = normalizeEnterpriseNewsStatus(v);
+  return PUBLISH_STATUS_OPTIONS.find((x) => x.value === key)?.tag || "info";
 }
 
 export function layoutTemplateLabel(v) {
@@ -99,7 +150,7 @@
     readScope: "all",
     targetDeptIds: [],
     targetUserIds: [],
-    publishStatus: "draft",
+    publishStatus: "DRAFT",
     publisherName: "",
     publishTime: "",
     readRecords: [],
@@ -109,6 +160,8 @@
     versions: [],
     versionNo: 1,
     requireReadConfirm: false,
+    templateId: null,
+    templateName: "",
   };
 }
 

--
Gitblit v1.9.3