| | |
| | | export const TRANSFER_ITEM_REPORT_TITLE = '调拨明细报表' |
| | | import { $t } from '@/locales' |
| | | |
| | | export function getTransferItemReportTitle(t = $t) { |
| | | return t('pages.orders.transferItem.reportTitle') |
| | | } |
| | | export const TRANSFER_ITEM_REPORT_STYLE = { |
| | | titleAlign: 'center', |
| | | titleLevel: 'strong', |
| | |
| | | showBorder: true |
| | | } |
| | | |
| | | const STATUS_META = { |
| | | 1: { text: '正常', type: 'success', bool: true }, |
| | | 0: { text: '冻结', type: 'danger', bool: false } |
| | | function getTransferItemStatusMetaMap(t = $t) { |
| | | return { |
| | | 1: { text: t('common.status.normal'), type: 'success', bool: true }, |
| | | 0: { text: t('common.status.frozen'), type: 'danger', bool: false } |
| | | } |
| | | } |
| | | |
| | | function normalizeText(value, fallback = '--') { |
| | |
| | | } |
| | | } |
| | | |
| | | function getStatusMeta(status, statusText) { |
| | | function getStatusMeta(status, statusText, t = $t) { |
| | | const numericStatus = Number(status) |
| | | return STATUS_META[numericStatus] || { |
| | | text: normalizeText(statusText || status || '--'), |
| | | const statusMetaMap = getTransferItemStatusMetaMap(t) |
| | | return statusMetaMap[numericStatus] || { |
| | | text: normalizeText(statusText || status || t('common.status.unknown')), |
| | | type: 'info', |
| | | bool: false |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | export function getTransferItemStatusOptions() { |
| | | export function getTransferItemStatusOptions(t = $t) { |
| | | return [ |
| | | { label: '正常', value: 1 }, |
| | | { label: '冻结', value: 0 } |
| | | { label: t('common.status.normal'), value: 1 }, |
| | | { label: t('common.status.frozen'), value: 0 } |
| | | ] |
| | | } |
| | | |
| | | export function getTransferItemStatusMeta(status) { |
| | | export function getTransferItemStatusMeta(status, t = $t) { |
| | | const statusMetaMap = getTransferItemStatusMetaMap(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 buildTransferItemSearchParams(params = {}) { |
| | |
| | | } |
| | | } |
| | | |
| | | export function normalizeTransferItemRow(record = {}) { |
| | | const statusMeta = getStatusMeta(record.statusBool ?? record.status, record['status$'] || record.statusText) |
| | | export function normalizeTransferItemRow(record = {}, t = $t) { |
| | | const statusMeta = getStatusMeta(record.statusBool ?? record.status, record['status$'] || record.statusText, t) |
| | | |
| | | return { |
| | | ...record, |
| | |
| | | } |
| | | } |
| | | |
| | | export function buildTransferItemPrintRows(records = []) { |
| | | export function buildTransferItemPrintRows(records = [], t = $t) { |
| | | if (!Array.isArray(records)) { |
| | | return [] |
| | | } |
| | | return records.map((record) => normalizeTransferItemRow(record)) |
| | | return records.map((record) => normalizeTransferItemRow(record, t)) |
| | | } |
| | | |
| | | export function buildTransferItemReportMeta({ |
| | | previewMeta = {}, |
| | | count = 0, |
| | | orientation = TRANSFER_ITEM_REPORT_STYLE.orientation |
| | | orientation = TRANSFER_ITEM_REPORT_STYLE.orientation, |
| | | t = $t |
| | | } = {}) { |
| | | return { |
| | | reportTitle: TRANSFER_ITEM_REPORT_TITLE, |
| | | reportTitle: getTransferItemReportTitle(t), |
| | | reportDate: previewMeta.reportDate, |
| | | printedAt: previewMeta.printedAt, |
| | | operator: previewMeta.operator, |
| | |
| | | } |
| | | } |
| | | } |
| | | |