This commit is contained in:
aihe 2024-07-25 01:32:26 +08:00
parent 3ca83e0f15
commit 0814c5b7fc
4 changed files with 112 additions and 8 deletions

View File

@ -0,0 +1,93 @@
<template>
<!-- 打印预览 -->
<tpx-dialog
v-model:show="previewModel.show"
@onClose="handleCloseModal"
custom-style="width: 600rpx;padding: 10rpx;"
title="打印预览"
>
<view style="height: calc(75vh);">
<tpx-layout>
<template v-slot:header></template>
<template v-slot:body>
<view v-for="(imgUrl, index) in imageUrl" class="mb-20">
<!-- canvas绘图后再显示预览图 -->
<u-row justify="center" @click="handlePreview(index)">
<image :src="imgUrl" mode="widthFix" style="max-width: 100%;"></image>
</u-row>
</view>
</template>
<template v-slot:footer>
<view 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>
</u-row>
</view>
</template>
</tpx-layout>
</view>
</tpx-dialog>
</template>
<script>
import { promiseTimeout } from "@/common/untool"
export default {
props:{
},
computed: {
},
components: {
},
data () {
return {
previewModel: { show: false },
imageUrl: []
}
},
mounted () {
// Test
// this.startPrint({ imageUrl: 'https://image-c.weimobwmc.com/ol-6NoX9/ed4f6d5da41f4606811aa8018e2918da.jpg', paperWidth: this.paperWidth })
},
unmounted() {
},
methods: {
handleCloseModal(){
},
handlePreview(index){
uni.previewImage({
urls: this.imageUrl,
current:index
})
},
async startPrint({ imageUrl } = {}) {
this.imageUrl = [] // 每次打印前,清空历史数据
// 默认先做预览
if(imageUrl.length > 0) {
if(!Array.isArray(imageUrl)){
imageUrl = [imageUrl]
}
this.imageUrl = imageUrl
this.previewModel.show = true
}
},
async confirmPrint(){
if(this.imageUrl.length == 0) {
this.showToast('缺少预览内容')
} else {
this.goto(`print/bluetoothPrinter?imageUrl=${this.imageUrl.join(",")}`)
}
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -285,7 +285,7 @@
</buns-edit-sheet>
<tpx-bluetooth-print ref="curPrint"></tpx-bluetooth-print>
<tpx-bluetooth-print-preview ref="curPrint"></tpx-bluetooth-print-preview>
</tpx-page>
</template>
@ -299,6 +299,7 @@
import BpeGoodphotoTmp from "@/components/buns-post-edit-templates/bpe-goodphoto-tmp"
import BpeGoodKuaidiTmp from "@/components/buns-post-edit-templates/bpe-good-kuaidi-tmp"
import BpeGoodsizeTmp from "@/components/buns-post-edit-templates/bpe-goodsize-tmp"
import TpxBluetoothPrintPreview from "@/components/tpx-bluetooth-print/tpx-bluetooth-print-preview"
import { debounce } from "@/common/util"
import * as apiService from "@/common/api"
import { getOrderModels } from "./model"
@ -308,7 +309,7 @@
}
export default {
components: { BpeAddressinfoTmp, BpeGoodstaticTmp, BpeCostTmp, BpeGooditemEditTmp, BpeGoodphotoTmp, BpeGoodKuaidiTmp, BpeGoodsizeTmp },
components: { BpeAddressinfoTmp, BpeGoodstaticTmp, BpeCostTmp, BpeGooditemEditTmp, BpeGoodphotoTmp, BpeGoodKuaidiTmp, BpeGoodsizeTmp, TpxBluetoothPrintPreview },
props: {
// hasLeftWin: {
// type: Boolean

View File

@ -1,8 +1,6 @@
<template>
<tpx-page>
<tpx-bluetooth-print show="!pageLoading"
:imageUrl="queryOption.imageUrl"
></tpx-bluetooth-print>
<tpx-bluetooth-print ref="curPrint"></tpx-bluetooth-print>
</tpx-page>
</template>
@ -22,18 +20,26 @@ export default {
}
},
mounted () {
// 保证ref节点加载
this.initData();
},
unmounted() {
},
onLoad(option) {
this.queryOption = option
this.initData();
},
methods: {
initData(){
let urls = this.queryOption?.imageUrl?.split(",")
this.pageLoading = false
if(urls?.length > 0) {
this.$refs.curPrint.startPrint({
imageUrl: urls,
}, false)
} else {
this.showToast('缺少打印内容')
}
},
}
}

View File

@ -124,7 +124,7 @@
</view>
</template>
</tpx-layout>
<tpx-bluetooth-print ref="curPrint"></tpx-bluetooth-print>
<tpx-bluetooth-print-preview ref="curPrint"></tpx-bluetooth-print-preview>
</tpx-page>
</template>
@ -133,7 +133,11 @@
import dayjs from "dayjs"
import * as apiService from "@/common/api"
import { checkParams } from "@/common/validate"
import TpxBluetoothPrintPreview from "@/components/tpx-bluetooth-print/tpx-bluetooth-print-preview"
export default {
components: {
TpxBluetoothPrintPreview,
},
props: {
// hasLeftWin: {
// type: Boolean