dbPoundQr.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * 磅单二维码弹窗文案工具(与 web-admin PoundSlipQrcodeView / DbPoundSlipQrcodeDialog 对齐)
  3. */
  4. export function poundQrDialogTitle(businessType) {
  5. return String(businessType || '').trim() === '出库' ? '出库磅单二维码' : '入库磅单二维码'
  6. }
  7. /** 与 DbPoundSlipQrcodeDialog.formatQrcodeProductLabel 一致 */
  8. export function formatQrcodeProductLabel(row) {
  9. const product = String(row?.product || '').trim()
  10. const specification = String(row?.specification || '').trim()
  11. if (!specification) return product
  12. if (product.endsWith(specification)) {
  13. const base = product.slice(0, -specification.length).trimEnd()
  14. return base ? `${base} ${specification}` : specification
  15. }
  16. return `${product} ${specification}`.trim()
  17. }
  18. export function formatPoundQrProductLine(row, quantityUnit = '吨') {
  19. const unit = String(quantityUnit || '').trim() || '吨'
  20. const label = formatQrcodeProductLabel(row)
  21. const qty = row?.quantity
  22. const qtyText = qty === 0 || qty ? String(qty) : '--'
  23. return `${label}(${qtyText} ${unit})`
  24. }
  25. export function normalizePoundQrRemarks(row) {
  26. const a = String(row?.remarks ?? '').trim()
  27. if (a) return a
  28. return String(row?.remark ?? '').trim()
  29. }