gm-printer-label 3.1.0-beta.3 → 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 +1 -1
- package/package.json +1 -1
- package/src/printer/block.js +28 -26
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":
|
|
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
package/src/printer/block.js
CHANGED
|
@@ -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,
|
|
@@ -110,6 +111,7 @@ class Block extends React.Component {
|
|
|
110
111
|
} = this.props
|
|
111
112
|
const { isEdit } = this.state
|
|
112
113
|
let content = null
|
|
114
|
+
|
|
113
115
|
if (!type || type === 'text') {
|
|
114
116
|
if (fieldType === ' ') {
|
|
115
117
|
// 字段类型为表格
|
|
@@ -121,7 +123,14 @@ class Block extends React.Component {
|
|
|
121
123
|
/>
|
|
122
124
|
)
|
|
123
125
|
} else {
|
|
124
|
-
|
|
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
|
+
)
|
|
125
134
|
}
|
|
126
135
|
} else if (type === 'line') {
|
|
127
136
|
content = null
|
|
@@ -309,7 +318,7 @@ class Block extends React.Component {
|
|
|
309
318
|
)
|
|
310
319
|
} else if (type === 'diyqrcode') {
|
|
311
320
|
content = isStation ? (
|
|
312
|
-
<QrCode value={template(text, data)} size={parseInt(style.height)}
|
|
321
|
+
<QrCode value={template(text, data)} size={parseInt(style.height)}/>
|
|
313
322
|
) : (
|
|
314
323
|
<div
|
|
315
324
|
data-diyqrcode={template(text, data)}
|
|
@@ -331,11 +340,8 @@ class Block extends React.Component {
|
|
|
331
340
|
/>
|
|
332
341
|
)
|
|
333
342
|
}
|
|
334
|
-
console.log('content', content)
|
|
335
|
-
if (content.indexOf('div') != '-1') {
|
|
336
|
-
// console.log('content', dangerouslySetInnerHTML={{ __html: content }})
|
|
337
|
-
}
|
|
338
343
|
const active = index === selected
|
|
344
|
+
|
|
339
345
|
return (
|
|
340
346
|
<div
|
|
341
347
|
{...rest}
|
|
@@ -345,7 +351,7 @@ class Block extends React.Component {
|
|
|
345
351
|
`gm-printer-label-block-type-${type}`,
|
|
346
352
|
className,
|
|
347
353
|
{
|
|
348
|
-
active
|
|
354
|
+
active
|
|
349
355
|
}
|
|
350
356
|
)}
|
|
351
357
|
draggable
|
|
@@ -355,11 +361,7 @@ class Block extends React.Component {
|
|
|
355
361
|
onDoubleClick={this.handleDoubleClick}
|
|
356
362
|
data-name={index}
|
|
357
363
|
>
|
|
358
|
-
{content
|
|
359
|
-
<div dangerouslySetInnerHTML={{ __html: content?.split(':')?.(1) }} />
|
|
360
|
-
) : (
|
|
361
|
-
content
|
|
362
|
-
)}
|
|
364
|
+
{content}
|
|
363
365
|
{(!type || type === 'text') && active && isEdit && (
|
|
364
366
|
<textarea
|
|
365
367
|
ref={(ref) => (this.refEdit = ref)}
|
|
@@ -379,7 +381,7 @@ Block.propTypes = {
|
|
|
379
381
|
config: PropTypes.object.isRequired,
|
|
380
382
|
data: PropTypes.object.isRequired,
|
|
381
383
|
selected: PropTypes.number,
|
|
382
|
-
isStation: PropTypes.bool
|
|
384
|
+
isStation: PropTypes.bool
|
|
383
385
|
}
|
|
384
386
|
|
|
385
387
|
export default Block
|