Browse Source

add 模板打印

master
周俊杰 4 weeks ago
parent
commit
ad380c20ae
  1. 4
      acs/nladmin-ui/package.json
  2. 14
      acs/nladmin-ui/public/config.js
  3. 26
      acs/nladmin-ui/src/main.js
  4. 55
      acs/nladmin-ui/src/views/acs/order/template.vue

4
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",

14
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'
}
}
}

26
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)
})

55
acs/nladmin-ui/src/views/acs/order/template.vue

@ -66,7 +66,12 @@
:value="item.template_id"
/>
</el-select>
<el-select
<el-input
v-model="template_number"
style="width: 200px;"
placeholder="请输入需要打印的份数"
/>
<!-- <el-select
v-model="ticketId"
filterable
placeholder="请选择模板需要关联的工单"
@ -79,10 +84,11 @@
:label="item.ticket_code"
:value="item.ticket_code"
/>
</el-select>
</el-select> -->
</div>
<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="PreviewData"> 导出</el-button>
<el-button type="primary" @click="addTable"> 保存</el-button>
@ -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

Loading…
Cancel
Save