yh-hiprint 2.6.13 → 2.6.15
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 +670 -687
- package/config.json +399 -0
- package/doc.md +265 -0
- package/hiprintPreview.vue +132 -133
- package/hooks/useHipirntCanvas.ts +3 -0
- package/hooks/{useHiprint.js → useHiprint.ts} +115 -53
- package/hooks/useHiprintep.ts +0 -0
- package/index.ts +539 -0
- package/libs/index.js +2 -2
- package/libs/previewHiprint.ts +55 -0
- package/package.json +10 -4
- package/store/defaultPrintElement.ts +175 -0
- package/store/useHiprintStore.ts +92 -0
- package/types.ts +756 -0
- package/index.d.ts +0 -377
- package/index.js +0 -376
package/HiprintDesigner.vue
CHANGED
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
<el-col :span="8">
|
|
248
248
|
<a
|
|
249
249
|
class="ep-draggable-item"
|
|
250
|
-
tid="
|
|
250
|
+
tid="text">
|
|
251
251
|
<i class="iconfont icon-font-size"></i>
|
|
252
252
|
<span>文本</span>
|
|
253
253
|
</a>
|
|
@@ -255,7 +255,7 @@
|
|
|
255
255
|
<el-col :span="8">
|
|
256
256
|
<a
|
|
257
257
|
class="ep-draggable-item"
|
|
258
|
-
tid="
|
|
258
|
+
tid="textVal">
|
|
259
259
|
<i class="iconfont icon-font-size"></i>
|
|
260
260
|
<span>值(文本)</span>
|
|
261
261
|
</a>
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
<el-col :span="8">
|
|
264
264
|
<a
|
|
265
265
|
class="ep-draggable-item"
|
|
266
|
-
tid="
|
|
266
|
+
tid="image">
|
|
267
267
|
<i class="iconfont icon-image-fill"></i>
|
|
268
268
|
<span>图片</span>
|
|
269
269
|
</a>
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
<el-col :span="8">
|
|
272
272
|
<a
|
|
273
273
|
class="ep-draggable-item"
|
|
274
|
-
tid="
|
|
274
|
+
tid="longText">
|
|
275
275
|
<i class="iconfont icon-file-text"></i>
|
|
276
276
|
<span>长文本</span>
|
|
277
277
|
</a>
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
<el-col :span="8">
|
|
280
280
|
<a
|
|
281
281
|
class="ep-draggable-item"
|
|
282
|
-
tid="
|
|
282
|
+
tid="table">
|
|
283
283
|
<i class="iconfont icon-table"></i>
|
|
284
284
|
<span>表格</span>
|
|
285
285
|
</a>
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
<el-col :span="8">
|
|
288
288
|
<a
|
|
289
289
|
class="ep-draggable-item"
|
|
290
|
-
tid="
|
|
290
|
+
tid="emptyTable">
|
|
291
291
|
<i class="iconfont icon-layout"></i>
|
|
292
292
|
<span>空白表格</span>
|
|
293
293
|
</a>
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
<el-col :span="8">
|
|
296
296
|
<a
|
|
297
297
|
class="ep-draggable-item"
|
|
298
|
-
tid="
|
|
298
|
+
tid="html">
|
|
299
299
|
<i class="iconfont icon-HTML"></i>
|
|
300
300
|
<span>html</span>
|
|
301
301
|
</a>
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
<el-col :span="8">
|
|
304
304
|
<a
|
|
305
305
|
class="ep-draggable-item"
|
|
306
|
-
tid="
|
|
306
|
+
tid="customText">
|
|
307
307
|
<i class="iconfont icon-container-fill"></i>
|
|
308
308
|
<span>自定义文本</span>
|
|
309
309
|
</a>
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
<el-col :span="8">
|
|
312
312
|
<a
|
|
313
313
|
class="ep-draggable-item"
|
|
314
|
-
tid="
|
|
314
|
+
tid="barcode">
|
|
315
315
|
<i class="iconfont icon-barcode"></i>
|
|
316
316
|
<span>条形码</span>
|
|
317
317
|
</a>
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
<el-col :span="8">
|
|
320
320
|
<a
|
|
321
321
|
class="ep-draggable-item"
|
|
322
|
-
tid="
|
|
322
|
+
tid="qrcode">
|
|
323
323
|
<i class="iconfont icon-qrcode"></i>
|
|
324
324
|
<span>二维码</span>
|
|
325
325
|
</a>
|
|
@@ -330,7 +330,7 @@
|
|
|
330
330
|
<el-col :span="8">
|
|
331
331
|
<a
|
|
332
332
|
class="ep-draggable-item"
|
|
333
|
-
tid="
|
|
333
|
+
tid="hline">
|
|
334
334
|
<i class="iconfont icon-border-verticle"></i>
|
|
335
335
|
<span>横线</span>
|
|
336
336
|
</a>
|
|
@@ -338,7 +338,7 @@
|
|
|
338
338
|
<el-col :span="8">
|
|
339
339
|
<a
|
|
340
340
|
class="ep-draggable-item"
|
|
341
|
-
tid="
|
|
341
|
+
tid="vline">
|
|
342
342
|
<i class="iconfont icon-border-horizontal"></i>
|
|
343
343
|
<span>竖线</span>
|
|
344
344
|
</a>
|
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
<el-col :span="8">
|
|
347
347
|
<a
|
|
348
348
|
class="ep-draggable-item"
|
|
349
|
-
tid="
|
|
349
|
+
tid="rect">
|
|
350
350
|
<i class="iconfont icon-border"></i>
|
|
351
351
|
<span>矩形</span>
|
|
352
352
|
</a>
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
<el-col :span="8">
|
|
355
355
|
<a
|
|
356
356
|
class="ep-draggable-item"
|
|
357
|
-
tid="
|
|
357
|
+
tid="oval">
|
|
358
358
|
<i class="iconfont icon-round"></i>
|
|
359
359
|
<span>椭圆</span>
|
|
360
360
|
</a>
|
|
@@ -430,769 +430,752 @@
|
|
|
430
430
|
</el-dialog>
|
|
431
431
|
</template>
|
|
432
432
|
<script setup lang="ts">
|
|
433
|
-
// @ts-nocheck
|
|
434
|
-
import {onMounted, ref, onActivated, onDeactivated, computed, watch, shallowRef} from 'vue';
|
|
435
|
-
import {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
433
|
+
// @ts-nocheck
|
|
434
|
+
import {onMounted, ref, onActivated, onDeactivated, computed, watch, shallowRef} from 'vue';
|
|
435
|
+
import {
|
|
436
|
+
hiprint,
|
|
437
|
+
defaultElementTypeProvider,
|
|
438
|
+
fontSize,
|
|
439
|
+
scale,
|
|
440
|
+
zIndex,
|
|
441
|
+
panel,
|
|
442
|
+
usePaper,
|
|
443
|
+
useScale,
|
|
444
|
+
useDataSource,
|
|
445
|
+
} from 'yh-hiprint';
|
|
446
|
+
import {useRoute, onBeforeRouteUpdate} from 'vue-router';
|
|
447
|
+
import {toValue} from '@vueuse/core';
|
|
448
|
+
import {ElMessageBox, ElMessage} from 'element-plus';
|
|
449
|
+
import axios from '@/libs/api.request';
|
|
450
|
+
import previewHiprint from './libs/previewHiprint';
|
|
451
|
+
import {defaultPrintElement} from 'yh-hiprint';
|
|
440
452
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
zoom: (scale: number) => void;
|
|
444
|
-
getJson: () => any;
|
|
445
|
-
clear: () => void;
|
|
446
|
-
}
|
|
453
|
+
const route = useRoute();
|
|
454
|
+
const hiprintTemplate = shallowRef<HiprintTemplate | null>(null);
|
|
447
455
|
|
|
448
|
-
const
|
|
449
|
-
const hiprintTemplate = shallowRef<HiprintTemplate | null>(null);
|
|
456
|
+
const {paperType, paperTypeName, paperTypesObj, paperWidth, paperHeight, setPaper} = usePaper();
|
|
450
457
|
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
458
|
+
const canvasRef = ref();
|
|
459
|
+
const {scaleValue, scalePercentage, canZoomIn, canZoomOut, zoomIn, zoomOut} = useScale(() => {
|
|
460
|
+
hiprintTemplate.value?.zoom(scaleValue.value);
|
|
461
|
+
canvasRef?.value.update();
|
|
455
462
|
});
|
|
456
|
-
}
|
|
457
463
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
hiprintTemplate.value?.zoom(scaleValue.value);
|
|
461
|
-
canvasRef?.value.update();
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
const previewShow = ref(false);
|
|
465
|
-
const previewHtml = ref('');
|
|
466
|
-
async function previewPrint() {
|
|
467
|
-
let {
|
|
468
|
-
data: {list, json},
|
|
469
|
-
} = await axios.request({
|
|
470
|
-
url: `/printTemplate/data/${detailData.value.code}`,
|
|
471
|
-
method: 'post',
|
|
472
|
-
type: 'json',
|
|
473
|
-
data: [
|
|
474
|
-
{
|
|
475
|
-
code: '50101820',
|
|
476
|
-
},
|
|
477
|
-
],
|
|
478
|
-
});
|
|
479
|
-
if (json) {
|
|
480
|
-
if (Array.isArray(list) && list.length > 0) {
|
|
481
|
-
list = list.map((item) => {
|
|
482
|
-
let printData = {};
|
|
483
|
-
let datas = Object.entries(item);
|
|
484
|
-
datas.forEach((arr) => {
|
|
485
|
-
if (Array.isArray(arr[1])) {
|
|
486
|
-
printData[arr[0]] = arr[1];
|
|
487
|
-
} else {
|
|
488
|
-
if (arr[1] !== null) {
|
|
489
|
-
let itemsEntries = Object.entries(arr[1]);
|
|
490
|
-
itemsEntries.forEach((cArr) => {
|
|
491
|
-
printData[`$${arr[0]}[${cArr[0]}]`] = cArr[1];
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
return printData;
|
|
497
|
-
});
|
|
498
|
-
} else {
|
|
499
|
-
list = [];
|
|
500
|
-
}
|
|
501
|
-
previewHtml.value = new hiprint.PrintTemplate({template: JSON.parse(json)}).getHtml(list)[0].innerHTML;
|
|
502
|
-
previewShow.value = true;
|
|
503
|
-
} else {
|
|
504
|
-
ElMessage.warning({
|
|
505
|
-
message: '模板配置不存在,请检查',
|
|
506
|
-
});
|
|
464
|
+
async function previewPrint() {
|
|
465
|
+
previewHiprint(detailData.value.code);
|
|
507
466
|
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
function saveConfig() {
|
|
511
|
-
let arr = [].concat(formCode.value);
|
|
512
|
-
let json = hiprintTemplate.value?.getJson();
|
|
513
|
-
json.panels[0].printElements.forEach((item) => {
|
|
514
|
-
if (item.printElementType.type === 'table') {
|
|
515
|
-
arr.push(item.options.field);
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
467
|
|
|
519
|
-
|
|
520
|
-
.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
type
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
json: JSON.stringify(json),
|
|
527
|
-
dsIds: arr.join(','),
|
|
528
|
-
},
|
|
529
|
-
})
|
|
530
|
-
.then((res) => {
|
|
531
|
-
ElMessage.success({
|
|
532
|
-
message: '恭喜模板保存成功',
|
|
533
|
-
});
|
|
468
|
+
function saveConfig() {
|
|
469
|
+
let arr = [].concat(formCode.value);
|
|
470
|
+
let json = hiprintTemplate.value?.getJson();
|
|
471
|
+
json.panels[0].printElements.forEach((item) => {
|
|
472
|
+
if (item.printElementType.type === 'table') {
|
|
473
|
+
arr.push(item.options.field);
|
|
474
|
+
}
|
|
534
475
|
});
|
|
535
|
-
}
|
|
536
476
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
477
|
+
axios
|
|
478
|
+
.request({
|
|
479
|
+
url: '/printTemplate/save',
|
|
480
|
+
method: 'post',
|
|
481
|
+
type: 'json',
|
|
482
|
+
data: {
|
|
483
|
+
id: detailData.value.id,
|
|
484
|
+
json: JSON.stringify(json),
|
|
485
|
+
dsIds: arr.join(','),
|
|
486
|
+
},
|
|
487
|
+
})
|
|
488
|
+
.then((res) => {
|
|
489
|
+
ElMessage.success({
|
|
490
|
+
message: '恭喜模板保存成功',
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
}
|
|
540
494
|
|
|
541
|
-
function
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
a.options.top = a.options.top + 10;
|
|
545
|
-
hiprintJQuery(a.designTarget[0]).css('top', a.options.displayTop());
|
|
546
|
-
}
|
|
495
|
+
function clearPrint() {
|
|
496
|
+
hiprintTemplate.value?.clear();
|
|
497
|
+
}
|
|
547
498
|
|
|
548
|
-
const {
|
|
499
|
+
const {
|
|
500
|
+
detailData,
|
|
501
|
+
getDetail,
|
|
502
|
+
listCode,
|
|
503
|
+
dataSourceList,
|
|
504
|
+
listColumns,
|
|
505
|
+
formCode,
|
|
506
|
+
formColumns,
|
|
507
|
+
dataSourceForm,
|
|
508
|
+
getDataSourceList,
|
|
509
|
+
} = useDataSource(axios);
|
|
549
510
|
|
|
550
|
-
watch(
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
511
|
+
watch(
|
|
512
|
+
() => formColumns.value,
|
|
513
|
+
(val) => {
|
|
514
|
+
if (val && val.length && hiprintTemplate.value) {
|
|
515
|
+
hiprintTemplate.value.setFields(
|
|
516
|
+
val.map((item) => {
|
|
517
|
+
return {
|
|
518
|
+
field: item,
|
|
519
|
+
text: item,
|
|
520
|
+
};
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
} else {
|
|
524
|
+
hiprintTemplate.value?.setFields('');
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
deep: true,
|
|
529
|
+
immediate: true,
|
|
564
530
|
}
|
|
565
|
-
|
|
566
|
-
{
|
|
567
|
-
deep: true,
|
|
568
|
-
immediate: true,
|
|
569
|
-
}
|
|
570
|
-
);
|
|
531
|
+
);
|
|
571
532
|
|
|
572
|
-
const selectedEle = shallowRef([]);
|
|
533
|
+
const selectedEle = shallowRef([]);
|
|
573
534
|
|
|
574
|
-
const isLessThanTwoSelected = computed(() => {
|
|
575
|
-
|
|
576
|
-
});
|
|
535
|
+
const isLessThanTwoSelected = computed(() => {
|
|
536
|
+
return !selectedEle.value || selectedEle.value.length < 2;
|
|
537
|
+
});
|
|
577
538
|
|
|
578
|
-
const isMoreThanTwoSelected = computed(() => {
|
|
579
|
-
|
|
580
|
-
});
|
|
539
|
+
const isMoreThanTwoSelected = computed(() => {
|
|
540
|
+
return selectedEle.value && selectedEle.value.length >= 2;
|
|
541
|
+
});
|
|
581
542
|
|
|
582
|
-
const isMoreSelected = computed(() => {
|
|
583
|
-
|
|
584
|
-
});
|
|
543
|
+
const isMoreSelected = computed(() => {
|
|
544
|
+
return selectedEle.value && selectedEle.value.length >= 3;
|
|
545
|
+
});
|
|
585
546
|
|
|
586
|
-
let selectedTableEle = ref(null);
|
|
547
|
+
let selectedTableEle = ref(null);
|
|
587
548
|
|
|
588
|
-
let selectedTableEleColumns = computed(() => {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
});
|
|
549
|
+
let selectedTableEleColumns = computed(() => {
|
|
550
|
+
if (selectedTableEle.value && selectedTableEle.value.printElementType.type === 'table') {
|
|
551
|
+
return selectedTableEle.value.options?.columns[0]['columns'] || [];
|
|
552
|
+
} else {
|
|
553
|
+
return [];
|
|
554
|
+
}
|
|
555
|
+
});
|
|
595
556
|
|
|
596
|
-
function onAlign(e) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
604
|
-
});
|
|
605
|
-
break;
|
|
606
|
-
case 'middle':
|
|
607
|
-
let mys = selectedEle.value.map((item) => item.options.top);
|
|
608
|
-
let mminY = Math.min(...mys);
|
|
609
|
-
let mbaseIndex = mys.indexOf(mminY);
|
|
610
|
-
let mbaseObj = selectedEle.value[mbaseIndex];
|
|
611
|
-
let baseY = mbaseObj.options.height / 2 + mbaseObj.options.top;
|
|
612
|
-
selectedEle.value.forEach((item, index) => {
|
|
613
|
-
if (mbaseIndex !== index) {
|
|
614
|
-
item.options.top = baseY - item.options.height / 2;
|
|
557
|
+
function onAlign(e) {
|
|
558
|
+
switch (e) {
|
|
559
|
+
case 'top':
|
|
560
|
+
let tys = selectedEle.value.map((item) => item.options.top);
|
|
561
|
+
let tminY = Math.min(...tys);
|
|
562
|
+
selectedEle.value.forEach((item) => {
|
|
563
|
+
item.options.top = tminY;
|
|
615
564
|
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
break;
|
|
619
|
-
case 'bottom':
|
|
620
|
-
let bys = selectedEle.value.map((item) => item.options.top + item.options.height);
|
|
621
|
-
let bmaxY = Math.max(...bys);
|
|
622
|
-
selectedEle.value.forEach((item) => {
|
|
623
|
-
item.options.top = bmaxY - item.options.height;
|
|
624
|
-
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
625
|
-
});
|
|
626
|
-
break;
|
|
627
|
-
case 'left':
|
|
628
|
-
let lxs = selectedEle.value.map((item) => item.options.left);
|
|
629
|
-
let lminX = Math.min(...lxs);
|
|
630
|
-
selectedEle.value.forEach((item) => {
|
|
631
|
-
item.options.left = lminX;
|
|
632
|
-
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
633
|
-
});
|
|
634
|
-
break;
|
|
635
|
-
case 'center':
|
|
636
|
-
let cxs = selectedEle.value.map((item) => item.options.left);
|
|
637
|
-
let cminX = Math.min(...cxs);
|
|
638
|
-
let cbaseIndex = cxs.indexOf(cminX);
|
|
639
|
-
let cbaseObj = selectedEle.value[cbaseIndex];
|
|
640
|
-
let baseX = cbaseObj.options.width / 2 + cbaseObj.options.left;
|
|
641
|
-
selectedEle.value.forEach((item, index) => {
|
|
642
|
-
if (cbaseIndex !== index) {
|
|
643
|
-
item.options.left = baseX - item.options.width / 2;
|
|
644
|
-
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
break;
|
|
648
|
-
case 'right':
|
|
649
|
-
let rxs = selectedEle.value.map((item) => item.options.left + item.options.width);
|
|
650
|
-
let rmaxX = Math.max(...rxs);
|
|
651
|
-
selectedEle.value.forEach((item) => {
|
|
652
|
-
item.options.left = rmaxX - item.options.width;
|
|
653
|
-
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
654
|
-
});
|
|
655
|
-
break;
|
|
656
|
-
default:
|
|
657
|
-
break;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
function onSplit(key) {
|
|
662
|
-
switch (key) {
|
|
663
|
-
case 'horizontal':
|
|
664
|
-
let lxs = selectedEle.value.map((item) => item.options.left);
|
|
665
|
-
let rxs = selectedEle.value.map((item) => item.options.left + item.options.width);
|
|
666
|
-
let minlx = Math.min(...lxs);
|
|
667
|
-
let maxrx = Math.max(...rxs);
|
|
668
|
-
let minlxIndex = lxs.indexOf(minlx);
|
|
669
|
-
let maxrxIndex = rxs.indexOf(maxrx);
|
|
670
|
-
if (minlxIndex !== maxrxIndex) {
|
|
671
|
-
let sortCompos = selectedEle.value.sort((a, b) => {
|
|
672
|
-
return a.options.left - b.options.left;
|
|
673
565
|
});
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
let
|
|
679
|
-
let
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
item.options.
|
|
684
|
-
hiprintJQuery(item.designTarget[0]).css('
|
|
566
|
+
break;
|
|
567
|
+
case 'middle':
|
|
568
|
+
let mys = selectedEle.value.map((item) => item.options.top);
|
|
569
|
+
let mminY = Math.min(...mys);
|
|
570
|
+
let mbaseIndex = mys.indexOf(mminY);
|
|
571
|
+
let mbaseObj = selectedEle.value[mbaseIndex];
|
|
572
|
+
let baseY = mbaseObj.options.height / 2 + mbaseObj.options.top;
|
|
573
|
+
selectedEle.value.forEach((item, index) => {
|
|
574
|
+
if (mbaseIndex !== index) {
|
|
575
|
+
item.options.top = baseY - item.options.height / 2;
|
|
576
|
+
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
685
577
|
}
|
|
686
578
|
});
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
let tys = selectedEle.value.map((item) => item.options.top);
|
|
695
|
-
let bys = selectedEle.value.map((item) => item.options.top + item.options.height);
|
|
696
|
-
let minly = Math.min(...tys);
|
|
697
|
-
let maxry = Math.max(...bys);
|
|
698
|
-
let minlyIndex = tys.indexOf(minly);
|
|
699
|
-
let maxryIndex = bys.indexOf(maxry);
|
|
700
|
-
if (minlyIndex !== maxryIndex) {
|
|
701
|
-
let sortCompos = selectedEle.value.sort((a, b) => {
|
|
702
|
-
return a.options.top - b.options.top;
|
|
579
|
+
break;
|
|
580
|
+
case 'bottom':
|
|
581
|
+
let bys = selectedEle.value.map((item) => item.options.top + item.options.height);
|
|
582
|
+
let bmaxY = Math.max(...bys);
|
|
583
|
+
selectedEle.value.forEach((item) => {
|
|
584
|
+
item.options.top = bmaxY - item.options.height;
|
|
585
|
+
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
703
586
|
});
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
587
|
+
break;
|
|
588
|
+
case 'left':
|
|
589
|
+
let lxs = selectedEle.value.map((item) => item.options.left);
|
|
590
|
+
let lminX = Math.min(...lxs);
|
|
591
|
+
selectedEle.value.forEach((item) => {
|
|
592
|
+
item.options.left = lminX;
|
|
593
|
+
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
707
594
|
});
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
595
|
+
break;
|
|
596
|
+
case 'center':
|
|
597
|
+
let cxs = selectedEle.value.map((item) => item.options.left);
|
|
598
|
+
let cminX = Math.min(...cxs);
|
|
599
|
+
let cbaseIndex = cxs.indexOf(cminX);
|
|
600
|
+
let cbaseObj = selectedEle.value[cbaseIndex];
|
|
601
|
+
let baseX = cbaseObj.options.width / 2 + cbaseObj.options.left;
|
|
602
|
+
selectedEle.value.forEach((item, index) => {
|
|
603
|
+
if (cbaseIndex !== index) {
|
|
604
|
+
item.options.left = baseX - item.options.width / 2;
|
|
605
|
+
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
715
606
|
}
|
|
716
607
|
});
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
608
|
+
break;
|
|
609
|
+
case 'right':
|
|
610
|
+
let rxs = selectedEle.value.map((item) => item.options.left + item.options.width);
|
|
611
|
+
let rmaxX = Math.max(...rxs);
|
|
612
|
+
selectedEle.value.forEach((item) => {
|
|
613
|
+
item.options.left = rmaxX - item.options.width;
|
|
614
|
+
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
615
|
+
});
|
|
616
|
+
break;
|
|
617
|
+
default:
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
725
620
|
}
|
|
726
|
-
}
|
|
727
621
|
|
|
728
|
-
function
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
622
|
+
function onSplit(key) {
|
|
623
|
+
switch (key) {
|
|
624
|
+
case 'horizontal':
|
|
625
|
+
let lxs = selectedEle.value.map((item) => item.options.left);
|
|
626
|
+
let rxs = selectedEle.value.map((item) => item.options.left + item.options.width);
|
|
627
|
+
let minlx = Math.min(...lxs);
|
|
628
|
+
let maxrx = Math.max(...rxs);
|
|
629
|
+
let minlxIndex = lxs.indexOf(minlx);
|
|
630
|
+
let maxrxIndex = rxs.indexOf(maxrx);
|
|
631
|
+
if (minlxIndex !== maxrxIndex) {
|
|
632
|
+
let sortCompos = selectedEle.value.sort((a, b) => {
|
|
633
|
+
return a.options.left - b.options.left;
|
|
634
|
+
});
|
|
635
|
+
let countWidth = 0;
|
|
636
|
+
sortCompos.forEach((item) => {
|
|
637
|
+
countWidth += item.options.width;
|
|
638
|
+
});
|
|
639
|
+
let countGap = maxrx - minlx - countWidth;
|
|
640
|
+
let gap = countGap / (sortCompos.length - 1);
|
|
641
|
+
sortCompos.forEach((item, index, arr) => {
|
|
642
|
+
if (index > 0 && index < arr.length - 1) {
|
|
643
|
+
let preItem = arr[index - 1];
|
|
644
|
+
item.options.left = preItem.options.left + preItem.options.width + gap;
|
|
645
|
+
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
} else {
|
|
649
|
+
// TODO 此处隐藏了操作提示,这一处提示是告知为什么不能进行操作的原因,不过措辞没有研究好。所以遇到这种情况暂时做静默处理吧。
|
|
650
|
+
// let obj = selectedEle.value[minlxIndex];
|
|
651
|
+
// this.$message.info(`[${obj.compName}]元素影响均匀分布计算了,请取消选中[${obj.compName}]`)
|
|
652
|
+
}
|
|
653
|
+
break;
|
|
654
|
+
case 'vertical':
|
|
655
|
+
let tys = selectedEle.value.map((item) => item.options.top);
|
|
656
|
+
let bys = selectedEle.value.map((item) => item.options.top + item.options.height);
|
|
657
|
+
let minly = Math.min(...tys);
|
|
658
|
+
let maxry = Math.max(...bys);
|
|
659
|
+
let minlyIndex = tys.indexOf(minly);
|
|
660
|
+
let maxryIndex = bys.indexOf(maxry);
|
|
661
|
+
if (minlyIndex !== maxryIndex) {
|
|
662
|
+
let sortCompos = selectedEle.value.sort((a, b) => {
|
|
663
|
+
return a.options.top - b.options.top;
|
|
664
|
+
});
|
|
665
|
+
let countHeight = 0;
|
|
666
|
+
sortCompos.forEach((item) => {
|
|
667
|
+
countHeight += item.options.height;
|
|
668
|
+
});
|
|
669
|
+
let countGap = maxry - minly - countHeight;
|
|
670
|
+
let gap = countGap / (sortCompos.length - 1);
|
|
671
|
+
sortCompos.forEach((item, index, arr) => {
|
|
672
|
+
if (index > 0 && index < arr.length - 1) {
|
|
673
|
+
let preItem = arr[index - 1];
|
|
674
|
+
item.options.top = preitem.options.top + preItem.options.height + gap;
|
|
675
|
+
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
} else {
|
|
679
|
+
// TODO 此处隐藏了操作提示,这一处提示是告知为什么不能进行操作的原因,不过措辞没有研究好。所以遇到这种情况暂时做静默处理吧。
|
|
680
|
+
// let obj = selectedEle.value[minlxIndex];
|
|
681
|
+
// this.$message.info(`[${obj.compName}]元素影响均匀分布计算了,请取消选中[${obj.compName}]`)
|
|
682
|
+
}
|
|
683
|
+
break;
|
|
684
|
+
default:
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
746
688
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
689
|
+
function onSize(key) {
|
|
690
|
+
switch (key) {
|
|
691
|
+
case 'width':
|
|
692
|
+
let width = selectedEle.value[0].options.width;
|
|
693
|
+
selectedEle.value.forEach((item) => {
|
|
694
|
+
item.options.width = width;
|
|
695
|
+
hiprintJQuery(item.designTarget[0]).css('width', item.options.displayWidth());
|
|
696
|
+
});
|
|
697
|
+
break;
|
|
698
|
+
case 'height':
|
|
699
|
+
let height = selectedEle.value[0].options.height;
|
|
700
|
+
selectedEle.value.forEach((item) => {
|
|
701
|
+
item.options.height = height;
|
|
702
|
+
hiprintJQuery(item.designTarget[0]).css('height', item.options.displayHeight());
|
|
703
|
+
});
|
|
704
|
+
break;
|
|
705
|
+
case 'both':
|
|
706
|
+
let {w, h} = selectedEle.value[0].rect;
|
|
707
|
+
|
|
708
|
+
selectedEle.value.forEach((item) => {
|
|
709
|
+
item.options.height = h;
|
|
710
|
+
item.options.width = w;
|
|
711
|
+
hiprintJQuery(item.designTarget[0])
|
|
712
|
+
.css('height', item.options.displayHeight())
|
|
713
|
+
.css('width', item.options.displayWidth());
|
|
714
|
+
});
|
|
715
|
+
break;
|
|
716
|
+
default:
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
755
719
|
}
|
|
756
|
-
}
|
|
757
720
|
|
|
758
|
-
function tableFieldChange(val) {
|
|
759
|
-
|
|
760
|
-
}
|
|
721
|
+
function tableFieldChange(val) {
|
|
722
|
+
selectedTableEle.value.updateOption('field', val);
|
|
723
|
+
}
|
|
761
724
|
|
|
762
|
-
function tableColumnCancel() {
|
|
763
|
-
|
|
764
|
-
}
|
|
725
|
+
function tableColumnCancel() {
|
|
726
|
+
selectedTableEle.value = null;
|
|
727
|
+
}
|
|
765
728
|
|
|
766
|
-
function init() {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
729
|
+
function init() {
|
|
730
|
+
try {
|
|
731
|
+
hiprint.init({
|
|
732
|
+
providers: [new defaultElementTypeProvider()],
|
|
733
|
+
});
|
|
734
|
+
hiprint.setConfig();
|
|
735
|
+
hiprint.setConfig({
|
|
736
|
+
optionItems: [fontSize, scale, zIndex],
|
|
737
|
+
movingDistance: 2.5,
|
|
738
|
+
text: {
|
|
739
|
+
tabs: [
|
|
740
|
+
{
|
|
741
|
+
options: [],
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: '样式',
|
|
745
|
+
options: [
|
|
746
|
+
{
|
|
747
|
+
name: 'scale',
|
|
748
|
+
after: 'transform',
|
|
749
|
+
hidden: false,
|
|
750
|
+
},
|
|
751
|
+
],
|
|
752
|
+
},
|
|
753
|
+
],
|
|
754
|
+
supportOptions: [
|
|
755
|
+
{
|
|
756
|
+
name: 'styler',
|
|
757
|
+
hidden: true,
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
name: 'scale',
|
|
761
|
+
after: 'transform',
|
|
762
|
+
hidden: false,
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
name: 'formatter',
|
|
766
|
+
hidden: true,
|
|
767
|
+
},
|
|
768
|
+
],
|
|
769
|
+
},
|
|
770
|
+
image: {
|
|
771
|
+
tabs: [
|
|
772
|
+
{
|
|
773
|
+
replace: true,
|
|
774
|
+
name: '基本',
|
|
775
|
+
options: [
|
|
776
|
+
{
|
|
777
|
+
name: 'field',
|
|
778
|
+
hidden: false,
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
name: 'src',
|
|
782
|
+
hidden: false,
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
name: 'fit',
|
|
786
|
+
hidden: false,
|
|
787
|
+
},
|
|
788
|
+
],
|
|
789
|
+
},
|
|
790
|
+
],
|
|
791
|
+
},
|
|
792
|
+
table: {
|
|
793
|
+
tabs: [{options: [{name: 'field', hidden: true}]}],
|
|
794
|
+
},
|
|
795
|
+
});
|
|
833
796
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
797
|
+
hiprint.PrintElementTypeManager.buildByHtml(hiprintJQuery('.ep-draggable-item'));
|
|
798
|
+
hiprintJQuery('#hiprint-printTemplate').empty();
|
|
799
|
+
let template = JSON.parse(detailData.value.json) || panel;
|
|
800
|
+
hiprintTemplate.value = new hiprint.PrintTemplate({
|
|
801
|
+
template,
|
|
802
|
+
onImageChooseClick: (target) => {
|
|
803
|
+
console.log(target);
|
|
804
|
+
},
|
|
805
|
+
fontList: [
|
|
806
|
+
{title: '微软雅黑', value: 'Microsoft YaHei'},
|
|
807
|
+
{title: '黑体', value: 'STHeitiSC-Light'},
|
|
808
|
+
{title: '思源黑体', value: 'SourceHanSansCN-Normal'},
|
|
809
|
+
{title: '宋体', value: 'SimSun'},
|
|
810
|
+
{title: '华为楷体', value: 'STKaiti'},
|
|
811
|
+
{title: 'cursive', value: 'cursive'},
|
|
812
|
+
{title: 'Times New Roman', value: 'Times New Roman'},
|
|
813
|
+
],
|
|
814
|
+
dataMode: 1,
|
|
815
|
+
history: true,
|
|
816
|
+
onDataChanged: (type, json) => {},
|
|
817
|
+
onUpdateError: (e) => {
|
|
818
|
+
console.error(e);
|
|
819
|
+
},
|
|
820
|
+
settingContainer: '#PrintElementOptionSetting',
|
|
821
|
+
paginationContainer: '.hiprint-printPagination',
|
|
822
|
+
});
|
|
860
823
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
824
|
+
hiprintTemplate.value?.design('#hiprint-printTemplate', {grid: true});
|
|
825
|
+
scaleValue.value = hiprintTemplate.value.editingPanel.scale || 1;
|
|
826
|
+
window.ht = hiprintTemplate.value;
|
|
864
827
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}
|
|
875
|
-
hiprintJQuery('.hiprint-designer').on('mousedown', '.hiprint-printElement', (e) => {
|
|
876
|
-
let t = e.currentTarget;
|
|
877
|
-
selectedEle.value = hiprintTemplate.value?.getSelectEls() || [];
|
|
878
|
-
let pes = hiprintTemplate.value?.editingPanel.printElements;
|
|
879
|
-
let index = pes.map((item) => item.designTarget[0]).findIndex((item) => t === item);
|
|
880
|
-
let pe = pes[index];
|
|
881
|
-
selectedTableEle.value = pe || null;
|
|
882
|
-
if (pe && pe.options.field) {
|
|
883
|
-
listCode.value = pe.options.field;
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
hiprintJQuery('#PrintElementOptionSetting').on('input', 'input[type=number]', ($el) => {
|
|
887
|
-
let val = parseInt($el.target.value);
|
|
888
|
-
if (val < 1) {
|
|
889
|
-
$el.target.value = 1;
|
|
828
|
+
if (formColumns.value) {
|
|
829
|
+
hiprintTemplate.value?.setFields(
|
|
830
|
+
formColumns.value.map((item) => {
|
|
831
|
+
return {
|
|
832
|
+
field: item,
|
|
833
|
+
text: item,
|
|
834
|
+
};
|
|
835
|
+
})
|
|
836
|
+
);
|
|
890
837
|
}
|
|
891
|
-
|
|
892
|
-
|
|
838
|
+
hiprintJQuery('.hiprint-designer').on('mousedown', '.hiprint-printElement', (e) => {
|
|
839
|
+
let t = e.currentTarget;
|
|
840
|
+
selectedEle.value = hiprintTemplate.value?.getSelectEls() || [];
|
|
841
|
+
let pes = hiprintTemplate.value?.editingPanel.printElements;
|
|
842
|
+
let index = pes.map((item) => item.designTarget[0]).findIndex((item) => t === item);
|
|
843
|
+
let pe = pes[index];
|
|
844
|
+
selectedTableEle.value = pe || null;
|
|
845
|
+
if (pe && pe.options.field) {
|
|
846
|
+
listCode.value = pe.options.field;
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
hiprintJQuery('#PrintElementOptionSetting').on('input', 'input[type=number]', ($el) => {
|
|
850
|
+
let val = parseInt($el.target.value);
|
|
851
|
+
if (val < 1) {
|
|
852
|
+
$el.target.value = 1;
|
|
853
|
+
}
|
|
854
|
+
if (val > 2000) {
|
|
855
|
+
$el.target.value = 2000;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
} catch (error) {
|
|
859
|
+
console.log(error.message);
|
|
860
|
+
clearPrint();
|
|
861
|
+
hiprintTemplate.value = null;
|
|
862
|
+
if (error.message.indexOf('setTemplateId') > -1) {
|
|
863
|
+
ElMessageBox.alert('模板有错误,请返回列表手动修改或这清空模板!');
|
|
893
864
|
}
|
|
894
|
-
});
|
|
895
|
-
} catch (error) {
|
|
896
|
-
console.log(error.message);
|
|
897
|
-
clearPrint();
|
|
898
|
-
hiprintTemplate.value = null;
|
|
899
|
-
if (error.message.indexOf('setTemplateId') > -1) {
|
|
900
|
-
ElMessageBox.alert('模板有错误,请返回列表手动修改或这清空模板!');
|
|
901
865
|
}
|
|
902
866
|
}
|
|
903
|
-
}
|
|
904
867
|
|
|
905
|
-
let updateing = false;
|
|
906
|
-
async function updateTemplate(code) {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
updateing = true;
|
|
911
|
-
if (hiprintTemplate.value) {
|
|
912
|
-
await getDetail(code);
|
|
913
|
-
if (detailData.value && detailData.value.json) {
|
|
914
|
-
let jsonObj = JSON.parse(detailData.value.json);
|
|
915
|
-
hiprintTemplate.value?.update(jsonObj);
|
|
916
|
-
let {width, height} = jsonObj.panels[0];
|
|
917
|
-
paperWidth.value = width;
|
|
918
|
-
paperHeight.value = height;
|
|
919
|
-
setPaperHandler('other');
|
|
920
|
-
scaleValue.value = 1;
|
|
921
|
-
} else {
|
|
922
|
-
hiprintTemplate.value?.update({
|
|
923
|
-
panels: [
|
|
924
|
-
{
|
|
925
|
-
index: 0,
|
|
926
|
-
name: 1,
|
|
927
|
-
height: 297,
|
|
928
|
-
width: 210,
|
|
929
|
-
paperHeader: 125,
|
|
930
|
-
paperFooter: 272.5,
|
|
931
|
-
paperNumberLeft: 430,
|
|
932
|
-
paperNumberTop: 5,
|
|
933
|
-
printElements: [],
|
|
934
|
-
watermarkOptions: {content: '', rotate: 25, timestamp: false, format: 'YYYY-MM-DD HH:mm'},
|
|
935
|
-
},
|
|
936
|
-
],
|
|
937
|
-
});
|
|
938
|
-
paperWidth.value = 210;
|
|
939
|
-
paperHeight.value = 297;
|
|
940
|
-
setPaperHandler('other');
|
|
941
|
-
scaleValue.value = 1;
|
|
868
|
+
let updateing = false;
|
|
869
|
+
async function updateTemplate(code) {
|
|
870
|
+
if (updateing === true) {
|
|
871
|
+
return false;
|
|
942
872
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
873
|
+
updateing = true;
|
|
874
|
+
if (hiprintTemplate.value) {
|
|
875
|
+
await getDetail(code);
|
|
876
|
+
if (detailData.value && detailData.value.json) {
|
|
877
|
+
let jsonObj = JSON.parse(detailData.value.json);
|
|
878
|
+
hiprintTemplate.value?.update(jsonObj);
|
|
879
|
+
let {width, height} = jsonObj.panels[0];
|
|
880
|
+
paperWidth.value = width;
|
|
881
|
+
paperHeight.value = height;
|
|
882
|
+
setPaperHandler('other');
|
|
883
|
+
scaleValue.value = 1;
|
|
884
|
+
} else {
|
|
885
|
+
hiprintTemplate.value?.update({
|
|
886
|
+
panels: [
|
|
887
|
+
{
|
|
888
|
+
index: 0,
|
|
889
|
+
name: 1,
|
|
890
|
+
height: 297,
|
|
891
|
+
width: 210,
|
|
892
|
+
paperHeader: 125,
|
|
893
|
+
paperFooter: 272.5,
|
|
894
|
+
paperNumberLeft: 430,
|
|
895
|
+
paperNumberTop: 5,
|
|
896
|
+
printElements: [],
|
|
897
|
+
watermarkOptions: {
|
|
898
|
+
content: '',
|
|
899
|
+
rotate: 25,
|
|
900
|
+
timestamp: false,
|
|
901
|
+
format: 'YYYY-MM-DD HH:mm',
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
],
|
|
905
|
+
});
|
|
906
|
+
paperWidth.value = 210;
|
|
907
|
+
paperHeight.value = 297;
|
|
908
|
+
setPaperHandler('other');
|
|
909
|
+
scaleValue.value = 1;
|
|
910
|
+
}
|
|
951
911
|
} else {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
912
|
+
await getDetail(code);
|
|
913
|
+
if (detailData.value && detailData.value.json) {
|
|
914
|
+
let jsonObj = JSON.parse(detailData.value.json);
|
|
915
|
+
let {width, height} = jsonObj.panels[0];
|
|
916
|
+
paperWidth.value = width;
|
|
917
|
+
paperHeight.value = height;
|
|
918
|
+
setPaperHandler('other');
|
|
919
|
+
} else {
|
|
920
|
+
paperWidth.value = 210;
|
|
921
|
+
paperHeight.value = 297;
|
|
922
|
+
setPaperHandler('other');
|
|
923
|
+
}
|
|
924
|
+
init();
|
|
955
925
|
}
|
|
956
|
-
|
|
926
|
+
updateing = false;
|
|
957
927
|
}
|
|
958
|
-
updateing = false;
|
|
959
|
-
}
|
|
960
928
|
|
|
961
|
-
const hasDataSource = computed(() => {
|
|
962
|
-
|
|
963
|
-
});
|
|
929
|
+
const hasDataSource = computed(() => {
|
|
930
|
+
return Array.isArray(formCode.value) ? formCode.value.length > 0 : formCode.value;
|
|
931
|
+
});
|
|
964
932
|
|
|
965
|
-
function wheelHandler(e: MouseEvent) {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
933
|
+
function wheelHandler(e: MouseEvent) {
|
|
934
|
+
if (e.ctrlKey) {
|
|
935
|
+
const isZoomIn = e.wheelDelta < 0;
|
|
936
|
+
const isZoomOut = e.wheelDelta > 0;
|
|
937
|
+
if (isZoomIn && canZoomIn) {
|
|
938
|
+
e.preventDefault();
|
|
939
|
+
e.stopPropagation();
|
|
940
|
+
zoomIn();
|
|
941
|
+
}
|
|
942
|
+
if (isZoomOut && canZoomOut) {
|
|
943
|
+
e.preventDefault();
|
|
944
|
+
e.stopPropagation();
|
|
945
|
+
zoomOut();
|
|
946
|
+
}
|
|
979
947
|
}
|
|
980
948
|
}
|
|
981
|
-
}
|
|
982
949
|
|
|
983
|
-
onActivated(() => {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
});
|
|
950
|
+
onActivated(() => {
|
|
951
|
+
updateTemplate(route.query.code);
|
|
952
|
+
window.addEventListener('wheel', wheelHandler, {passive: false});
|
|
953
|
+
});
|
|
987
954
|
|
|
988
|
-
onBeforeRouteUpdate((to) => {
|
|
989
|
-
|
|
990
|
-
});
|
|
955
|
+
onBeforeRouteUpdate((to) => {
|
|
956
|
+
updateTemplate(to.query.code);
|
|
957
|
+
});
|
|
991
958
|
|
|
992
|
-
onDeactivated(() => {
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
});
|
|
959
|
+
onDeactivated(() => {
|
|
960
|
+
clearPrint();
|
|
961
|
+
window.removeEventListener('wheel', wheelHandler);
|
|
962
|
+
});
|
|
996
963
|
|
|
997
|
-
onMounted(async () => {
|
|
998
|
-
|
|
999
|
-
});
|
|
964
|
+
onMounted(async () => {
|
|
965
|
+
await getDataSourceList();
|
|
966
|
+
});
|
|
1000
967
|
</script>
|
|
1001
968
|
<style lang="scss">
|
|
1002
|
-
.hiprint-designer {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
display: flex;
|
|
1007
|
-
flex-direction: column;
|
|
1008
|
-
background-color: var(--el-bg-color-page);
|
|
1009
|
-
margin: 0 -16px;
|
|
1010
|
-
&__header {
|
|
1011
|
-
padding: 0 16px;
|
|
1012
|
-
height: 50px;
|
|
969
|
+
.hiprint-designer {
|
|
970
|
+
width: calc(100% + 32px);
|
|
971
|
+
height: calc(100%);
|
|
972
|
+
overflow: hidden;
|
|
1013
973
|
display: flex;
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
display: inline-block;
|
|
1027
|
-
padding: 0 10px 0 20px;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
.percentage {
|
|
1031
|
-
width: 165px;
|
|
1032
|
-
}
|
|
1033
|
-
.el-select {
|
|
1034
|
-
--el-select-width: auto;
|
|
1035
|
-
width: 150px;
|
|
1036
|
-
}
|
|
1037
|
-
> .el-button {
|
|
1038
|
-
padding: 5px;
|
|
1039
|
-
}
|
|
1040
|
-
.el-form-item {
|
|
1041
|
-
margin-bottom: 0;
|
|
1042
|
-
margin-right: 10px;
|
|
1043
|
-
}
|
|
1044
|
-
&_content {
|
|
1045
|
-
flex: 1;
|
|
974
|
+
flex-direction: column;
|
|
975
|
+
background-color: var(--el-bg-color-page);
|
|
976
|
+
margin: 0 -16px;
|
|
977
|
+
&__header {
|
|
978
|
+
padding: 0 16px;
|
|
979
|
+
height: 50px;
|
|
980
|
+
display: flex;
|
|
981
|
+
background-color: var(--el-bg-color);
|
|
982
|
+
align-items: center;
|
|
983
|
+
box-shadow: var(--el-box-shadow-lighter);
|
|
984
|
+
position: relative;
|
|
985
|
+
z-index: 1;
|
|
1046
986
|
> * {
|
|
1047
987
|
margin-right: 10px;
|
|
1048
988
|
margin-left: 0 !important;
|
|
1049
989
|
}
|
|
990
|
+
.paper-setting-text {
|
|
991
|
+
width: 100px;
|
|
992
|
+
.iconfont {
|
|
993
|
+
display: inline-block;
|
|
994
|
+
padding: 0 10px 0 20px;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
.percentage {
|
|
998
|
+
width: 165px;
|
|
999
|
+
}
|
|
1000
|
+
.el-select {
|
|
1001
|
+
--el-select-width: auto;
|
|
1002
|
+
width: 150px;
|
|
1003
|
+
}
|
|
1004
|
+
> .el-button {
|
|
1005
|
+
padding: 5px;
|
|
1006
|
+
}
|
|
1007
|
+
.el-form-item {
|
|
1008
|
+
margin-bottom: 0;
|
|
1009
|
+
margin-right: 10px;
|
|
1010
|
+
}
|
|
1011
|
+
&_content {
|
|
1012
|
+
flex: 1;
|
|
1013
|
+
> * {
|
|
1014
|
+
margin-right: 10px;
|
|
1015
|
+
margin-left: 0 !important;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1050
1018
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
margin-bottom: 10px;
|
|
1057
|
-
}
|
|
1058
|
-
.ep-draggable-item {
|
|
1059
|
-
user-select: none;
|
|
1060
|
-
width: 100%;
|
|
1061
|
-
height: 70px;
|
|
1062
|
-
display: inline-flex;
|
|
1063
|
-
flex-direction: column;
|
|
1064
|
-
align-items: center;
|
|
1065
|
-
margin-bottom: 10px;
|
|
1066
|
-
.iconfont {
|
|
1067
|
-
font-size: 30px;
|
|
1068
|
-
width: 40px;
|
|
1069
|
-
height: 40px;
|
|
1070
|
-
text-align: center;
|
|
1071
|
-
line-height: 40px;
|
|
1019
|
+
&_title {
|
|
1020
|
+
font-size: 18px;
|
|
1021
|
+
font-weight: bold;
|
|
1022
|
+
line-height: 1.7em;
|
|
1023
|
+
margin-bottom: 10px;
|
|
1072
1024
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1025
|
+
.ep-draggable-item {
|
|
1026
|
+
user-select: none;
|
|
1027
|
+
width: 100%;
|
|
1028
|
+
height: 70px;
|
|
1029
|
+
display: inline-flex;
|
|
1030
|
+
flex-direction: column;
|
|
1031
|
+
align-items: center;
|
|
1032
|
+
margin-bottom: 10px;
|
|
1033
|
+
.iconfont {
|
|
1034
|
+
font-size: 30px;
|
|
1035
|
+
width: 40px;
|
|
1036
|
+
height: 40px;
|
|
1037
|
+
text-align: center;
|
|
1038
|
+
line-height: 40px;
|
|
1085
1039
|
}
|
|
1086
1040
|
}
|
|
1087
|
-
&
|
|
1041
|
+
&__main {
|
|
1088
1042
|
flex: 1;
|
|
1089
1043
|
overflow: hidden;
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1044
|
+
display: flex;
|
|
1045
|
+
&_left {
|
|
1046
|
+
width: 300px;
|
|
1047
|
+
overflow: hidden;
|
|
1048
|
+
background-color: var(--el-color-white);
|
|
1049
|
+
box-shadow: var(--el-box-shadow-lighter);
|
|
1050
|
+
.el-scrollbar__view {
|
|
1051
|
+
padding: 16px;
|
|
1094
1052
|
}
|
|
1095
1053
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
width: 340px;
|
|
1099
|
-
overflow: hidden;
|
|
1100
|
-
background-color: var(--el-color-white);
|
|
1101
|
-
box-shadow: var(--el-box-shadow-lighter);
|
|
1102
|
-
display: flex;
|
|
1103
|
-
flex-direction: column;
|
|
1104
|
-
.prop-tabs {
|
|
1105
|
-
height: 100%;
|
|
1054
|
+
&_canvas {
|
|
1055
|
+
flex: 1;
|
|
1106
1056
|
overflow: hidden;
|
|
1057
|
+
.el-scrollbar__view {
|
|
1058
|
+
padding: 20px 10px 40px 20px;
|
|
1059
|
+
#hiprint-printTemplate {
|
|
1060
|
+
position: relative;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
&_right {
|
|
1065
|
+
width: 340px;
|
|
1066
|
+
overflow: hidden;
|
|
1067
|
+
background-color: var(--el-color-white);
|
|
1068
|
+
box-shadow: var(--el-box-shadow-lighter);
|
|
1107
1069
|
display: flex;
|
|
1108
1070
|
flex-direction: column;
|
|
1109
|
-
.prop-
|
|
1071
|
+
.prop-tabs {
|
|
1072
|
+
height: 100%;
|
|
1073
|
+
overflow: hidden;
|
|
1110
1074
|
display: flex;
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
height:
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1075
|
+
flex-direction: column;
|
|
1076
|
+
.prop-tab-items {
|
|
1077
|
+
display: flex;
|
|
1078
|
+
height: 43px;
|
|
1079
|
+
box-sizing: border-box;
|
|
1080
|
+
.prop-tab-item {
|
|
1081
|
+
height: 40px;
|
|
1082
|
+
line-height: 40px;
|
|
1083
|
+
flex: 1;
|
|
1084
|
+
text-align: center;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
.hiprint-option-items.active {
|
|
1088
|
+
display: block;
|
|
1089
|
+
padding: 0 6px 0 12px;
|
|
1118
1090
|
}
|
|
1119
1091
|
}
|
|
1120
|
-
.hiprint-option-items
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
box-sizing: border-box;
|
|
1130
|
-
&::-webkit-scrollbar {
|
|
1131
|
-
width: 4px;
|
|
1132
|
-
height: 4px;
|
|
1133
|
-
}
|
|
1092
|
+
.hiprint-option-items {
|
|
1093
|
+
height: 100%;
|
|
1094
|
+
overflow: auto;
|
|
1095
|
+
padding: 16px;
|
|
1096
|
+
box-sizing: border-box;
|
|
1097
|
+
&::-webkit-scrollbar {
|
|
1098
|
+
width: 4px;
|
|
1099
|
+
height: 4px;
|
|
1100
|
+
}
|
|
1134
1101
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1102
|
+
&::-webkit-scrollbar-thumb {
|
|
1103
|
+
border-radius: 4px;
|
|
1104
|
+
background: #bbb;
|
|
1105
|
+
}
|
|
1138
1106
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
margin: 0;
|
|
1143
|
-
}
|
|
1144
|
-
#PrintElementOptionSetting {
|
|
1145
|
-
flex: 1;
|
|
1146
|
-
overflow: hidden;
|
|
1147
|
-
}
|
|
1148
|
-
.el-form {
|
|
1149
|
-
padding: 0 10px 10px;
|
|
1150
|
-
.el-form-item--small {
|
|
1151
|
-
margin-bottom: 5px;
|
|
1107
|
+
.hiprint-designer_title {
|
|
1108
|
+
padding: 0 10px;
|
|
1109
|
+
margin: 0;
|
|
1152
1110
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1111
|
+
#PrintElementOptionSetting {
|
|
1112
|
+
flex: 1;
|
|
1113
|
+
overflow: hidden;
|
|
1155
1114
|
}
|
|
1156
|
-
.el-
|
|
1157
|
-
|
|
1115
|
+
.el-form {
|
|
1116
|
+
padding: 0 10px 10px;
|
|
1117
|
+
.el-form-item--small {
|
|
1118
|
+
margin-bottom: 5px;
|
|
1119
|
+
}
|
|
1120
|
+
.el-form-item__label {
|
|
1121
|
+
margin-bottom: 0;
|
|
1122
|
+
}
|
|
1123
|
+
.el-button {
|
|
1124
|
+
width: 100%;
|
|
1125
|
+
}
|
|
1158
1126
|
}
|
|
1159
1127
|
}
|
|
1160
1128
|
}
|
|
1161
1129
|
}
|
|
1162
|
-
}
|
|
1163
1130
|
|
|
1164
|
-
.
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
&:
|
|
1176
|
-
|
|
1131
|
+
.print-preview-dialog {
|
|
1132
|
+
min-width: 1000px;
|
|
1133
|
+
max-width: 1200px;
|
|
1134
|
+
.el-message-box__container {
|
|
1135
|
+
justify-content: center;
|
|
1136
|
+
background-color: #f2f2f2;
|
|
1137
|
+
}
|
|
1138
|
+
.hiprint-printPaper {
|
|
1139
|
+
margin-top: 5px;
|
|
1140
|
+
position: relative;
|
|
1141
|
+
background-color: #fff;
|
|
1142
|
+
&:last-child {
|
|
1143
|
+
margin-bottom: 5px;
|
|
1177
1144
|
}
|
|
1178
1145
|
}
|
|
1179
1146
|
}
|
|
1180
|
-
.paper-
|
|
1181
|
-
|
|
1182
|
-
.
|
|
1183
|
-
width:
|
|
1184
|
-
|
|
1185
|
-
.
|
|
1186
|
-
|
|
1147
|
+
.paper-setting {
|
|
1148
|
+
display: flex;
|
|
1149
|
+
.paper-setting_types {
|
|
1150
|
+
width: 100px;
|
|
1151
|
+
margin-right: 10px;
|
|
1152
|
+
.paper-setting-type-item {
|
|
1153
|
+
width: 100%;
|
|
1154
|
+
text-align: center;
|
|
1155
|
+
height: 40px;
|
|
1156
|
+
line-height: 40px;
|
|
1157
|
+
cursor: pointer;
|
|
1158
|
+
&:hover {
|
|
1159
|
+
background-color: var(--el-color-primary-light-9);
|
|
1160
|
+
}
|
|
1187
1161
|
}
|
|
1188
1162
|
}
|
|
1189
|
-
.
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1163
|
+
.paper-setting__content {
|
|
1164
|
+
flex: 1;
|
|
1165
|
+
.el-input {
|
|
1166
|
+
width: 140px;
|
|
1167
|
+
.el-input-group__prepend,
|
|
1168
|
+
.el-input-group__append {
|
|
1169
|
+
padding: 0 9px;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
.el-button + .el-button {
|
|
1173
|
+
margin-left: 0;
|
|
1174
|
+
}
|
|
1175
|
+
> * {
|
|
1176
|
+
width: 100%;
|
|
1177
|
+
margin-bottom: 10px;
|
|
1178
|
+
}
|
|
1195
1179
|
}
|
|
1196
1180
|
}
|
|
1197
|
-
}
|
|
1198
1181
|
</style>
|