yh-hiprint 2.3.5 → 2.4.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 +494 -86
- package/hooks/useHiprint.js +48 -27
- package/libs/jquery.js +1 -0
- package/libs/jsbarcode/JsBarcode.js +225 -251
- package/libs/jsbarcode/barcodes/Barcode.js +9 -17
- package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
- package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
- package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
- package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
- package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
- package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
- package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
- package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
- package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
- package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
- package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
- package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
- package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
- package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
- package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
- package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
- package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
- package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
- package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
- package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
- package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
- package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
- package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
- package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
- package/libs/jsbarcode/barcodes/index.js +20 -33
- package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
- package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
- package/libs/jsbarcode/exceptions/exceptions.js +21 -59
- package/libs/jsbarcode/help/fixOptions.js +3 -9
- package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
- package/libs/jsbarcode/help/getRenderProperties.js +63 -69
- package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
- package/libs/jsbarcode/help/merge.js +1 -11
- package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
- package/libs/jsbarcode/options/defaults.js +2 -7
- package/libs/jsbarcode/renderers/canvas.js +106 -127
- package/libs/jsbarcode/renderers/index.js +4 -20
- package/libs/jsbarcode/renderers/object.js +7 -23
- package/libs/jsbarcode/renderers/shared.js +32 -39
- package/libs/jsbarcode/renderers/svg.js +136 -154
- package/package.json +1 -1
- package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
package/HiprintDesigner.vue
CHANGED
|
@@ -1,86 +1,239 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<section class="hiprint-designer">
|
|
3
3
|
<header class="hiprint-designer__header">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
4
|
+
<div class="hiprint-designer__header_content">
|
|
5
|
+
<el-popover
|
|
6
|
+
placement="bottom-start"
|
|
7
|
+
:width="250"
|
|
8
|
+
trigger="hover">
|
|
9
|
+
<template #reference>
|
|
10
|
+
<el-button-group>
|
|
11
|
+
<el-button
|
|
12
|
+
class="paper-setting-text"
|
|
13
|
+
type="primary"
|
|
14
|
+
plain>
|
|
15
|
+
宽高:{{ paperTypeName }}
|
|
16
|
+
</el-button>
|
|
17
|
+
<el-button
|
|
18
|
+
type="primary"
|
|
19
|
+
style="padding: 8px">
|
|
20
|
+
<i
|
|
21
|
+
style="padding: 0"
|
|
22
|
+
class="iconfont icon-down"></i>
|
|
23
|
+
</el-button>
|
|
24
|
+
</el-button-group>
|
|
25
|
+
</template>
|
|
26
|
+
<div class="paper-setting">
|
|
27
|
+
<div class="paper-setting_types">
|
|
28
|
+
<div
|
|
29
|
+
class="paper-setting-type-item"
|
|
30
|
+
v-for="type in paperTypesObj"
|
|
31
|
+
@click="setPaperHandler(type.value)">
|
|
32
|
+
{{ type.label }}
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="paper-setting__content">
|
|
36
|
+
<el-input
|
|
37
|
+
v-model="paperWidth"
|
|
38
|
+
type="number">
|
|
39
|
+
<template #prepend>宽</template>
|
|
40
|
+
<template #append>px</template>
|
|
41
|
+
</el-input>
|
|
42
|
+
<el-input
|
|
43
|
+
v-model="paperHeight"
|
|
44
|
+
type="number">
|
|
45
|
+
<template #prepend>高</template>
|
|
46
|
+
<template #append>px</template>
|
|
47
|
+
</el-input>
|
|
48
|
+
<el-button
|
|
49
|
+
type="primary"
|
|
50
|
+
@click="setPaperHandler('other')">
|
|
51
|
+
设置
|
|
52
|
+
</el-button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</el-popover>
|
|
56
|
+
<el-dropdown>
|
|
57
|
+
<el-button-group>
|
|
58
|
+
<el-button
|
|
59
|
+
class="paper-setting-text"
|
|
60
|
+
type="primary"
|
|
61
|
+
plain>
|
|
62
|
+
缩放:{{ scalePercentage }}
|
|
63
|
+
</el-button>
|
|
64
|
+
<el-button
|
|
65
|
+
type="primary"
|
|
66
|
+
style="padding: 8px">
|
|
67
|
+
<i
|
|
68
|
+
style="padding: 0"
|
|
69
|
+
class="iconfont icon-down"></i>
|
|
70
|
+
</el-button>
|
|
71
|
+
</el-button-group>
|
|
72
|
+
<template #dropdown>
|
|
73
|
+
<el-dropdown-menu>
|
|
74
|
+
<el-dropdown-item
|
|
75
|
+
:disabled="!canZoomIn"
|
|
76
|
+
@click="zoomIn">
|
|
77
|
+
<i class="iconfont icon-zoom-out"></i>
|
|
78
|
+
缩小
|
|
79
|
+
</el-dropdown-item>
|
|
80
|
+
<el-dropdown-item
|
|
81
|
+
:disabled="!canZoomOut"
|
|
82
|
+
@click="zoomOut">
|
|
83
|
+
<i class="iconfont icon-zoom-in"></i>
|
|
84
|
+
放大
|
|
85
|
+
</el-dropdown-item>
|
|
86
|
+
</el-dropdown-menu>
|
|
87
|
+
</template>
|
|
88
|
+
</el-dropdown>
|
|
89
|
+
<el-dropdown @command="onAlign">
|
|
90
|
+
<el-button-group>
|
|
91
|
+
<el-button
|
|
92
|
+
type="primary"
|
|
93
|
+
plain>
|
|
94
|
+
对齐
|
|
95
|
+
</el-button>
|
|
96
|
+
<el-button
|
|
97
|
+
type="primary"
|
|
98
|
+
style="padding: 8px">
|
|
99
|
+
<i
|
|
100
|
+
style="padding: 0"
|
|
101
|
+
class="iconfont icon-down"></i>
|
|
102
|
+
</el-button>
|
|
103
|
+
</el-button-group>
|
|
104
|
+
<template #dropdown>
|
|
105
|
+
<el-dropdown-menu>
|
|
106
|
+
<el-dropdown-item
|
|
107
|
+
:disabled="isLessThanTwoSelected"
|
|
108
|
+
command="top">
|
|
109
|
+
顶部对齐
|
|
110
|
+
</el-dropdown-item>
|
|
111
|
+
<el-dropdown-item
|
|
112
|
+
:disabled="isLessThanTwoSelected"
|
|
113
|
+
command="middle">
|
|
114
|
+
上下居中
|
|
115
|
+
</el-dropdown-item>
|
|
116
|
+
<el-dropdown-item
|
|
117
|
+
:disabled="isLessThanTwoSelected"
|
|
118
|
+
command="bottom">
|
|
119
|
+
底部对齐
|
|
120
|
+
</el-dropdown-item>
|
|
121
|
+
<el-dropdown-item
|
|
122
|
+
:disabled="isLessThanTwoSelected"
|
|
123
|
+
command="left">
|
|
124
|
+
左对齐
|
|
125
|
+
</el-dropdown-item>
|
|
126
|
+
<el-dropdown-item
|
|
127
|
+
:disabled="isLessThanTwoSelected"
|
|
128
|
+
command="center">
|
|
129
|
+
左右居中
|
|
130
|
+
</el-dropdown-item>
|
|
131
|
+
<el-dropdown-item
|
|
132
|
+
:disabled="isLessThanTwoSelected"
|
|
133
|
+
command="right">
|
|
134
|
+
右对齐
|
|
135
|
+
</el-dropdown-item>
|
|
136
|
+
</el-dropdown-menu>
|
|
137
|
+
</template>
|
|
138
|
+
</el-dropdown>
|
|
139
|
+
<el-dropdown @command="onSplit">
|
|
140
|
+
<el-button-group>
|
|
141
|
+
<el-button
|
|
142
|
+
type="primary"
|
|
143
|
+
plain>
|
|
144
|
+
分布
|
|
145
|
+
</el-button>
|
|
146
|
+
<el-button
|
|
147
|
+
type="primary"
|
|
148
|
+
style="padding: 8px">
|
|
149
|
+
<i
|
|
150
|
+
style="padding: 0"
|
|
151
|
+
class="iconfont icon-down"></i>
|
|
152
|
+
</el-button>
|
|
153
|
+
</el-button-group>
|
|
154
|
+
<template #dropdown>
|
|
155
|
+
<el-dropdown-menu class="cna-actions-dropdown">
|
|
156
|
+
<el-dropdown-item
|
|
157
|
+
:disabled="!isMoreSelected"
|
|
158
|
+
command="horizontal">
|
|
159
|
+
水平分布
|
|
160
|
+
</el-dropdown-item>
|
|
161
|
+
<el-dropdown-item
|
|
162
|
+
:disabled="!isMoreSelected"
|
|
163
|
+
command="vertical">
|
|
164
|
+
垂直分布
|
|
165
|
+
</el-dropdown-item>
|
|
166
|
+
</el-dropdown-menu>
|
|
167
|
+
</template>
|
|
168
|
+
</el-dropdown>
|
|
169
|
+
<el-dropdown @command="onSize">
|
|
170
|
+
<el-button-group>
|
|
171
|
+
<el-button
|
|
172
|
+
type="primary"
|
|
173
|
+
plain>
|
|
174
|
+
尺寸
|
|
175
|
+
</el-button>
|
|
176
|
+
<el-button
|
|
177
|
+
type="primary"
|
|
178
|
+
style="padding: 8px">
|
|
179
|
+
<i
|
|
180
|
+
style="padding: 0"
|
|
181
|
+
class="iconfont icon-down"></i>
|
|
182
|
+
</el-button>
|
|
183
|
+
</el-button-group>
|
|
184
|
+
<template #dropdown>
|
|
185
|
+
<el-dropdown-menu class="cna-actions-dropdown">
|
|
186
|
+
<el-dropdown-item
|
|
187
|
+
:disabled="isLessThanTwoSelected"
|
|
188
|
+
command="width">
|
|
189
|
+
等宽
|
|
190
|
+
</el-dropdown-item>
|
|
191
|
+
<el-dropdown-item
|
|
192
|
+
:disabled="isLessThanTwoSelected"
|
|
193
|
+
command="height">
|
|
194
|
+
等高
|
|
195
|
+
</el-dropdown-item>
|
|
196
|
+
<el-dropdown-item
|
|
197
|
+
:disabled="isLessThanTwoSelected"
|
|
198
|
+
command="both">
|
|
199
|
+
大小相等
|
|
200
|
+
</el-dropdown-item>
|
|
201
|
+
</el-dropdown-menu>
|
|
202
|
+
</template>
|
|
203
|
+
</el-dropdown>
|
|
204
|
+
</div>
|
|
205
|
+
<el-form inline>
|
|
206
|
+
<el-form-item label="数据源">
|
|
207
|
+
<el-select
|
|
208
|
+
placeholder="请选择数据源"
|
|
209
|
+
multiple
|
|
210
|
+
v-model="formCode"
|
|
211
|
+
collapse-tags
|
|
212
|
+
collapse-tags-tooltip>
|
|
213
|
+
<el-option
|
|
214
|
+
v-for="d in dataSourceForm"
|
|
215
|
+
:label="d.label"
|
|
216
|
+
:value="d.value"></el-option>
|
|
217
|
+
</el-select>
|
|
40
218
|
</el-form-item>
|
|
41
219
|
</el-form>
|
|
42
|
-
<el-input
|
|
43
|
-
class="percentage"
|
|
44
|
-
readonly
|
|
45
|
-
v-model="scalePercentage">
|
|
46
|
-
<template #prepend>
|
|
47
|
-
<el-button
|
|
48
|
-
:disabled="!canZoomIn"
|
|
49
|
-
@click="zoomIn">
|
|
50
|
-
<i class="iconfont icon-zoom-out"></i>
|
|
51
|
-
</el-button>
|
|
52
|
-
</template>
|
|
53
|
-
<template #append>
|
|
54
|
-
<el-button
|
|
55
|
-
:disabled="!canZoomOut"
|
|
56
|
-
@click="zoomOut">
|
|
57
|
-
<i class="iconfont icon-zoom-in"></i>
|
|
58
|
-
</el-button>
|
|
59
|
-
</template>
|
|
60
|
-
</el-input>
|
|
61
|
-
<el-select
|
|
62
|
-
placeholder="请选择数据源"
|
|
63
|
-
multiple
|
|
64
|
-
v-model="formCode">
|
|
65
|
-
<el-option
|
|
66
|
-
v-for="d in dataSourceForm"
|
|
67
|
-
:label="d.label"
|
|
68
|
-
:value="d.value"></el-option>
|
|
69
|
-
</el-select>
|
|
70
220
|
<el-button
|
|
71
221
|
type="primary"
|
|
222
|
+
text
|
|
72
223
|
@click="previewPrint">
|
|
73
224
|
<i class="iconfont icon-print"></i>
|
|
74
225
|
预览
|
|
75
226
|
</el-button>
|
|
76
227
|
<el-button
|
|
77
228
|
type="primary"
|
|
229
|
+
text
|
|
78
230
|
@click="saveConfig">
|
|
79
231
|
<i class="iconfont icon-save"></i>
|
|
80
232
|
保存
|
|
81
233
|
</el-button>
|
|
82
234
|
<el-button
|
|
83
235
|
type="danger"
|
|
236
|
+
text
|
|
84
237
|
@click="clearPrint">
|
|
85
238
|
<i class="iconfont icon-clear"></i>
|
|
86
239
|
清空
|
|
@@ -216,7 +369,7 @@
|
|
|
216
369
|
</section>
|
|
217
370
|
<aside class="hiprint-designer__main_right">
|
|
218
371
|
<div id="PrintElementOptionSetting"></div>
|
|
219
|
-
<template v-if="
|
|
372
|
+
<template v-if="selectedTableEleColumns.length">
|
|
220
373
|
<div class="hiprint-designer_title">表格字段设置</div>
|
|
221
374
|
<el-form
|
|
222
375
|
label-position="top"
|
|
@@ -241,7 +394,7 @@
|
|
|
241
394
|
<el-row gutter="10">
|
|
242
395
|
<el-col
|
|
243
396
|
:span="12"
|
|
244
|
-
v-for="col in
|
|
397
|
+
v-for="col in selectedTableEleColumns">
|
|
245
398
|
<el-form-item :label="col.title">
|
|
246
399
|
<template v-if="hasDataSource">
|
|
247
400
|
<el-select v-model="col.field">
|
|
@@ -278,9 +431,10 @@
|
|
|
278
431
|
</template>
|
|
279
432
|
<script setup lang="ts">
|
|
280
433
|
// @ts-nocheck
|
|
281
|
-
import {onMounted, ref, onActivated, onDeactivated, computed, watch} from 'vue';
|
|
434
|
+
import {onMounted, ref, onActivated, onDeactivated, computed, watch, shallowRef} from 'vue';
|
|
282
435
|
import {hiprint, defaultElementTypeProvider, fontSize, scale, zIndex, panel, usePaper, useScale, useDataSource} from 'yh-hiprint';
|
|
283
436
|
import {useRoute, onBeforeRouteUpdate} from 'vue-router';
|
|
437
|
+
import {toValue} from '@vueuse/core';
|
|
284
438
|
import {ElMessageBox, ElMessage} from 'element-plus';
|
|
285
439
|
import axios from '@/libs/api.request';
|
|
286
440
|
|
|
@@ -292,9 +446,9 @@ interface HiprintTemplate {
|
|
|
292
446
|
}
|
|
293
447
|
|
|
294
448
|
const route = useRoute();
|
|
295
|
-
const hiprintTemplate =
|
|
449
|
+
const hiprintTemplate = shallowRef<HiprintTemplate | null>(null);
|
|
296
450
|
|
|
297
|
-
const {paperType, paperWidth, paperHeight, setPaper} = usePaper();
|
|
451
|
+
const {paperType, paperTypeName, paperTypesObj, paperWidth, paperHeight, setPaper} = usePaper();
|
|
298
452
|
function setPaperHandler(type) {
|
|
299
453
|
setPaper(type, () => {
|
|
300
454
|
hiprintTemplate.value?.setPaper(paperWidth.value, paperHeight.value);
|
|
@@ -384,6 +538,13 @@ function clearPrint() {
|
|
|
384
538
|
hiprintTemplate.value?.clear();
|
|
385
539
|
}
|
|
386
540
|
|
|
541
|
+
function testUpdate() {
|
|
542
|
+
let els = hiprintTemplate.value.getSelectEls();
|
|
543
|
+
window.a = els[0];
|
|
544
|
+
a.options.top = a.options.top + 10;
|
|
545
|
+
hiprintJQuery(a.designTarget[0]).css('top', a.options.displayTop());
|
|
546
|
+
}
|
|
547
|
+
|
|
387
548
|
const {detailData, getDetail, listCode, dataSourceList, listColumns, formCode, formColumns, dataSourceForm, getDataSourceList} = useDataSource(axios);
|
|
388
549
|
|
|
389
550
|
watch(
|
|
@@ -407,21 +568,199 @@ watch(
|
|
|
407
568
|
immediate: true,
|
|
408
569
|
}
|
|
409
570
|
);
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
571
|
+
|
|
572
|
+
const selectedEle = shallowRef([]);
|
|
573
|
+
|
|
574
|
+
const isLessThanTwoSelected = computed(() => {
|
|
575
|
+
return !selectedEle.value || selectedEle.value.length < 2;
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const isMoreThanTwoSelected = computed(() => {
|
|
579
|
+
return selectedEle.value && selectedEle.value.length >= 2;
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
const isMoreSelected = computed(() => {
|
|
583
|
+
return selectedEle.value && selectedEle.value.length >= 3;
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
let selectedTableEle = ref(null);
|
|
587
|
+
|
|
588
|
+
let selectedTableEleColumns = computed(() => {
|
|
589
|
+
if (selectedTableEle.value && selectedTableEle.value.printElementType.type === 'table') {
|
|
590
|
+
return selectedTableEle.value.options?.columns[0]['columns'] || [];
|
|
414
591
|
} else {
|
|
415
592
|
return [];
|
|
416
593
|
}
|
|
417
594
|
});
|
|
418
595
|
|
|
596
|
+
function onAlign(e) {
|
|
597
|
+
switch (e) {
|
|
598
|
+
case 'top':
|
|
599
|
+
let tys = selectedEle.value.map((item) => item.options.top);
|
|
600
|
+
let tminY = Math.min(...tys);
|
|
601
|
+
selectedEle.value.forEach((item) => {
|
|
602
|
+
item.options.top = tminY;
|
|
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;
|
|
615
|
+
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
|
+
});
|
|
674
|
+
let countWidth = 0;
|
|
675
|
+
sortCompos.forEach((item) => {
|
|
676
|
+
countWidth += item.options.width;
|
|
677
|
+
});
|
|
678
|
+
let countGap = maxrx - minlx - countWidth;
|
|
679
|
+
let gap = countGap / (sortCompos.length - 1);
|
|
680
|
+
sortCompos.forEach((item, index, arr) => {
|
|
681
|
+
if (index > 0 && index < arr.length - 1) {
|
|
682
|
+
let preItem = arr[index - 1];
|
|
683
|
+
item.options.left = preItem.options.left + preItem.options.width + gap;
|
|
684
|
+
hiprintJQuery(item.designTarget[0]).css('left', item.options.displayLeft());
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
} else {
|
|
688
|
+
// TODO 此处隐藏了操作提示,这一处提示是告知为什么不能进行操作的原因,不过措辞没有研究好。所以遇到这种情况暂时做静默处理吧。
|
|
689
|
+
// let obj = selectedEle.value[minlxIndex];
|
|
690
|
+
// this.$message.info(`[${obj.compName}]元素影响均匀分布计算了,请取消选中[${obj.compName}]`)
|
|
691
|
+
}
|
|
692
|
+
break;
|
|
693
|
+
case 'vertical':
|
|
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;
|
|
703
|
+
});
|
|
704
|
+
let countHeight = 0;
|
|
705
|
+
sortCompos.forEach((item) => {
|
|
706
|
+
countHeight += item.options.height;
|
|
707
|
+
});
|
|
708
|
+
let countGap = maxry - minly - countHeight;
|
|
709
|
+
let gap = countGap / (sortCompos.length - 1);
|
|
710
|
+
sortCompos.forEach((item, index, arr) => {
|
|
711
|
+
if (index > 0 && index < arr.length - 1) {
|
|
712
|
+
let preItem = arr[index - 1];
|
|
713
|
+
item.options.top = preitem.options.top + preItem.options.height + gap;
|
|
714
|
+
hiprintJQuery(item.designTarget[0]).css('top', item.options.displayTop());
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
} else {
|
|
718
|
+
// TODO 此处隐藏了操作提示,这一处提示是告知为什么不能进行操作的原因,不过措辞没有研究好。所以遇到这种情况暂时做静默处理吧。
|
|
719
|
+
// let obj = selectedEle.value[minlxIndex];
|
|
720
|
+
// this.$message.info(`[${obj.compName}]元素影响均匀分布计算了,请取消选中[${obj.compName}]`)
|
|
721
|
+
}
|
|
722
|
+
break;
|
|
723
|
+
default:
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function onSize(key) {
|
|
729
|
+
switch (key) {
|
|
730
|
+
case 'width':
|
|
731
|
+
let width = selectedEle.value[0].options.width;
|
|
732
|
+
selectedEle.value.forEach((item) => {
|
|
733
|
+
item.options.width = width;
|
|
734
|
+
hiprintJQuery(item.designTarget[0]).css('width', item.options.displayWidth());
|
|
735
|
+
});
|
|
736
|
+
break;
|
|
737
|
+
case 'height':
|
|
738
|
+
let height = selectedEle.value[0].options.height;
|
|
739
|
+
selectedEle.value.forEach((item) => {
|
|
740
|
+
item.options.height = height;
|
|
741
|
+
hiprintJQuery(item.designTarget[0]).css('height', item.options.displayHeight());
|
|
742
|
+
});
|
|
743
|
+
break;
|
|
744
|
+
case 'both':
|
|
745
|
+
let {w, h} = selectedEle.value[0].rect;
|
|
746
|
+
|
|
747
|
+
selectedEle.value.forEach((item) => {
|
|
748
|
+
item.options.height = h;
|
|
749
|
+
item.options.width = w;
|
|
750
|
+
hiprintJQuery(item.designTarget[0]).css('height', item.options.displayHeight()).css('width', item.options.displayWidth());
|
|
751
|
+
});
|
|
752
|
+
break;
|
|
753
|
+
default:
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
419
758
|
function tableFieldChange(val) {
|
|
420
|
-
|
|
759
|
+
selectedTableEle.value.updateOption('field', val);
|
|
421
760
|
}
|
|
422
761
|
|
|
423
762
|
function tableColumnCancel() {
|
|
424
|
-
|
|
763
|
+
selectedTableEle.value = null;
|
|
425
764
|
}
|
|
426
765
|
|
|
427
766
|
function init() {
|
|
@@ -497,7 +836,9 @@ function init() {
|
|
|
497
836
|
let template = JSON.parse(detailData.value.json) || panel;
|
|
498
837
|
hiprintTemplate.value = new hiprint.PrintTemplate({
|
|
499
838
|
template,
|
|
500
|
-
onImageChooseClick: (target) => {
|
|
839
|
+
onImageChooseClick: (target) => {
|
|
840
|
+
console.log(target);
|
|
841
|
+
},
|
|
501
842
|
fontList: [
|
|
502
843
|
{title: '微软雅黑', value: 'Microsoft YaHei'},
|
|
503
844
|
{title: '黑体', value: 'STHeitiSC-Light'},
|
|
@@ -530,11 +871,12 @@ function init() {
|
|
|
530
871
|
}
|
|
531
872
|
hiprintJQuery('.hiprint-designer').on('mousedown', '.hiprint-printElement', (e) => {
|
|
532
873
|
let t = e.currentTarget;
|
|
874
|
+
selectedEle.value = hiprintTemplate.value?.getSelectEls() || [];
|
|
533
875
|
let pes = hiprintTemplate.value?.editingPanel.printElements;
|
|
534
|
-
let index = pes.map((item) => item.designTarget[0]).
|
|
876
|
+
let index = pes.map((item) => item.designTarget[0]).findIndex((item) => t === item);
|
|
535
877
|
let pe = pes[index];
|
|
536
|
-
|
|
537
|
-
if (pe.options.field) {
|
|
878
|
+
selectedTableEle.value = pe || null;
|
|
879
|
+
if (pe && pe.options.field) {
|
|
538
880
|
listCode.value = pe.options.field;
|
|
539
881
|
}
|
|
540
882
|
});
|
|
@@ -605,8 +947,28 @@ async function updateTemplate(code) {
|
|
|
605
947
|
const hasDataSource = computed(() => {
|
|
606
948
|
return Array.isArray(formCode.value) ? formCode.value.length > 0 : formCode.value;
|
|
607
949
|
});
|
|
950
|
+
|
|
951
|
+
function wheelHandler(e: MouseEvent) {
|
|
952
|
+
console.log(e);
|
|
953
|
+
if (e.ctrlKey) {
|
|
954
|
+
const isZoomIn = e.wheelDelta < 0;
|
|
955
|
+
const isZoomOut = e.wheelDelta > 0;
|
|
956
|
+
if (isZoomIn && canZoomIn) {
|
|
957
|
+
e.preventDefault();
|
|
958
|
+
e.stopPropagation();
|
|
959
|
+
zoomIn();
|
|
960
|
+
}
|
|
961
|
+
if (isZoomOut && canZoomOut) {
|
|
962
|
+
e.preventDefault();
|
|
963
|
+
e.stopPropagation();
|
|
964
|
+
zoomOut();
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
608
969
|
onActivated(() => {
|
|
609
970
|
updateTemplate(route.query.code);
|
|
971
|
+
window.addEventListener('wheel', wheelHandler, {passive: false});
|
|
610
972
|
});
|
|
611
973
|
|
|
612
974
|
onBeforeRouteUpdate((to) => {
|
|
@@ -615,6 +977,7 @@ onBeforeRouteUpdate((to) => {
|
|
|
615
977
|
|
|
616
978
|
onDeactivated(() => {
|
|
617
979
|
clearPrint();
|
|
980
|
+
window.removeEventListener('wheel', wheelHandler);
|
|
618
981
|
});
|
|
619
982
|
|
|
620
983
|
onMounted(async () => {
|
|
@@ -643,22 +1006,32 @@ onMounted(async () => {
|
|
|
643
1006
|
margin-right: 10px;
|
|
644
1007
|
margin-left: 0 !important;
|
|
645
1008
|
}
|
|
1009
|
+
.paper-setting-text {
|
|
1010
|
+
width: 100px;
|
|
1011
|
+
.iconfont {
|
|
1012
|
+
display: inline-block;
|
|
1013
|
+
padding: 0 10px 0 20px;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
646
1016
|
.percentage {
|
|
647
1017
|
width: 165px;
|
|
648
1018
|
}
|
|
649
1019
|
.el-select {
|
|
650
1020
|
--el-select-width: auto;
|
|
651
|
-
|
|
1021
|
+
width: 150px;
|
|
1022
|
+
}
|
|
1023
|
+
> .el-button {
|
|
1024
|
+
padding: 5px;
|
|
652
1025
|
}
|
|
653
1026
|
.el-form-item {
|
|
654
1027
|
margin-bottom: 0;
|
|
655
1028
|
margin-right: 10px;
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
1029
|
+
}
|
|
1030
|
+
&_content {
|
|
1031
|
+
flex: 1;
|
|
1032
|
+
> * {
|
|
1033
|
+
margin-right: 10px;
|
|
1034
|
+
margin-left: 0 !important;
|
|
662
1035
|
}
|
|
663
1036
|
}
|
|
664
1037
|
}
|
|
@@ -763,4 +1136,39 @@ onMounted(async () => {
|
|
|
763
1136
|
}
|
|
764
1137
|
}
|
|
765
1138
|
}
|
|
1139
|
+
|
|
1140
|
+
.paper-setting {
|
|
1141
|
+
display: flex;
|
|
1142
|
+
.paper-setting_types {
|
|
1143
|
+
width: 100px;
|
|
1144
|
+
margin-right: 10px;
|
|
1145
|
+
.paper-setting-type-item {
|
|
1146
|
+
width: 100%;
|
|
1147
|
+
text-align: center;
|
|
1148
|
+
height: 40px;
|
|
1149
|
+
line-height: 40px;
|
|
1150
|
+
cursor: pointer;
|
|
1151
|
+
&:hover {
|
|
1152
|
+
background-color: var(--el-color-primary-light-9);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
.paper-setting__content {
|
|
1157
|
+
flex: 1;
|
|
1158
|
+
.el-input {
|
|
1159
|
+
width: 140px;
|
|
1160
|
+
.el-input-group__prepend,
|
|
1161
|
+
.el-input-group__append {
|
|
1162
|
+
padding: 0 9px;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
.el-button + .el-button {
|
|
1166
|
+
margin-left: 0;
|
|
1167
|
+
}
|
|
1168
|
+
> * {
|
|
1169
|
+
width: 100%;
|
|
1170
|
+
margin-bottom: 10px;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
766
1174
|
</style>
|