yh-hiprint 2.4.1 → 2.4.2
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 +3 -0
- package/designer.vue +54 -55
- package/package.json +1 -1
package/HiprintDesigner.vue
CHANGED
|
@@ -842,8 +842,11 @@ function init() {
|
|
|
842
842
|
fontList: [
|
|
843
843
|
{title: '微软雅黑', value: 'Microsoft YaHei'},
|
|
844
844
|
{title: '黑体', value: 'STHeitiSC-Light'},
|
|
845
|
+
{title: '思源黑体', value: 'SourceHanSansCN-Normal'},
|
|
845
846
|
{title: '宋体', value: 'SimSun'},
|
|
847
|
+
{title: '华为楷体', value: 'STKaiti'},
|
|
846
848
|
{title: 'cursive', value: 'cursive'},
|
|
849
|
+
{title: 'Times New Roman', value: 'Times New Roman'},
|
|
847
850
|
],
|
|
848
851
|
dataMode: 1,
|
|
849
852
|
history: true,
|
package/designer.vue
CHANGED
|
@@ -265,14 +265,14 @@
|
|
|
265
265
|
</el-dialog>
|
|
266
266
|
</template>
|
|
267
267
|
<script setup>
|
|
268
|
-
import {
|
|
269
|
-
import {
|
|
270
|
-
import {
|
|
271
|
-
import {
|
|
272
|
-
import axios from
|
|
268
|
+
import {onMounted, ref, onActivated, onDeactivated, computed, watch, nextTick} from 'vue';
|
|
269
|
+
import {hiprint, defaultElementTypeProvider, fontSize, scale, zIndex, panel, usePaper, useScale, useDataSource} from 'yh-hiprint';
|
|
270
|
+
import {useRoute, onBeforeRouteUpdate} from 'vue-router/dist/vue-router';
|
|
271
|
+
import {ElMessageBox} from 'element-plus';
|
|
272
|
+
import axios from '@/libs/api.request';
|
|
273
273
|
|
|
274
274
|
const route = useRoute();
|
|
275
|
-
const {
|
|
275
|
+
const {paperType, paperWidth, paperHeight, setPaper} = usePaper();
|
|
276
276
|
function setPaperHandler(type) {
|
|
277
277
|
setPaper(type, () => {
|
|
278
278
|
hiprintTemplate.value.setPaper(paperWidth.value, paperHeight.value);
|
|
@@ -281,23 +281,23 @@ function setPaperHandler(type) {
|
|
|
281
281
|
|
|
282
282
|
const hiprintTemplate = ref(null);
|
|
283
283
|
const canvasRef = ref();
|
|
284
|
-
const {
|
|
284
|
+
const {scaleValue, scalePercentage, canZoomIn, canZoomOut, zoomIn, zoomOut} = useScale(() => {
|
|
285
285
|
hiprintTemplate.value.zoom(scaleValue.value);
|
|
286
286
|
canvasRef?.value.update();
|
|
287
287
|
});
|
|
288
288
|
|
|
289
289
|
const previewShow = ref(false);
|
|
290
|
-
const previewHtml = ref(
|
|
290
|
+
const previewHtml = ref('');
|
|
291
291
|
async function previewPrint() {
|
|
292
292
|
let {
|
|
293
|
-
data: {
|
|
293
|
+
data: {list, json},
|
|
294
294
|
} = await axios.request({
|
|
295
295
|
url: `/printTemplate/data/${detailData.value.code}`,
|
|
296
|
-
method:
|
|
297
|
-
type:
|
|
296
|
+
method: 'post',
|
|
297
|
+
type: 'json',
|
|
298
298
|
data: [
|
|
299
299
|
{
|
|
300
|
-
code:
|
|
300
|
+
code: '50101820',
|
|
301
301
|
},
|
|
302
302
|
],
|
|
303
303
|
});
|
|
@@ -323,12 +323,12 @@ async function previewPrint() {
|
|
|
323
323
|
} else {
|
|
324
324
|
list = [];
|
|
325
325
|
}
|
|
326
|
-
previewHtml.value = new hiprint.PrintTemplate({
|
|
326
|
+
previewHtml.value = new hiprint.PrintTemplate({template: JSON.parse(json)}).getHtml(list)[0].innerHTML;
|
|
327
327
|
previewShow.value = true;
|
|
328
328
|
} else {
|
|
329
329
|
ElMessage.warning({
|
|
330
|
-
title:
|
|
331
|
-
message:
|
|
330
|
+
title: '警告',
|
|
331
|
+
message: '模板配置不存在,请检查',
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
334
|
}
|
|
@@ -337,25 +337,25 @@ function saveConfig() {
|
|
|
337
337
|
let arr = [].concat(formCode.value);
|
|
338
338
|
let json = hiprintTemplate.value.getJson();
|
|
339
339
|
json.panels[0].printElements.forEach((item) => {
|
|
340
|
-
if (item.printElementType.type ===
|
|
340
|
+
if (item.printElementType.type === 'table') {
|
|
341
341
|
arr.push(item.options.field);
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
|
|
345
345
|
axios
|
|
346
346
|
.request({
|
|
347
|
-
url:
|
|
348
|
-
method:
|
|
349
|
-
type:
|
|
347
|
+
url: '/printTemplate/save',
|
|
348
|
+
method: 'post',
|
|
349
|
+
type: 'json',
|
|
350
350
|
data: {
|
|
351
351
|
id: detailData.value.id,
|
|
352
352
|
json: JSON.stringify(json),
|
|
353
|
-
dsIds: arr.join(
|
|
353
|
+
dsIds: arr.join(','),
|
|
354
354
|
},
|
|
355
355
|
})
|
|
356
356
|
.then((res) => {
|
|
357
357
|
ElMessage.success({
|
|
358
|
-
message:
|
|
358
|
+
message: '恭喜模板保存成功',
|
|
359
359
|
});
|
|
360
360
|
});
|
|
361
361
|
}
|
|
@@ -364,7 +364,7 @@ function clearPrint() {
|
|
|
364
364
|
hiprintTemplate.value?.clear();
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
const {
|
|
367
|
+
const {detailData, getDetail, listCode, dataSourceList, listColumns, formCode, formColumns, dataSourceForm, getDataSourceList} = useDataSource(axios);
|
|
368
368
|
|
|
369
369
|
watch(
|
|
370
370
|
() => formColumns.value,
|
|
@@ -387,15 +387,15 @@ watch(
|
|
|
387
387
|
);
|
|
388
388
|
let currentElementObj = ref(null);
|
|
389
389
|
let currentElementObjColumns = computed(() => {
|
|
390
|
-
if (currentElementObj.value?.printElementType.type ===
|
|
391
|
-
return currentElementObj.value.options.columns[0][
|
|
390
|
+
if (currentElementObj.value?.printElementType.type === 'table') {
|
|
391
|
+
return currentElementObj.value.options.columns[0]['columns'] || [];
|
|
392
392
|
} else {
|
|
393
393
|
return [];
|
|
394
394
|
}
|
|
395
395
|
});
|
|
396
396
|
|
|
397
397
|
function tableFieldChange(val) {
|
|
398
|
-
currentElementObj.value.updateOption(
|
|
398
|
+
currentElementObj.value.updateOption('field', val);
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
function tableColumnCancel() {
|
|
@@ -417,11 +417,11 @@ function init() {
|
|
|
417
417
|
options: [],
|
|
418
418
|
},
|
|
419
419
|
{
|
|
420
|
-
name:
|
|
420
|
+
name: '样式',
|
|
421
421
|
options: [
|
|
422
422
|
{
|
|
423
|
-
name:
|
|
424
|
-
after:
|
|
423
|
+
name: 'scale',
|
|
424
|
+
after: 'transform',
|
|
425
425
|
hidden: false,
|
|
426
426
|
},
|
|
427
427
|
],
|
|
@@ -429,16 +429,16 @@ function init() {
|
|
|
429
429
|
],
|
|
430
430
|
supportOptions: [
|
|
431
431
|
{
|
|
432
|
-
name:
|
|
432
|
+
name: 'styler',
|
|
433
433
|
hidden: true,
|
|
434
434
|
},
|
|
435
435
|
{
|
|
436
|
-
name:
|
|
437
|
-
after:
|
|
436
|
+
name: 'scale',
|
|
437
|
+
after: 'transform',
|
|
438
438
|
hidden: false,
|
|
439
439
|
},
|
|
440
440
|
{
|
|
441
|
-
name:
|
|
441
|
+
name: 'formatter',
|
|
442
442
|
hidden: true,
|
|
443
443
|
},
|
|
444
444
|
],
|
|
@@ -447,18 +447,18 @@ function init() {
|
|
|
447
447
|
tabs: [
|
|
448
448
|
{
|
|
449
449
|
replace: true,
|
|
450
|
-
name:
|
|
450
|
+
name: '基本',
|
|
451
451
|
options: [
|
|
452
452
|
{
|
|
453
|
-
name:
|
|
453
|
+
name: 'field',
|
|
454
454
|
hidden: false,
|
|
455
455
|
},
|
|
456
456
|
{
|
|
457
|
-
name:
|
|
457
|
+
name: 'src',
|
|
458
458
|
hidden: false,
|
|
459
459
|
},
|
|
460
460
|
{
|
|
461
|
-
name:
|
|
461
|
+
name: 'fit',
|
|
462
462
|
hidden: false,
|
|
463
463
|
},
|
|
464
464
|
],
|
|
@@ -466,31 +466,30 @@ function init() {
|
|
|
466
466
|
],
|
|
467
467
|
},
|
|
468
468
|
table: {
|
|
469
|
-
tabs: [{
|
|
469
|
+
tabs: [{options: [{name: 'field', hidden: true}]}],
|
|
470
470
|
},
|
|
471
471
|
});
|
|
472
472
|
|
|
473
|
-
hiprint.PrintElementTypeManager.buildByHtml(hiprintJQuery(
|
|
474
|
-
hiprintJQuery(
|
|
473
|
+
hiprint.PrintElementTypeManager.buildByHtml(hiprintJQuery('.ep-draggable-item'));
|
|
474
|
+
hiprintJQuery('#hiprint-printTemplate').empty();
|
|
475
475
|
let template = JSON.parse(detailData.value.json) || panel;
|
|
476
476
|
hiprintTemplate.value = new hiprint.PrintTemplate({
|
|
477
477
|
template,
|
|
478
478
|
onImageChooseClick: (target) => {
|
|
479
479
|
// 测试 3秒后修改图片地址值
|
|
480
480
|
setTimeout(() => {
|
|
481
|
-
target.refresh(
|
|
481
|
+
target.refresh('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtAAAAIIAQMAAAB99EudAAAABlBMVEUmf8vG2O41LStnAAABD0lEQVR42u3XQQqCQBSAYcWFS4/QUTpaHa2jdISWLUJjjMpclJoPGvq+1WsYfiJCZ4oCAAAAAAAAAAAAAAAAAHin6pL9c6H/fOzHbRrP0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0u/SY9LS0tLS0tLS0tLS0n+edm+UlpaWlpaWlpaWlpaW/tl0Ndyzbno7/+tPTJdd1wal69dNa6abx+Lq6TSeYtK7BX/Diek0XULSZZrakPRtV0i6Hu/KIt30q4fM0pvBqvR9mvsQkZaW9gyJT+f5lsnzjR54xAk8mAUeJyMPwYFH98ALx5Jr0kRLLndT7b64UX9QR/0eAAAAAAAAAAAAAAAAAAD/4gpryzr/bja4QgAAAABJRU5ErkJggg==', {
|
|
482
482
|
real: true,
|
|
483
483
|
});
|
|
484
484
|
}, 3000);
|
|
485
485
|
},
|
|
486
486
|
fontList: [
|
|
487
|
-
{
|
|
488
|
-
{
|
|
489
|
-
{
|
|
490
|
-
{
|
|
491
|
-
{
|
|
492
|
-
{
|
|
493
|
-
{ title: "cursive", value: "cursive" },
|
|
487
|
+
{title: '微软雅黑', value: 'Microsoft YaHei'},
|
|
488
|
+
{title: '黑体', value: 'STHeitiSC-Light'},
|
|
489
|
+
{title: '思源黑体', value: 'SourceHanSansCN-Normal'},
|
|
490
|
+
{title: '宋体', value: 'SimSun'},
|
|
491
|
+
{title: 'cursive', value: 'cursive'},
|
|
492
|
+
{title: 'Times New Roman', value: 'Times New Roman'},
|
|
494
493
|
],
|
|
495
494
|
dataMode: 1,
|
|
496
495
|
history: true,
|
|
@@ -501,11 +500,11 @@ function init() {
|
|
|
501
500
|
onUpdateError: (e) => {
|
|
502
501
|
// console.error(e);
|
|
503
502
|
},
|
|
504
|
-
settingContainer:
|
|
505
|
-
paginationContainer:
|
|
503
|
+
settingContainer: '#PrintElementOptionSetting',
|
|
504
|
+
paginationContainer: '.hiprint-printPagination',
|
|
506
505
|
});
|
|
507
506
|
|
|
508
|
-
hiprintTemplate.value.design(
|
|
507
|
+
hiprintTemplate.value.design('#hiprint-printTemplate', {grid: true});
|
|
509
508
|
scaleValue.value = hiprintTemplate.value.editingPanel.scale || 1;
|
|
510
509
|
window.ht = hiprintTemplate.value;
|
|
511
510
|
|
|
@@ -519,7 +518,7 @@ function init() {
|
|
|
519
518
|
})
|
|
520
519
|
);
|
|
521
520
|
}
|
|
522
|
-
hiprintJQuery(
|
|
521
|
+
hiprintJQuery('.hiprint-designer').on('mousedown', '.hiprint-printElement', (e) => {
|
|
523
522
|
let t = e.currentTarget;
|
|
524
523
|
let pes = hiprintTemplate.value.editingPanel.printElements;
|
|
525
524
|
let index = pes.map((item) => item.designTarget[0]).indexOf(t);
|
|
@@ -533,8 +532,8 @@ function init() {
|
|
|
533
532
|
console.log(error.message);
|
|
534
533
|
clearPrint();
|
|
535
534
|
hiprintTemplate.value = null;
|
|
536
|
-
if (error.message.indexOf(
|
|
537
|
-
ElMessageBox.alert(
|
|
535
|
+
if (error.message.indexOf('setTemplateId') > -1) {
|
|
536
|
+
ElMessageBox.alert('模板有错误,请返回列表手动修改或这清空模板!');
|
|
538
537
|
}
|
|
539
538
|
}
|
|
540
539
|
}
|
|
@@ -550,7 +549,7 @@ async function updateTemplate() {
|
|
|
550
549
|
if (detailData.value && detailData.value.json) {
|
|
551
550
|
let jsonObj = JSON.parse(detailData.value.json);
|
|
552
551
|
hiprintTemplate.value.update(jsonObj);
|
|
553
|
-
let {
|
|
552
|
+
let {width, height} = jsonObj.panels[0];
|
|
554
553
|
paperWidth.value = width;
|
|
555
554
|
paperHeight.value = height;
|
|
556
555
|
hiprintTemplate.value.setPaper(width, height);
|
|
@@ -567,7 +566,7 @@ async function updateTemplate() {
|
|
|
567
566
|
paperNumberLeft: 430,
|
|
568
567
|
paperNumberTop: 5,
|
|
569
568
|
printElements: [],
|
|
570
|
-
watermarkOptions: {
|
|
569
|
+
watermarkOptions: {content: '', rotate: 25, timestamp: false, format: 'YYYY-MM-DD HH:mm'},
|
|
571
570
|
},
|
|
572
571
|
],
|
|
573
572
|
});
|