对企业新闻状态处理机制进行重构,并移除不再使用的导入项。引入了状态规范化所需的数值与标签映射功能,从而提升了清晰度和可维护性。
| | |
| | | createEmptyForm, |
| | | normalizeEnterpriseNewsStatus, |
| | | publishStatusLabel, |
| | | PUBLISH_STATUS_OPTIONS, |
| | | publishStatusTag, |
| | | } from "./enterpriseNewsUtils.js"; |
| | | |
| | | /** formPayload 中存放完整企业新闻业务数据的键(审批实例保存用) */ |
| | |
| | | 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 }, |
| | |
| | | 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; |
| | | } |
| | |
| | | } 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 { |