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 |  125 ++++++++++++++++++++---------------------
 1 files changed, 61 insertions(+), 64 deletions(-)

diff --git a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
index 9e74340..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 = [
@@ -40,8 +89,6 @@
   { value: "editor", label: "鍐呭缂栬緫" },
 ];
 
-export const STORAGE_KEY = "oa_enterprise_news_v1";
-
 /** 鐩爣鍙椾紬锛堝鎺ョ粍缁囨灦鏋� API 鍓嶄负绌猴級 */
 export const MOCK_AUDIENCE = [];
 
@@ -65,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) {
@@ -101,7 +150,7 @@
     readScope: "all",
     targetDeptIds: [],
     targetUserIds: [],
-    publishStatus: "draft",
+    publishStatus: "DRAFT",
     publisherName: "",
     publishTime: "",
     readRecords: [],
@@ -111,51 +160,10 @@
     versions: [],
     versionNo: 1,
     requireReadConfirm: false,
+    templateId: null,
+    templateName: "",
   };
 }
-
-function buildReadRecords(readUserIds = []) {
-  return (readUserIds || []).map((userId) => ({
-    userId,
-    employeeNo: "",
-    name: "",
-    deptName: "",
-    readAt: "",
-    lastRemindAt: "",
-  }));
-}
-
-function createVersionSnapshot(row, changeNote = "鍙戝竷") {
-  return {
-    versionNo: row.versionNo || 1,
-    title: row.title,
-    summary: row.summary,
-    contentHtml: row.contentHtml,
-    newsType: row.newsType,
-    publishTime: row.publishTime || dayjs().format("YYYY-MM-DD HH:mm:ss"),
-    archivedAt: dayjs().format("YYYY-MM-DD HH:mm:ss"),
-    changeNote,
-    publisherName: row.publisherName || "绯荤粺",
-  };
-}
-
-/** @deprecated 涓嶅啀娉ㄥ叆婕旂ず鏁版嵁锛屽垵濮嬪垪琛ㄤ负绌� */
-export function createInitialMockNews() {
-  return [];
-}
-
-/** 涓嶅啀浣跨敤鍓嶇鏈湴缂撳瓨锛屽垪琛ㄦ暟鎹互鎺ュ彛涓哄噯锛涘苟娓呴櫎鍘嗗彶 localStorage 鏁版嵁 */
-export function loadStoredNews() {
-  try {
-    localStorage.removeItem(STORAGE_KEY);
-  } catch {
-    /* ignore */
-  }
-  return [];
-}
-
-/** @deprecated 淇濈暀绌哄疄鐜帮紝閬垮厤鏃ц皟鐢ㄦ姤閿欙紱涓嶅仛浠讳綍鎸佷箙鍖� */
-export function saveStoredNews() {}
 
 /** 鎸夐槄璇昏寖鍥磋В鏋愮洰鏍囧彈浼� */
 export function resolveTargetAudience(row) {
@@ -186,17 +194,6 @@
   if (!audience.length) return 0;
   const readCount = (row.readRecords || []).filter((r) => r.readAt).length;
   return Math.round((readCount / audience.length) * 100);
-}
-
-export function nextNewsNo() {
-  return `EN${dayjs().format("YYYYMMDD")}${String(Math.floor(Math.random() * 9000) + 1000)}`;
-}
-
-export function pushVersionBeforeUpdate(row, changeNote) {
-  const versions = row.versions || [];
-  versions.unshift(createVersionSnapshot(row, changeNote));
-  row.versions = versions;
-  row.versionNo = (row.versionNo || 1) + 1;
 }
 
 export function validateNewsForm(form) {

--
Gitblit v1.9.3