add:添加socket打印
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
/>
|
||||
<el-button slot="reference">自定义纸张1</el-button>
|
||||
</el-popover>
|
||||
<!--
|
||||
<!--
|
||||
<el-select
|
||||
v-model="templateId"
|
||||
filterable
|
||||
@@ -269,6 +269,7 @@ import $ from 'jquery'
|
||||
import { hiprint, defaultElementTypeProvider } from 'vue-plugin-hiprint'
|
||||
import template from '@/api/acs/order/template'
|
||||
import Preview from '@/views/acs/order/preview.vue'
|
||||
import uuidv1 from 'uuid/v1'
|
||||
|
||||
// 初始化 provider
|
||||
hiprint.init({
|
||||
@@ -349,14 +350,29 @@ export default {
|
||||
})
|
||||
},
|
||||
created() {
|
||||
template.getTemplateList().then(data => {
|
||||
this.templateList = data
|
||||
})
|
||||
template.getTicketList().then(data => {
|
||||
this.ticketList = data
|
||||
template.getTemplateList().then(data => {
|
||||
this.templateList = data
|
||||
})
|
||||
template.getTicketList().then(data => {
|
||||
this.ticketList = data
|
||||
})
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
this.$notify({
|
||||
title: '提示',
|
||||
message: '当前浏览器无法接收实时打印信息,请使用谷歌浏览器!',
|
||||
type: 'warning',
|
||||
duration: 0
|
||||
})
|
||||
}
|
||||
const wsUri = window.g.prod.VUE_APP_BASE_API.replace('http', 'ws') + '/webSocket/sendPrint/' + uuidv1()
|
||||
this.websock = new WebSocket(wsUri)
|
||||
this.websock.onmessage = this.webSocketOnMessage
|
||||
},
|
||||
methods: {
|
||||
webSocketOnMessage(e) {
|
||||
console.log('-----获取到消息------')
|
||||
console.log(e)
|
||||
},
|
||||
addTable() {
|
||||
this.formDias = true
|
||||
this.isDisabled = false
|
||||
@@ -410,7 +426,7 @@ export default {
|
||||
template.see(this.templateId).then(res => {
|
||||
try {
|
||||
this.hiprintTemplate.update(JSON.parse(res.template))
|
||||
} catch (e) {
|
||||
} catch (e) {
|
||||
this.$message.error(`更新失败: ${e}`)
|
||||
}
|
||||
})
|
||||
@@ -490,7 +506,7 @@ this.hiprintTemplate.print2(this.printData1);
|
||||
// if (hiprint.hiwebSocket && hiprint.hiwebSocket.opened) {
|
||||
// // let printData1 = {name:'名称1'};
|
||||
// // let printData2 = {name:'名称2'};
|
||||
// const count = Number(this.template_number);
|
||||
// const count = Number(this.template_number);
|
||||
// for (let i = 0; i < count; i++) {
|
||||
// let i={name:i};
|
||||
// this.printDataList.push(i);
|
||||
@@ -504,7 +520,7 @@ this.hiprintTemplate.print2(this.printData1);
|
||||
// alert('请先连接客户端(刷新网页), 然后再点击「直接打印」')
|
||||
// }
|
||||
},
|
||||
|
||||
|
||||
PreviewData() {
|
||||
this.hiprintTemplate.toPdf('', '').then((tempPrintResults) => {
|
||||
// 处理生成的 PDF 数据
|
||||
|
||||
Reference in New Issue
Block a user