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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import watermark from '../libs/plugins/watermark';
|
|
2
|
+
import {HlinePrintElementType, ImagePrintElementType, PrintElementTypes, TextPrintElementType, VlinePrintElementType, RectPrintElementType, OvalPrintElementType, TablePrintElementType, LongTextPrintElementType, BarcodePrintElementType, QRCodePrintElementType, HTMLPrintElementType} from '../types';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
text: {
|
|
6
|
+
printElementType: {
|
|
7
|
+
title: '文本',
|
|
8
|
+
type: PrintElementTypes.TEXT,
|
|
9
|
+
},
|
|
10
|
+
options: {
|
|
11
|
+
textType: 'text',
|
|
12
|
+
title: '文本',
|
|
13
|
+
},
|
|
14
|
+
} as TextPrintElementType,
|
|
15
|
+
textVal: {
|
|
16
|
+
printElementType: {
|
|
17
|
+
title: '值(文本)',
|
|
18
|
+
type: PrintElementTypes.TEXT,
|
|
19
|
+
},
|
|
20
|
+
options: {
|
|
21
|
+
textType: 'text',
|
|
22
|
+
title: '值(文本)',
|
|
23
|
+
},
|
|
24
|
+
} as TextPrintElementType,
|
|
25
|
+
ImageElement: {
|
|
26
|
+
printElementType: {
|
|
27
|
+
title: '图片',
|
|
28
|
+
type: PrintElementTypes.IMAGE,
|
|
29
|
+
},
|
|
30
|
+
options: {
|
|
31
|
+
title: '图片',
|
|
32
|
+
},
|
|
33
|
+
} as ImagePrintElementType,
|
|
34
|
+
HlineElement: {
|
|
35
|
+
printElementType: {
|
|
36
|
+
title: '横线',
|
|
37
|
+
type: PrintElementTypes.HLINE,
|
|
38
|
+
},
|
|
39
|
+
options: {
|
|
40
|
+
title: '横线',
|
|
41
|
+
},
|
|
42
|
+
} as HlinePrintElementType,
|
|
43
|
+
VlineElement: {
|
|
44
|
+
printElementType: {
|
|
45
|
+
title: '竖线',
|
|
46
|
+
type: PrintElementTypes.VLINE,
|
|
47
|
+
},
|
|
48
|
+
options: {
|
|
49
|
+
title: '竖线',
|
|
50
|
+
},
|
|
51
|
+
} as VlinePrintElementType,
|
|
52
|
+
ReactElement: {
|
|
53
|
+
printElementType: {
|
|
54
|
+
title: '矩形',
|
|
55
|
+
type: PrintElementTypes.RECT,
|
|
56
|
+
},
|
|
57
|
+
options: {
|
|
58
|
+
title: '矩形',
|
|
59
|
+
},
|
|
60
|
+
} as RectPrintElementType,
|
|
61
|
+
OvalElement: {
|
|
62
|
+
printElementType: {
|
|
63
|
+
title: '圆形',
|
|
64
|
+
type: PrintElementTypes.OVAL,
|
|
65
|
+
},
|
|
66
|
+
options: {
|
|
67
|
+
title: '圆形',
|
|
68
|
+
},
|
|
69
|
+
} as OvalPrintElementType,
|
|
70
|
+
TableElement: {
|
|
71
|
+
printElementType: {
|
|
72
|
+
title: '表格',
|
|
73
|
+
type: PrintElementTypes.TABLE,
|
|
74
|
+
columns: [
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
title: '列1',
|
|
78
|
+
width: 100,
|
|
79
|
+
rowspan: 1,
|
|
80
|
+
colspan: 1,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
title: '列2',
|
|
84
|
+
width: 100,
|
|
85
|
+
rowspan: 1,
|
|
86
|
+
colspan: 1,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
options: {
|
|
92
|
+
title: '表格',
|
|
93
|
+
},
|
|
94
|
+
} as TablePrintElementType,
|
|
95
|
+
emptyTableElement: {
|
|
96
|
+
printElementType: {
|
|
97
|
+
title: '空白表格',
|
|
98
|
+
type: PrintElementTypes.TABLE,
|
|
99
|
+
columns: [],
|
|
100
|
+
},
|
|
101
|
+
options: {
|
|
102
|
+
title: '空白表格',
|
|
103
|
+
},
|
|
104
|
+
} as TablePrintElementType,
|
|
105
|
+
LongTextElement: {
|
|
106
|
+
printElementType: {
|
|
107
|
+
title: '长文本',
|
|
108
|
+
type: PrintElementTypes.LONGTEXT,
|
|
109
|
+
},
|
|
110
|
+
options: {
|
|
111
|
+
title: '长文本',
|
|
112
|
+
},
|
|
113
|
+
} as LongTextPrintElementType,
|
|
114
|
+
HTMLElement: {
|
|
115
|
+
printElementType: {
|
|
116
|
+
title: 'HTML',
|
|
117
|
+
type: PrintElementTypes.HTML,
|
|
118
|
+
},
|
|
119
|
+
options: {
|
|
120
|
+
title: 'HTML',
|
|
121
|
+
},
|
|
122
|
+
} as HTMLPrintElementType,
|
|
123
|
+
QRCodeElement: {
|
|
124
|
+
printElementType: {
|
|
125
|
+
title: '二维码',
|
|
126
|
+
type: PrintElementTypes.TEXT,
|
|
127
|
+
},
|
|
128
|
+
options: {
|
|
129
|
+
title: '二维码',
|
|
130
|
+
textType: 'qrcode',
|
|
131
|
+
},
|
|
132
|
+
} as QRCodePrintElementType,
|
|
133
|
+
barcode: {
|
|
134
|
+
printElementType: {
|
|
135
|
+
title: '条形码',
|
|
136
|
+
type: PrintElementTypes.TEXT,
|
|
137
|
+
},
|
|
138
|
+
options: {
|
|
139
|
+
title: '条形码',
|
|
140
|
+
textType: 'barcode',
|
|
141
|
+
},
|
|
142
|
+
} as BarcodePrintElementType,
|
|
143
|
+
panel: {
|
|
144
|
+
index: 0,
|
|
145
|
+
name: 1,
|
|
146
|
+
height: 297,
|
|
147
|
+
width: 210,
|
|
148
|
+
paperHeader: 7.5,
|
|
149
|
+
paperFooter: 780,
|
|
150
|
+
paperNumberLeft: 565,
|
|
151
|
+
paperNumberTop: 45,
|
|
152
|
+
paperNumberContinue: false,
|
|
153
|
+
paperNumberFormat: '1',
|
|
154
|
+
panelPaperRule: 'odd',
|
|
155
|
+
panelPageRule: 'none',
|
|
156
|
+
firstPaperFooter: 1,
|
|
157
|
+
evenPaperFooter: 1,
|
|
158
|
+
oddPaperFooter: 1,
|
|
159
|
+
lastPaperFooter: 1,
|
|
160
|
+
topOffset: 1,
|
|
161
|
+
fontFamily: 'Microsoft YaHei',
|
|
162
|
+
leftOffset: 1,
|
|
163
|
+
orient: 1,
|
|
164
|
+
},
|
|
165
|
+
watermark: {
|
|
166
|
+
content: '阿恃多伐底',
|
|
167
|
+
rotate: 25,
|
|
168
|
+
timestamp: true,
|
|
169
|
+
format: 'YYYY-MM-DD HH:mm',
|
|
170
|
+
fillStyle: 'rgba(184, 184, 184, 0.3)',
|
|
171
|
+
fontSize: '14px',
|
|
172
|
+
width: 200,
|
|
173
|
+
height: 200,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {computed, ref} from 'vue';
|
|
2
|
+
import {
|
|
3
|
+
HiprintPrintOption,
|
|
4
|
+
PrintElementType,
|
|
5
|
+
PrintElementTypes,
|
|
6
|
+
PrintPanelOptions,
|
|
7
|
+
TextPrintElementType,
|
|
8
|
+
} from '../types';
|
|
9
|
+
import {defineStore} from 'pinia';
|
|
10
|
+
import defaultPrintElement from 'yh-hiprint/store/defaultPrintElement';
|
|
11
|
+
|
|
12
|
+
export default defineStore('useHiprintStore', () => {
|
|
13
|
+
const printElements = ref<PrintElementType[]>([]);
|
|
14
|
+
const panelOption = ref<PrintPanelOptions>();
|
|
15
|
+
const watermarkOptions = ref<PrintPanelOptions['watermarkOptions']>();
|
|
16
|
+
|
|
17
|
+
const activeElements = ref<PrintElementType[]>([]);
|
|
18
|
+
|
|
19
|
+
const activeElement = computed<PrintElementType | null>(() => {
|
|
20
|
+
if (activeElements.value.length && activeElements.value.length === 1) {
|
|
21
|
+
return activeElements.value[0];
|
|
22
|
+
} else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const panelType = computed<PrintElementTypes>(() => {
|
|
28
|
+
if (activeElement.value === null) {
|
|
29
|
+
return PrintElementTypes.PANEL;
|
|
30
|
+
} else {
|
|
31
|
+
if (activeElement.value.printElementType.type === PrintElementTypes.TEXT) {
|
|
32
|
+
if ((activeElement.value as TextPrintElementType).options.textType === 'qrcode') {
|
|
33
|
+
return PrintElementTypes.QRCODE;
|
|
34
|
+
} else if ((activeElement.value as TextPrintElementType).options.textType === 'barcode') {
|
|
35
|
+
return PrintElementTypes.BARCODE;
|
|
36
|
+
} else {
|
|
37
|
+
return PrintElementTypes.TEXT;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
switch (activeElement.value.printElementType.type) {
|
|
41
|
+
case PrintElementTypes.IMAGE:
|
|
42
|
+
return PrintElementTypes.IMAGE;
|
|
43
|
+
case PrintElementTypes.TABLE:
|
|
44
|
+
return PrintElementTypes.TABLE;
|
|
45
|
+
case PrintElementTypes.HLINE:
|
|
46
|
+
return PrintElementTypes.HLINE;
|
|
47
|
+
case PrintElementTypes.VLINE:
|
|
48
|
+
return PrintElementTypes.VLINE;
|
|
49
|
+
case PrintElementTypes.RECT:
|
|
50
|
+
return PrintElementTypes.RECT;
|
|
51
|
+
case PrintElementTypes.OVAL:
|
|
52
|
+
return PrintElementTypes.OVAL;
|
|
53
|
+
case PrintElementTypes.LONGTEXT:
|
|
54
|
+
return PrintElementTypes.LONGTEXT;
|
|
55
|
+
case PrintElementTypes.HTML:
|
|
56
|
+
return PrintElementTypes.HTML;
|
|
57
|
+
default:
|
|
58
|
+
return PrintElementTypes.PANEL;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const hiprontPrintOption = computed<string>(() => {
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
panels: [
|
|
67
|
+
{
|
|
68
|
+
...panelOption.value,
|
|
69
|
+
printElements: printElements.value,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const setPaperOption = (width, height) => {
|
|
76
|
+
if (panelOption.value) {
|
|
77
|
+
panelOption.value.width = width;
|
|
78
|
+
panelOption.value.height = height;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
hiprontPrintOption,
|
|
84
|
+
panelType,
|
|
85
|
+
panelOption,
|
|
86
|
+
setPaperOption,
|
|
87
|
+
watermarkOptions,
|
|
88
|
+
printElements,
|
|
89
|
+
activeElement,
|
|
90
|
+
activeElements,
|
|
91
|
+
};
|
|
92
|
+
});
|