优化
This commit is contained in:
@@ -74,9 +74,17 @@ test('退货签收详情使用独立路由和紧凑连续页面', () => {
|
|||||||
assert.doesNotMatch(view, /class="return-detail-dialog"/)
|
assert.doesNotMatch(view, /class="return-detail-dialog"/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('退货箱唛打印复用统一的紧凑单页模板并按箱分页', () => {
|
||||||
|
assert.match(view, /@page\{size:100mm 100mm;margin:8mm\}/)
|
||||||
|
assert.match(view, /\.label\{width:84mm;height:84mm;padding:8mm/)
|
||||||
|
assert.match(view, /html\.slice\(contentStart, bodyEnd\)/)
|
||||||
|
assert.match(view, /打印全部箱唛(\{\{ receipt\.labels\?\.length \|\| receipt\.boxCount \|\| 1 \}\} 箱)/)
|
||||||
|
})
|
||||||
|
|
||||||
test('待审核退货可编辑,完成入库后从独立新增页发起贴标', () => {
|
test('待审核退货可编辑,完成入库后从独立新增页发起贴标', () => {
|
||||||
assert.match(view, /row\.status === 'PENDING_REVIEW'.*key: 'edit'/)
|
assert.match(view, /row\.status === 'PENDING_REVIEW'.*key: 'edit'/)
|
||||||
assert.match(view, /await \(editingReturnNo\.value \? updateReturnOrder\(editingReturnNo\.value, payload\) : createReturnOrder\(payload\)\)/)
|
assert.match(view, /if \(editingReturnNo\.value\) await updateReturnOrder\(editingReturnNo\.value, payload\)/)
|
||||||
|
assert.match(view, /else await createReturnOrder\(payload\)/)
|
||||||
assert.match(view, /order\.status === 'COMPLETED' && order\.needRelabel === true/)
|
assert.match(view, /order\.status === 'COMPLETED' && order\.needRelabel === true/)
|
||||||
assert.match(view, /name: 'overseas-labeling-create'/)
|
assert.match(view, /name: 'overseas-labeling-create'/)
|
||||||
assert.match(view, /query: \{ returnNo: order\.returnNo, warehouseId: String\(order\.overseasWarehouseId\) \}/)
|
assert.match(view, /query: \{ returnNo: order\.returnNo, warehouseId: String\(order\.overseasWarehouseId\) \}/)
|
||||||
|
|||||||
@@ -184,15 +184,13 @@ async function printReturnLabel(receipt: ReturnReceipt) {
|
|||||||
const labels = receipt.labels?.length
|
const labels = receipt.labels?.length
|
||||||
? receipt.labels
|
? receipt.labels
|
||||||
: [{ cartonMark: receipt.cartonMark, printableHtml: receipt.printableHtml || (await getReturnInventoryLabel(receipt.cartonMark)).printableHtml }]
|
: [{ cartonMark: receipt.cartonMark, printableHtml: receipt.printableHtml || (await getReturnInventoryLabel(receipt.cartonMark)).printableHtml }]
|
||||||
const printableHtml = labels.length === 1
|
const printStyle = '<style>@page{size:100mm 100mm;margin:8mm}*{box-sizing:border-box}html,body{margin:0;background:#fff;color:#111;font-family:Arial,\'Microsoft YaHei\',sans-serif}.label{width:84mm;height:84mm;padding:8mm;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;page-break-after:always}.label:last-child{page-break-after:auto}.mark{font:800 18px Arial,sans-serif;line-height:1.15;word-break:break-all;margin:0 0 6mm}.barcode{width:84mm;margin:0 0 5mm}.barcode svg{display:block;width:100%;height:auto}.line{display:flex;justify-content:center;align-items:baseline;width:100%;padding:2mm 0;font-size:15px}.sku{max-width:84mm;overflow-wrap:anywhere;font-weight:700}</style>'
|
||||||
? labels[0].printableHtml
|
const printableHtml = `<!doctype html><html><head><meta charset="utf-8"><title>退货箱唛</title>${printStyle}</head><body>${labels.map((label) => {
|
||||||
: `<!doctype html><html><head><meta charset="utf-8"><title>退货箱唛</title><style>@page{size:100mm 100mm;margin:8mm}.return-label{page-break-after:always}.return-label:last-child{page-break-after:auto}body{margin:0}</style></head><body>${labels.map((label) => {
|
|
||||||
const html = label.printableHtml || ''
|
const html = label.printableHtml || ''
|
||||||
const bodyStart = html.indexOf('<body')
|
const bodyStart = html.indexOf('<body')
|
||||||
const contentStart = bodyStart < 0 ? 0 : html.indexOf('>', bodyStart) + 1
|
const contentStart = bodyStart < 0 ? 0 : html.indexOf('>', bodyStart) + 1
|
||||||
const bodyEnd = html.lastIndexOf('</body>')
|
const bodyEnd = html.lastIndexOf('</body>')
|
||||||
const content = contentStart > 0 && bodyEnd > contentStart ? html.slice(contentStart, bodyEnd) : html
|
return contentStart > 0 && bodyEnd > contentStart ? html.slice(contentStart, bodyEnd) : html
|
||||||
return `<section class="return-label">${content}</section>`
|
|
||||||
}).join('')}</body></html>`
|
}).join('')}</body></html>`
|
||||||
popup.document.open()
|
popup.document.open()
|
||||||
popup.document.write(printableHtml)
|
popup.document.write(printableHtml)
|
||||||
|
|||||||
Reference in New Issue
Block a user