Files

34 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 磅单二维码弹窗文案工具(与 web-admin PoundSlipQrcodeView / DbPoundSlipQrcodeDialog 对齐)
*/
export function poundQrDialogTitle(businessType) {
return String(businessType || '').trim() === '出库' ? '出库磅单二维码' : '入库磅单二维码'
}
/** 与 DbPoundSlipQrcodeDialog.formatQrcodeProductLabel 一致 */
export function formatQrcodeProductLabel(row) {
const product = String(row?.product || '').trim()
const specification = String(row?.specification || '').trim()
if (!specification) return product
if (product.endsWith(specification)) {
const base = product.slice(0, -specification.length).trimEnd()
return base ? `${base} ${specification}` : specification
}
return `${product} ${specification}`.trim()
}
export function formatPoundQrProductLine(row, quantityUnit = '吨') {
const unit = String(quantityUnit || '').trim() || '吨'
const label = formatQrcodeProductLabel(row)
const qty = row?.quantity
const qtyText = qty === 0 || qty ? String(qty) : '--'
return `${label}(${qtyText} ${unit})`
}
export function normalizePoundQrRemarks(row) {
const a = String(row?.remarks ?? '').trim()
if (a) return a
return String(row?.remark ?? '').trim()
}