| | |
| | | import { $t } from '@/locales' |
| | | |
| | | export const ASN_ORDER_REPORT_TITLE = $t('pages.orders.asnOrder.reportTitle') |
| | | export function getAsnOrderReportTitle(t = $t) { |
| | | return t('pages.orders.asnOrder.reportTitle') |
| | | } |
| | | export const ASN_ORDER_REPORT_STYLE = { |
| | | titleAlign: 'center', |
| | | titleLevel: 'strong', |
| | | orientation: 'landscape', |
| | | density: 'compact', |
| | | showSequence: true |
| | | } |
| | | |
| | | const ASN_ORDER_STATUS_MAP = { |
| | | 0: { label: $t('pages.orders.asnOrder.status.pending'), tagType: 'info' }, |
| | | 1: { label: $t('pages.orders.asnOrder.status.running'), tagType: 'warning' }, |
| | | 2: { label: $t('pages.orders.asnOrder.status.receiving'), tagType: 'success' }, |
| | | 3: { label: $t('pages.orders.asnOrder.status.taskRunning'), tagType: 'warning' }, |
| | | 4: { label: $t('pages.orders.asnOrder.status.completed'), tagType: 'success' }, |
| | | 8: { label: $t('pages.orders.asnOrder.status.cancelled'), tagType: 'danger' }, |
| | | 9: { label: $t('pages.orders.asnOrder.status.closed'), tagType: 'info' } |
| | | } |
| | | |
| | | function normalizeText(value) { |
| | |
| | | return Number.isFinite(numericValue) ? numericValue : '-' |
| | | } |
| | | |
| | | function getStatusConfig(status, statusText) { |
| | | function getAsnOrderStatusMap(t = $t) { |
| | | return { |
| | | 0: { label: t('pages.orders.asnOrder.status.pending'), tagType: 'info' }, |
| | | 1: { label: t('pages.orders.asnOrder.status.running'), tagType: 'warning' }, |
| | | 2: { label: t('pages.orders.asnOrder.status.receiving'), tagType: 'success' }, |
| | | 3: { label: t('pages.orders.asnOrder.status.taskRunning'), tagType: 'warning' }, |
| | | 4: { label: t('pages.orders.asnOrder.status.completed'), tagType: 'success' }, |
| | | 8: { label: t('pages.orders.asnOrder.status.cancelled'), tagType: 'danger' }, |
| | | 9: { label: t('pages.orders.asnOrder.status.closed'), tagType: 'info' } |
| | | } |
| | | } |
| | | |
| | | function getStatusConfig(status, statusText, t = $t) { |
| | | const numericStatus = Number(status) |
| | | const fallback = ASN_ORDER_STATUS_MAP[numericStatus] || { |
| | | const fallback = getAsnOrderStatusMap(t)[numericStatus] || { |
| | | label: statusText || '-', |
| | | tagType: 'info' |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | export function normalizeAsnOrderRow(record = {}) { |
| | | const statusConfig = getStatusConfig(record.exceStatus, record['exceStatus$']) |
| | | export function normalizeAsnOrderRow(record = {}, t = $t) { |
| | | const statusConfig = getStatusConfig(record.exceStatus, record['exceStatus$'], t) |
| | | return { |
| | | ...record, |
| | | id: record.id ?? null, |
| | |
| | | } |
| | | } |
| | | |
| | | export function buildAsnOrderPrintRows(records = []) { |
| | | export function buildAsnOrderPrintRows(records = [], t = $t) { |
| | | if (!Array.isArray(records)) { |
| | | return [] |
| | | } |
| | | return records.map((record) => normalizeAsnOrderRow(record)) |
| | | return records.map((record) => normalizeAsnOrderRow(record, t)) |
| | | } |
| | | |
| | | export function buildAsnOrderReportMeta({ |
| | | previewMeta = {}, |
| | | count = 0, |
| | | orientation = ASN_ORDER_REPORT_STYLE.orientation |
| | | orientation = ASN_ORDER_REPORT_STYLE.orientation, |
| | | t = $t |
| | | } = {}) { |
| | | return { |
| | | reportTitle: ASN_ORDER_REPORT_TITLE, |
| | | reportTitle: getAsnOrderReportTitle(t), |
| | | reportDate: previewMeta.reportDate, |
| | | printedAt: previewMeta.printedAt, |
| | | operator: previewMeta.operator, |
| | |
| | | } |
| | | } |
| | | |
| | | export function getAsnOrderStatusOptions() { |
| | | return Object.entries(ASN_ORDER_STATUS_MAP).map(([value, item]) => ({ |
| | | export function getAsnOrderStatusOptions(t = $t) { |
| | | return Object.entries(getAsnOrderStatusMap(t)).map(([value, item]) => ({ |
| | | label: item.label, |
| | | value: Number(value) |
| | | })) |