34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
/**
|
||
* 磅单二维码弹窗文案工具(与 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()
|
||
}
|