gm-printer-label 3.3.6 → 3.4.0-beat.1
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/README.md +71 -71
- package/lib/main.js +27 -0
- package/lib/package.json +96 -0
- package/package.json +96 -100
- package/.eslintrc.js +0 -12
- package/.github/workflows/release.yml +0 -46
- package/.prettierrc.js +0 -5
- package/.stylelintrc +0 -3
- package/babel.config.js +0 -7
- package/i18n.config.js +0 -9
- package/locales/en.json +0 -42
- package/locales/index.js +0 -32
- package/locales/th.json +0 -42
- package/locales/zh-HK.json +0 -43
- package/locales/zh.json +0 -1
- package/postcss.config.js +0 -9
- package/src/common/config.js +0 -82
- package/src/common/editor_compoents/component.js +0 -481
- package/src/common/editor_compoents/config_text.js +0 -47
- package/src/common/editor_compoents/context_menu.js +0 -129
- package/src/common/editor_compoents/edit.js +0 -106
- package/src/common/editor_compoents/edit_add_filed.js +0 -54
- package/src/common/editor_compoents/edit_modify_filed.js +0 -199
- package/src/common/editor_compoents/edit_select.js +0 -212
- package/src/common/editor_compoents/edit_title.js +0 -110
- package/src/common/editor_compoents/index.js +0 -10
- package/src/common/editor_compoents/store.js +0 -381
- package/src/common/editor_compoents/style.less +0 -425
- package/src/common/editor_compoents/with_shadow_dom_hoc.js +0 -30
- package/src/common/editor_compoents/with_store_hoc.js +0 -92
- package/src/components/css/animation.less +0 -95
- package/src/components/css/button.less +0 -49
- package/src/components/css/distance.less +0 -324
- package/src/components/css/text.less +0 -74
- package/src/components/css/variables.less +0 -12
- package/src/components/dialog/index.js +0 -72
- package/src/components/dialog/style.less +0 -64
- package/src/components/dropdown/drop_down.js +0 -67
- package/src/components/dropdown/drop_down_item.js +0 -37
- package/src/components/dropdown/drop_down_items.js +0 -22
- package/src/components/dropdown/index.js +0 -9
- package/src/components/dropdown/style.less +0 -51
- package/src/components/flex/index.js +0 -103
- package/src/components/flex/style.less +0 -101
- package/src/components/index.js +0 -15
- package/src/components/index.less +0 -10
- package/src/components/input_number/index.js +0 -158
- package/src/components/input_number/style.less +0 -10
- package/src/components/select/index.js +0 -7
- package/src/components/select/option.js +0 -32
- package/src/components/select/select.js +0 -122
- package/src/components/select/style.less +0 -79
- package/src/components/tip/index.js +0 -48
- package/src/components/tip/style.less +0 -22
- package/src/editor_label/edit_store.js +0 -3
- package/src/editor_label/editor.js +0 -5
- package/src/editor_label/editor_with_shadow_dom.js +0 -4
- package/src/editor_label/index.js +0 -1
- package/src/editor_presorting/edit_store.js +0 -3
- package/src/editor_presorting/editor_with_shadow_dom.js +0 -6
- package/src/editor_presorting/index.js +0 -1
- package/src/index.js +0 -7
- package/src/printer/barcode.js +0 -38
- package/src/printer/batch_printer.js +0 -43
- package/src/printer/block.js +0 -544
- package/src/printer/components/table_type.js +0 -46
- package/src/printer/index.js +0 -111
- package/src/printer/normalize.css +0 -341
- package/src/printer/page.js +0 -26
- package/src/printer/printer.js +0 -71
- package/src/printer/qrcode.js +0 -17
- package/src/printer/style.less +0 -28
- package/src/util.js +0 -87
- package/webpack.config.js +0 -53
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
/*! normalize.css v8.0.0 | MIT License | github.com/necolas/normalize.css */
|
|
2
|
-
|
|
3
|
-
/* Document
|
|
4
|
-
========================================================================== */
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 1. Correct the line height in all browsers.
|
|
8
|
-
* 2. Prevent adjustments of font size after orientation changes in iOS.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
html {
|
|
12
|
-
line-height: 1.15; /* 1 */
|
|
13
|
-
-webkit-text-size-adjust: 100%; /* 2 */
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* Sections
|
|
17
|
-
========================================================================== */
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Remove the margin in all browsers.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
body {
|
|
24
|
-
margin: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Correct the font size and margin on `h1` elements within `section` and
|
|
29
|
-
* `article` contexts in Chrome, Firefox, and Safari.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
h1 {
|
|
33
|
-
font-size: 2em;
|
|
34
|
-
margin: 0.67em 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Grouping content
|
|
38
|
-
========================================================================== */
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 1. Add the correct box sizing in Firefox.
|
|
42
|
-
* 2. Show the overflow in Edge and IE.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
hr {
|
|
46
|
-
box-sizing: content-box; /* 1 */
|
|
47
|
-
height: 0; /* 1 */
|
|
48
|
-
overflow: visible; /* 2 */
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 1. Correct the inheritance and scaling of font size in all browsers.
|
|
53
|
-
* 2. Correct the odd `em` font sizing in all browsers.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
pre {
|
|
57
|
-
font-family: monospace, monospace; /* 1 */
|
|
58
|
-
font-size: 1em; /* 2 */
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/* Text-level semantics
|
|
62
|
-
========================================================================== */
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Remove the gray background on active links in IE 10.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
a {
|
|
69
|
-
background-color: transparent;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 1. Remove the bottom border in Chrome 57-
|
|
74
|
-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
abbr[title] {
|
|
78
|
-
border-bottom: none; /* 1 */
|
|
79
|
-
text-decoration: underline; /* 2 */
|
|
80
|
-
text-decoration: underline dotted; /* 2 */
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Add the correct font weight in Chrome, Edge, and Safari.
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
b,
|
|
88
|
-
strong {
|
|
89
|
-
font-weight: bolder;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 1. Correct the inheritance and scaling of font size in all browsers.
|
|
94
|
-
* 2. Correct the odd `em` font sizing in all browsers.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
code,
|
|
98
|
-
kbd,
|
|
99
|
-
samp {
|
|
100
|
-
font-family: monospace, monospace; /* 1 */
|
|
101
|
-
font-size: 1em; /* 2 */
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Add the correct font size in all browsers.
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
small {
|
|
109
|
-
font-size: 80%;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Prevent `sub` and `sup` elements from affecting the line height in
|
|
114
|
-
* all browsers.
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
sub,
|
|
118
|
-
sup {
|
|
119
|
-
font-size: 75%;
|
|
120
|
-
line-height: 0;
|
|
121
|
-
position: relative;
|
|
122
|
-
vertical-align: baseline;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
sub {
|
|
126
|
-
bottom: -0.25em;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
sup {
|
|
130
|
-
top: -0.5em;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/* Embedded content
|
|
134
|
-
========================================================================== */
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Remove the border on images inside links in IE 10.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
img {
|
|
141
|
-
border-style: none;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/* Forms
|
|
145
|
-
========================================================================== */
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* 1. Change the font styles in all browsers.
|
|
149
|
-
* 2. Remove the margin in Firefox and Safari.
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
button,
|
|
153
|
-
input,
|
|
154
|
-
optgroup,
|
|
155
|
-
select,
|
|
156
|
-
textarea {
|
|
157
|
-
font-family: inherit; /* 1 */
|
|
158
|
-
font-size: 100%; /* 1 */
|
|
159
|
-
line-height: 1.15; /* 1 */
|
|
160
|
-
margin: 0; /* 2 */
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Show the overflow in IE.
|
|
165
|
-
* 1. Show the overflow in Edge.
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
button,
|
|
169
|
-
input { /* 1 */
|
|
170
|
-
overflow: visible;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
|
175
|
-
* 1. Remove the inheritance of text transform in Firefox.
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
button,
|
|
179
|
-
select { /* 1 */
|
|
180
|
-
text-transform: none;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Correct the inability to style clickable types in iOS and Safari.
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
button,
|
|
188
|
-
[type="button"],
|
|
189
|
-
[type="reset"],
|
|
190
|
-
[type="submit"] {
|
|
191
|
-
-webkit-appearance: button;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Remove the inner border and padding in Firefox.
|
|
196
|
-
*/
|
|
197
|
-
|
|
198
|
-
button::-moz-focus-inner,
|
|
199
|
-
[type="button"]::-moz-focus-inner,
|
|
200
|
-
[type="reset"]::-moz-focus-inner,
|
|
201
|
-
[type="submit"]::-moz-focus-inner {
|
|
202
|
-
border-style: none;
|
|
203
|
-
padding: 0;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Restore the focus styles unset by the previous rule.
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
button:-moz-focusring,
|
|
211
|
-
[type="button"]:-moz-focusring,
|
|
212
|
-
[type="reset"]:-moz-focusring,
|
|
213
|
-
[type="submit"]:-moz-focusring {
|
|
214
|
-
outline: 1px dotted ButtonText;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Correct the padding in Firefox.
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
fieldset {
|
|
222
|
-
padding: 0.35em 0.75em 0.625em;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 1. Correct the text wrapping in Edge and IE.
|
|
227
|
-
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
|
228
|
-
* 3. Remove the padding so developers are not caught out when they zero out
|
|
229
|
-
* `fieldset` elements in all browsers.
|
|
230
|
-
*/
|
|
231
|
-
|
|
232
|
-
legend {
|
|
233
|
-
box-sizing: border-box; /* 1 */
|
|
234
|
-
color: inherit; /* 2 */
|
|
235
|
-
display: table; /* 1 */
|
|
236
|
-
max-width: 100%; /* 1 */
|
|
237
|
-
padding: 0; /* 3 */
|
|
238
|
-
white-space: normal; /* 1 */
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
|
243
|
-
*/
|
|
244
|
-
|
|
245
|
-
progress {
|
|
246
|
-
vertical-align: baseline;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Remove the default vertical scrollbar in IE 10+.
|
|
251
|
-
*/
|
|
252
|
-
|
|
253
|
-
textarea {
|
|
254
|
-
overflow: auto;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* 1. Add the correct box sizing in IE 10.
|
|
259
|
-
* 2. Remove the padding in IE 10.
|
|
260
|
-
*/
|
|
261
|
-
|
|
262
|
-
[type="checkbox"],
|
|
263
|
-
[type="radio"] {
|
|
264
|
-
box-sizing: border-box; /* 1 */
|
|
265
|
-
padding: 0; /* 2 */
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Correct the cursor style of increment and decrement buttons in Chrome.
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
[type="number"]::-webkit-inner-spin-button,
|
|
273
|
-
[type="number"]::-webkit-outer-spin-button {
|
|
274
|
-
height: auto;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* 1. Correct the odd appearance in Chrome and Safari.
|
|
279
|
-
* 2. Correct the outline style in Safari.
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
[type="search"] {
|
|
283
|
-
-webkit-appearance: textfield; /* 1 */
|
|
284
|
-
outline-offset: -2px; /* 2 */
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Remove the inner padding in Chrome and Safari on macOS.
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
[type="search"]::-webkit-search-decoration {
|
|
292
|
-
-webkit-appearance: none;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* 1. Correct the inability to style clickable types in iOS and Safari.
|
|
297
|
-
* 2. Change font properties to `inherit` in Safari.
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
::-webkit-file-upload-button {
|
|
301
|
-
-webkit-appearance: button; /* 1 */
|
|
302
|
-
font: inherit; /* 2 */
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/* Interactive
|
|
306
|
-
========================================================================== */
|
|
307
|
-
|
|
308
|
-
/*
|
|
309
|
-
* Add the correct display in Edge, IE 10+, and Firefox.
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
details {
|
|
313
|
-
display: block;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/*
|
|
317
|
-
* Add the correct display in all browsers.
|
|
318
|
-
*/
|
|
319
|
-
|
|
320
|
-
summary {
|
|
321
|
-
display: list-item;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/* Misc
|
|
325
|
-
========================================================================== */
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Add the correct display in IE 10+.
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
template {
|
|
332
|
-
display: none;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Add the correct display in IE 10.
|
|
337
|
-
*/
|
|
338
|
-
|
|
339
|
-
[hidden] {
|
|
340
|
-
display: none;
|
|
341
|
-
}
|
package/src/printer/page.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
|
|
4
|
-
@observer
|
|
5
|
-
class Page extends React.Component {
|
|
6
|
-
render() {
|
|
7
|
-
const {
|
|
8
|
-
pageStyle: { width, height },
|
|
9
|
-
children,
|
|
10
|
-
} = this.props
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div
|
|
14
|
-
className='gm-printer-label-page'
|
|
15
|
-
style={{
|
|
16
|
-
width,
|
|
17
|
-
height,
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
{children}
|
|
21
|
-
</div>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default Page
|
package/src/printer/printer.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
import Page from './page'
|
|
5
|
-
import _ from 'lodash'
|
|
6
|
-
import Block from './block'
|
|
7
|
-
import { pageTypeMap } from '../common/config'
|
|
8
|
-
|
|
9
|
-
@observer
|
|
10
|
-
class Printer extends React.Component {
|
|
11
|
-
componentDidMount () {
|
|
12
|
-
// Printer 不是立马就呈现出最终样式,有个过程。这个过程需要时间,什么 ready,不太清楚,估借 setState 来获取过程结束时刻
|
|
13
|
-
this.setState({}, () => {
|
|
14
|
-
this.props.onReady && this.props.onReady()
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
render () {
|
|
19
|
-
const { config, selected, data, isStation } = this.props
|
|
20
|
-
const { type, style, customizeWidth, customizeHeight, doublePage } =
|
|
21
|
-
config.page
|
|
22
|
-
const ratio = doublePage ? 2 : 1
|
|
23
|
-
const width =
|
|
24
|
-
(type === '-1'
|
|
25
|
-
? customizeWidth
|
|
26
|
-
: +pageTypeMap[type].width.split('mm')[0]) *
|
|
27
|
-
ratio +
|
|
28
|
-
'mm'
|
|
29
|
-
const height =
|
|
30
|
-
(type === '-1'
|
|
31
|
-
? customizeHeight
|
|
32
|
-
: +pageTypeMap[type].height.split('mm')[0]) *
|
|
33
|
-
ratio +
|
|
34
|
-
'mm'
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div
|
|
38
|
-
className='gm-printer-label'
|
|
39
|
-
style={{
|
|
40
|
-
...style,
|
|
41
|
-
width,
|
|
42
|
-
height
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
<Page pageStyle={{ width, height }}>
|
|
46
|
-
{_.map(config.blocks, (block, i) => (
|
|
47
|
-
<Block
|
|
48
|
-
key={i}
|
|
49
|
-
index={i}
|
|
50
|
-
selected={selected}
|
|
51
|
-
config={block}
|
|
52
|
-
data={data}
|
|
53
|
-
isStation={isStation}
|
|
54
|
-
doublePage={doublePage}
|
|
55
|
-
/>
|
|
56
|
-
))}
|
|
57
|
-
</Page>
|
|
58
|
-
</div>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
Printer.propTypes = {
|
|
64
|
-
selected: PropTypes.number,
|
|
65
|
-
config: PropTypes.object.isRequired,
|
|
66
|
-
data: PropTypes.object.isRequired, // 格式化后的数据
|
|
67
|
-
onReady: PropTypes.func,
|
|
68
|
-
isStation: PropTypes.bool
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default Printer
|
package/src/printer/qrcode.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import QRCode from 'qrcode.react'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
import _ from 'lodash'
|
|
5
|
-
|
|
6
|
-
const QrCode = props => {
|
|
7
|
-
const { value, size } = props
|
|
8
|
-
return (
|
|
9
|
-
<QRCode renderAs='svg' value={value} size={_.isFinite(size) ? size : 75}/>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
QrCode.propTypes = {
|
|
14
|
-
value: PropTypes.string.isRequired,
|
|
15
|
-
size: PropTypes.number.isRequired
|
|
16
|
-
}
|
|
17
|
-
export default QrCode
|
package/src/printer/style.less
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.gm-printer-label {
|
|
2
|
-
// 因为 shadow dom 没有 html body,估把些css迁移过来
|
|
3
|
-
line-height: 1.15;
|
|
4
|
-
-webkit-text-size-adjust: 100%;
|
|
5
|
-
|
|
6
|
-
font-size: 14px;
|
|
7
|
-
background: white;
|
|
8
|
-
page-break-before: always
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.gm-printer-label-page {
|
|
12
|
-
overflow: hidden;
|
|
13
|
-
position: relative;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// block
|
|
17
|
-
.gm-printer-label-block {
|
|
18
|
-
position: relative;
|
|
19
|
-
|
|
20
|
-
.gm-printer-label-block-text-edit {
|
|
21
|
-
display: none;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 保留,打印的时候有用
|
|
26
|
-
@page {
|
|
27
|
-
margin: 0;
|
|
28
|
-
}
|
package/src/util.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
|
|
3
|
-
function pxAdd (origin, add) {
|
|
4
|
-
return parseFloat(origin, 10) + add + 'px'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function getStyleWithDiff (style, diffX, diffY) {
|
|
8
|
-
const newStyle = Object.assign({}, style)
|
|
9
|
-
|
|
10
|
-
if (!style.left && style.right) {
|
|
11
|
-
newStyle.right = pxAdd(newStyle.right, -diffX)
|
|
12
|
-
} else {
|
|
13
|
-
newStyle.left = pxAdd(newStyle.left, diffX)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (!style.top && style.bottom) {
|
|
17
|
-
newStyle.bottom = pxAdd(newStyle.bottom, -diffY)
|
|
18
|
-
} else {
|
|
19
|
-
newStyle.top = pxAdd(newStyle.top, diffY)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return newStyle
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function insertCSS (cssString, target) {
|
|
26
|
-
const style = window.document.createElement('style')
|
|
27
|
-
style.type = 'text/css'
|
|
28
|
-
style.appendChild(document.createTextNode(cssString))
|
|
29
|
-
|
|
30
|
-
if (target) {
|
|
31
|
-
target.appendChild(style)
|
|
32
|
-
} else {
|
|
33
|
-
window.document.head.appendChild(style)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function dispatchMsg (event, data) {
|
|
38
|
-
window.document.dispatchEvent(
|
|
39
|
-
new window.CustomEvent(event, {
|
|
40
|
-
detail: data
|
|
41
|
-
})
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
function substring (target, start = 0, end) {
|
|
45
|
-
return target.substring(start, end)
|
|
46
|
-
}
|
|
47
|
-
function template (text, data) {
|
|
48
|
-
try {
|
|
49
|
-
return _.template(text, {
|
|
50
|
-
interpolate: /{{([\s\S]+?)}}/g
|
|
51
|
-
})({
|
|
52
|
-
...data,
|
|
53
|
-
substring: substring // 添加一个截取字符串函数
|
|
54
|
-
})
|
|
55
|
-
} catch (err) {
|
|
56
|
-
console.warn(err)
|
|
57
|
-
return text
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let timer
|
|
62
|
-
|
|
63
|
-
function afterImgAndSvgLoaded (callback, $printer) {
|
|
64
|
-
const $imgList = $printer.querySelectorAll('img')
|
|
65
|
-
const $svgList = $printer.querySelectorAll('svg')
|
|
66
|
-
|
|
67
|
-
clearTimeout(timer)
|
|
68
|
-
|
|
69
|
-
const everyThingIsOk =
|
|
70
|
-
_.every($imgList, (img) => img.complete) &&
|
|
71
|
-
_.every($svgList, (svg) => svg.children.length)
|
|
72
|
-
if (everyThingIsOk) {
|
|
73
|
-
callback()
|
|
74
|
-
} else {
|
|
75
|
-
timer = setTimeout(afterImgAndSvgLoaded.bind(this, callback, $printer), 300)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const miniAppLink = 'https://miniapp.guanmai.cn/traceability/?id='
|
|
79
|
-
export {
|
|
80
|
-
pxAdd,
|
|
81
|
-
getStyleWithDiff,
|
|
82
|
-
insertCSS,
|
|
83
|
-
dispatchMsg,
|
|
84
|
-
template,
|
|
85
|
-
afterImgAndSvgLoaded,
|
|
86
|
-
miniAppLink
|
|
87
|
-
}
|
package/webpack.config.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const webpack = require('webpack')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
mode: 'development',
|
|
6
|
-
entry: {
|
|
7
|
-
label: './demo/label/index.js',
|
|
8
|
-
pre_sorting: './demo/pre_sorting/index.js',
|
|
9
|
-
},
|
|
10
|
-
output: {
|
|
11
|
-
path: path.resolve('build'),
|
|
12
|
-
publicPath: '/',
|
|
13
|
-
filename: '[name].js'
|
|
14
|
-
},
|
|
15
|
-
module: {
|
|
16
|
-
rules: [{
|
|
17
|
-
test: /\.js$/,
|
|
18
|
-
use: 'babel-loader'
|
|
19
|
-
}, {
|
|
20
|
-
test: /\.(css|less)$/,
|
|
21
|
-
use: [
|
|
22
|
-
'style-loader',
|
|
23
|
-
'css-loader',
|
|
24
|
-
'postcss-loader',
|
|
25
|
-
'less-loader'
|
|
26
|
-
]
|
|
27
|
-
}, {
|
|
28
|
-
test: /(fontawesome-webfont|glyphicons-halflings-regular|iconfont)\.(woff|woff2|ttf|eot|svg)($|\?)/,
|
|
29
|
-
use: [{
|
|
30
|
-
loader: 'url-loader',
|
|
31
|
-
options: {
|
|
32
|
-
limit: 1024,
|
|
33
|
-
name: 'font/[name].[ext]'
|
|
34
|
-
}
|
|
35
|
-
}]
|
|
36
|
-
}]
|
|
37
|
-
},
|
|
38
|
-
plugins: [
|
|
39
|
-
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /zh-cn/)
|
|
40
|
-
],
|
|
41
|
-
devServer: {
|
|
42
|
-
compress: true,
|
|
43
|
-
host: '0.0.0.0',
|
|
44
|
-
inline: false,
|
|
45
|
-
disableHostCheck: true,
|
|
46
|
-
proxy: {
|
|
47
|
-
'/gm_account/*': {
|
|
48
|
-
target: 'http://station.env-lyf.dev.k8s.guanmai.cn',
|
|
49
|
-
changeOrigin: true
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|