83 lines
1.4 KiB
Vue
83 lines
1.4 KiB
Vue
<template>
|
|
<template v-if="type == 'modal'">
|
|
<tpx-dialog
|
|
v-model:show="show"
|
|
@onClose="handleCloseModal"
|
|
custom-style="width: 600rpx;padding: 10rpx;"
|
|
title="打印"
|
|
>
|
|
<view style="height: calc(75vh);">
|
|
<render-template ref="curPrint"></render-template>
|
|
</view>
|
|
</tpx-dialog>
|
|
|
|
</template>
|
|
<template v-else>
|
|
<template >
|
|
<render-template ref="curPrint"></render-template>
|
|
</template>
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import RenderTemplate from "./render-template"
|
|
import { promiseTimeout } from "@/common/untool"
|
|
|
|
export default {
|
|
props:{
|
|
type: {
|
|
default () {
|
|
return 'modal'
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
|
|
},
|
|
components: {
|
|
RenderTemplate, RenderTemplate
|
|
},
|
|
data () {
|
|
return {
|
|
imageUrl: '',
|
|
paperWidth: 320,
|
|
show: false,
|
|
}
|
|
},
|
|
mounted () {
|
|
|
|
},
|
|
unmounted() {
|
|
|
|
},
|
|
methods: {
|
|
handleCloseModal(){
|
|
this.$emit('update:show', false)
|
|
this.$emit('onClose')
|
|
},
|
|
async startPrint({ imageUrl, paperWidth } = {}) {
|
|
if(imageUrl.length > 0) {
|
|
if(Array.isArray(imageUrl)){
|
|
imageUrl = imageUrl[0]
|
|
}
|
|
this.imageUrl = imageUrl
|
|
this.paperWidth = paperWidth
|
|
this.show = true
|
|
await promiseTimeout(1000)
|
|
let res = await this.$refs.curPrint.callPrint({
|
|
imageUrl,
|
|
paperWidth
|
|
})
|
|
} else {
|
|
this.showToast('缺少打印内容')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
</style> |