add 模板打印
This commit is contained in:
@@ -67,6 +67,7 @@
|
|||||||
"path-to-regexp": "2.4.0",
|
"path-to-regexp": "2.4.0",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
"qrcode-generator": "^1.4.4",
|
"qrcode-generator": "^1.4.4",
|
||||||
|
"qrcode-vue": "^1.2.0",
|
||||||
"qrcode.vue": "^3.4.1",
|
"qrcode.vue": "^3.4.1",
|
||||||
"qrcodejs2": "0.0.2",
|
"qrcodejs2": "0.0.2",
|
||||||
"qs": "^6.9.1",
|
"qs": "^6.9.1",
|
||||||
@@ -139,7 +140,8 @@
|
|||||||
"svg-sprite-loader": "4.1.3",
|
"svg-sprite-loader": "4.1.3",
|
||||||
"svgo": "1.2.0",
|
"svgo": "1.2.0",
|
||||||
"vue-particles": "^1.0.9",
|
"vue-particles": "^1.0.9",
|
||||||
"vue-template-compiler": "2.6.10"
|
"vue-template-compiler": "2.6.10",
|
||||||
|
"webpack": "^4.47.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.9",
|
"node": ">=8.9",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
window.g = {
|
window.g = {
|
||||||
dev: {
|
dev: {
|
||||||
VUE_APP_BASE_API: 'http://127.0.0.1:8011'
|
VUE_APP_BASE_API: 'http://192.168.2.100:8011'
|
||||||
},
|
},
|
||||||
prod: {
|
prod: {
|
||||||
VUE_APP_BASE_API: 'http://10.1.3.96:8011'
|
VUE_APP_BASE_API: 'http://192.168.2.100:8011'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,8 +41,8 @@ import LogicFlow from '@logicflow/core'
|
|||||||
import { Menu } from '@logicflow/extension'
|
import { Menu } from '@logicflow/extension'
|
||||||
|
|
||||||
import { hiPrintPlugin } from 'vue-plugin-hiprint'
|
import { hiPrintPlugin } from 'vue-plugin-hiprint'
|
||||||
// 关闭客户端连接
|
// // 关闭客户端连接
|
||||||
hiPrintPlugin.disAutoConnect()
|
// hiPrintPlugin.disAutoConnect()
|
||||||
import '@logicflow/extension/lib/style/index.css'
|
import '@logicflow/extension/lib/style/index.css'
|
||||||
|
|
||||||
// Form Generator 组件需要使用到 tinymce
|
// Form Generator 组件需要使用到 tinymce
|
||||||
|
|||||||
@@ -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 数据
|
||||||
|
|||||||
Reference in New Issue
Block a user