fix:平库入库
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="app-container">
|
||||
<div class="head-container">
|
||||
<el-alert
|
||||
title="此类交货单由 SAP 同步,仅存储信息;实际入库以物料凭证为准。"
|
||||
title="此类交货单由 SAP 同步;打印标签后可在 PDA 扫码入库,收货完成后按 MM064 回传 SAP。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
@@ -54,6 +54,15 @@
|
||||
:disabled="isReturnConfirmDisabled()"
|
||||
@click="handleReturnConfirm"
|
||||
>退货确认</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
:disabled="multipleSelection.length === 0"
|
||||
@click="printBill"
|
||||
>打印标签</el-button>
|
||||
</crudOperation>
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" border row-key="id" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
@@ -109,6 +118,14 @@
|
||||
<el-button size="mini" @click="closeDetailDialog">关闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :close-on-click-modal="false" title="打印预览" :visible.sync="printPreviewVisible" width="700px" @close="printPreviewVisible = false">
|
||||
<iframe ref="printIframe" src="about:blank" style="width: 100%; height: 500px; border: 1px solid #ddd;" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="info" @click="printPreviewVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="doPrint">打印</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -118,6 +135,7 @@ import crudOperation from '@crud/CRUD.operation'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import { getDetail } from './outBoundDelivery'
|
||||
import QRCode from 'qrcode'
|
||||
|
||||
export default {
|
||||
name: 'SapDeliveryInbound',
|
||||
@@ -151,7 +169,8 @@ export default {
|
||||
detailVisible: false,
|
||||
detailLoading: false,
|
||||
currentOrder: {},
|
||||
itemList: []
|
||||
itemList: [],
|
||||
printPreviewVisible: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -250,6 +269,84 @@ export default {
|
||||
this.detailVisible = false
|
||||
this.currentOrder = {}
|
||||
this.itemList = []
|
||||
},
|
||||
// 打印扫码入库标签:内容与 PDA 扫码解析保持一致(单据号#行号#物料#名称##数量#)
|
||||
printBill() {
|
||||
const selections = this.multipleSelection
|
||||
if (!selections.length) {
|
||||
this.$message.info('请至少选择一条单据')
|
||||
return
|
||||
}
|
||||
const nos = selections.map(item => item.vbeln).join('、')
|
||||
this.$confirm('确认打印以下交货单的扫码入库标签?\n' + nos, '打印标签', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
Promise.all(selections.map(bill => getDetail(bill.vbeln).then(res => {
|
||||
const detail = res.data || res || {}
|
||||
return (detail.items || [])
|
||||
.filter(item => !item.rspos || item.rspos === 0)
|
||||
.map(item => ({ ...item, vbeln: detail.vbeln || bill.vbeln }))
|
||||
}))).then(results => {
|
||||
const allItems = results.reduce((acc, cur) => acc.concat(cur), [])
|
||||
if (!allItems.length) {
|
||||
this.$message.info('未查询到明细数据')
|
||||
return
|
||||
}
|
||||
this.printPreviewVisible = true
|
||||
this.$nextTick(() => this.renderPrintContent(allItems))
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
async renderPrintContent(itemList) {
|
||||
const iframe = this.$refs.printIframe
|
||||
if (!iframe) return
|
||||
const doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document)
|
||||
if (!doc) {
|
||||
setTimeout(() => this.renderPrintContent(itemList), 100)
|
||||
return
|
||||
}
|
||||
let html = '<!DOCTYPE html><html><head><meta charset="utf-8"><style>'
|
||||
html += '*{margin:0;padding:0;box-sizing:border-box}'
|
||||
html += 'body{font-family:"Microsoft YaHei",Arial,sans-serif;padding:10px}'
|
||||
html += '.label{page-break-after:always;padding:10px;text-align:center;}'
|
||||
html += 'h3{text-align:center;font-size:13px;margin-bottom:3px}'
|
||||
html += 'table{width:463px;border-collapse:collapse;margin:0 auto;height:224px}'
|
||||
html += 'td{padding:3px 5px;border:2px solid #333;font-size:17px}'
|
||||
html += '.lbl{width:25%;text-align:right;background:#f9f9f9}'
|
||||
html += '.val{width:45%;text-align:left}'
|
||||
html += '.qr{width:30%;text-align:center;vertical-align:middle}'
|
||||
html += '@media print{@page{size:auto;margin:5mm}}'
|
||||
html += '</style></head><body>'
|
||||
for (const item of itemList) {
|
||||
const vbeln = item.vbeln || ''
|
||||
const posnr = item.posnr || ''
|
||||
const material = item.material || ''
|
||||
const matlDesc = item.matl_desc || ''
|
||||
const lgort = item.lgort || ''
|
||||
const delivQty = item.deliv_qty == null ? '' : item.deliv_qty
|
||||
const qrText = vbeln + '#' + posnr + '#' + material + '#' + matlDesc + '##' + delivQty + '#'
|
||||
const imgSrc = await QRCode.toDataURL(qrText, { width: 300 })
|
||||
html += '<div class="label"><h3>上海诺力</h3><table>'
|
||||
html += '<tr><td class="lbl">交货单号</td><td class="val">' + vbeln + '</td><td class="qr" rowspan="6"><img src="' + imgSrc + '" width="150" height="150" /></td></tr>'
|
||||
html += '<tr><td class="lbl">行号</td><td class="val">' + posnr + '</td></tr>'
|
||||
html += '<tr><td class="lbl">物料编码</td><td class="val">' + material + '</td></tr>'
|
||||
html += '<tr><td class="lbl">物料名称</td><td class="val">' + matlDesc + '</td></tr>'
|
||||
html += '<tr><td class="lbl">数量</td><td class="val">' + delivQty + '</td></tr>'
|
||||
html += '<tr><td class="lbl">仓库</td><td class="val">' + lgort + '</td></tr>'
|
||||
html += '</table></div>'
|
||||
}
|
||||
html += '</body></html>'
|
||||
doc.open()
|
||||
doc.write(html)
|
||||
doc.close()
|
||||
},
|
||||
doPrint() {
|
||||
const iframe = this.$refs.printIframe
|
||||
if (!iframe) return
|
||||
iframe.contentWindow.focus()
|
||||
iframe.contentWindow.print()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user