gm-printer-label 3.3.5-beta.2 → 3.3.6-beta.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.
Files changed (74) hide show
  1. package/lib/main.js +27 -0
  2. package/lib/package.json +96 -0
  3. package/package.json +10 -14
  4. package/.eslintcache +0 -1
  5. package/.eslintrc.js +0 -12
  6. package/.github/workflows/release.yml +0 -46
  7. package/.prettierrc.js +0 -5
  8. package/.stylelintrc +0 -3
  9. package/babel.config.js +0 -7
  10. package/i18n.config.js +0 -9
  11. package/locales/en.json +0 -42
  12. package/locales/index.js +0 -32
  13. package/locales/th.json +0 -42
  14. package/locales/zh-HK.json +0 -43
  15. package/locales/zh.json +0 -1
  16. package/postcss.config.js +0 -9
  17. package/src/common/config.js +0 -77
  18. package/src/common/editor_compoents/component.js +0 -481
  19. package/src/common/editor_compoents/config_text.js +0 -47
  20. package/src/common/editor_compoents/context_menu.js +0 -129
  21. package/src/common/editor_compoents/edit.js +0 -106
  22. package/src/common/editor_compoents/edit_add_filed.js +0 -54
  23. package/src/common/editor_compoents/edit_modify_filed.js +0 -199
  24. package/src/common/editor_compoents/edit_select.js +0 -212
  25. package/src/common/editor_compoents/edit_title.js +0 -110
  26. package/src/common/editor_compoents/index.js +0 -10
  27. package/src/common/editor_compoents/store.js +0 -381
  28. package/src/common/editor_compoents/style.less +0 -425
  29. package/src/common/editor_compoents/with_shadow_dom_hoc.js +0 -30
  30. package/src/common/editor_compoents/with_store_hoc.js +0 -92
  31. package/src/components/css/animation.less +0 -95
  32. package/src/components/css/button.less +0 -49
  33. package/src/components/css/distance.less +0 -324
  34. package/src/components/css/text.less +0 -74
  35. package/src/components/css/variables.less +0 -12
  36. package/src/components/dialog/index.js +0 -72
  37. package/src/components/dialog/style.less +0 -64
  38. package/src/components/dropdown/drop_down.js +0 -67
  39. package/src/components/dropdown/drop_down_item.js +0 -37
  40. package/src/components/dropdown/drop_down_items.js +0 -22
  41. package/src/components/dropdown/index.js +0 -9
  42. package/src/components/dropdown/style.less +0 -51
  43. package/src/components/flex/index.js +0 -103
  44. package/src/components/flex/style.less +0 -101
  45. package/src/components/index.js +0 -15
  46. package/src/components/index.less +0 -10
  47. package/src/components/input_number/index.js +0 -158
  48. package/src/components/input_number/style.less +0 -10
  49. package/src/components/select/index.js +0 -7
  50. package/src/components/select/option.js +0 -32
  51. package/src/components/select/select.js +0 -122
  52. package/src/components/select/style.less +0 -79
  53. package/src/components/tip/index.js +0 -48
  54. package/src/components/tip/style.less +0 -22
  55. package/src/editor_label/edit_store.js +0 -3
  56. package/src/editor_label/editor.js +0 -5
  57. package/src/editor_label/editor_with_shadow_dom.js +0 -4
  58. package/src/editor_label/index.js +0 -1
  59. package/src/editor_presorting/edit_store.js +0 -3
  60. package/src/editor_presorting/editor_with_shadow_dom.js +0 -6
  61. package/src/editor_presorting/index.js +0 -1
  62. package/src/index.js +0 -7
  63. package/src/printer/barcode.js +0 -38
  64. package/src/printer/batch_printer.js +0 -43
  65. package/src/printer/block.js +0 -578
  66. package/src/printer/components/table_type.js +0 -46
  67. package/src/printer/index.js +0 -111
  68. package/src/printer/normalize.css +0 -341
  69. package/src/printer/page.js +0 -26
  70. package/src/printer/printer.js +0 -71
  71. package/src/printer/qrcode.js +0 -17
  72. package/src/printer/style.less +0 -28
  73. package/src/util.js +0 -87
  74. package/webpack.config.js +0 -53
@@ -1,578 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import classNames from 'classnames'
4
- import { observer } from 'mobx-react'
5
- import { getStyleWithDiff, dispatchMsg, template, miniAppLink } from '../util'
6
- import TableType from './components/table_type'
7
- import BarCode from './barcode'
8
- import QrCode from './qrcode'
9
- import _ from 'lodash'
10
-
11
- @observer
12
- class Block extends React.Component {
13
- dragBlock = React.createRef(null)
14
- handleChangeDebounce = null
15
- constructor(props) {
16
- super(props)
17
- this.state = {
18
- clientX: null,
19
- clientY: null,
20
- isEdit: false,
21
- }
22
- }
23
-
24
- handleDragStart = ({ clientX, clientY }) => {
25
- const { index } = this.props
26
-
27
- this.setState({
28
- clientX,
29
- clientY,
30
- })
31
-
32
- window.document.dispatchEvent(
33
- new window.CustomEvent('gm-printer-label-select', {
34
- detail: {
35
- selected: index,
36
- },
37
- })
38
- )
39
- }
40
-
41
- handleDragEnd = ({ clientX, clientY }) => {
42
- const { config } = this.props
43
- const diffX = clientX - this.state.clientX
44
- const diffY = clientY - this.state.clientY
45
-
46
- const style = getStyleWithDiff(config.style, diffX, diffY)
47
-
48
- dispatchMsg('gm-printer-label-block-style-set', {
49
- style,
50
- })
51
- }
52
-
53
- handleClick = () => {
54
- const { index } = this.props
55
-
56
- dispatchMsg('gm-printer-label-select', {
57
- selected: index,
58
- })
59
- }
60
-
61
- handleDoubleClick = () => {
62
- const {
63
- config: { type },
64
- } = this.props
65
- if (!type || type === 'text') {
66
- this.setState(
67
- {
68
- isEdit: true,
69
- },
70
- () => {
71
- this.refEdit.focus()
72
- }
73
- )
74
- }
75
- }
76
-
77
- handleEditBlur = () => {
78
- this.setState({
79
- isEdit: false,
80
- })
81
- }
82
-
83
- handleText = (e) => {
84
- dispatchMsg('gm-printer-label-block-text-set', {
85
- text: e.target.value,
86
- })
87
- }
88
-
89
- /** TODO: 鼠标移动事件 */
90
- handleMouseMove = (e) => {
91
- e.persist()
92
- if (!this.handleChangeDebounce) {
93
- this.handleChangeDebounce = _.debounce(this.handleChange, 200)
94
- }
95
- this.handleChangeDebounce(e)
96
- }
97
-
98
- /** TODO: 拖拉设置条形码宽高 */
99
- handleChange = (e) => {
100
- const ref = this.dragBlock.current
101
- const rect = ref.getBoundingClientRect()
102
- const diffX_r = Math.abs(e.nativeEvent.clientX - rect.right)
103
- const isActive = ref.classList.contains('gm-printer-resize-active')
104
- console.log('diffX_r', diffX_r, ref.classList)
105
- if (diffX_r < 20 && !isActive) {
106
- ref.classList.add('gm-printer-resize-active')
107
- return
108
- }
109
-
110
- if (isActive) {
111
- ref.classList.remove('gm-printer-resize-active')
112
- }
113
- }
114
-
115
- render() {
116
- const {
117
- index,
118
- selected,
119
- config: {
120
- type,
121
- text,
122
- qrcode,
123
- order_qrcode,
124
- style,
125
- barcode,
126
- in_stock_barcode,
127
- package_id_qrcode,
128
- diycode,
129
- url,
130
- fieldType,
131
- fieldKey,
132
- production_barcode,
133
- new_production_barcode,
134
- merchandise_trace_qrcode,
135
- verification_qrcode,
136
- rack_barcode,
137
- customer_barcode,
138
- delivery_qrcode,
139
- package_order_qrcode,
140
- },
141
- data,
142
- config,
143
- className,
144
- isStation,
145
- doublePage,
146
- ...rest
147
- } = this.props
148
- const { isEdit } = this.state
149
- let content = null
150
-
151
- if (!type || type === 'text') {
152
- if (fieldType === 'table') {
153
- // 字段类型为表格
154
- content = (
155
- <TableType
156
- data={data[fieldKey]}
157
- data-name={index}
158
- style={{ width: '100%', height: '100%' }}
159
- />
160
- )
161
- } else {
162
- /** 渲染一个html */
163
- const value = text.split(':')?.[1]
164
- const isHtml = value && value.indexOf('_html') !== -1
165
- content = isHtml ? (
166
- <div dangerouslySetInnerHTML={{ __html: template(value, data) }} />
167
- ) : (
168
- template(text, data)
169
- )
170
- }
171
- } else if (type === 'line') {
172
- content = null
173
- } else if (type === 'qrcode') {
174
- content = isStation ? (
175
- <QrCode
176
- value={miniAppLink + template(qrcode, data)}
177
- size={parseInt(style.height)}
178
- />
179
- ) : (
180
- <div
181
- data-qrcode={template(qrcode, data)}
182
- data-width={style.width}
183
- data-height={style.height}
184
- data-name={index}
185
- style={{ width: '100%', height: '100%' }}
186
- data-placeholder='商品溯源'
187
- />
188
- )
189
- } else if (type === 'order_qrcode') {
190
- content = isStation ? (
191
- <QrCode
192
- value={miniAppLink + template(order_qrcode, data)}
193
- size={parseInt(style.height)}
194
- />
195
- ) : (
196
- <div
197
- data-orderQrcode={template(order_qrcode, data)}
198
- data-width={style.width}
199
- data-height={style.height}
200
- data-name={index}
201
- style={{ width: '100%', height: '100%' }}
202
- data-placeholder='订单溯源'
203
- />
204
- )
205
- } else if (type === 'merchandise_trace_qrcode') {
206
- content = isStation ? (
207
- <QrCode
208
- value={miniAppLink + template(merchandise_trace_qrcode, data)}
209
- size={parseInt(style.height)}
210
- />
211
- ) : (
212
- <div
213
- data-traceqrcode={template(merchandise_trace_qrcode, data)}
214
- data-width={style.width}
215
- data-height={style.height}
216
- data-name={index}
217
- style={{ width: '100%', height: '100%' }}
218
- data-placeholder='商品溯源二维码'
219
- />
220
- )
221
- } else if (type === 'verification_qrcode') {
222
- content = isStation ? (
223
- <QrCode
224
- value={miniAppLink + template(verification_qrcode, data)}
225
- size={parseInt(style.height)}
226
- />
227
- ) : (
228
- <div
229
- data-verificationqrcode={template(verification_qrcode, data)}
230
- data-width={style.width}
231
- data-height={style.height}
232
- data-name={index}
233
- style={{ width: '100%', height: '100%' }}
234
- data-placeholder='验收二维码'
235
- />
236
- )
237
- } else if (type === 'barcode') {
238
- content = isStation ? (
239
- <>
240
- <BarCode
241
- value={template(barcode, data)}
242
- textMargin={0}
243
- margin={0}
244
- height={parseInt(style.height) - 14}
245
- width={2}
246
- displayValue={false}
247
- dataName={barcode}
248
- background='transparent'
249
- />
250
- <div style={{ marginLeft: '50px' }}>{template(barcode, data)}</div>
251
- </>
252
- ) : (
253
- <div
254
- data-packagecode='验货条形码'
255
- data-name={index}
256
- style={{ width: '100%', height: '100%' }}
257
- >
258
- <svg
259
- style={{ height: '100%', width: '100%' }}
260
- data-packagecode={template(barcode, data)}
261
- // 需要减去14才能打印出正确高度
262
- data-height={parseInt(style.height) - 14}
263
- data-name={index}
264
- id={`package${template(barcode, data)}`}
265
- />
266
- </div>
267
- )
268
- } else if (type === 'in_stock_barcode') {
269
- content = isStation ? (
270
- <BarCode
271
- value={template(in_stock_barcode, data)}
272
- textMargin={0}
273
- margin={0}
274
- height={parseInt(style.height) - 14}
275
- width={2}
276
- displayValue={false}
277
- dataName={in_stock_barcode}
278
- background='transparent'
279
- />
280
- ) : (
281
- <div
282
- data-instockcode='入库条码'
283
- data-name={index}
284
- style={{ width: '100%', height: '100%' }}
285
- >
286
- <svg
287
- style={{ height: '100%', width: '100%' }}
288
- data-instockcode={template(in_stock_barcode, data)}
289
- // 需要减去14才能打印出正确高度
290
- data-height={parseInt(style.height) - 14}
291
- data-name={index}
292
- id={`instock${template(in_stock_barcode, data)}`}
293
- />
294
- </div>
295
- )
296
- } else if (type === 'production_barcode') {
297
- content = isStation ? (
298
- <BarCode
299
- value={template(production_barcode, data)}
300
- textMargin={0}
301
- margin={0}
302
- height={parseInt(style.height) - 14}
303
- width={doublePage ? 2.4 : 1.2}
304
- displayValue={false}
305
- dataName={production_barcode}
306
- background='transparent'
307
- />
308
- ) : (
309
- <div
310
- data-productionbarcode={template(production_barcode, data)}
311
- data-name={index}
312
- // 内标里叫做"PDA出入库条码"
313
- data-title={'PDA出入库条码'}
314
- style={{ width: '100%', height: '100%' }}
315
- >
316
- <svg
317
- style={{ height: '100%', width: '100%' }}
318
- data-productionbarcode={template(production_barcode, data)}
319
- // 需要减去14才能打印出正确高度
320
- data-doublepage={doublePage}
321
- data-height={parseInt(style.height) - 14}
322
- data-name={index}
323
- id={`production${template(production_barcode, data)}`}
324
- />
325
- </div>
326
- )
327
- } else if (type === 'new_production_barcode') {
328
- // 判断是否是69码
329
- const reg = /^69[0-9]{11}$/
330
- const is69 = reg.test(template(new_production_barcode, data))
331
- content = isStation ? (
332
- <BarCode
333
- data-newproductionbarcode={template(new_production_barcode, data)}
334
- value={template(new_production_barcode, data)}
335
- textMargin={0}
336
- margin={0}
337
- height={parseInt(style.height) - 14}
338
- width={doublePage ? 2.4 : 1.2}
339
- displayValue={is69}
340
- format={is69 ? 'EAN13' : undefined}
341
- dataName={new_production_barcode}
342
- background='transparent'
343
- />
344
- ) : (
345
- <div
346
- data-newproductionbarcode={template(new_production_barcode, data)}
347
- data-name={index}
348
- style={{ width: '100%', height: '100%' }}
349
- >
350
- <svg
351
- style={{ height: '100%', width: '100%' }}
352
- data-newproductionbarcode={template(new_production_barcode, data)}
353
- // 需要减去14才能打印出正确高度
354
- data-doublepage={doublePage}
355
- data-height={parseInt(style.height) - 14}
356
- data-format={is69 ? 'EAN13' : undefined}
357
- displayValue={is69}
358
- data-name={index}
359
- id={`newproduction${template(new_production_barcode, data)}`}
360
- />
361
- </div>
362
- )
363
- } else if (type === 'package_id_qrcode') {
364
- content = isStation ? (
365
- <QrCode
366
- value={template(package_id_qrcode, data)}
367
- size={parseInt(style.height)}
368
- />
369
- ) : (
370
- <div
371
- data-packageqrcode={template(package_id_qrcode, data)}
372
- data-width={style.width}
373
- data-height={style.height}
374
- data-name={index}
375
- style={{ width: '100%', height: '100%' }}
376
- data-placeholder='验货二维码'
377
- />
378
- )
379
- } else if (type === 'diycode') {
380
- content = isStation ? (
381
- <>
382
- <BarCode
383
- value={template(diycode, data)}
384
- textMargin={0}
385
- margin={0}
386
- height={35}
387
- width={2}
388
- displayValue={false}
389
- dataName={'diycode'}
390
- background='transparent'
391
- />
392
- <div style={{ marginLeft: '50px' }}>{template(diycode, data)}</div>
393
- </>
394
- ) : (
395
- <div
396
- data-diycode='自定义编码条形码'
397
- data-name={index}
398
- style={{ width: '100%', height: '100%' }}
399
- >
400
- <svg
401
- style={{ height: '100%', width: '100%' }}
402
- data-diycode={template(diycode, data)}
403
- // 需要减去14才能打印出正确高度
404
- data-height={parseInt(style.height) - 14}
405
- data-name={index}
406
- id={`package${template(diycode, data)}`}
407
- />
408
- </div>
409
- )
410
- } else if (type === 'diyqrcode') {
411
- content = isStation ? (
412
- <QrCode value={template(text, data)} size={parseInt(style.height)} />
413
- ) : (
414
- <div
415
- data-diyqrcode={template(text, data)}
416
- data-width={style.width}
417
- data-height={style.height}
418
- data-name={index}
419
- style={{ width: '100%', height: '100%' }}
420
- data-placeholder='自定义二维码'
421
- />
422
- )
423
- } else if (type === 'delivery_qrcode') {
424
- content = isStation ? (
425
- <QrCode
426
- value={template(delivery_qrcode, data)}
427
- size={parseInt(style.height)}
428
- />
429
- ) : (
430
- <div
431
- data-deliveryqrcode={template(delivery_qrcode, data)}
432
- data-width={style.width}
433
- data-height={style.height}
434
- data-name={index}
435
- style={{ width: '100%', height: '100%' }}
436
- data-placeholder='配送单二维码'
437
- />
438
- )
439
- } else if (type === 'image') {
440
- content = (
441
- <img
442
- src={url}
443
- data-width={style.width}
444
- data-height={style.height}
445
- style={{ width: '100%', height: '100%' }}
446
- data-name={index}
447
- />
448
- )
449
- } else if (type === 'rack_barcode') {
450
- /** 浏览器端的货位标签打印 */
451
- content = (
452
- <BarCode
453
- value={template(rack_barcode, data)}
454
- // textAlign='center'
455
- textMargin={0}
456
- margin={0}
457
- height={parseInt(style.height)}
458
- width={2}
459
- svgWidth={style.width}
460
- // font={rack_barcode}
461
- displayValue={false}
462
- dataName={rack_barcode}
463
- background='transparent'
464
- />
465
- )
466
- } else if (type === 'customer_barcode') {
467
- console.log(isStation, 'isStationisStationisStation')
468
- // : (
469
- // <div
470
- // data-productionbarcode={template(customer_barcode, data)}
471
- // data-name={index}
472
- // data-title={'客户码'}
473
- // style={{ width: '100%', height: '100%' }}
474
- // >
475
- // <svg
476
- // style={{ height: '100%', width: '100%' }}
477
- // data-productionbarcode={template(customer_barcode, data)}
478
- // // 需要减去14才能打印出正确高度
479
- // data-doublepage={doublePage}
480
- // data-height={parseInt(style.height) - 14}
481
- // data-name={index}
482
- // id={`production${template(customer_barcode, data)}`}
483
- // />
484
- // </div>
485
- // )
486
- // content = isStation ? (
487
- content = (
488
- <BarCode
489
- value={template(customer_barcode, data)}
490
- textMargin={0}
491
- margin={0}
492
- height={parseInt(style.height) - 14}
493
- width={doublePage ? 2.4 : 1.2}
494
- displayValue={false}
495
- dataName={customer_barcode}
496
- background='transparent'
497
- />
498
- )
499
- // )
500
- // /** 浏览器端的货位标签打印 */
501
- // content = (
502
- // <BarCode
503
- // value={template(customer_barcode, data)}
504
- // textMargin={0}
505
- // margin={0}
506
- // height={parseInt(style.height) - 14}
507
- // width={doublePage ? 2.4 : 1.2}
508
- // displayValue={false}
509
- // dataName={customer_barcode}
510
- // background='transparent'
511
- // />
512
- // )
513
- } else if (type === 'package_order_qrcode') {
514
- content = isStation ? (
515
- <QrCode
516
- value={template(package_order_qrcode, data)}
517
- size={parseInt(style.height)}
518
- />
519
- ) : (
520
- <div
521
- data-packageorderqrcode={template(package_order_qrcode, data)}
522
- data-width={style.width}
523
- data-height={style.height}
524
- data-name={index}
525
- style={{ width: '100%', height: '100%' }}
526
- data-placeholder='验货二维码'
527
- />
528
- )
529
- }
530
- const active = index === selected
531
-
532
- return (
533
- <div
534
- {...rest}
535
- style={style}
536
- className={classNames(
537
- 'gm-printer-label-block',
538
- `gm-printer-label-block-type-${type}`,
539
- className,
540
- {
541
- active,
542
- }
543
- )}
544
- draggable
545
- ref={this.dragBlock}
546
- onDragStart={this.handleDragStart}
547
- onDragEnd={this.handleDragEnd}
548
- onClick={this.handleClick}
549
- onDoubleClick={this.handleDoubleClick}
550
- /** TODO: 拖拉设置条形码宽高 */
551
- // onMouseMove={this.handleMouseMove}
552
- data-name={index}
553
- >
554
- {content}
555
- {(!type || type === 'text') && active && isEdit && (
556
- <textarea
557
- ref={(ref) => (this.refEdit = ref)}
558
- className='gm-printer-label-block-text-edit'
559
- value={text}
560
- onChange={this.handleText}
561
- onBlur={this.handleEditBlur}
562
- />
563
- )}
564
- </div>
565
- )
566
- }
567
- }
568
-
569
- Block.propTypes = {
570
- index: PropTypes.number.isRequired,
571
- config: PropTypes.object.isRequired,
572
- data: PropTypes.object.isRequired,
573
- selected: PropTypes.number,
574
- isStation: PropTypes.bool,
575
- doublePage: PropTypes.bool,
576
- }
577
-
578
- export default Block
@@ -1,46 +0,0 @@
1
- import React from 'react'
2
- import _ from 'lodash'
3
- import PropTypes from 'prop-types'
4
-
5
- const Table = (props) => {
6
- const { data, style } = props
7
-
8
- return (
9
- <div style={style} data-name={props['data-name']}>
10
- <div style={{textAlign: 'center'}}>{data.title}</div>
11
- <table style={{border: '1px solid black', borderCollapse: 'collapse'}}>
12
- <thead style={{border: '1px solid black'}}>
13
- <tr>
14
- {_.map(data.tHeadInfo, (th) => {
15
- return (
16
- <th data-name={props['data-name']} key={th}>
17
- {th}
18
- </th>
19
- )
20
- })}
21
- </tr>
22
- </thead>
23
- <tbody>
24
- {_.map(data.tBodyInfo, (tr) => {
25
- return (
26
- <tr key={tr}>
27
- {_.map(tr, (td) => (
28
- <td data-name={props['data-name']} key={td}>
29
- {td}
30
- </td>
31
- ))}
32
- </tr>
33
- )
34
- })}
35
- </tbody>
36
- </table>
37
- </div>
38
- )
39
- }
40
-
41
- Table.propTypes = {
42
- // data:[tHeadInfo: [th, th,...], tBodyInfo: [[td, td,..],[],...]
43
- data: PropTypes.object.isRequired
44
- }
45
-
46
- export default Table