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

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/.eslintcache CHANGED
@@ -1 +1 @@
1
- [{"/Volumes/gm-project/gm-printer-label/src/index.js":"1","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/edit_modify_filed.js":"2","/Volumes/gm-project/gm-printer-label/src/common/config.js":"3","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/store.js":"4","/Volumes/gm-project/gm-printer-label/src/util.js":"5","/Volumes/gm-project/gm-printer-label/src/printer/printer.js":"6","/Volumes/gm-project/gm-printer-label/src/printer/page.js":"7","/Volumes/gm-project/gm-printer-label/src/printer/block.js":"8","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/edit.js":"9"},{"size":180,"mtime":1658462117054,"results":"10","hashOfConfig":"11"},{"size":4629,"mtime":1658462013375},{"size":1699,"mtime":1658461960259},{"size":7194,"mtime":1658890412916,"results":"12","hashOfConfig":"11"},{"size":1962,"mtime":1660567552794},{"size":1913,"mtime":1660567552793},{"size":411,"mtime":1660567552793},{"size":10502,"mtime":1660726333740},{"size":2958,"mtime":1660567552792},{"filePath":"13","messages":"14","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"17s6x9q",{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Volumes/gm-project/gm-printer-label/src/index.js",[],"/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/store.js",[]]
1
+ [{"/Volumes/gm-project/gm-printer-label/src/index.js":"1","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/edit_modify_filed.js":"2","/Volumes/gm-project/gm-printer-label/src/common/config.js":"3","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/store.js":"4","/Volumes/gm-project/gm-printer-label/src/util.js":"5","/Volumes/gm-project/gm-printer-label/src/printer/printer.js":"6","/Volumes/gm-project/gm-printer-label/src/printer/page.js":"7","/Volumes/gm-project/gm-printer-label/src/printer/block.js":"8","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/edit.js":"9"},{"size":180,"mtime":1658462117054,"results":"10","hashOfConfig":"11"},{"size":4629,"mtime":1658462013375},{"size":1699,"mtime":1658461960259},{"size":7194,"mtime":1658890412916,"results":"12","hashOfConfig":"11"},{"size":1962,"mtime":1660567552794},{"size":1913,"mtime":1660567552793},{"size":411,"mtime":1660567552793},{"size":10454,"mtime":1660737942184},{"size":2958,"mtime":1660567552792},{"filePath":"13","messages":"14","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"17s6x9q",{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Volumes/gm-project/gm-printer-label/src/index.js",[],"/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/store.js",[]]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer-label",
3
- "version": "3.1.0-beta.5",
3
+ "version": "3.1.0-beta.6",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,12 +10,12 @@ import _ from 'lodash'
10
10
 
11
11
  @observer
12
12
  class Block extends React.Component {
13
- constructor(props) {
13
+ constructor (props) {
14
14
  super(props)
15
15
  this.state = {
16
16
  clientX: null,
17
17
  clientY: null,
18
- isEdit: false,
18
+ isEdit: false
19
19
  }
20
20
  }
21
21
 
@@ -24,14 +24,14 @@ class Block extends React.Component {
24
24
 
25
25
  this.setState({
26
26
  clientX,
27
- clientY,
27
+ clientY
28
28
  })
29
29
 
30
30
  window.document.dispatchEvent(
31
31
  new window.CustomEvent('gm-printer-label-select', {
32
32
  detail: {
33
- selected: index,
34
- },
33
+ selected: index
34
+ }
35
35
  })
36
36
  )
37
37
  }
@@ -44,7 +44,7 @@ class Block extends React.Component {
44
44
  const style = getStyleWithDiff(config.style, diffX, diffY)
45
45
 
46
46
  dispatchMsg('gm-printer-label-block-style-set', {
47
- style,
47
+ style
48
48
  })
49
49
  }
50
50
 
@@ -52,18 +52,18 @@ class Block extends React.Component {
52
52
  const { index } = this.props
53
53
 
54
54
  dispatchMsg('gm-printer-label-select', {
55
- selected: index,
55
+ selected: index
56
56
  })
57
57
  }
58
58
 
59
59
  handleDoubleClick = () => {
60
60
  const {
61
- config: { type },
61
+ config: { type }
62
62
  } = this.props
63
63
  if (!type || type === 'text') {
64
64
  this.setState(
65
65
  {
66
- isEdit: true,
66
+ isEdit: true
67
67
  },
68
68
  () => {
69
69
  this.refEdit.focus()
@@ -74,17 +74,17 @@ class Block extends React.Component {
74
74
 
75
75
  handleEditBlur = () => {
76
76
  this.setState({
77
- isEdit: false,
77
+ isEdit: false
78
78
  })
79
79
  }
80
80
 
81
81
  handleText = (e) => {
82
82
  dispatchMsg('gm-printer-label-block-text-set', {
83
- text: e.target.value,
83
+ text: e.target.value
84
84
  })
85
85
  }
86
86
 
87
- render() {
87
+ render () {
88
88
  const {
89
89
  index,
90
90
  selected,
@@ -102,7 +102,7 @@ class Block extends React.Component {
102
102
  fieldType,
103
103
  fieldKey,
104
104
  production_barcode,
105
- merchandise_trace_qrcode,
105
+ merchandise_trace_qrcode
106
106
  },
107
107
  data,
108
108
  className,
@@ -111,6 +111,7 @@ class Block extends React.Component {
111
111
  } = this.props
112
112
  const { isEdit } = this.state
113
113
  let content = null
114
+
114
115
  if (!type || type === 'text') {
115
116
  if (fieldType === ' ') {
116
117
  // 字段类型为表格
@@ -122,7 +123,14 @@ class Block extends React.Component {
122
123
  />
123
124
  )
124
125
  } else {
125
- content = template(text, data)
126
+ /** html */
127
+ const value = text.split(':')?.[1]
128
+ const isHtml = value.indexOf('_html') !== -1
129
+ content = isHtml ? (
130
+ <div dangerouslySetInnerHTML={{ __html: template(value, data) }}/>
131
+ ) : (
132
+ template(text, data)
133
+ )
126
134
  }
127
135
  } else if (type === 'line') {
128
136
  content = null
@@ -310,7 +318,7 @@ class Block extends React.Component {
310
318
  )
311
319
  } else if (type === 'diyqrcode') {
312
320
  content = isStation ? (
313
- <QrCode value={template(text, data)} size={parseInt(style.height)} />
321
+ <QrCode value={template(text, data)} size={parseInt(style.height)}/>
314
322
  ) : (
315
323
  <div
316
324
  data-diyqrcode={template(text, data)}
@@ -332,11 +340,8 @@ class Block extends React.Component {
332
340
  />
333
341
  )
334
342
  }
335
- if (content.indexOf('div') != '-1') {
336
- // console.log('content', dangerouslySetInnerHTML={{ __html: content }})
337
- console.log('div', _.split(content, ':', 2))
338
- }
339
343
  const active = index === selected
344
+
340
345
  return (
341
346
  <div
342
347
  {...rest}
@@ -346,7 +351,7 @@ class Block extends React.Component {
346
351
  `gm-printer-label-block-type-${type}`,
347
352
  className,
348
353
  {
349
- active,
354
+ active
350
355
  }
351
356
  )}
352
357
  draggable
@@ -356,18 +361,7 @@ class Block extends React.Component {
356
361
  onDoubleClick={this.handleDoubleClick}
357
362
  data-name={index}
358
363
  >
359
- {content.indexOf('div') != '-1' ? (
360
- /** 表单 */
361
- <div
362
- dangerouslySetInnerHTML={{
363
- __html: _.slice(content, _.indexOf(content, ':') + 1, -1).join(
364
- ''
365
- ),
366
- }}
367
- />
368
- ) : (
369
- content
370
- )}
364
+ {content}
371
365
  {(!type || type === 'text') && active && isEdit && (
372
366
  <textarea
373
367
  ref={(ref) => (this.refEdit = ref)}
@@ -387,7 +381,7 @@ Block.propTypes = {
387
381
  config: PropTypes.object.isRequired,
388
382
  data: PropTypes.object.isRequired,
389
383
  selected: PropTypes.number,
390
- isStation: PropTypes.bool,
384
+ isStation: PropTypes.bool
391
385
  }
392
386
 
393
387
  export default Block