|
@ -66,7 +66,12 @@ |
|
|
:value="item.template_id" |
|
|
:value="item.template_id" |
|
|
/> |
|
|
/> |
|
|
</el-select> |
|
|
</el-select> |
|
|
<el-select |
|
|
<el-input |
|
|
|
|
|
v-model="template_number" |
|
|
|
|
|
style="width: 200px;" |
|
|
|
|
|
placeholder="请输入需要打印的份数" |
|
|
|
|
|
/> |
|
|
|
|
|
<!-- <el-select |
|
|
v-model="ticketId" |
|
|
v-model="ticketId" |
|
|
filterable |
|
|
filterable |
|
|
placeholder="请选择模板需要关联的工单" |
|
|
placeholder="请选择模板需要关联的工单" |
|
@ -79,10 +84,11 @@ |
|
|
:label="item.ticket_code" |
|
|
:label="item.ticket_code" |
|
|
:value="item.ticket_code" |
|
|
:value="item.ticket_code" |
|
|
/> |
|
|
/> |
|
|
</el-select> |
|
|
</el-select> --> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<el-button type="primary" icon="el-icon-printer" @click="print"> 浏览器打印</el-button> |
|
|
<el-button type="primary" icon="el-icon-printer" @click="print"> 浏览器打印</el-button> |
|
|
|
|
|
<el-button type="primary" icon="el-icon-printer" @click="print2"> 直接打印</el-button> |
|
|
<el-button type="primary" @click="preview"> 预览</el-button> |
|
|
<el-button type="primary" @click="preview"> 预览</el-button> |
|
|
<el-button type="primary" @click="PreviewData"> 导出</el-button> |
|
|
<el-button type="primary" @click="PreviewData"> 导出</el-button> |
|
|
<el-button type="primary" @click="addTable"> 保存</el-button> |
|
|
<el-button type="primary" @click="addTable"> 保存</el-button> |
|
@ -273,6 +279,8 @@ export default { |
|
|
components: { Preview }, |
|
|
components: { Preview }, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
|
|
|
template_number:'', |
|
|
|
|
|
printDataList: [], |
|
|
previewShow: false, |
|
|
previewShow: false, |
|
|
radio1:null, |
|
|
radio1:null, |
|
|
ticketList: [], |
|
|
ticketList: [], |
|
@ -420,7 +428,6 @@ export default { |
|
|
*/ |
|
|
*/ |
|
|
setPaper(type) { |
|
|
setPaper(type) { |
|
|
try { |
|
|
try { |
|
|
// debugger |
|
|
|
|
|
if (Object.keys(this.paperTypes).includes(type)) { |
|
|
if (Object.keys(this.paperTypes).includes(type)) { |
|
|
// this.curPaper = {type: type, width: value.width, height: value.height} |
|
|
// this.curPaper = {type: type, width: value.width, height: value.height} |
|
|
const value = this.paperTypes[type] |
|
|
const value = this.paperTypes[type] |
|
@ -455,23 +462,49 @@ export default { |
|
|
// 调用浏览器打印 |
|
|
// 调用浏览器打印 |
|
|
if (this.hiprintTemplate) { |
|
|
if (this.hiprintTemplate) { |
|
|
console.log('准备打印,参数:', { printData, options, ext }) |
|
|
console.log('准备打印,参数:', { printData, options, ext }) |
|
|
debugger |
|
|
|
|
|
this.hiprintTemplate.print(printData, options, ext) |
|
|
this.hiprintTemplate.print(printData, options, ext) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 直接打印: 借助客户端,静默打印(无弹窗直接打印) |
|
|
* 直接打印: 借助客户端,静默打印(无弹窗直接打印) |
|
|
* 注意: 需要先连接客户端 |
|
|
* 注意: 需要先连接客户端 |
|
|
*/ |
|
|
*/ |
|
|
print2() { |
|
|
print2() { |
|
|
if (hiprint.hiwebSocket && hiprint.hiwebSocket.opened) { |
|
|
let jsonString=JSON.stringify(this.hiprintTemplate.getJson() || {}) |
|
|
if (this.hiprintTemplate) { |
|
|
// 1. 解析 JSON 字符串为 JavaScript 对象 |
|
|
this.hiprintTemplate.print2({}) |
|
|
let jsonObject = JSON.parse(jsonString); |
|
|
} |
|
|
|
|
|
} else { |
|
|
let testDataValue = parseInt(jsonObject.panels[0].printElements[0].options.testData, 10); |
|
|
alert('请先连接客户端(刷新网页), 然后再点击「直接打印」') |
|
|
jsonObject.panels[0].printElements[0].options.testData = testDataValue + 1; |
|
|
} |
|
|
jsonObject.panels[0].printElements[0].options.testData = jsonObject.panels[0].printElements[0].options.testData.toString(); |
|
|
|
|
|
// 3. 转换回 JSON 字符串 |
|
|
|
|
|
let updatedJsonString = JSON.stringify(jsonObject); |
|
|
|
|
|
this.hiprintTemplate.update(JSON.parse(updatedJsonString)) |
|
|
|
|
|
let printData1 = {name:'名称1'}; |
|
|
|
|
|
this.hiprintTemplate.print2(this.printData1); |
|
|
|
|
|
// this.hiprintTemplate.print2(printData); |
|
|
|
|
|
// console.log('打印份数为',this.template_number); |
|
|
|
|
|
const printerList = this.hiprintTemplate.getPrinterList() |
|
|
|
|
|
console.info('打印机列表', printerList) |
|
|
|
|
|
// if (hiprint.hiwebSocket && hiprint.hiwebSocket.opened) { |
|
|
|
|
|
// // let printData1 = {name:'名称1'}; |
|
|
|
|
|
// // let printData2 = {name:'名称2'}; |
|
|
|
|
|
// const count = Number(this.template_number); |
|
|
|
|
|
// for (let i = 0; i < count; i++) { |
|
|
|
|
|
// let i={name:i}; |
|
|
|
|
|
// this.printDataList.push(i); |
|
|
|
|
|
// } |
|
|
|
|
|
// if (this.hiprintTemplate) { |
|
|
|
|
|
// // this.hiprintTemplate.print2([printData1,printData2]); |
|
|
|
|
|
// this.hiprintTemplate.print2(this.printDataList); |
|
|
|
|
|
// } |
|
|
|
|
|
// } else { |
|
|
|
|
|
// hiprint.hiwebSocket.setHost("http://192.168.81.182:17521") |
|
|
|
|
|
// alert('请先连接客户端(刷新网页), 然后再点击「直接打印」') |
|
|
|
|
|
// } |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
PreviewData() { |
|
|
PreviewData() { |
|
|
this.hiprintTemplate.toPdf('', '').then((tempPrintResults) => { |
|
|
this.hiprintTemplate.toPdf('', '').then((tempPrintResults) => { |
|
|
// 处理生成的 PDF 数据 |
|
|
// 处理生成的 PDF 数据 |
|
|