yyb
9 小时以前 97081b89ee45da49b8dbb4173ab45df031fe3c0d
src/views/officeProcessAutomation/EnterpriseNews/news-manage/enterpriseNewsUtils.js
@@ -40,8 +40,6 @@
  { value: "editor", label: "内容编辑" },
];
export const STORAGE_KEY = "oa_enterprise_news_v1";
/** 目标受众(对接组织架构 API 前为空) */
export const MOCK_AUDIENCE = [];
@@ -114,49 +112,6 @@
  };
}
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) {
  const scope = row.readScope || "all";
@@ -186,17 +141,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) {