| | |
| | | export const WAVE_REPORT_TITLE = '波次单报表' |
| | | import { $t } from '@/locales' |
| | | |
| | | function translate(t, key, params) { |
| | | return (typeof t === 'function' ? t : $t)(key, params) |
| | | } |
| | | |
| | | export function getWaveReportTitle(t) { |
| | | return translate(t, 'pages.orders.wave.reportTitle') |
| | | } |
| | | export const WAVE_REPORT_STYLE = { |
| | | titleAlign: 'center', |
| | | titleLevel: 'strong', |
| | |
| | | showSequence: true |
| | | } |
| | | |
| | | const WAVE_STATUS_MAP = { |
| | | 0: { label: '等待执行', tagType: 'info' }, |
| | | 1: { label: '正在执行', tagType: 'warning' }, |
| | | 2: { label: '暂停执行', tagType: 'warning' }, |
| | | 3: { label: '执行完成', tagType: 'success' } |
| | | const WAVE_STATUS_TAG_MAP = { |
| | | 0: 'info', |
| | | 1: 'warning', |
| | | 2: 'warning', |
| | | 3: 'success' |
| | | } |
| | | |
| | | 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 normalizeText(value) { |
| | |
| | | return Number.isFinite(numericValue) ? numericValue : 0 |
| | | } |
| | | |
| | | function getStatusConfig(status, statusText) { |
| | | const fallback = WAVE_STATUS_MAP[Number(status)] || { |
| | | label: statusText || '-', |
| | | tagType: 'info' |
| | | } |
| | | function getStatusConfig(status, statusText, t) { |
| | | const statusKey = `pages.orders.wave.status.exceStatus.${Number(status)}` |
| | | const fallbackLabel = statusText || translate(t, statusKey) |
| | | return { |
| | | label: statusText || fallback.label, |
| | | tagType: fallback.tagType |
| | | label: fallbackLabel || '-', |
| | | tagType: WAVE_STATUS_TAG_MAP[Number(status)] || 'info' |
| | | } |
| | | } |
| | | |
| | | function getItemStatusConfig(status, statusText) { |
| | | const fallback = WAVE_ITEM_STATUS_MAP[Number(status)] || { |
| | | label: statusText || '-', |
| | | tagType: 'info' |
| | | } |
| | | function getItemStatusConfig(status, statusText, t) { |
| | | const statusKey = `pages.orders.waveItem.status.exceStatus.${Number(status)}` |
| | | const fallbackLabel = statusText || translate(t, statusKey) |
| | | return { |
| | | label: statusText || fallback.label, |
| | | tagType: fallback.tagType |
| | | label: fallbackLabel || '-', |
| | | tagType: WAVE_ITEM_STATUS_TAG_MAP[Number(status)] || 'info' |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | export function normalizeWaveRow(record = {}) { |
| | | const statusConfig = getStatusConfig(record.exceStatus, record['exceStatus$']) |
| | | export function normalizeWaveRow(record = {}, t) { |
| | | const statusConfig = getStatusConfig(record.exceStatus, record['exceStatus$'], t) |
| | | const progress = normalizeNumber(record.anfme) > 0 |
| | | ? Math.min(Math.round((normalizeNumber(record.workQty) / normalizeNumber(record.anfme)) * 100), 100) |
| | | : 0 |
| | |
| | | return { |
| | | ...record, |
| | | code: record.code || '-', |
| | | typeLabel: record['type$'] || record.type || '-', |
| | | typeLabel: record['type$'] || translate(t, `pages.orders.wave.status.type.${record.type}`) || record.type || '-', |
| | | exceStatusText: statusConfig.label, |
| | | exceStatusTagType: statusConfig.tagType, |
| | | statusLabel: record['status$'] || record.status || '-', |
| | | statusLabel: |
| | | record['status$'] || |
| | | translate(t, Number(record.status) === 1 ? 'common.status.normal' : 'common.status.disabled') || |
| | | record.status || |
| | | '-', |
| | | anfme: normalizeNumber(record.anfme), |
| | | qty: normalizeNumber(record.qty), |
| | | workQty: normalizeNumber(record.workQty), |
| | |
| | | } |
| | | } |
| | | |
| | | 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 buildWavePrintRows(records = []) { |
| | | export function buildWavePrintRows(records = [], t) { |
| | | if (!Array.isArray(records)) { |
| | | return [] |
| | | } |
| | | return records.map((record) => normalizeWaveRow(record)) |
| | | return records.map((record) => normalizeWaveRow(record, t)) |
| | | } |
| | | |
| | | export function buildWaveReportMeta({ |
| | | previewMeta = {}, |
| | | count = 0, |
| | | orientation = WAVE_REPORT_STYLE.orientation |
| | | orientation = WAVE_REPORT_STYLE.orientation, |
| | | t |
| | | } = {}) { |
| | | return { |
| | | reportTitle: WAVE_REPORT_TITLE, |
| | | reportTitle: getWaveReportTitle(t), |
| | | reportDate: previewMeta.reportDate, |
| | | printedAt: previewMeta.printedAt, |
| | | operator: previewMeta.operator, |
| | |
| | | } |
| | | } |
| | | |
| | | export function getWaveActionList(row = {}) { |
| | | const normalizedRow = normalizeWaveRow(row) |
| | | export function getWaveActionList(row = {}, t) { |
| | | const normalizedRow = normalizeWaveRow(row, t) |
| | | return [ |
| | | { |
| | | key: 'view', |
| | | label: '查看详情', |
| | | label: translate(t, 'pages.orders.wave.actions.view'), |
| | | icon: 'ri:eye-line' |
| | | }, |
| | | { |
| | | key: 'publicTask', |
| | | label: '下发任务', |
| | | label: translate(t, 'pages.orders.wave.actions.publicTask'), |
| | | icon: 'ri:play-circle-line', |
| | | disabled: !normalizedRow.canPublicTask |
| | | }, |
| | | { |
| | | key: 'pause', |
| | | label: '暂停', |
| | | label: translate(t, 'pages.orders.wave.actions.pause'), |
| | | icon: 'ri:pause-circle-line', |
| | | disabled: !normalizedRow.canPause |
| | | }, |
| | | { |
| | | key: 'continue', |
| | | label: '继续', |
| | | label: translate(t, 'pages.orders.wave.actions.continue'), |
| | | icon: 'ri:play-line', |
| | | disabled: !normalizedRow.canContinue |
| | | }, |
| | | { |
| | | key: 'stop', |
| | | label: '终止', |
| | | label: translate(t, 'pages.orders.wave.actions.stop'), |
| | | icon: 'ri:stop-circle-line', |
| | | disabled: !normalizedRow.canStop |
| | | }, |
| | | { |
| | | key: 'print', |
| | | label: '打印', |
| | | label: translate(t, 'pages.orders.wave.actions.print'), |
| | | icon: 'ri:printer-line' |
| | | } |
| | | ] |