add:出库单标签打印
This commit is contained in:
@@ -261,7 +261,7 @@ export default {
|
||||
isPushDisabled() {
|
||||
// 没有选中、选中多行、或选中的行状态不是 '0' 时禁用
|
||||
if (this.multipleSelection.length !== 1) return true
|
||||
return this.multipleSelection[0].status !== '10'
|
||||
return this.multipleSelection[0].status !== 10
|
||||
},
|
||||
statusFormat(row) {
|
||||
return this.statusLabel(row.status)
|
||||
@@ -342,7 +342,7 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
upload(this.multipleSelection).then(res => {
|
||||
upload(this.multipleSelection[0]).then(res => {
|
||||
if (res.code == 400){
|
||||
this.$message.warning('分配失败'+res.message)
|
||||
return
|
||||
|
||||
@@ -151,6 +151,15 @@
|
||||
>
|
||||
强制确认
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
@click="printBill"
|
||||
>出库标签打印
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
@@ -213,6 +222,20 @@
|
||||
<AddDialog @AddChanged="querytable" />
|
||||
<ViewDialog :dialog-show.sync="viewShow" :rowmst="mstrow" @AddChanged="querytable" />
|
||||
<DivDialog :dialog-show.sync="divShow" :open-array="openParam" :stor-code="storCode" :rowmst="mstrow" @DivChanged="querytable" />
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
title="打印预览"
|
||||
:visible.sync="printPreviewVisible"
|
||||
width="700px"
|
||||
@close="closePrintPreview"
|
||||
>
|
||||
<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>
|
||||
|
||||
@@ -227,6 +250,8 @@ import AddDialog from '@/views/wms/st/outbill/AddDialog'
|
||||
import DivDialog from '@/views/wms/st/outbill/DivDialog'
|
||||
import ViewDialog from '@/views/wms/st/outbill/ViewDialog'
|
||||
import crudBsrealstorattr from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
|
||||
import crudPurchase from "@/views/wms/pm_manage/otherIn/purchase";
|
||||
import QRCode from "qrcode";
|
||||
|
||||
const start = new Date()
|
||||
|
||||
@@ -259,12 +284,14 @@ export default {
|
||||
},
|
||||
loadingConfirm: false,
|
||||
divShow: false,
|
||||
printPreviewVisible: false,
|
||||
dis_flag: true,
|
||||
confirm_flag: true,
|
||||
business_confirm_flag: true,
|
||||
outReturn_flag: true,
|
||||
openParam: [],
|
||||
mstrow: {},
|
||||
audit_flag: true,
|
||||
viewShow: false,
|
||||
uploadDialogShow: false,
|
||||
currentRow: null,
|
||||
@@ -340,6 +367,103 @@ export default {
|
||||
this.$refs.table.clearSelection()
|
||||
this.handleCurrentChange(null)
|
||||
},
|
||||
doPrint() {
|
||||
const iframe = this.$refs.printIframe
|
||||
if (!iframe) return
|
||||
iframe.contentWindow.focus()
|
||||
iframe.contentWindow.print()
|
||||
},
|
||||
printBill() {
|
||||
const selections = this.crud.selections
|
||||
if (!selections || selections.length === 0 || selections.length > 1) {
|
||||
this.crud.notify('请选择一条单据', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return
|
||||
}
|
||||
const billIds = selections.map(s => s.order_no).join('、')
|
||||
this.$confirm('确认打印以下单据的物料标签?\n' + billIds, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.fetchDetailsAndPrint(selections)
|
||||
}).catch(() => {})
|
||||
},
|
||||
fetchDetailsAndPrint(selections) {
|
||||
const promises = selections.map(bill => {
|
||||
return checkoutbill.getOutBillDtl({ 'iostorinv_id': bill.iostorinv_id }).then(res => {
|
||||
const dtlList = (res.data) || []
|
||||
return dtlList.map(dtl => ({
|
||||
...dtl
|
||||
}))
|
||||
})
|
||||
})
|
||||
Promise.all(promises).then(results => {
|
||||
const allDtls = results.reduce((acc, cur) => acc.concat(cur), [])
|
||||
if (allDtls.length === 0) {
|
||||
this.crud.notify('未查询到明细数据', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return
|
||||
}
|
||||
this.printPreviewVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.renderPrintContent(allDtls)
|
||||
})
|
||||
}).catch(() => {
|
||||
this.crud.notify('查询明细失败', CRUD.NOTIFICATION_TYPE.ERROR)
|
||||
})
|
||||
},
|
||||
closePrintPreview() {
|
||||
this.printPreviewVisible = false
|
||||
},
|
||||
async renderPrintContent(dtlList) {
|
||||
const iframe = this.$refs.printIframe
|
||||
if (!iframe) return
|
||||
const doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document)
|
||||
if (!doc) {
|
||||
setTimeout(() => this.renderPrintContent(dtlList), 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 += '.label:last-child{page-break-after:auto}'
|
||||
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 dtl of dtlList) {
|
||||
const orderNo = dtl.bill_code || ''
|
||||
const itemNo = dtl.seq_no || ''
|
||||
const skuCode = dtl.material_code || ''
|
||||
const house_code = dtl.source_load_port || ''
|
||||
const skuName = dtl.material_name || ''
|
||||
const qty = dtl.plan_qty || ''
|
||||
const assQty = dtl.assign_qty || ''
|
||||
const qrText = orderNo + '#' + itemNo + '#' + skuCode + '#' + skuName + '##' + qty + '#'
|
||||
const imgSrc = await QRCode.toDataURL(qrText, {
|
||||
width: 300
|
||||
})
|
||||
html += '<div class="label">'
|
||||
html += '<h3>上海诺力</h3>'
|
||||
html += '<table>'
|
||||
html += '<tr><td class="lbl">出库单号</td><td class="val">' + orderNo + '</td><td class="qr" rowspan="6"><img src="' + imgSrc + '" width="150" height="150" /></td></tr>'
|
||||
html += '<tr><td class="lbl">行号</td><td class="val">' + itemNo + '</td></tr>'
|
||||
html += '<tr><td class="lbl">物料编码</td><td class="val">' + skuCode + '</td></tr>'
|
||||
html += '<tr><td class="lbl">物料名称</td><td class="val">' + skuName + '</td></tr>'
|
||||
html += '<tr><td class="lbl">计划出库量</td><td class="val">' + qty + '</td></tr>'
|
||||
html += '<tr><td class="lbl">实出库数量</td><td class="val">' + assQty + '</td></tr>'
|
||||
html += '<tr><td class="lbl">用料位置</td><td class="val">' + house_code + '</td></tr>'
|
||||
html += '</table></div>'
|
||||
}
|
||||
html += '</body></html>'
|
||||
doc.open()
|
||||
doc.write(html)
|
||||
doc.close()
|
||||
},
|
||||
buttonChange(current) {
|
||||
if (current !== null) {
|
||||
this.currentRow = current
|
||||
|
||||
Reference in New Issue
Block a user