From ad380c20aed59e80db8d7cfbe4701e835a8f6d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E4=BF=8A=E6=9D=B0?= <9463626+zhou-junjiezjj@user.noreply.gitee.com> Date: Tue, 29 Oct 2024 16:56:39 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=A8=A1=E6=9D=BF=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- acs/nladmin-ui/package.json | 4 +- acs/nladmin-ui/public/config.js | 14 ++--- acs/nladmin-ui/src/main.js | 26 ++++----- .../src/views/acs/order/template.vue | 55 +++++++++++++++---- 4 files changed, 67 insertions(+), 32 deletions(-) diff --git a/acs/nladmin-ui/package.json b/acs/nladmin-ui/package.json index 5381695..1a85025 100644 --- a/acs/nladmin-ui/package.json +++ b/acs/nladmin-ui/package.json @@ -67,6 +67,7 @@ "path-to-regexp": "2.4.0", "qrcode": "^1.5.3", "qrcode-generator": "^1.4.4", + "qrcode-vue": "^1.2.0", "qrcode.vue": "^3.4.1", "qrcodejs2": "0.0.2", "qs": "^6.9.1", @@ -139,7 +140,8 @@ "svg-sprite-loader": "4.1.3", "svgo": "1.2.0", "vue-particles": "^1.0.9", - "vue-template-compiler": "2.6.10" + "vue-template-compiler": "2.6.10", + "webpack": "^4.47.0" }, "engines": { "node": ">=8.9", diff --git a/acs/nladmin-ui/public/config.js b/acs/nladmin-ui/public/config.js index 4f59769..ec99d20 100644 --- a/acs/nladmin-ui/public/config.js +++ b/acs/nladmin-ui/public/config.js @@ -1,9 +1,9 @@ window.g = { - dev: { - VUE_APP_BASE_API: 'http://127.0.0.1:8011' - }, - prod: { - VUE_APP_BASE_API: 'http://10.1.3.96:8011' - } + dev: { + VUE_APP_BASE_API: 'http://192.168.2.100:8011' + }, + prod: { + VUE_APP_BASE_API: 'http://192.168.2.100:8011' + } -} +} \ No newline at end of file diff --git a/acs/nladmin-ui/src/main.js b/acs/nladmin-ui/src/main.js index debc19c..dc010b3 100644 --- a/acs/nladmin-ui/src/main.js +++ b/acs/nladmin-ui/src/main.js @@ -41,8 +41,8 @@ import LogicFlow from '@logicflow/core' import { Menu } from '@logicflow/extension' import { hiPrintPlugin } from 'vue-plugin-hiprint' -// 关闭客户端连接 -hiPrintPlugin.disAutoConnect() +// // 关闭客户端连接 +// hiPrintPlugin.disAutoConnect() import '@logicflow/extension/lib/style/index.css' // Form Generator 组件需要使用到 tinymce @@ -82,25 +82,25 @@ Vue.use(permission) Vue.use(dict) Vue.use(VueBus) Vue.use(hiPrintPlugin) -// 全局设置控件样式https://codeantenna.com/a/0IN5FMJk5h + // 全局设置控件样式https://codeantenna.com/a/0IN5FMJk5h Element.Table.props.border = { type: Boolean, default: true } Element.TableColumn.props.align = { type: String, default: 'center' } Vue.use(Element, { - size: 'mini' // set element-ui default size + size: 'mini' // set element-ui default size }) Vue.prototype.$langPre = { - computedProp(suffix) { - return localStorage.getItem('lang') + '_' + suffix - } + computedProp(suffix) { + return localStorage.getItem('lang') + '_' + suffix + } } Vue.config.productionTip = false new Vue({ - el: '#app', - router, - store, - i18n, - render: h => h(App) -}) + el: '#app', + router, + store, + i18n, + render: h => h(App) +}) \ No newline at end of file diff --git a/acs/nladmin-ui/src/views/acs/order/template.vue b/acs/nladmin-ui/src/views/acs/order/template.vue index e41829e..64e85e2 100644 --- a/acs/nladmin-ui/src/views/acs/order/template.vue +++ b/acs/nladmin-ui/src/views/acs/order/template.vue @@ -66,7 +66,12 @@ :value="item.template_id" /> - + 浏览器打印 + 直接打印 预览 导出 保存 @@ -273,6 +279,8 @@ export default { components: { Preview }, data() { return { + template_number:'', + printDataList: [], previewShow: false, radio1:null, ticketList: [], @@ -420,7 +428,6 @@ export default { */ setPaper(type) { try { - // debugger if (Object.keys(this.paperTypes).includes(type)) { // this.curPaper = {type: type, width: value.width, height: value.height} const value = this.paperTypes[type] @@ -455,23 +462,49 @@ export default { // 调用浏览器打印 if (this.hiprintTemplate) { console.log('准备打印,参数:', { printData, options, ext }) - debugger this.hiprintTemplate.print(printData, options, ext) } }, + /** * 直接打印: 借助客户端,静默打印(无弹窗直接打印) * 注意: 需要先连接客户端 */ print2() { - if (hiprint.hiwebSocket && hiprint.hiwebSocket.opened) { - if (this.hiprintTemplate) { - this.hiprintTemplate.print2({}) - } - } else { - alert('请先连接客户端(刷新网页), 然后再点击「直接打印」') - } +let jsonString=JSON.stringify(this.hiprintTemplate.getJson() || {}) +// 1. 解析 JSON 字符串为 JavaScript 对象 +let jsonObject = JSON.parse(jsonString); + +let testDataValue = parseInt(jsonObject.panels[0].printElements[0].options.testData, 10); +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() { this.hiprintTemplate.toPdf('', '').then((tempPrintResults) => { // 处理生成的 PDF 数据