gm-printer-label 3.1.0-beta.2 → 3.1.0-beta.5

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.1.0-beta.2",
3
+ "version": "3.1.0-beta.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -6,15 +6,16 @@ import { getStyleWithDiff, dispatchMsg, template, miniAppLink } from '../util'
6
6
  import TableType from './components/table_type'
7
7
  import BarCode from './barcode'
8
8
  import QrCode from './qrcode'
9
+ import _ from 'lodash'
9
10
 
10
11
  @observer
11
12
  class Block extends React.Component {
12
- constructor (props) {
13
+ constructor(props) {
13
14
  super(props)
14
15
  this.state = {
15
16
  clientX: null,
16
17
  clientY: null,
17
- isEdit: false
18
+ isEdit: false,
18
19
  }
19
20
  }
20
21
 
@@ -23,14 +24,14 @@ class Block extends React.Component {
23
24
 
24
25
  this.setState({
25
26
  clientX,
26
- clientY
27
+ clientY,
27
28
  })
28
29
 
29
30
  window.document.dispatchEvent(
30
31
  new window.CustomEvent('gm-printer-label-select', {
31
32
  detail: {
32
- selected: index
33
- }
33
+ selected: index,
34
+ },
34
35
  })
35
36
  )
36
37
  }
@@ -43,7 +44,7 @@ class Block extends React.Component {
43
44
  const style = getStyleWithDiff(config.style, diffX, diffY)
44
45
 
45
46
  dispatchMsg('gm-printer-label-block-style-set', {
46
- style
47
+ style,
47
48
  })
48
49
  }
49
50
 
@@ -51,18 +52,18 @@ class Block extends React.Component {
51
52
  const { index } = this.props
52
53
 
53
54
  dispatchMsg('gm-printer-label-select', {
54
- selected: index
55
+ selected: index,
55
56
  })
56
57
  }
57
58
 
58
59
  handleDoubleClick = () => {
59
60
  const {
60
- config: { type }
61
+ config: { type },
61
62
  } = this.props
62
63
  if (!type || type === 'text') {
63
64
  this.setState(
64
65
  {
65
- isEdit: true
66
+ isEdit: true,
66
67
  },
67
68
  () => {
68
69
  this.refEdit.focus()
@@ -73,17 +74,17 @@ class Block extends React.Component {
73
74
 
74
75
  handleEditBlur = () => {
75
76
  this.setState({
76
- isEdit: false
77
+ isEdit: false,
77
78
  })
78
79
  }
79
80
 
80
81
  handleText = (e) => {
81
82
  dispatchMsg('gm-printer-label-block-text-set', {
82
- text: e.target.value
83
+ text: e.target.value,
83
84
  })
84
85
  }
85
86
 
86
- render () {
87
+ render() {
87
88
  const {
88
89
  index,
89
90
  selected,
@@ -101,7 +102,7 @@ class Block extends React.Component {
101
102
  fieldType,
102
103
  fieldKey,
103
104
  production_barcode,
104
- merchandise_trace_qrcode
105
+ merchandise_trace_qrcode,
105
106
  },
106
107
  data,
107
108
  className,
@@ -309,7 +310,7 @@ class Block extends React.Component {
309
310
  )
310
311
  } else if (type === 'diyqrcode') {
311
312
  content = isStation ? (
312
- <QrCode value={template(text, data)} size={parseInt(style.height)}/>
313
+ <QrCode value={template(text, data)} size={parseInt(style.height)} />
313
314
  ) : (
314
315
  <div
315
316
  data-diyqrcode={template(text, data)}
@@ -331,9 +332,9 @@ class Block extends React.Component {
331
332
  />
332
333
  )
333
334
  }
334
- console.log('content', content)
335
335
  if (content.indexOf('div') != '-1') {
336
336
  // console.log('content', dangerouslySetInnerHTML={{ __html: content }})
337
+ console.log('div', _.split(content, ':', 2))
337
338
  }
338
339
  const active = index === selected
339
340
  return (
@@ -345,7 +346,7 @@ class Block extends React.Component {
345
346
  `gm-printer-label-block-type-${type}`,
346
347
  className,
347
348
  {
348
- active
349
+ active,
349
350
  }
350
351
  )}
351
352
  draggable
@@ -356,7 +357,14 @@ class Block extends React.Component {
356
357
  data-name={index}
357
358
  >
358
359
  {content.indexOf('div') != '-1' ? (
359
- <div dangerouslySetInnerHTML={{ __html: content.split(':')?.(1) }}/>
360
+ /** 表单 */
361
+ <div
362
+ dangerouslySetInnerHTML={{
363
+ __html: _.slice(content, _.indexOf(content, ':') + 1, -1).join(
364
+ ''
365
+ ),
366
+ }}
367
+ />
360
368
  ) : (
361
369
  content
362
370
  )}
@@ -379,7 +387,7 @@ Block.propTypes = {
379
387
  config: PropTypes.object.isRequired,
380
388
  data: PropTypes.object.isRequired,
381
389
  selected: PropTypes.number,
382
- isStation: PropTypes.bool
390
+ isStation: PropTypes.bool,
383
391
  }
384
392
 
385
393
  export default Block