yh-hiprint 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HiprintDesigner.vue +18 -7
- package/hiprintPreview.vue +30 -4
- package/package.json +1 -1
package/HiprintDesigner.vue
CHANGED
|
@@ -378,6 +378,8 @@ watch(
|
|
|
378
378
|
};
|
|
379
379
|
})
|
|
380
380
|
);
|
|
381
|
+
} else {
|
|
382
|
+
hiprintTemplate.value?.setFields("");
|
|
381
383
|
}
|
|
382
384
|
},
|
|
383
385
|
{
|
|
@@ -492,12 +494,12 @@ function init() {
|
|
|
492
494
|
paginationContainer: ".hiprint-printPagination",
|
|
493
495
|
});
|
|
494
496
|
|
|
495
|
-
hiprintTemplate.value
|
|
497
|
+
hiprintTemplate.value?.design("#hiprint-printTemplate", { grid: true });
|
|
496
498
|
scaleValue.value = hiprintTemplate.value.editingPanel.scale || 1;
|
|
497
499
|
window.ht = hiprintTemplate.value;
|
|
498
500
|
|
|
499
501
|
if (formColumns.value) {
|
|
500
|
-
hiprintTemplate.value
|
|
502
|
+
hiprintTemplate.value?.setFields(
|
|
501
503
|
formColumns.value.map((item) => {
|
|
502
504
|
return {
|
|
503
505
|
field: item,
|
|
@@ -508,7 +510,7 @@ function init() {
|
|
|
508
510
|
}
|
|
509
511
|
$(".hiprint-designer").on("mousedown", ".hiprint-printElement", (e) => {
|
|
510
512
|
let t = e.currentTarget;
|
|
511
|
-
let pes = hiprintTemplate.value
|
|
513
|
+
let pes = hiprintTemplate.value?.editingPanel.printElements;
|
|
512
514
|
let index = pes.map((item) => item.designTarget[0]).indexOf(t);
|
|
513
515
|
let pe = pes[index];
|
|
514
516
|
currentElementObj.value = pe;
|
|
@@ -516,6 +518,15 @@ function init() {
|
|
|
516
518
|
listCode.value = pe.options.field;
|
|
517
519
|
}
|
|
518
520
|
});
|
|
521
|
+
$("#PrintElementOptionSetting").on("input", "input[type=number]", ($el) => {
|
|
522
|
+
let val = parseInt($el.target.value);
|
|
523
|
+
if (val < 1) {
|
|
524
|
+
$el.target.value = 1;
|
|
525
|
+
}
|
|
526
|
+
if (val > 2000) {
|
|
527
|
+
$el.target.value = 2000;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
519
530
|
} catch (error) {
|
|
520
531
|
console.log(error.message);
|
|
521
532
|
clearPrint();
|
|
@@ -536,14 +547,14 @@ async function updateTemplate(code) {
|
|
|
536
547
|
await getDetail(code);
|
|
537
548
|
if (detailData.value && detailData.value.json) {
|
|
538
549
|
let jsonObj = JSON.parse(detailData.value.json);
|
|
539
|
-
hiprintTemplate.value
|
|
550
|
+
hiprintTemplate.value?.update(jsonObj);
|
|
540
551
|
let { width, height } = jsonObj.panels[0];
|
|
541
552
|
paperWidth.value = width;
|
|
542
553
|
paperHeight.value = height;
|
|
543
|
-
hiprintTemplate.value
|
|
554
|
+
hiprintTemplate.value?.setPaper(width, height);
|
|
544
555
|
scaleValue.value = 1;
|
|
545
556
|
} else {
|
|
546
|
-
hiprintTemplate.value
|
|
557
|
+
hiprintTemplate.value?.update({
|
|
547
558
|
panels: [
|
|
548
559
|
{
|
|
549
560
|
index: 0,
|
|
@@ -561,7 +572,7 @@ async function updateTemplate(code) {
|
|
|
561
572
|
});
|
|
562
573
|
paperWidth.value = 210;
|
|
563
574
|
paperHeight.value = 297;
|
|
564
|
-
hiprintTemplate.value
|
|
575
|
+
hiprintTemplate.value?.setPaper(210, 297);
|
|
565
576
|
scaleValue.value = 1;
|
|
566
577
|
}
|
|
567
578
|
} else {
|
package/hiprintPreview.vue
CHANGED
|
@@ -45,9 +45,9 @@ let loading = ElLoading.service({
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
function getData(query) {
|
|
48
|
-
let { code, params } = query;
|
|
48
|
+
let { code, params, data, isCustom } = query;
|
|
49
49
|
loading.setText("获取打印配置和数据");
|
|
50
|
-
let reqParams = JSON.parse(params);
|
|
50
|
+
let reqParams = JSON.parse(params) || [];
|
|
51
51
|
|
|
52
52
|
axios
|
|
53
53
|
.request({
|
|
@@ -56,7 +56,7 @@ function getData(query) {
|
|
|
56
56
|
type: "json",
|
|
57
57
|
data: reqParams,
|
|
58
58
|
})
|
|
59
|
-
.then((res) => {
|
|
59
|
+
.then(async (res) => {
|
|
60
60
|
loading.setText("格式化数据,初始化打印插件");
|
|
61
61
|
let { list, json } = res.data;
|
|
62
62
|
if (json) {
|
|
@@ -64,7 +64,6 @@ function getData(query) {
|
|
|
64
64
|
if (Array.isArray(list) && list.length > 0) {
|
|
65
65
|
list = list.map((item, index) => {
|
|
66
66
|
let printData = {};
|
|
67
|
-
let reqData = reqParams[index];
|
|
68
67
|
let datas = Object.entries(item);
|
|
69
68
|
datas.forEach((arr) => {
|
|
70
69
|
if (Array.isArray(arr[1])) {
|
|
@@ -86,6 +85,33 @@ function getData(query) {
|
|
|
86
85
|
list = [];
|
|
87
86
|
}
|
|
88
87
|
let hiprintTemplate = new hiprint.PrintTemplate({ template: JSON.parse(json) });
|
|
88
|
+
// 如若有本地数据,那么将本地数据替换远端数据。传入预览中。
|
|
89
|
+
if (isCustom === "1") {
|
|
90
|
+
await ElMessageBox.prompt("在下面输入框中输入您给的自定义数据", "自定义数据", {
|
|
91
|
+
inputType: "textarea",
|
|
92
|
+
}).then((e) => {
|
|
93
|
+
try {
|
|
94
|
+
hasData = true;
|
|
95
|
+
list = JSON.parse(e.value);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
try {
|
|
98
|
+
hasData = true;
|
|
99
|
+
list = JSON.parse(data);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
hasData = false;
|
|
102
|
+
list = [];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} else if (data) {
|
|
107
|
+
try {
|
|
108
|
+
hasData = true;
|
|
109
|
+
list = JSON.parse(data);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
hasData = false;
|
|
112
|
+
list = [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
89
115
|
let html = hiprintTemplate.getHtml(list);
|
|
90
116
|
document.body.innerHTML = "";
|
|
91
117
|
document.body.appendChild(html[0]);
|