| | |
| | | export const WAVE_ITEM_REPORT_TITLE = '波次明细报表' |
| | | import { $t } from '@/locales' |
| | | |
| | | function translate(t, key, params) { |
| | | return (typeof t === 'function' ? t : $t)(key, params) |
| | | } |
| | | |
| | | export function getWaveItemReportTitle(t) { |
| | | return translate(t, 'pages.orders.waveItem.reportTitle') |
| | | } |
| | | export const WAVE_ITEM_REPORT_STYLE = { |
| | | titleAlign: 'center', |
| | | titleLevel: 'strong', |
| | |
| | | return Number.isFinite(numericValue) ? numericValue : 0 |
| | | } |
| | | |
| | | const WAVE_ITEM_STATUS_MAP = { |
| | | 0: { label: '未执行', tagType: 'info' }, |
| | | 1: { label: '执行中', tagType: 'warning' }, |
| | | 2: { label: '暂停', tagType: 'warning' }, |
| | | 3: { label: '已下发', tagType: 'primary' }, |
| | | 4: { label: '任务完成', tagType: 'success' } |
| | | const WAVE_ITEM_STATUS_TAG_MAP = { |
| | | 0: 'info', |
| | | 1: 'warning', |
| | | 2: 'warning', |
| | | 3: 'primary', |
| | | 4: 'success' |
| | | } |
| | | |
| | | function getItemStatusConfig(status, statusText) { |
| | | const fallback = WAVE_ITEM_STATUS_MAP[Number(status)] || { |
| | | label: statusText || '-', |
| | | tagType: 'info' |
| | | } |
| | | function getItemStatusConfig(status, statusText, t) { |
| | | const fallbackLabel = statusText || translate(t, `pages.orders.waveItem.status.exceStatus.${Number(status)}`) |
| | | return { |
| | | label: statusText || fallback.label, |
| | | tagType: fallback.tagType |
| | | label: fallbackLabel || '-', |
| | | tagType: WAVE_ITEM_STATUS_TAG_MAP[Number(status)] || 'info' |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | export function normalizeWaveItemRow(record = {}) { |
| | | const statusConfig = getItemStatusConfig(record.exceStatus, record['exceStatus$']) |
| | | export function normalizeWaveItemRow(record = {}, t) { |
| | | const statusConfig = getItemStatusConfig(record.exceStatus, record['exceStatus$'], t) |
| | | return { |
| | | ...record, |
| | | waveCode: record.waveCode || '-', |
| | |
| | | } |
| | | } |
| | | |
| | | export function buildWaveItemPrintRows(records = []) { |
| | | export function buildWaveItemPrintRows(records = [], t) { |
| | | if (!Array.isArray(records)) { |
| | | return [] |
| | | } |
| | | return records.map((record) => normalizeWaveItemRow(record)) |
| | | return records.map((record) => normalizeWaveItemRow(record, t)) |
| | | } |
| | | |
| | | export function buildWaveItemReportMeta({ |
| | | previewMeta = {}, |
| | | count = 0, |
| | | orientation = WAVE_ITEM_REPORT_STYLE.orientation |
| | | orientation = WAVE_ITEM_REPORT_STYLE.orientation, |
| | | t |
| | | } = {}) { |
| | | return { |
| | | reportTitle: WAVE_ITEM_REPORT_TITLE, |
| | | reportTitle: getWaveItemReportTitle(t), |
| | | reportDate: previewMeta.reportDate, |
| | | printedAt: previewMeta.printedAt, |
| | | operator: previewMeta.operator, |