emis-app/components/tpx-bluetooth-print/tpx-bluetooth-print.vue

83 lines
1.4 KiB
Vue
Raw Normal View History

2024-05-10 14:32:39 +00:00
<template>
2024-05-12 12:49:00 +00:00
<template v-if="type == 'modal'">
<tpx-dialog
v-model:show="show"
@onClose="handleCloseModal"
custom-style="width: 600rpx;padding: 10rpx;"
title="打印"
>
2024-05-13 09:47:19 +00:00
<view style="height: calc(75vh);">
<render-template ref="curPrint"></render-template>
2024-05-12 03:18:44 +00:00
</view>
2024-05-12 12:49:00 +00:00
</tpx-dialog>
</template>
<template v-else>
2024-05-13 09:47:19 +00:00
<template >
<render-template ref="curPrint"></render-template>
2024-05-12 12:49:00 +00:00
</template>
</template>
2024-05-12 03:18:44 +00:00
2024-05-10 14:32:39 +00:00
</template>
<script>
2024-06-07 10:04:39 +00:00
import RenderTemplate from "./render-template"
2024-05-13 09:47:19 +00:00
import { promiseTimeout } from "@/common/untool"
2024-05-12 03:18:44 +00:00
2024-05-10 14:32:39 +00:00
export default {
2024-05-11 05:11:46 +00:00
props:{
2024-05-12 12:49:00 +00:00
type: {
2024-05-11 05:11:46 +00:00
default () {
2024-05-12 12:49:00 +00:00
return 'modal'
2024-05-11 05:11:46 +00:00
}
},
},
2024-05-10 14:32:39 +00:00
computed: {
2024-05-12 12:49:00 +00:00
},
components: {
RenderTemplate, RenderTemplate
2024-05-10 14:32:39 +00:00
},
data () {
return {
2024-05-12 12:49:00 +00:00
imageUrl: '',
paperWidth: 320,
show: false,
2024-05-10 14:32:39 +00:00
}
},
mounted () {
2024-05-12 12:49:00 +00:00
2024-05-10 14:32:39 +00:00
},
unmounted() {
2024-05-12 12:49:00 +00:00
2024-05-10 14:32:39 +00:00
},
methods: {
2024-05-12 12:49:00 +00:00
handleCloseModal(){
this.$emit('update:show', false)
this.$emit('onClose')
2024-05-10 15:33:45 +00:00
},
2024-05-12 12:49:00 +00:00
async startPrint({ imageUrl, paperWidth } = {}) {
if(imageUrl.length > 0) {
if(Array.isArray(imageUrl)){
imageUrl = imageUrl[0]
2024-05-12 03:18:44 +00:00
}
2024-05-12 12:49:00 +00:00
this.imageUrl = imageUrl
this.paperWidth = paperWidth
this.show = true
2024-05-13 09:47:19 +00:00
await promiseTimeout(1000)
let res = await this.$refs.curPrint.callPrint({
imageUrl,
paperWidth
})
2024-05-12 12:49:00 +00:00
} else {
this.showToast('缺少打印内容')
2024-05-10 14:32:39 +00:00
}
}
}
}
</script>
<style scoped lang="scss">
2024-05-12 12:49:00 +00:00
2024-05-10 14:32:39 +00:00
</style>