zhou zhou
21 小时以前 50e95b985a72fcec4a93a2470e9efdfb2620148a
rsf-design/src/views/orders/wave-item/waveItemPage.helpers.js
@@ -1,4 +1,12 @@
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',
@@ -19,22 +27,19 @@
  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'
  }
}
@@ -115,8 +120,8 @@
  }
}
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 || '-',
@@ -139,20 +144,21 @@
  }
}
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,