Commit b76fee56 authored by zhoutong's avatar zhoutong

打印封箱标签

parent 24ab40d9
...@@ -121,18 +121,26 @@ ...@@ -121,18 +121,26 @@
<el-button size="small" type="primary" @click="sealBoxdialogVisible = false">{{ $t('取消') }}</el-button> <el-button size="small" type="primary" @click="sealBoxdialogVisible = false">{{ $t('取消') }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 打印标签 -->
<el-dialog :title="$t('集运封箱标签')" :visible.sync="printdialogVisible" width="300px" :modal-append-to-body="false" append-to-body>
<print-tag v-if="printdialogVisible" :tagData="tagData" />
</el-dialog>
</el-row> </el-row>
</div> </div>
</template> </template>
<script> <script>
import { getPkgPageByPkgId, deleteRelate, deleteBatchRelate, getMergePkgInfoById, updateMergePkg } from '@/api/ecw/boxAir' import { getPkgPageByPkgId, deleteRelate, deleteBatchRelate, getMergePkgInfoById, updateMergePkg, getMergeTagById } from '@/api/ecw/boxAir'
import { formatDate, serviceMsg } from '../../utils' import { formatDate, serviceMsg } from '../../utils'
import printTag from './printTag.vue'
export default { export default {
props: { props: {
pkgData: Object, pkgData: Object,
shipmentObj: Object, shipmentObj: Object,
}, },
components: {
printTag
},
data() { data() {
return { return {
pagList: [], pagList: [],
...@@ -145,7 +153,9 @@ export default { ...@@ -145,7 +153,9 @@ export default {
// 勾选行 // 勾选行
selectedRows: [], selectedRows: [],
sealBoxdialogVisible: false, sealBoxdialogVisible: false,
sealBoxForm: {} sealBoxForm: {},
printdialogVisible: false,
tagData: {}
} }
}, },
created() { created() {
...@@ -231,7 +241,10 @@ export default { ...@@ -231,7 +241,10 @@ export default {
cancelButtonText: this.$t('稍后再试'), cancelButtonText: this.$t('稍后再试'),
}) })
.then((_) => { .then((_) => {
getMergeTagById(this.pkgData.id).then(res=>{
this.tagData = res.data
this.printdialogVisible = true
})
}) })
.catch((_) => { .catch((_) => {
this.$emit('closeDialog'); this.$emit('closeDialog');
......
<template> <template>
<div>
<div class="tag"> <div class="tag">
<div style="display: flex;height: 200px;"> <div style="display: flex;height: 200px;">
<div style="border-right: 1px solid #999; width: 125px"> <div style="border-right: 1px solid #999; width: 125px">
...@@ -48,15 +49,52 @@ ...@@ -48,15 +49,52 @@
</p> </p>
</div> </div>
</div> </div>
<div style="text-align:center;">
<el-button type="primary" @click="print">{{$t('确定打印')}}</el-button>
</div>
</div>
</template> </template>
<script> <script>
import lodop from '@/utils/lodop'
export default { export default {
props: { props: {
tagData: Object tagData: Object
}, },
created() { methods: {
console.log(this.tagData, 'tagData') print(){
let items = document.getElementsByClassName('tag')
if(!items.length){
return this.$message.error(this.$t('没有可打印的内容'))
}
if(items.length > 1000){
this.$alert(this.$t('标签超过1000需要耐心等候标签生成,请稍候'))
}
lodop().then(LODOP => {
LODOP.PRINT_INIT(this.title);
LODOP.SET_PRINT_STYLE("FontSize",18);
LODOP.SET_PRINT_STYLE("Bold",1);
// LODOP.ADD_PRINT_TEXT(50,231,260,39,"打印页面部分内容");
LODOP.SET_PRINT_PAGESIZE(0, 800, 600, "TAG");
for(let i in items){
LODOP.ADD_PRINT_HTM("2mm",0,800,600, items[i].innerHTML);
if(i < items.length){
LODOP.NewPage()
}
}
LODOP.PREVIEW();
// // 预览
/* LODOP.PRINTA(); // 选择打印机
// 直接打印 */
console.log('打印哦')
}).catch(err => {
console.error('lodop异常', err)
// alert('请检查LODOP打印控件是否安装并启动');
})
}
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment