This commit is contained in:
xielue 2023-12-06 18:00:05 +08:00
parent 2ff447e713
commit bebcd47310
3 changed files with 380 additions and 6 deletions

View File

@ -563,13 +563,15 @@ export default {
preView() {
let hiPrint = this.$hiPrint
let data = require('./data.json')
let templates = data.value
console.log("templates:", templates)
let template = {}
let data = require('./data2.json')
let templates = data
let hiprintTemplate = new hiPrint.PrintTemplate({
template: template,
template: templates
});
//hiprintTemplate.print({});
let {width} = this.curPaper
this.$refs.preView.show(hiprintTemplate, {}, width)
},

View File

@ -0,0 +1,369 @@
{
"panels": [
{
"index": 0,
"name": 1,
"height": 296.6,
"width": 210,
"paperHeader": 82.5,
"paperFooter": 802.5,
"printElements": [
{
"options": {
"left": 165,
"top": 32.5,
"height": 17,
"width": 256.5,
"testData": "单据表头",
"fontSize": 16.5,
"fontWeight": "700",
"textAlign": "center",
"hideTitle": true,
"title": "凤翔模具厂送货单",
"right": 420.75,
"bottom": 48.74609375,
"vCenter": 292.5,
"hCenter": 40.24609375
},
"printElementType": {
"title": "单据表头",
"type": "text"
}
},
{
"options": {
"left": 90,
"top": 55,
"height": 9,
"width": 427.5,
"borderWidth": 0.75,
"right": 516.75,
"bottom": 63.4921875,
"vCenter": 303,
"hCenter": 58.9921875
},
"printElementType": {
"title": "横线",
"type": "hline"
}
},
{
"options": {
"left": 25,
"top": 67.5,
"height": 9.75,
"width": 120,
"title": "客户名称:"
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 165,
"top": 67.5,
"height": 9.75,
"width": 120,
"title": "联系方式:",
"right": 285.4921875,
"bottom": 82.5,
"vCenter": 225.4921875,
"hCenter": 77.625
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 287.5,
"top": 67.5,
"height": 9.75,
"width": 120,
"title": "客户地址:",
"right": 408.24609375,
"bottom": 83.25,
"vCenter": 348.24609375,
"hCenter": 78.375
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 25,
"top": 87.5,
"height": 54,
"width": 546,
"tableFooterRepeat": "last",
"fields": [
{
"text": "商品编号",
"field": "code"
},
{
"text": "商品名称",
"field": "name"
},
{
"text": "规格",
"field": "spec"
},
{
"text": "单位",
"field": "unit"
},
{
"text": "数量",
"field": "out_stock"
},
{
"text": "单价",
"field": "price"
},
{
"text": "金额",
"field": "total_price"
},
{
"text": "备注",
"field": "remark"
}
],
"field": "table",
"tableHeaderRepeat": "page",
"right": 571.24609375,
"bottom": 141.4921875,
"vCenter": 296.24609375,
"hCenter": 114.4921875,
"coordinateSync": false,
"widthHeightSync": false,
"columns": [
[
{
"width": 86.76923076923077,
"title": "商品编号",
"field": "data.product_stock_log.product_detail.code",
"checked": true,
"columnId": "code",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 111.19956476421586,
"title": "商品名称",
"field": "data.product_stock_log.product_detail.name",
"checked": true,
"columnId": "name",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 59.30643454091512,
"title": "规格",
"field": "spec",
"checked": true,
"columnId": "spec",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 73.42011834319527,
"title": "单位",
"field": "unit",
"checked": true,
"columnId": "unit",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 62.12471552116523,
"title": "数量",
"field": "out_stock",
"checked": true,
"columnId": "out_stock",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 52.567066979447496,
"title": "单价",
"field": "price",
"checked": true,
"columnId": "price",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 44.47982590568635,
"title": "金额",
"field": "total_price",
"checked": true,
"columnId": "total_price",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
},
{
"width": 74.13304317614391,
"title": "备注",
"field": "remark",
"checked": true,
"columnId": "remark",
"fixed": false,
"rowspan": 1,
"colspan": 1,
"align": "center"
}
]
]
},
"printElementType": {
"title": "订单数据",
"type": "table",
"editable": true,
"columnDisplayEditable": true,
"columnDisplayIndexEditable": true,
"columnTitleEditable": true,
"columnResizable": true,
"columnAlignEditable": true,
"isEnableEditField": true,
"isEnableContextMenu": true,
"isEnableInsertRow": true,
"isEnableDeleteRow": true,
"isEnableInsertColumn": true,
"isEnableDeleteColumn": true,
"isEnableMergeCell": true
}
},
{
"options": {
"left": 25,
"top": 150,
"height": 9.75,
"width": 235.5,
"title": "地址:潮州市浮洋镇潮汕公路乌洋路段 0768-5223999",
"right": 261.177920254794,
"bottom": 159.9694664695046,
"vCenter": 143.42792025479403,
"hCenter": 155.0944664695046,
"coordinateSync": false,
"widthHeightSync": false,
"qrCodeLevel": 0
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 25,
"top": 167.5,
"height": 22.5,
"width": 544.5,
"title": "凡属本公司送出的塑料壳体请收到即检查验收质量呱后才能使用如有问题请于3天内与本公司联系协高处理否则恕不负责!一经装配,恕不退货",
"right": 567,
"bottom": 190.44673919677734,
"vCenter": 294.75,
"hCenter": 179.19673919677734,
"coordinateSync": false,
"widthHeightSync": false,
"qrCodeLevel": 0
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 25,
"top": 197.5,
"height": 9.75,
"width": 120,
"title": "制单人:吴淑银",
"right": 145.2421875,
"bottom": 207.24609375,
"vCenter": 85.2421875,
"hCenter": 202.37109375,
"coordinateSync": false,
"widthHeightSync": false,
"fontSize": 18,
"qrCodeLevel": 0
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 395,
"top": 197.5,
"height": 9.75,
"width": 120,
"title": "收货人:",
"right": 542.49609375,
"bottom": 204.99609375,
"vCenter": 482.49609375,
"hCenter": 200.12109375,
"coordinateSync": false,
"widthHeightSync": false,
"fontSize": 18,
"qrCodeLevel": 0
},
"printElementType": {
"title": "文本",
"type": "text"
}
},
{
"options": {
"left": 192.5,
"top": 197.5,
"height": 9.75,
"width": 120,
"title": "送货人:",
"right": 294.75,
"bottom": 207,
"vCenter": 234.75,
"hCenter": 202.125,
"coordinateSync": false,
"widthHeightSync": false,
"fontSize": 18,
"qrCodeLevel": 0
},
"printElementType": {
"title": "文本",
"type": "text"
}
}
],
"paperNumberLeft": 555,
"paperNumberTop": 204,
"paperNumberDisabled": true,
"paperNumberContinue": true,
"scale": 1,
"watermarkOptions": {}
}
]
}

View File

@ -55,6 +55,9 @@ export default {
this.width = hiprintTemplate.editingPanel ? hiprintTemplate.editingPanel.width : width;
this.hiprintTemplate = hiprintTemplate
this.printData = printData
//this.hiprintTemplate.print(this.printData);
setTimeout(() => {
// eslint-disable-next-line no-undef
$('#preview_content_custom').html(hiprintTemplate.getHtml(printData))