zhou zhou
11 小时以前 50e95b985a72fcec4a93a2470e9efdfb2620148a
rsf-design/src/views/orders/wave/wavePage.helpers.js
@@ -1,4 +1,12 @@
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',
@@ -7,19 +15,19 @@
  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) {
@@ -34,25 +42,21 @@
  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'
  }
}
@@ -123,8 +127,8 @@
  }
}
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
@@ -132,10 +136,14 @@
  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),
@@ -157,8 +165,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 || '-',
@@ -183,20 +191,21 @@
  }
}
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,
@@ -208,41 +217,41 @@
  }
}
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'
    }
  ]