const defaultTaskStatuses = { UNREPORTED: { text: '未上报', type: 'info' }, REPORTED_XCB: { text: '已上报rk_XCB', type: 'warning' }, RETURNED: { text: '上级打回', type: 'danger' }, XCB_REVIEWED: { text: 'rk_XCB助理审核完成', type: 'primary' }, CMB_APPROVED: { text: 'rk_CMB领导审批完成', type: 'success' }, JCC_ASSISTANT_APPROVED: { text: 'rk_JCC助理审批完成', type: 'success' }, JCC_DIRECTOR_APPROVED: { text: 'rk_JCC处长已阅', type: 'success' }, DISPATCHED: { text: '已派单', type: 'primary' }, CANCELLED: { text: '已销项', type: 'info' } } const defaultCompletionStatuses = { UNFINISHED: { text: '未完工', type: 'info' }, WAIT_PARTS: { text: '待备件', type: 'warning' }, WAIT_TEST: { text: '完工待试验', type: 'primary' }, COMPLETED: { text: '完工', type: 'success' } } const defaultAcceptanceStatuses = { APPLICATION_PENDING: { text: '待提交验收申请', type: 'warning' }, QUALITY_INSPECTOR_PENDING: { text: '待质检员验收', type: 'primary' }, QUALITY_LEADER_PENDING: { text: '待质检负责人验收', type: 'primary' }, PRINT_PENDING: { text: '待打印输出', type: 'warning' }, RATING_PENDING: { text: '待修后质量评级', type: 'warning' }, COMPLETED: { text: '验收完成', type: 'success' }, RETURNED_APPLICATION: { text: '已打回验收申请', type: 'danger' }, RETURNED_INSPECTOR: { text: '已打回质检员验收', type: 'danger' } } export const taskStatuses = { ...defaultTaskStatuses } export const completionStatuses = { ...defaultCompletionStatuses } export const acceptanceStatuses = { ...defaultAcceptanceStatuses } function normalizeDictionary(source, fallback) { if (!source || typeof source !== 'object' || Array.isArray(source)) { return fallback } const result = {} Object.keys(source).forEach(key => { const item = source[key] if (item && typeof item === 'object' && item.text) { result[key] = { text: String(item.text), type: item.type ? String(item.type) : 'info' } } }) return Object.keys(result).length ? result : fallback } function replaceDictionary(target, source) { Object.keys(target).forEach(key => { delete target[key] }) Object.keys(source).forEach(key => { target[key] = source[key] }) } function applyRuntimeDictionary() { const runtime = window.__APP_DICT__ || {} replaceDictionary(taskStatuses, normalizeDictionary(runtime.taskStatuses, defaultTaskStatuses)) replaceDictionary(completionStatuses, normalizeDictionary(runtime.completionStatuses, defaultCompletionStatuses)) replaceDictionary(acceptanceStatuses, normalizeDictionary(runtime.acceptanceStatuses, defaultAcceptanceStatuses)) } let loadingPromise = null export function loadDictionary() { if (loadingPromise) { return loadingPromise } loadingPromise = new Promise(resolve => { const script = document.createElement('script') const baseUrl = process.env.BASE_URL || '/' script.async = true script.src = baseUrl + 'dict.js?ts=' + Date.now() script.onload = () => { applyRuntimeDictionary() resolve() } script.onerror = () => resolve() document.head.appendChild(script) }) return loadingPromise } export function statusMeta(dict, value) { return dict[value] || { text: value || '-', type: 'info' } }