yh-hiprint 2.2.6 → 2.2.7
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/CHANGE.md +0 -0
- package/HiprintDesigner.vue +77 -65
- package/README.md +0 -0
- package/column-field.js +0 -0
- package/font-size.js +42 -42
- package/hiprint.js +0 -0
- package/hiprint.vue +0 -0
- package/hiprintPreview.vue +0 -0
- package/hooks/useHiprint.js +0 -0
- package/index.d.ts +0 -0
- package/index.js +0 -0
- package/libs/css/hiprint.css +996 -996
- package/libs/css/image/jquery.minicolors.png +0 -0
- package/libs/css/image/l_img.svg +0 -0
- package/libs/css/image/v_img.svg +0 -0
- package/libs/css/print-lock.css +339 -339
- package/libs/etypes/default-etyps-provider.js +157 -157
- package/libs/hiprint.bundle.js +0 -0
- package/libs/hiprint.config.js +1802 -1802
- package/libs/plugins/jquery.hiwprint.js +110 -110
- package/libs/plugins/qrcode.js +617 -617
- package/libs/plugins/watermark.js +199 -199
- package/package.json +1 -1
- package/panel.js +18 -18
- package/scale.js +42 -42
- package/z-index.js +0 -0
package/CHANGE.md
CHANGED
|
File without changes
|
package/HiprintDesigner.vue
CHANGED
|
@@ -222,25 +222,37 @@
|
|
|
222
222
|
label-position="top"
|
|
223
223
|
size="small">
|
|
224
224
|
<el-form-item label="表数据选择">
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
<template v-if="formCode">
|
|
226
|
+
<el-select
|
|
227
|
+
v-model="listCode"
|
|
228
|
+
@change="tableFieldChange">
|
|
229
|
+
<el-option
|
|
230
|
+
v-for="d in dataSourceList"
|
|
231
|
+
:label="d.label"
|
|
232
|
+
:value="d.value"></el-option>
|
|
233
|
+
</el-select>
|
|
234
|
+
</template>
|
|
235
|
+
<template v-else>
|
|
236
|
+
<el-input
|
|
237
|
+
v-model="listCode"
|
|
238
|
+
@change="tableFieldChange"></el-input>
|
|
239
|
+
</template>
|
|
233
240
|
</el-form-item>
|
|
234
241
|
<el-row gutter="10">
|
|
235
242
|
<el-col
|
|
236
243
|
:span="12"
|
|
237
244
|
v-for="col in currentElementObjColumns">
|
|
238
245
|
<el-form-item :label="col.title">
|
|
239
|
-
<
|
|
240
|
-
<el-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
<template v-if="formCode">
|
|
247
|
+
<el-select v-model="col.field">
|
|
248
|
+
<el-option
|
|
249
|
+
v-for="d in listColumns"
|
|
250
|
+
:value="d"></el-option>
|
|
251
|
+
</el-select>
|
|
252
|
+
</template>
|
|
253
|
+
<template v-else>
|
|
254
|
+
<el-input v-model="col.field"></el-input>
|
|
255
|
+
</template>
|
|
244
256
|
</el-form-item>
|
|
245
257
|
</el-col>
|
|
246
258
|
</el-row>
|
|
@@ -266,11 +278,11 @@
|
|
|
266
278
|
</template>
|
|
267
279
|
<script setup lang="ts">
|
|
268
280
|
// @ts-nocheck
|
|
269
|
-
import {
|
|
270
|
-
import {
|
|
271
|
-
import {
|
|
272
|
-
import {
|
|
273
|
-
import axios from
|
|
281
|
+
import {onMounted, ref, onActivated, onDeactivated, computed, watch} from 'vue';
|
|
282
|
+
import {hiprint, defaultElementTypeProvider, fontSize, scale, zIndex, panel, usePaper, useScale, useDataSource, jquery as $} from 'yh-hiprint';
|
|
283
|
+
import {useRoute, onBeforeRouteUpdate} from 'vue-router';
|
|
284
|
+
import {ElMessageBox, ElMessage} from 'element-plus';
|
|
285
|
+
import axios from '@/libs/api.request';
|
|
274
286
|
|
|
275
287
|
interface HiprintTemplate {
|
|
276
288
|
setPaper: (width: number, height: number) => void;
|
|
@@ -282,7 +294,7 @@ interface HiprintTemplate {
|
|
|
282
294
|
const route = useRoute();
|
|
283
295
|
const hiprintTemplate = ref<HiprintTemplate | null>(null);
|
|
284
296
|
|
|
285
|
-
const {
|
|
297
|
+
const {paperType, paperWidth, paperHeight, setPaper} = usePaper();
|
|
286
298
|
function setPaperHandler(type) {
|
|
287
299
|
setPaper(type, () => {
|
|
288
300
|
hiprintTemplate.value?.setPaper(paperWidth.value, paperHeight.value);
|
|
@@ -290,23 +302,23 @@ function setPaperHandler(type) {
|
|
|
290
302
|
}
|
|
291
303
|
|
|
292
304
|
const canvasRef = ref();
|
|
293
|
-
const {
|
|
305
|
+
const {scaleValue, scalePercentage, canZoomIn, canZoomOut, zoomIn, zoomOut} = useScale(() => {
|
|
294
306
|
hiprintTemplate.value?.zoom(scaleValue.value);
|
|
295
307
|
canvasRef?.value.update();
|
|
296
308
|
});
|
|
297
309
|
|
|
298
310
|
const previewShow = ref(false);
|
|
299
|
-
const previewHtml = ref(
|
|
311
|
+
const previewHtml = ref('');
|
|
300
312
|
async function previewPrint() {
|
|
301
313
|
let {
|
|
302
|
-
data: {
|
|
314
|
+
data: {list, json},
|
|
303
315
|
} = await axios.request({
|
|
304
316
|
url: `/printTemplate/data/${detailData.value.code}`,
|
|
305
|
-
method:
|
|
306
|
-
type:
|
|
317
|
+
method: 'post',
|
|
318
|
+
type: 'json',
|
|
307
319
|
data: [
|
|
308
320
|
{
|
|
309
|
-
code:
|
|
321
|
+
code: '50101820',
|
|
310
322
|
},
|
|
311
323
|
],
|
|
312
324
|
});
|
|
@@ -332,11 +344,11 @@ async function previewPrint() {
|
|
|
332
344
|
} else {
|
|
333
345
|
list = [];
|
|
334
346
|
}
|
|
335
|
-
previewHtml.value = new hiprint.PrintTemplate({
|
|
347
|
+
previewHtml.value = new hiprint.PrintTemplate({template: JSON.parse(json)}).getHtml(list)[0].innerHTML;
|
|
336
348
|
previewShow.value = true;
|
|
337
349
|
} else {
|
|
338
350
|
ElMessage.warning({
|
|
339
|
-
message:
|
|
351
|
+
message: '模板配置不存在,请检查',
|
|
340
352
|
});
|
|
341
353
|
}
|
|
342
354
|
}
|
|
@@ -345,25 +357,25 @@ function saveConfig() {
|
|
|
345
357
|
let arr = [].concat(formCode.value);
|
|
346
358
|
let json = hiprintTemplate.value?.getJson();
|
|
347
359
|
json.panels[0].printElements.forEach((item) => {
|
|
348
|
-
if (item.printElementType.type ===
|
|
360
|
+
if (item.printElementType.type === 'table') {
|
|
349
361
|
arr.push(item.options.field);
|
|
350
362
|
}
|
|
351
363
|
});
|
|
352
364
|
|
|
353
365
|
axios
|
|
354
366
|
.request({
|
|
355
|
-
url:
|
|
356
|
-
method:
|
|
357
|
-
type:
|
|
367
|
+
url: '/printTemplate/save',
|
|
368
|
+
method: 'post',
|
|
369
|
+
type: 'json',
|
|
358
370
|
data: {
|
|
359
371
|
id: detailData.value.id,
|
|
360
372
|
json: JSON.stringify(json),
|
|
361
|
-
dsIds: arr.join(
|
|
373
|
+
dsIds: arr.join(','),
|
|
362
374
|
},
|
|
363
375
|
})
|
|
364
376
|
.then((res) => {
|
|
365
377
|
ElMessage.success({
|
|
366
|
-
message:
|
|
378
|
+
message: '恭喜模板保存成功',
|
|
367
379
|
});
|
|
368
380
|
});
|
|
369
381
|
}
|
|
@@ -372,7 +384,7 @@ function clearPrint() {
|
|
|
372
384
|
hiprintTemplate.value?.clear();
|
|
373
385
|
}
|
|
374
386
|
|
|
375
|
-
const {
|
|
387
|
+
const {detailData, getDetail, listCode, dataSourceList, listColumns, formCode, formColumns, dataSourceForm, getDataSourceList} = useDataSource(axios);
|
|
376
388
|
|
|
377
389
|
watch(
|
|
378
390
|
() => formColumns.value,
|
|
@@ -387,7 +399,7 @@ watch(
|
|
|
387
399
|
})
|
|
388
400
|
);
|
|
389
401
|
} else {
|
|
390
|
-
hiprintTemplate.value?.setFields(
|
|
402
|
+
hiprintTemplate.value?.setFields('');
|
|
391
403
|
}
|
|
392
404
|
},
|
|
393
405
|
{
|
|
@@ -397,15 +409,15 @@ watch(
|
|
|
397
409
|
);
|
|
398
410
|
let currentElementObj = ref(null);
|
|
399
411
|
let currentElementObjColumns = computed(() => {
|
|
400
|
-
if (currentElementObj.value?.printElementType.type ===
|
|
401
|
-
return currentElementObj.value.options.columns[0][
|
|
412
|
+
if (currentElementObj.value?.printElementType.type === 'table') {
|
|
413
|
+
return currentElementObj.value.options.columns[0]['columns'] || [];
|
|
402
414
|
} else {
|
|
403
415
|
return [];
|
|
404
416
|
}
|
|
405
417
|
});
|
|
406
418
|
|
|
407
419
|
function tableFieldChange(val) {
|
|
408
|
-
currentElementObj.value.updateOption(
|
|
420
|
+
currentElementObj.value.updateOption('field', val);
|
|
409
421
|
}
|
|
410
422
|
|
|
411
423
|
function tableColumnCancel() {
|
|
@@ -427,11 +439,11 @@ function init() {
|
|
|
427
439
|
options: [],
|
|
428
440
|
},
|
|
429
441
|
{
|
|
430
|
-
name:
|
|
442
|
+
name: '样式',
|
|
431
443
|
options: [
|
|
432
444
|
{
|
|
433
|
-
name:
|
|
434
|
-
after:
|
|
445
|
+
name: 'scale',
|
|
446
|
+
after: 'transform',
|
|
435
447
|
hidden: false,
|
|
436
448
|
},
|
|
437
449
|
],
|
|
@@ -439,16 +451,16 @@ function init() {
|
|
|
439
451
|
],
|
|
440
452
|
supportOptions: [
|
|
441
453
|
{
|
|
442
|
-
name:
|
|
454
|
+
name: 'styler',
|
|
443
455
|
hidden: true,
|
|
444
456
|
},
|
|
445
457
|
{
|
|
446
|
-
name:
|
|
447
|
-
after:
|
|
458
|
+
name: 'scale',
|
|
459
|
+
after: 'transform',
|
|
448
460
|
hidden: false,
|
|
449
461
|
},
|
|
450
462
|
{
|
|
451
|
-
name:
|
|
463
|
+
name: 'formatter',
|
|
452
464
|
hidden: true,
|
|
453
465
|
},
|
|
454
466
|
],
|
|
@@ -457,18 +469,18 @@ function init() {
|
|
|
457
469
|
tabs: [
|
|
458
470
|
{
|
|
459
471
|
replace: true,
|
|
460
|
-
name:
|
|
472
|
+
name: '基本',
|
|
461
473
|
options: [
|
|
462
474
|
{
|
|
463
|
-
name:
|
|
475
|
+
name: 'field',
|
|
464
476
|
hidden: false,
|
|
465
477
|
},
|
|
466
478
|
{
|
|
467
|
-
name:
|
|
479
|
+
name: 'src',
|
|
468
480
|
hidden: false,
|
|
469
481
|
},
|
|
470
482
|
{
|
|
471
|
-
name:
|
|
483
|
+
name: 'fit',
|
|
472
484
|
hidden: false,
|
|
473
485
|
},
|
|
474
486
|
],
|
|
@@ -476,21 +488,21 @@ function init() {
|
|
|
476
488
|
],
|
|
477
489
|
},
|
|
478
490
|
table: {
|
|
479
|
-
tabs: [{
|
|
491
|
+
tabs: [{options: [{name: 'field', hidden: true}]}],
|
|
480
492
|
},
|
|
481
493
|
});
|
|
482
494
|
|
|
483
|
-
hiprint.PrintElementTypeManager.buildByHtml($(
|
|
484
|
-
$(
|
|
495
|
+
hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
|
|
496
|
+
$('#hiprint-printTemplate').empty();
|
|
485
497
|
let template = JSON.parse(detailData.value.json) || panel;
|
|
486
498
|
hiprintTemplate.value = new hiprint.PrintTemplate({
|
|
487
499
|
template,
|
|
488
500
|
onImageChooseClick: (target) => {},
|
|
489
501
|
fontList: [
|
|
490
|
-
{
|
|
491
|
-
{
|
|
492
|
-
{
|
|
493
|
-
{
|
|
502
|
+
{title: '微软雅黑', value: 'Microsoft YaHei'},
|
|
503
|
+
{title: '黑体', value: 'STHeitiSC-Light'},
|
|
504
|
+
{title: '宋体', value: 'SimSun'},
|
|
505
|
+
{title: 'cursive', value: 'cursive'},
|
|
494
506
|
],
|
|
495
507
|
dataMode: 1,
|
|
496
508
|
history: true,
|
|
@@ -498,11 +510,11 @@ function init() {
|
|
|
498
510
|
onUpdateError: (e) => {
|
|
499
511
|
console.error(e);
|
|
500
512
|
},
|
|
501
|
-
settingContainer:
|
|
502
|
-
paginationContainer:
|
|
513
|
+
settingContainer: '#PrintElementOptionSetting',
|
|
514
|
+
paginationContainer: '.hiprint-printPagination',
|
|
503
515
|
});
|
|
504
516
|
|
|
505
|
-
hiprintTemplate.value?.design(
|
|
517
|
+
hiprintTemplate.value?.design('#hiprint-printTemplate', {grid: true});
|
|
506
518
|
scaleValue.value = hiprintTemplate.value.editingPanel.scale || 1;
|
|
507
519
|
window.ht = hiprintTemplate.value;
|
|
508
520
|
|
|
@@ -516,7 +528,7 @@ function init() {
|
|
|
516
528
|
})
|
|
517
529
|
);
|
|
518
530
|
}
|
|
519
|
-
$(
|
|
531
|
+
$('.hiprint-designer').on('mousedown', '.hiprint-printElement', (e) => {
|
|
520
532
|
let t = e.currentTarget;
|
|
521
533
|
let pes = hiprintTemplate.value?.editingPanel.printElements;
|
|
522
534
|
let index = pes.map((item) => item.designTarget[0]).indexOf(t);
|
|
@@ -526,7 +538,7 @@ function init() {
|
|
|
526
538
|
listCode.value = pe.options.field;
|
|
527
539
|
}
|
|
528
540
|
});
|
|
529
|
-
$(
|
|
541
|
+
$('#PrintElementOptionSetting').on('input', 'input[type=number]', ($el) => {
|
|
530
542
|
let val = parseInt($el.target.value);
|
|
531
543
|
if (val < 1) {
|
|
532
544
|
$el.target.value = 1;
|
|
@@ -539,8 +551,8 @@ function init() {
|
|
|
539
551
|
console.log(error.message);
|
|
540
552
|
clearPrint();
|
|
541
553
|
hiprintTemplate.value = null;
|
|
542
|
-
if (error.message.indexOf(
|
|
543
|
-
ElMessageBox.alert(
|
|
554
|
+
if (error.message.indexOf('setTemplateId') > -1) {
|
|
555
|
+
ElMessageBox.alert('模板有错误,请返回列表手动修改或这清空模板!');
|
|
544
556
|
}
|
|
545
557
|
}
|
|
546
558
|
}
|
|
@@ -556,7 +568,7 @@ async function updateTemplate(code) {
|
|
|
556
568
|
if (detailData.value && detailData.value.json) {
|
|
557
569
|
let jsonObj = JSON.parse(detailData.value.json);
|
|
558
570
|
hiprintTemplate.value?.update(jsonObj);
|
|
559
|
-
let {
|
|
571
|
+
let {width, height} = jsonObj.panels[0];
|
|
560
572
|
paperWidth.value = width;
|
|
561
573
|
paperHeight.value = height;
|
|
562
574
|
hiprintTemplate.value?.setPaper(width, height);
|
|
@@ -574,7 +586,7 @@ async function updateTemplate(code) {
|
|
|
574
586
|
paperNumberLeft: 430,
|
|
575
587
|
paperNumberTop: 5,
|
|
576
588
|
printElements: [],
|
|
577
|
-
watermarkOptions: {
|
|
589
|
+
watermarkOptions: {content: '', rotate: 25, timestamp: false, format: 'YYYY-MM-DD HH:mm'},
|
|
578
590
|
},
|
|
579
591
|
],
|
|
580
592
|
});
|
package/README.md
CHANGED
|
File without changes
|
package/column-field.js
CHANGED
|
File without changes
|
package/font-size.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import $ from "jquery";
|
|
2
|
-
export default (function () {
|
|
3
|
-
function t() {
|
|
4
|
-
this.name = "fontSize"; // 重写的参数 key
|
|
5
|
-
}
|
|
6
|
-
// 涉及修改元素样式, 添加一个 css 方法
|
|
7
|
-
return (
|
|
8
|
-
(t.prototype.css = function (t, e) {
|
|
9
|
-
if (t && t.length) {
|
|
10
|
-
if (e) return t.css("font-size", e + "pt"), "font-size:" + e + "pt";
|
|
11
|
-
t[0].style.fontSize = "";
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
}),
|
|
15
|
-
// 创建 DOM
|
|
16
|
-
(t.prototype.createTarget = function () {
|
|
17
|
-
let list = [4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72];
|
|
18
|
-
let fontSizeList = '\n <option value="" >默认</option>';
|
|
19
|
-
list.forEach(function (e) {
|
|
20
|
-
fontSizeList += '\n <option value="' + e + '">' + e + "pt</option>";
|
|
21
|
-
});
|
|
22
|
-
this.target = $(' <div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 字体大小\n </div>\n <div class="hiprint-option-item-field">\n <select class="auto-submit"> </select>\n </div>\n </div>');
|
|
23
|
-
this.target.find(".auto-submit").append($(fontSizeList));
|
|
24
|
-
return this.target;
|
|
25
|
-
}),
|
|
26
|
-
// 获取值
|
|
27
|
-
(t.prototype.getValue = function () {
|
|
28
|
-
var t = this.target.find("select").val();
|
|
29
|
-
if (t) return parseFloat(t.toString());
|
|
30
|
-
}),
|
|
31
|
-
// 设置值
|
|
32
|
-
(t.prototype.setValue = function (t) {
|
|
33
|
-
t && (this.target.find('option[value="' + t + '"]').length || this.target.find("select").prepend('<option value="' + t + '" >' + t + "</option>"));
|
|
34
|
-
this.target.find("select").val(t);
|
|
35
|
-
}),
|
|
36
|
-
// 销毁 DOM
|
|
37
|
-
(t.prototype.destroy = function () {
|
|
38
|
-
this.target.remove();
|
|
39
|
-
}),
|
|
40
|
-
t
|
|
41
|
-
);
|
|
42
|
-
})();
|
|
1
|
+
import $ from "jquery";
|
|
2
|
+
export default (function () {
|
|
3
|
+
function t() {
|
|
4
|
+
this.name = "fontSize"; // 重写的参数 key
|
|
5
|
+
}
|
|
6
|
+
// 涉及修改元素样式, 添加一个 css 方法
|
|
7
|
+
return (
|
|
8
|
+
(t.prototype.css = function (t, e) {
|
|
9
|
+
if (t && t.length) {
|
|
10
|
+
if (e) return t.css("font-size", e + "pt"), "font-size:" + e + "pt";
|
|
11
|
+
t[0].style.fontSize = "";
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}),
|
|
15
|
+
// 创建 DOM
|
|
16
|
+
(t.prototype.createTarget = function () {
|
|
17
|
+
let list = [4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72];
|
|
18
|
+
let fontSizeList = '\n <option value="" >默认</option>';
|
|
19
|
+
list.forEach(function (e) {
|
|
20
|
+
fontSizeList += '\n <option value="' + e + '">' + e + "pt</option>";
|
|
21
|
+
});
|
|
22
|
+
this.target = $(' <div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 字体大小\n </div>\n <div class="hiprint-option-item-field">\n <select class="auto-submit"> </select>\n </div>\n </div>');
|
|
23
|
+
this.target.find(".auto-submit").append($(fontSizeList));
|
|
24
|
+
return this.target;
|
|
25
|
+
}),
|
|
26
|
+
// 获取值
|
|
27
|
+
(t.prototype.getValue = function () {
|
|
28
|
+
var t = this.target.find("select").val();
|
|
29
|
+
if (t) return parseFloat(t.toString());
|
|
30
|
+
}),
|
|
31
|
+
// 设置值
|
|
32
|
+
(t.prototype.setValue = function (t) {
|
|
33
|
+
t && (this.target.find('option[value="' + t + '"]').length || this.target.find("select").prepend('<option value="' + t + '" >' + t + "</option>"));
|
|
34
|
+
this.target.find("select").val(t);
|
|
35
|
+
}),
|
|
36
|
+
// 销毁 DOM
|
|
37
|
+
(t.prototype.destroy = function () {
|
|
38
|
+
this.target.remove();
|
|
39
|
+
}),
|
|
40
|
+
t
|
|
41
|
+
);
|
|
42
|
+
})();
|
package/hiprint.js
CHANGED
|
File without changes
|
package/hiprint.vue
CHANGED
|
File without changes
|
package/hiprintPreview.vue
CHANGED
|
File without changes
|
package/hooks/useHiprint.js
CHANGED
|
File without changes
|
package/index.d.ts
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
File without changes
|