This commit is contained in:
aihe 2024-08-01 13:52:44 +08:00
parent d7f1639d4a
commit 6c570f06c5
5 changed files with 33 additions and 20 deletions

View File

@ -4,7 +4,7 @@
v-model:show="previewModel.show"
@onClose="handleCloseModal"
custom-style="width: 600rpx;padding: 10rpx;"
title="打印预览"
title="预览"
>
<view style="height: calc(75vh);">
<tpx-layout>
@ -18,7 +18,7 @@
</view>
</template>
<template v-slot:footer>
<view class="blcok-white-noradius">
<view v-if="showPrint" class="blcok-white-noradius">
<u-row>
<u-button @click="confirmPrint" type="primary" size="large" shape="square"
custom-style="height:80rpx;font-size: 30rpx;border-radius: 14rpx;margin: 0 10rpx;">确认打印</u-button>
@ -37,7 +37,11 @@ import { promiseTimeout } from "@/common/untool"
export default {
props:{
showPrint: {
default () {
return false
}
},
},
computed: {
},
@ -66,7 +70,7 @@ export default {
current:index
})
},
async startPrint({ imageUrl } = {}) {
async showPreview({ imageUrl } = {}) {
this.imageUrl = [] // 每次打印前,清空历史数据
// 默认先做预览
if(imageUrl.length > 0) {
@ -77,13 +81,14 @@ export default {
this.previewModel.show = true
}
},
async confirmPrint(){
if(this.imageUrl.length == 0) {
async confirmPrint(imgs){
imgs = imgs || this.imageUrl
if(imgs.length == 0) {
this.showToast('缺少预览内容')
} else {
this.goto(`print/bluetoothPrinter?imageUrl=${this.imageUrl.join(",")}`)
this.goto(`print/bluetoothPrinter?imageUrl=${imgs.join(",")}`)
}
}
},
}
}
</script>

View File

@ -86,6 +86,7 @@ export default {
})
},
async startPrint({ imageUrl, paperWidth } = {}, preview = true) {
this.imageUrl = [] // 每次打印前,清空历史数据
this.allImgRes = []
// 默认先做预览
@ -112,9 +113,11 @@ export default {
url = `${url}?t=${new Date().valueOf()}`
return this.$refs[`curCanvas${index}`][0].renderCanvasImg(url, this.paperWidth)
})
this.showLoading()
return Promise.all(allRes).then((imgsRes)=> {
that.allImgRes = imgsRes
console.log("setAllImgRes len======", imgsRes.length)
that.hideLoading()
return imgsRes
})
},

View File

@ -526,9 +526,7 @@
}
let prtRes = await apiService.getRealGetWaybillPrintData({ ...param, _loading: true })
let imgUrls = prtRes?.data?.map(t=> t.imageUrl) || []
this.$refs.curPrint.startPrint({
imageUrl: imgUrls.filter(v=> !!v),
})
this.$refs.curPrint.confirmPrint(imgUrls.filter(v=> !!v))
this.resetForm()
},
async saveSuccessBack(){

View File

@ -38,6 +38,9 @@
<u-row justify="between" custom-style="padding-top:20rpx;">
<view class="com-section">打印配置</view>
<view style="width: 160rpx;">
<u-button @click="handlePreview" custom-style="height: 60rpx;">预览</u-button>
</view>
</u-row>
<view class="clr-prm mt-20">注意:当打印出来寄件分拨或未端分拨返回为空时,请等待5分钟后再补 打印</view>
@ -118,7 +121,7 @@
<template v-slot:footer>
<view class="blcok-white-noradius">
<u-row>
<u-button @click="handleSubmit()" type="primary" size="large" shape="square"
<u-button @click="handleSubmitPrint()" type="primary" size="large" shape="square"
custom-style="height:80rpx;font-size: 30rpx;border-radius: 14rpx;margin: 0 10rpx;">打印</u-button>
</u-row>
</view>
@ -211,11 +214,9 @@
handleSearch(){
this.triggerListReload()
},
async handleSubmit() {
async handleSubmitPrint() {
const imgUrls = await this.getPrintImages()
this.$refs.curPrint.startPrint({
imageUrl: imgUrls.filter(v=> !!v),
})
this.$refs.curPrint.confirmPrint(imgUrls.filter(v=> !!v))
},
handleSelAll() {
if(this.submitParam.billCode.length == this.resData.list.length) {
@ -238,7 +239,13 @@
let res = await this.getRealGetWaybillPrintData()
const imgUrls = res?.data?.map(t=> t.imageUrl) || []
return imgUrls
}
},
async handlePreview(){
const imgUrls = await this.getPrintImages()
this.$refs.curPrint.showPreview({
imageUrl: imgUrls.filter(v=> !!v)
})
},
}
}
</script>

View File

@ -23,12 +23,12 @@
<view class="mt-40">
<u-row justify="between">
<view style="width: 200rpx;" @click="handleSave">
<view style="flex:1;" @click="handleSave">
<u-button type="primary" custom-style="border-radius: 10rpx;">保存到本地</u-button>
</view>
<view style="width: 200rpx;" @click="handlePrint">
<!-- <view style="width: 200rpx;" @click="handlePrint">
<u-button type="primary" plain="true" custom-style="border-radius: 10rpx;">打印</u-button>
</view>
</view> -->
</u-row>
</view>
</view>