| | |
| | | const STATUS_META = { |
| | | 1: { text: '正常', type: 'success', bool: true }, |
| | | 0: { text: '冻结', type: 'danger', bool: false } |
| | | import { $t } from '@/locales' |
| | | |
| | | function getDeliveryItemStatusMetaMap(t = $t) { |
| | | return { |
| | | 1: { text: t('common.status.normal'), type: 'success', bool: true }, |
| | | 0: { text: t('common.status.frozen'), type: 'danger', bool: false } |
| | | } |
| | | } |
| | | |
| | | export const DELIVERY_ITEM_REPORT_TITLE = 'DO单明细报表' |
| | | export function getDeliveryItemReportTitle(t = $t) { |
| | | return t('pages.orders.deliveryItem.reportTitle') |
| | | } |
| | | |
| | | export const DELIVERY_ITEM_REPORT_STYLE = { |
| | | titleAlign: 'center', |
| | | titleLevel: 'strong', |
| | |
| | | return Number.isNaN(parsed) ? fallback : parsed |
| | | } |
| | | |
| | | function normalizeStatusMeta(status) { |
| | | function normalizeStatusMeta(status, t = $t) { |
| | | const statusMetaMap = getDeliveryItemStatusMetaMap(t) |
| | | if (status === true || Number(status) === 1) { |
| | | return STATUS_META[1] |
| | | return statusMetaMap[1] |
| | | } |
| | | if (status === false || Number(status) === 0) { |
| | | return STATUS_META[0] |
| | | return statusMetaMap[0] |
| | | } |
| | | return { text: '未知', type: 'info', bool: false } |
| | | return { text: t('common.status.unknown'), type: 'info', bool: false } |
| | | } |
| | | |
| | | export function createDeliveryItemSearchState() { |
| | |
| | | } |
| | | } |
| | | |
| | | export function normalizeDeliveryItemRow(record = {}) { |
| | | const statusMeta = normalizeStatusMeta(record.statusBool ?? record.status) |
| | | export function normalizeDeliveryItemRow(record = {}, t = $t) { |
| | | const statusMeta = normalizeStatusMeta(record.statusBool ?? record.status, t) |
| | | return { |
| | | ...record, |
| | | id: record.id ?? null, |
| | |
| | | } |
| | | } |
| | | |
| | | export function buildDeliveryItemPrintRows(records = []) { |
| | | export function buildDeliveryItemPrintRows(records = [], t = $t) { |
| | | if (!Array.isArray(records)) { |
| | | return [] |
| | | } |
| | | return records.map((record) => normalizeDeliveryItemRow(record)) |
| | | return records.map((record) => normalizeDeliveryItemRow(record, t)) |
| | | } |
| | | |
| | | export function buildDeliveryItemReportMeta({ |
| | | previewMeta = {}, |
| | | count = 0, |
| | | orientation = DELIVERY_ITEM_REPORT_STYLE.orientation |
| | | orientation = DELIVERY_ITEM_REPORT_STYLE.orientation, |
| | | t = $t |
| | | } = {}) { |
| | | return { |
| | | reportTitle: DELIVERY_ITEM_REPORT_TITLE, |
| | | reportTitle: getDeliveryItemReportTitle(t), |
| | | reportDate: previewMeta.reportDate, |
| | | printedAt: previewMeta.printedAt, |
| | | operator: previewMeta.operator, |