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/EnterpriseNews/news-manage/enterpriseNewsUtils.js | 99 +++++++++++++++++--------------------------------
1 files changed, 35 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..71ceaba 100644
--- a/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
+++ b/src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
@@ -8,13 +8,36 @@
{ 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",
+};
+
+/** 缁熶竴涓哄悗绔姸鎬佹灇涓惧�� */
+export function normalizeEnterpriseNewsStatus(v) {
+ if (v == null || v === "") return "DRAFT";
+ const upper = String(v).trim().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()];
+ if (legacy) return legacy;
+ return upper;
+}
/** 鎺掔増妯℃澘 */
export const LAYOUT_TEMPLATE_OPTIONS = [
@@ -40,8 +63,6 @@
{ value: "editor", label: "鍐呭缂栬緫" },
];
-export const STORAGE_KEY = "oa_enterprise_news_v1";
-
/** 鐩爣鍙椾紬锛堝鎺ョ粍缁囨灦鏋� API 鍓嶄负绌猴級 */
export const MOCK_AUDIENCE = [];
@@ -65,11 +86,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 +124,7 @@
readScope: "all",
targetDeptIds: [],
targetUserIds: [],
- publishStatus: "draft",
+ publishStatus: "DRAFT",
publisherName: "",
publishTime: "",
readRecords: [],
@@ -111,51 +134,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 +168,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