gm-printer-label 3.3.3 → 3.3.5-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer-label",
3
- "version": "3.3.3",
3
+ "version": "3.3.5-beta.0",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@ import {
10
10
  TextAlign,
11
11
  Textarea,
12
12
  TipInfo,
13
- Title
13
+ Title,
14
14
  } from './component'
15
15
  import i18next from '../../../locales'
16
16
  import _ from 'lodash'
@@ -34,26 +34,26 @@ class EditModifyFiled extends React.Component {
34
34
  const newStyle = _.has(style, 'transform')
35
35
  ? _.omit(style, 'transform')
36
36
  : {
37
- ...style,
38
- transform: 'rotate(90deg)'
39
- }
37
+ ...style,
38
+ transform: 'rotate(90deg)',
39
+ }
40
40
  this.handleChangeBlock('style', newStyle)
41
41
  }
42
42
 
43
- renderBlocks () {
43
+ renderBlocks() {
44
44
  const { editStore } = this.props
45
45
 
46
46
  const { type, text, style } = editStore.config.blocks[editStore.selected]
47
47
 
48
48
  return (
49
49
  <React.Fragment>
50
- <Title title={i18next.t('编辑字段')}/>
51
- <Gap/>
50
+ <Title title={i18next.t('编辑字段')} />
51
+ <Gap />
52
52
  <Position
53
53
  style={style}
54
54
  onChange={this.handleChangeBlock.bind(this, 'style')}
55
55
  />
56
- <Gap/>
56
+ <Gap />
57
57
 
58
58
  {(!type || type === 'text') && (
59
59
  <div>
@@ -61,12 +61,12 @@ class EditModifyFiled extends React.Component {
61
61
  style={style}
62
62
  onChange={this.handleChangeBlock.bind(this, 'style')}
63
63
  />
64
- <Separator/>
64
+ <Separator />
65
65
  <TextAlign
66
66
  style={style}
67
67
  onChange={this.handleChangeBlock.bind(this, 'style')}
68
68
  />
69
- <Gap/>
69
+ <Gap />
70
70
 
71
71
  <Textarea
72
72
  value={text}
@@ -86,11 +86,11 @@ class EditModifyFiled extends React.Component {
86
86
  type === 'package_id_qrcode' ||
87
87
  type === 'image' ||
88
88
  type === 'rack_barcode' ||
89
+ type === 'customer_barcode' ||
89
90
  type === 'delivery_qrcode' ||
90
91
  type === 'merchandise_trace_qrcode' ||
91
92
  type === 'verification_qrcode' ||
92
- type === 'package_order_qrcode'
93
- ) && (
93
+ type === 'package_order_qrcode') && (
94
94
  <div>
95
95
  <Size
96
96
  style={style}
@@ -176,7 +176,7 @@ class EditModifyFiled extends React.Component {
176
176
  text={i18next.t('注:可通过修改“{{}}”中的内容更改时间格式。')}
177
177
  />
178
178
  {_.map(DiyTimeType, (v, k) => (
179
- <TipInfo text={`${k + 1}。${v.text}`}/>
179
+ <TipInfo text={`${k + 1}。${v.text}`} />
180
180
  ))}
181
181
  </div>
182
182
  )}
@@ -184,7 +184,7 @@ class EditModifyFiled extends React.Component {
184
184
  )
185
185
  }
186
186
 
187
- render () {
187
+ render() {
188
188
  let content = null
189
189
  const { editStore } = this.props
190
190
 
@@ -18,7 +18,7 @@ class EditStore {
18
18
  originConfig = null
19
19
 
20
20
  @action.bound
21
- init (config, initDefaultTemp) {
21
+ init(config, initDefaultTemp) {
22
22
  this.config = this.getHandledConfig(config)
23
23
  this.originConfig = this.getHandledConfig(config)
24
24
  this.selected = null
@@ -26,46 +26,46 @@ class EditStore {
26
26
  }
27
27
 
28
28
  @action.bound
29
- setConfig (config, value) {
29
+ setConfig(config, value) {
30
30
  this.selected = null
31
31
  this.config = { ...this.config, ...config }
32
32
  this.tempKey = value
33
33
  }
34
34
 
35
35
  @action.bound
36
- setConfigName (name) {
36
+ setConfigName(name) {
37
37
  this.config.name = name
38
38
  }
39
39
 
40
40
  @action.bound
41
- setSizePageType (type) {
41
+ setSizePageType(type) {
42
42
  this.config.page.type = type
43
43
  }
44
44
 
45
45
  @action.bound
46
- setCustomizePageSize (name, value) {
46
+ setCustomizePageSize(name, value) {
47
47
  this.config.page[name] = value
48
48
  }
49
49
 
50
50
  @action.bound
51
- setPageName (name) {
51
+ setPageName(name) {
52
52
  this.config.name = name
53
53
  }
54
54
 
55
55
  @action.bound
56
- setSelected (selected = null) {
56
+ setSelected(selected = null) {
57
57
  this.selected = selected
58
58
  }
59
59
 
60
60
  @action.bound
61
- setConfigBlockBy (who, value) {
61
+ setConfigBlockBy(who, value) {
62
62
  if (this.selected !== null) {
63
63
  this.config.blocks[this.selected][who] = value
64
64
  }
65
65
  }
66
66
 
67
67
  @action.bound
68
- addConfigBlock (type, url) {
68
+ addConfigBlock(type, url) {
69
69
  switch (type) {
70
70
  case '':
71
71
  case 'text':
@@ -75,8 +75,8 @@ class EditStore {
75
75
  position: 'absolute',
76
76
  fontSize: '14px',
77
77
  left: '0px',
78
- top: '0px'
79
- }
78
+ top: '0px',
79
+ },
80
80
  })
81
81
  break
82
82
  case 'line':
@@ -89,8 +89,8 @@ class EditStore {
89
89
  borderTopColor: 'black',
90
90
  borderTopWidth: '1px',
91
91
  borderTopStyle: 'solid',
92
- width: '100%'
93
- }
92
+ width: '100%',
93
+ },
94
94
  })
95
95
  break
96
96
  case 'qrcode':
@@ -102,8 +102,8 @@ class EditStore {
102
102
  left: '0px',
103
103
  top: '0px',
104
104
  width: '50px',
105
- height: '50px'
106
- }
105
+ height: '50px',
106
+ },
107
107
  })
108
108
  break
109
109
  case 'merchandise_trace_qrcode':
@@ -115,8 +115,8 @@ class EditStore {
115
115
  left: '0px',
116
116
  top: '0px',
117
117
  width: '50px',
118
- height: '50px'
119
- }
118
+ height: '50px',
119
+ },
120
120
  })
121
121
  break
122
122
  case 'verification_qrcode':
@@ -128,8 +128,8 @@ class EditStore {
128
128
  left: '0px',
129
129
  top: '0px',
130
130
  width: '50px',
131
- height: '50px'
132
- }
131
+ height: '50px',
132
+ },
133
133
  })
134
134
  break
135
135
  case 'order_qrcode':
@@ -141,8 +141,8 @@ class EditStore {
141
141
  left: '0px',
142
142
  top: '0px',
143
143
  width: '50px',
144
- height: '50px'
145
- }
144
+ height: '50px',
145
+ },
146
146
  })
147
147
  break
148
148
  case 'barcode':
@@ -154,8 +154,8 @@ class EditStore {
154
154
  left: '0px',
155
155
  top: '0px',
156
156
  height: '30px',
157
- width: '165px'
158
- }
157
+ width: '165px',
158
+ },
159
159
  })
160
160
  break
161
161
  case 'in_stock_barcode':
@@ -167,8 +167,8 @@ class EditStore {
167
167
  left: '0px',
168
168
  top: '0px',
169
169
  height: '30px',
170
- width: '165px'
171
- }
170
+ width: '165px',
171
+ },
172
172
  })
173
173
  break
174
174
  case 'package_id_qrcode':
@@ -180,8 +180,8 @@ class EditStore {
180
180
  left: '0px',
181
181
  top: '0px',
182
182
  width: '50px',
183
- height: '50px'
184
- }
183
+ height: '50px',
184
+ },
185
185
  })
186
186
  break
187
187
  case 'diycode':
@@ -193,8 +193,8 @@ class EditStore {
193
193
  left: '0px',
194
194
  top: '0px',
195
195
  height: '30px',
196
- width: '165px'
197
- }
196
+ width: '165px',
197
+ },
198
198
  })
199
199
  break
200
200
  case 'diyqrcode':
@@ -207,8 +207,8 @@ class EditStore {
207
207
  left: '0px',
208
208
  top: '0px',
209
209
  width: '80px',
210
- height: '80px'
211
- }
210
+ height: '80px',
211
+ },
212
212
  })
213
213
  break
214
214
  case 'image':
@@ -220,8 +220,8 @@ class EditStore {
220
220
  left: '0px',
221
221
  top: '0px',
222
222
  height: '100px',
223
- width: '100px'
224
- }
223
+ width: '100px',
224
+ },
225
225
  })
226
226
  break
227
227
  case 'production_barcode':
@@ -233,8 +233,8 @@ class EditStore {
233
233
  left: '0px',
234
234
  top: '0px',
235
235
  height: '30px',
236
- width: '165px'
237
- }
236
+ width: '165px',
237
+ },
238
238
  })
239
239
  break
240
240
  case 'new_production_barcode':
@@ -246,8 +246,8 @@ class EditStore {
246
246
  left: '0px',
247
247
  top: '0px',
248
248
  height: '30px',
249
- width: '165px'
250
- }
249
+ width: '165px',
250
+ },
251
251
  })
252
252
  break
253
253
  case 'rack_barcode':
@@ -259,8 +259,21 @@ class EditStore {
259
259
  left: '0px',
260
260
  top: '0px',
261
261
  height: '30px',
262
- width: '165px'
263
- }
262
+ width: '165px',
263
+ },
264
+ })
265
+ break
266
+ case 'customer_barcode':
267
+ this.config.blocks.push({
268
+ type,
269
+ customer_barcode: i18next.t('{{客户码}}'),
270
+ style: {
271
+ position: 'absolute',
272
+ left: '0px',
273
+ top: '0px',
274
+ height: '30px',
275
+ width: '165px',
276
+ },
264
277
  })
265
278
  break
266
279
  case 'delivery_qrcode':
@@ -272,8 +285,8 @@ class EditStore {
272
285
  left: '0px',
273
286
  top: '0px',
274
287
  height: '80px',
275
- width: '80px'
276
- }
288
+ width: '80px',
289
+ },
277
290
  })
278
291
  break
279
292
  case 'package_order_qrcode':
@@ -284,9 +297,9 @@ class EditStore {
284
297
  position: 'absolute',
285
298
  left: '0px',
286
299
  top: '0px',
287
- width: '50px',
288
- height: '50px'
289
- }
300
+ width: '60px',
301
+ height: '60px',
302
+ },
290
303
  })
291
304
  break
292
305
  default:
@@ -297,7 +310,7 @@ class EditStore {
297
310
 
298
311
  // 删除所选字段
299
312
  @action.bound
300
- removeConfig () {
313
+ removeConfig() {
301
314
  if (this.selected !== null) {
302
315
  this.config.blocks.splice(this.selected, 1)
303
316
  this.selected = null
@@ -306,30 +319,30 @@ class EditStore {
306
319
 
307
320
  // 添加字段到打印单中 两种 :1-添加到打印的模板中 2-添加到自定义二维码中
308
321
  @action.bound
309
- addFieldToBlocks ({ value, key, fieldType }) {
322
+ addFieldToBlocks({ value, key, fieldType }) {
310
323
  // 不一定每次打印都传页码过去,为了不出现“页码:”情况,页码前不加前缀
311
324
  if (!this.config.blocks[this.selected]?.diyqrcode) {
312
325
  key === i18next.t('页码')
313
326
  ? this.config.blocks.push({
314
- text: `${value}`,
315
- fieldType,
316
- fieldKey: key,
317
- style: {
318
- position: 'absolute',
319
- left: '0px',
320
- top: '0px'
321
- }
322
- })
327
+ text: `${value}`,
328
+ fieldType,
329
+ fieldKey: key,
330
+ style: {
331
+ position: 'absolute',
332
+ left: '0px',
333
+ top: '0px',
334
+ },
335
+ })
323
336
  : this.config.blocks.push({
324
- text: `${key}:${value}`,
325
- fieldType,
326
- fieldKey: key,
327
- style: {
328
- position: 'absolute',
329
- left: '0px',
330
- top: '0px'
331
- }
332
- })
337
+ text: `${key}:${value}`,
338
+ fieldType,
339
+ fieldKey: key,
340
+ style: {
341
+ position: 'absolute',
342
+ left: '0px',
343
+ top: '0px',
344
+ },
345
+ })
333
346
  }
334
347
  if (this.config.blocks[this.selected]?.diyqrcode) {
335
348
  this.config.blocks[this.selected].text += value + ','
@@ -337,7 +350,7 @@ class EditStore {
337
350
  }
338
351
 
339
352
  @computed
340
- get computedIsTime () {
353
+ get computedIsTime() {
341
354
  if (this.selected !== null) {
342
355
  const block = this.config.blocks[this.selected]
343
356
  if (
@@ -351,14 +364,14 @@ class EditStore {
351
364
  }
352
365
 
353
366
  @action.bound
354
- getHandledConfig (config) {
367
+ getHandledConfig(config) {
355
368
  const result = _.cloneDeep(config)
356
369
  // 添加自定义尺寸字段
357
370
  result.page = {
358
371
  ...result.page,
359
372
  customizeWidth: result.page.customizeWidth || 100, // 若没有则默认为100
360
373
  customizeHeight: result.page.customizeHeight || 100,
361
- doublePage: result.page.doublePage || false
374
+ doublePage: result.page.doublePage || false,
362
375
  }
363
376
 
364
377
  return result
@@ -12,12 +12,12 @@ import _ from 'lodash'
12
12
  class Block extends React.Component {
13
13
  dragBlock = React.createRef(null)
14
14
  handleChangeDebounce = null
15
- constructor (props) {
15
+ constructor(props) {
16
16
  super(props)
17
17
  this.state = {
18
18
  clientX: null,
19
19
  clientY: null,
20
- isEdit: false
20
+ isEdit: false,
21
21
  }
22
22
  }
23
23
 
@@ -26,14 +26,14 @@ class Block extends React.Component {
26
26
 
27
27
  this.setState({
28
28
  clientX,
29
- clientY
29
+ clientY,
30
30
  })
31
31
 
32
32
  window.document.dispatchEvent(
33
33
  new window.CustomEvent('gm-printer-label-select', {
34
34
  detail: {
35
- selected: index
36
- }
35
+ selected: index,
36
+ },
37
37
  })
38
38
  )
39
39
  }
@@ -46,7 +46,7 @@ class Block extends React.Component {
46
46
  const style = getStyleWithDiff(config.style, diffX, diffY)
47
47
 
48
48
  dispatchMsg('gm-printer-label-block-style-set', {
49
- style
49
+ style,
50
50
  })
51
51
  }
52
52
 
@@ -54,18 +54,18 @@ class Block extends React.Component {
54
54
  const { index } = this.props
55
55
 
56
56
  dispatchMsg('gm-printer-label-select', {
57
- selected: index
57
+ selected: index,
58
58
  })
59
59
  }
60
60
 
61
61
  handleDoubleClick = () => {
62
62
  const {
63
- config: { type }
63
+ config: { type },
64
64
  } = this.props
65
65
  if (!type || type === 'text') {
66
66
  this.setState(
67
67
  {
68
- isEdit: true
68
+ isEdit: true,
69
69
  },
70
70
  () => {
71
71
  this.refEdit.focus()
@@ -76,13 +76,13 @@ class Block extends React.Component {
76
76
 
77
77
  handleEditBlur = () => {
78
78
  this.setState({
79
- isEdit: false
79
+ isEdit: false,
80
80
  })
81
81
  }
82
82
 
83
83
  handleText = (e) => {
84
84
  dispatchMsg('gm-printer-label-block-text-set', {
85
- text: e.target.value
85
+ text: e.target.value,
86
86
  })
87
87
  }
88
88
 
@@ -112,7 +112,7 @@ class Block extends React.Component {
112
112
  }
113
113
  }
114
114
 
115
- render () {
115
+ render() {
116
116
  const {
117
117
  index,
118
118
  selected,
@@ -134,8 +134,9 @@ class Block extends React.Component {
134
134
  merchandise_trace_qrcode,
135
135
  verification_qrcode,
136
136
  rack_barcode,
137
+ customer_barcode,
137
138
  delivery_qrcode,
138
- package_order_qrcode
139
+ package_order_qrcode,
139
140
  },
140
141
  data,
141
142
  config,
@@ -162,7 +163,7 @@ class Block extends React.Component {
162
163
  const value = text.split(':')?.[1]
163
164
  const isHtml = value && value.indexOf('_html') !== -1
164
165
  content = isHtml ? (
165
- <div dangerouslySetInnerHTML={{ __html: template(value, data) }}/>
166
+ <div dangerouslySetInnerHTML={{ __html: template(value, data) }} />
166
167
  ) : (
167
168
  template(text, data)
168
169
  )
@@ -408,7 +409,7 @@ class Block extends React.Component {
408
409
  )
409
410
  } else if (type === 'diyqrcode') {
410
411
  content = isStation ? (
411
- <QrCode value={template(text, data)} size={parseInt(style.height)}/>
412
+ <QrCode value={template(text, data)} size={parseInt(style.height)} />
412
413
  ) : (
413
414
  <div
414
415
  data-diyqrcode={template(text, data)}
@@ -462,6 +463,21 @@ class Block extends React.Component {
462
463
  background='transparent'
463
464
  />
464
465
  )
466
+ } else if (type === 'customer_barcode') {
467
+ /** 浏览器端的货位标签打印 */
468
+ content = (
469
+ <BarCode
470
+ value={template(customer_barcode, data)}
471
+ textMargin={0}
472
+ margin={0}
473
+ height={parseInt(style.height)}
474
+ width={2}
475
+ svgWidth={style.width}
476
+ displayValue={false}
477
+ dataName={customer_barcode}
478
+ background='transparent'
479
+ />
480
+ )
465
481
  } else if (type === 'package_order_qrcode') {
466
482
  content = isStation ? (
467
483
  <QrCode
@@ -490,7 +506,7 @@ class Block extends React.Component {
490
506
  `gm-printer-label-block-type-${type}`,
491
507
  className,
492
508
  {
493
- active
509
+ active,
494
510
  }
495
511
  )}
496
512
  draggable
@@ -524,7 +540,7 @@ Block.propTypes = {
524
540
  data: PropTypes.object.isRequired,
525
541
  selected: PropTypes.number,
526
542
  isStation: PropTypes.bool,
527
- doublePage: PropTypes.bool
543
+ doublePage: PropTypes.bool,
528
544
  }
529
545
 
530
546
  export default Block