Browse Source

add 模板打印

master
周俊杰 4 weeks ago
parent
commit
ad380c20ae
  1. 4
      acs/nladmin-ui/package.json
  2. 12
      acs/nladmin-ui/public/config.js
  3. 24
      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", "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",

12
acs/nladmin-ui/public/config.js

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

24
acs/nladmin-ui/src/main.js

@ -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
@ -82,25 +82,25 @@ Vue.use(permission)
Vue.use(dict) Vue.use(dict)
Vue.use(VueBus) Vue.use(VueBus)
Vue.use(hiPrintPlugin) Vue.use(hiPrintPlugin)
// 全局设置控件样式https://codeantenna.com/a/0IN5FMJk5h // 全局设置控件样式https://codeantenna.com/a/0IN5FMJk5h
Element.Table.props.border = { type: Boolean, default: true } Element.Table.props.border = { type: Boolean, default: true }
Element.TableColumn.props.align = { type: String, default: 'center' } Element.TableColumn.props.align = { type: String, default: 'center' }
Vue.use(Element, { Vue.use(Element, {
size: 'mini' // set element-ui default size size: 'mini' // set element-ui default size
}) })
Vue.prototype.$langPre = { Vue.prototype.$langPre = {
computedProp(suffix) { computedProp(suffix) {
return localStorage.getItem('lang') + '_' + suffix return localStorage.getItem('lang') + '_' + suffix
} }
} }
Vue.config.productionTip = false Vue.config.productionTip = false
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
store, store,
i18n, i18n,
render: h => h(App) render: h => h(App)
}) })

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

@ -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

Loading…
Cancel
Save