gm-printer-label 3.3.6-beta.2 → 3.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.
Files changed (73) hide show
  1. package/lib/main.js +27 -0
  2. package/lib/package.json +96 -0
  3. package/package.json +10 -14
  4. package/.eslintrc.js +0 -12
  5. package/.github/workflows/release.yml +0 -46
  6. package/.prettierrc.js +0 -5
  7. package/.stylelintrc +0 -3
  8. package/babel.config.js +0 -7
  9. package/i18n.config.js +0 -9
  10. package/locales/en.json +0 -42
  11. package/locales/index.js +0 -32
  12. package/locales/th.json +0 -42
  13. package/locales/zh-HK.json +0 -43
  14. package/locales/zh.json +0 -1
  15. package/postcss.config.js +0 -9
  16. package/src/common/config.js +0 -82
  17. package/src/common/editor_compoents/component.js +0 -481
  18. package/src/common/editor_compoents/config_text.js +0 -47
  19. package/src/common/editor_compoents/context_menu.js +0 -129
  20. package/src/common/editor_compoents/edit.js +0 -106
  21. package/src/common/editor_compoents/edit_add_filed.js +0 -54
  22. package/src/common/editor_compoents/edit_modify_filed.js +0 -199
  23. package/src/common/editor_compoents/edit_select.js +0 -212
  24. package/src/common/editor_compoents/edit_title.js +0 -110
  25. package/src/common/editor_compoents/index.js +0 -10
  26. package/src/common/editor_compoents/store.js +0 -381
  27. package/src/common/editor_compoents/style.less +0 -425
  28. package/src/common/editor_compoents/with_shadow_dom_hoc.js +0 -30
  29. package/src/common/editor_compoents/with_store_hoc.js +0 -92
  30. package/src/components/css/animation.less +0 -95
  31. package/src/components/css/button.less +0 -49
  32. package/src/components/css/distance.less +0 -324
  33. package/src/components/css/text.less +0 -74
  34. package/src/components/css/variables.less +0 -12
  35. package/src/components/dialog/index.js +0 -72
  36. package/src/components/dialog/style.less +0 -64
  37. package/src/components/dropdown/drop_down.js +0 -67
  38. package/src/components/dropdown/drop_down_item.js +0 -37
  39. package/src/components/dropdown/drop_down_items.js +0 -22
  40. package/src/components/dropdown/index.js +0 -9
  41. package/src/components/dropdown/style.less +0 -51
  42. package/src/components/flex/index.js +0 -103
  43. package/src/components/flex/style.less +0 -101
  44. package/src/components/index.js +0 -15
  45. package/src/components/index.less +0 -10
  46. package/src/components/input_number/index.js +0 -158
  47. package/src/components/input_number/style.less +0 -10
  48. package/src/components/select/index.js +0 -7
  49. package/src/components/select/option.js +0 -32
  50. package/src/components/select/select.js +0 -122
  51. package/src/components/select/style.less +0 -79
  52. package/src/components/tip/index.js +0 -48
  53. package/src/components/tip/style.less +0 -22
  54. package/src/editor_label/edit_store.js +0 -3
  55. package/src/editor_label/editor.js +0 -5
  56. package/src/editor_label/editor_with_shadow_dom.js +0 -4
  57. package/src/editor_label/index.js +0 -1
  58. package/src/editor_presorting/edit_store.js +0 -3
  59. package/src/editor_presorting/editor_with_shadow_dom.js +0 -6
  60. package/src/editor_presorting/index.js +0 -1
  61. package/src/index.js +0 -7
  62. package/src/printer/barcode.js +0 -38
  63. package/src/printer/batch_printer.js +0 -43
  64. package/src/printer/block.js +0 -544
  65. package/src/printer/components/table_type.js +0 -46
  66. package/src/printer/index.js +0 -111
  67. package/src/printer/normalize.css +0 -341
  68. package/src/printer/page.js +0 -26
  69. package/src/printer/printer.js +0 -71
  70. package/src/printer/qrcode.js +0 -17
  71. package/src/printer/style.less +0 -28
  72. package/src/util.js +0 -87
  73. package/webpack.config.js +0 -53
@@ -1,544 +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
- content = (
468
- <BarCode
469
- value={template(customer_barcode, data)}
470
- textMargin={0}
471
- margin={0}
472
- height={parseInt(style.height) - 14}
473
- width={doublePage ? 2.4 : 1.2}
474
- displayValue={false}
475
- dataName={customer_barcode}
476
- background='transparent'
477
- />
478
- )
479
- } else if (type === 'package_order_qrcode') {
480
- content = isStation ? (
481
- <QrCode
482
- value={template(package_order_qrcode, data)}
483
- size={parseInt(style.height)}
484
- />
485
- ) : (
486
- <div
487
- data-packageorderqrcode={template(package_order_qrcode, data)}
488
- data-width={style.width}
489
- data-height={style.height}
490
- data-name={index}
491
- style={{ width: '100%', height: '100%' }}
492
- data-placeholder='验货二维码'
493
- />
494
- )
495
- }
496
- const active = index === selected
497
-
498
- return (
499
- <div
500
- {...rest}
501
- style={style}
502
- className={classNames(
503
- 'gm-printer-label-block',
504
- `gm-printer-label-block-type-${type}`,
505
- className,
506
- {
507
- active
508
- }
509
- )}
510
- draggable
511
- ref={this.dragBlock}
512
- onDragStart={this.handleDragStart}
513
- onDragEnd={this.handleDragEnd}
514
- onClick={this.handleClick}
515
- onDoubleClick={this.handleDoubleClick}
516
- /** TODO: 拖拉设置条形码宽高 */
517
- // onMouseMove={this.handleMouseMove}
518
- data-name={index}
519
- >
520
- {content}
521
- {(!type || type === 'text') && active && isEdit && (
522
- <textarea
523
- ref={(ref) => (this.refEdit = ref)}
524
- className='gm-printer-label-block-text-edit'
525
- value={text}
526
- onChange={this.handleText}
527
- onBlur={this.handleEditBlur}
528
- />
529
- )}
530
- </div>
531
- )
532
- }
533
- }
534
-
535
- Block.propTypes = {
536
- index: PropTypes.number.isRequired,
537
- config: PropTypes.object.isRequired,
538
- data: PropTypes.object.isRequired,
539
- selected: PropTypes.number,
540
- isStation: PropTypes.bool,
541
- doublePage: PropTypes.bool
542
- }
543
-
544
- 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
@@ -1,111 +0,0 @@
1
- import React from 'react'
2
- import ReactDOMServer from 'react-dom/server'
3
- import Printer from './printer'
4
- import _ from 'lodash'
5
- import { isZoom } from 'gm-util'
6
- import ReactDOM from 'react-dom'
7
- import BatchPrinter from './batch_printer'
8
-
9
- // eslint-disable-next-line
10
- import normalizeCSS from '!!raw-loader!less-loader!./normalize.css'
11
- // eslint-disable-next-line
12
- import printerCSS from '!!raw-loader!less-loader!./style.less'
13
- import { afterImgAndSvgLoaded } from '../util'
14
-
15
- function getHtml (props) {
16
- return ReactDOMServer.renderToString(<Printer {...props}/>)
17
- }
18
-
19
- function getBatchHtml (propsArr) {
20
- return ReactDOMServer.renderToString(
21
- <React.Fragment>
22
- {_.map(propsArr, (props) => (
23
- <Printer {...props}/>
24
- ))}
25
- </React.Fragment>
26
- )
27
- }
28
-
29
- function getCSS () {
30
- return normalizeCSS.toString() + printerCSS.toString()
31
- }
32
-
33
- const printerId = '_gm-printer_' + Math.random()
34
- let $printer = window.document.getElementById(printerId)
35
-
36
- /**
37
- * @param {boolean} isTest 是否test
38
- * @param {boolean} isTipZoom zoom的时候是否提示
39
- */
40
- function init ({ isTest, isTipZoom = true } = {}) {
41
- isTipZoom &&
42
- isZoom() &&
43
- window.alert(
44
- '检测您的浏览器使用了缩放,为了避免影响打印布局,请重置缩放到100%后再进行打印'
45
- )
46
- if (!$printer) {
47
- $printer = window.document.createElement('iframe')
48
- $printer.id = printerId
49
- $printer.style.position = 'fixed'
50
- $printer.style.top = '0'
51
- $printer.style.width = '100%' // 使移动端可滚动
52
- if (isTest) {
53
- // 模板编辑[测试打印],隐藏起来
54
- // $printer.style.left = '-2000px'
55
- } else {
56
- $printer.style.left = '0px'
57
- $printer.style.height = '100vh'
58
- }
59
- window.document.body.appendChild($printer)
60
-
61
- const idocument = $printer.contentDocument
62
- idocument.open()
63
- idocument.write('<!DOCTYPE html><html><head></head><body></body></html>')
64
- idocument.close()
65
-
66
- const doc = $printer.contentWindow.document
67
-
68
- const style = doc.createElement('style')
69
- style.type = 'text/css'
70
- style.appendChild(doc.createTextNode(getCSS()))
71
- doc.head.appendChild(style)
72
-
73
- const div = doc.createElement('div')
74
- div.id = 'appContainer'
75
-
76
- doc.body.appendChild(div)
77
- }
78
- }
79
-
80
- function doBatchPrint (
81
- list,
82
- isTest,
83
- extraCofnig = { isPrint: true, isTipZoom: true },
84
- isStation = false
85
- ) {
86
- init({ isTest, isTipZoom: extraCofnig.isTipZoom })
87
-
88
- return toDoPrintBatch(list, extraCofnig.isPrint, isStation)
89
- }
90
-
91
- function toDoPrintBatch (list, isPrint = true, isStation = false) {
92
- return new window.Promise((resolve) => {
93
- const $app = $printer.contentWindow.document.getElementById('appContainer')
94
-
95
- ReactDOM.unmountComponentAtNode($app)
96
- ReactDOM.render(
97
- <BatchPrinter
98
- list={list}
99
- isStation={isStation}
100
- onReady={() => {
101
- afterImgAndSvgLoaded(() => {
102
- isPrint && $printer.contentWindow.print()
103
- resolve()
104
- }, $app)
105
- }}
106
- />,
107
- $app
108
- )
109
- })
110
- }
111
- export { getHtml, getBatchHtml, getCSS, Printer, doBatchPrint }