gm-printer-label 3.0.12 → 3.0.15-beta.1
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/common/editor_compoents/edit.js +30 -14
- package/src/common/editor_compoents/edit_modify_filed.js +3 -1
- package/src/common/editor_compoents/store.js +15 -2
- package/src/common/editor_compoents/style.lesss +3 -0
- package/src/index.js +1 -1
- package/src/printer/barcode.js +12 -2
- package/src/printer/block.js +61 -3
- package/src/printer/page.js +7 -5
- package/src/printer/printer.js +22 -7
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/
|
|
1
|
+
[{"/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/printer/block.js":"1","/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/printer/barcode.js":"2","/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/common/editor_compoents/store.js":"3","/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/common/editor_compoents/edit_modify_filed.js":"4","/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/common/editor_compoents/edit.js":"5"},{"size":11926,"mtime":1661845807605,"results":"6","hashOfConfig":"7"},{"size":811,"mtime":1661830658895,"results":"8","hashOfConfig":"7"},{"size":7521,"mtime":1661761909135,"results":"9","hashOfConfig":"7"},{"size":4703,"mtime":1661845704638,"results":"10","hashOfConfig":"7"},{"size":2949,"mtime":1661845754871,"results":"11","hashOfConfig":"7"},{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"boephf",{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/printer/block.js",[],"/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/printer/barcode.js",[],"/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/common/editor_compoents/store.js",[],"/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/common/editor_compoents/edit_modify_filed.js",[],"/Users/yancheng/Yancheng/gm/open_source/gm-printer-label/src/common/editor_compoents/edit.js",[]]
|
package/package.json
CHANGED
|
@@ -22,22 +22,34 @@ class Edit extends React.Component {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
render () {
|
|
25
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
data,
|
|
27
|
+
initDefaultTemp,
|
|
28
|
+
defaultTempList,
|
|
29
|
+
addFields,
|
|
30
|
+
onSave,
|
|
31
|
+
editStore,
|
|
32
|
+
insertBlocksConfig,
|
|
33
|
+
uploadQiniuImage,
|
|
34
|
+
doublePageType
|
|
35
|
+
} = this.props
|
|
26
36
|
return (
|
|
27
37
|
<div className='gm-printer-label-edit'>
|
|
28
|
-
|
|
29
38
|
<Flex className='gm-printer-label-edit-title-fixed'>
|
|
30
|
-
<Title
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
<Title
|
|
40
|
+
title={i18next.t('模板预览')}
|
|
41
|
+
text={
|
|
42
|
+
<span className='gm-text-desc gm-padding-left-5'>
|
|
43
|
+
{i18next.t(
|
|
44
|
+
'说明:单击选中内容,双击编辑,可拖动以摆放位置,可方向键细调位置,可点击右键删除'
|
|
45
|
+
)}
|
|
46
|
+
</span>
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
34
49
|
</Flex>
|
|
35
50
|
|
|
36
51
|
<div className='gm-printer-label-edit-header'>
|
|
37
|
-
<EditTitle
|
|
38
|
-
onSave={onSave}
|
|
39
|
-
initDefaultTemp={initDefaultTemp}
|
|
40
|
-
/>
|
|
52
|
+
<EditTitle onSave={onSave} initDefaultTemp={initDefaultTemp}/>
|
|
41
53
|
<Gap height='10px'/>
|
|
42
54
|
<EditSelect
|
|
43
55
|
insertBlocksConfig={insertBlocksConfig}
|
|
@@ -52,17 +64,19 @@ class Edit extends React.Component {
|
|
|
52
64
|
|
|
53
65
|
{/* 挂载shadow down中的Dialog组件 */}
|
|
54
66
|
<div id='gm-printer-label-modal'/>
|
|
55
|
-
|
|
56
67
|
</div>
|
|
57
68
|
|
|
58
|
-
<div
|
|
59
|
-
|
|
69
|
+
<div
|
|
70
|
+
className='gm-printer-label-edit-content'
|
|
71
|
+
onClick={this.handleCancel}
|
|
72
|
+
>
|
|
60
73
|
<ContextMenu>
|
|
61
74
|
<Printer
|
|
62
75
|
selected={editStore.selected}
|
|
63
76
|
config={editStore.config}
|
|
64
77
|
data={data}
|
|
65
78
|
onChange={this.handleChange}
|
|
79
|
+
doublePageType={doublePageType}
|
|
66
80
|
/>
|
|
67
81
|
</ContextMenu>
|
|
68
82
|
</div>
|
|
@@ -79,7 +93,9 @@ Edit.propTypes = {
|
|
|
79
93
|
initDefaultTemp: PropTypes.string,
|
|
80
94
|
defaultTempList: PropTypes.object,
|
|
81
95
|
addFields: PropTypes.object.isRequired,
|
|
82
|
-
insertBlocksConfig: PropTypes.array.isRequired
|
|
96
|
+
insertBlocksConfig: PropTypes.array.isRequired,
|
|
97
|
+
/** 放大编辑窗口 */
|
|
98
|
+
doublePageType: PropTypes.bool
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
Edit.deaultProps = {
|
|
@@ -84,7 +84,9 @@ class EditModifyFiled extends React.Component {
|
|
|
84
84
|
{(type === 'qrcode' ||
|
|
85
85
|
type === 'order_qrcode' ||
|
|
86
86
|
type === 'package_id_qrcode' ||
|
|
87
|
-
type === 'image'
|
|
87
|
+
type === 'image' ||
|
|
88
|
+
type === 'rack_barcode' ||
|
|
89
|
+
type === 'merchandise_trace_qrcode') && (
|
|
88
90
|
<div>
|
|
89
91
|
<Size
|
|
90
92
|
style={style}
|
|
@@ -114,8 +114,8 @@ class EditStore {
|
|
|
114
114
|
position: 'absolute',
|
|
115
115
|
left: '0px',
|
|
116
116
|
top: '0px',
|
|
117
|
-
width: '
|
|
118
|
-
height: '
|
|
117
|
+
width: '50px',
|
|
118
|
+
height: '50px'
|
|
119
119
|
}
|
|
120
120
|
})
|
|
121
121
|
break
|
|
@@ -224,6 +224,19 @@ class EditStore {
|
|
|
224
224
|
}
|
|
225
225
|
})
|
|
226
226
|
break
|
|
227
|
+
case 'rack_barcode':
|
|
228
|
+
this.config.blocks.push({
|
|
229
|
+
type,
|
|
230
|
+
rack_barcode: i18next.t('{{货位条形码}}'),
|
|
231
|
+
style: {
|
|
232
|
+
position: 'absolute',
|
|
233
|
+
left: '0px',
|
|
234
|
+
top: '0px',
|
|
235
|
+
height: '30px',
|
|
236
|
+
width: '165px'
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
break
|
|
227
240
|
default:
|
|
228
241
|
window.alert(i18next.t('出错啦,未识别类型,此信息不应该出现'))
|
|
229
242
|
break
|
package/src/index.js
CHANGED
package/src/printer/barcode.js
CHANGED
|
@@ -8,14 +8,24 @@ class BarCode extends React.Component {
|
|
|
8
8
|
componentDidMount () {
|
|
9
9
|
const { value, ...rest } = this.props
|
|
10
10
|
if (!value) return
|
|
11
|
+
/** jsBarCode的具体options前往:
|
|
12
|
+
* https://blog.csdn.net/shencailing/article/details/122101956
|
|
13
|
+
*/
|
|
11
14
|
jsBarcode(this.barcode.current, value, {
|
|
12
15
|
...rest
|
|
13
16
|
})
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
render () {
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
// 可设置条形码的宽高
|
|
21
|
+
const { dataName, height = '', svgWidth } = this.props
|
|
22
|
+
return <svg
|
|
23
|
+
data-name={dataName}
|
|
24
|
+
ref={this.barcode}
|
|
25
|
+
style={{
|
|
26
|
+
width: svgWidth, height: height + 'px'
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
19
29
|
}
|
|
20
30
|
}
|
|
21
31
|
|
package/src/printer/block.js
CHANGED
|
@@ -6,9 +6,12 @@ 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 {
|
|
13
|
+
dragBlock = React.createRef(null)
|
|
14
|
+
handleChangeDebounce = null
|
|
12
15
|
constructor (props) {
|
|
13
16
|
super(props)
|
|
14
17
|
this.state = {
|
|
@@ -83,6 +86,32 @@ class Block extends React.Component {
|
|
|
83
86
|
})
|
|
84
87
|
}
|
|
85
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
|
+
|
|
86
115
|
render () {
|
|
87
116
|
const {
|
|
88
117
|
index,
|
|
@@ -101,7 +130,8 @@ class Block extends React.Component {
|
|
|
101
130
|
fieldType,
|
|
102
131
|
fieldKey,
|
|
103
132
|
production_barcode,
|
|
104
|
-
merchandise_trace_qrcode
|
|
133
|
+
merchandise_trace_qrcode,
|
|
134
|
+
rack_barcode
|
|
105
135
|
},
|
|
106
136
|
data,
|
|
107
137
|
className,
|
|
@@ -110,6 +140,7 @@ class Block extends React.Component {
|
|
|
110
140
|
} = this.props
|
|
111
141
|
const { isEdit } = this.state
|
|
112
142
|
let content = null
|
|
143
|
+
|
|
113
144
|
if (!type || type === 'text') {
|
|
114
145
|
if (fieldType === 'table') {
|
|
115
146
|
// 字段类型为表格
|
|
@@ -121,7 +152,14 @@ class Block extends React.Component {
|
|
|
121
152
|
/>
|
|
122
153
|
)
|
|
123
154
|
} else {
|
|
124
|
-
|
|
155
|
+
/** 渲染一个html */
|
|
156
|
+
const value = text.split(':')?.[1]
|
|
157
|
+
const isHtml = value && value.indexOf('_html') !== -1
|
|
158
|
+
content = isHtml ? (
|
|
159
|
+
<div dangerouslySetInnerHTML={{ __html: template(value, data) }}/>
|
|
160
|
+
) : (
|
|
161
|
+
template(text, data)
|
|
162
|
+
)
|
|
125
163
|
}
|
|
126
164
|
} else if (type === 'line') {
|
|
127
165
|
content = null
|
|
@@ -330,9 +368,26 @@ class Block extends React.Component {
|
|
|
330
368
|
data-name={index}
|
|
331
369
|
/>
|
|
332
370
|
)
|
|
371
|
+
} else if (type === 'rack_barcode') {
|
|
372
|
+
/** 浏览器端的货位标签打印 */
|
|
373
|
+
content = (
|
|
374
|
+
<BarCode
|
|
375
|
+
value={template(rack_barcode, data)}
|
|
376
|
+
textAlign='center'
|
|
377
|
+
textMargin={0}
|
|
378
|
+
margin={0}
|
|
379
|
+
height={parseInt(style.height)}
|
|
380
|
+
width={2}
|
|
381
|
+
svgWidth={style.width}
|
|
382
|
+
font={rack_barcode}
|
|
383
|
+
displayValue
|
|
384
|
+
dataName={rack_barcode}
|
|
385
|
+
background='transparent'
|
|
386
|
+
/>
|
|
387
|
+
)
|
|
333
388
|
}
|
|
334
|
-
|
|
335
389
|
const active = index === selected
|
|
390
|
+
|
|
336
391
|
return (
|
|
337
392
|
<div
|
|
338
393
|
{...rest}
|
|
@@ -346,10 +401,13 @@ class Block extends React.Component {
|
|
|
346
401
|
}
|
|
347
402
|
)}
|
|
348
403
|
draggable
|
|
404
|
+
ref={this.dragBlock}
|
|
349
405
|
onDragStart={this.handleDragStart}
|
|
350
406
|
onDragEnd={this.handleDragEnd}
|
|
351
407
|
onClick={this.handleClick}
|
|
352
408
|
onDoubleClick={this.handleDoubleClick}
|
|
409
|
+
/** TODO: 拖拉设置条形码宽高 */
|
|
410
|
+
// onMouseMove={this.handleMouseMove}
|
|
353
411
|
data-name={index}
|
|
354
412
|
>
|
|
355
413
|
{content}
|
package/src/printer/page.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { observer } from 'mobx-react'
|
|
3
|
-
import { pageTypeMap } from '../common/config'
|
|
4
3
|
|
|
5
4
|
@observer
|
|
6
5
|
class Page extends React.Component {
|
|
7
|
-
render
|
|
8
|
-
const {
|
|
6
|
+
render() {
|
|
7
|
+
const {
|
|
8
|
+
pageStyle: { width, height },
|
|
9
|
+
children,
|
|
10
|
+
} = this.props
|
|
9
11
|
|
|
10
12
|
return (
|
|
11
13
|
<div
|
|
12
14
|
className='gm-printer-label-page'
|
|
13
15
|
style={{
|
|
14
|
-
width
|
|
15
|
-
height
|
|
16
|
+
width,
|
|
17
|
+
height,
|
|
16
18
|
}}
|
|
17
19
|
>
|
|
18
20
|
{children}
|
package/src/printer/printer.js
CHANGED
|
@@ -16,20 +16,33 @@ class Printer extends React.Component {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
render () {
|
|
19
|
-
const { config, selected, data, isStation } = this.props
|
|
19
|
+
const { config, selected, data, isStation, doublePageType } = this.props
|
|
20
20
|
const { type, style, customizeWidth, customizeHeight } = config.page
|
|
21
|
+
const ratio = doublePageType ? 2 : 1
|
|
22
|
+
|
|
23
|
+
const width =
|
|
24
|
+
(type === '-1'
|
|
25
|
+
? customizeWidth
|
|
26
|
+
: +pageTypeMap[type].width.split('mm')[0]) *
|
|
27
|
+
ratio +
|
|
28
|
+
'mm'
|
|
29
|
+
const height =
|
|
30
|
+
(type === '-1'
|
|
31
|
+
? customizeHeight
|
|
32
|
+
: +pageTypeMap[type].height.split('mm')[0]) *
|
|
33
|
+
ratio +
|
|
34
|
+
'mm'
|
|
35
|
+
|
|
21
36
|
return (
|
|
22
37
|
<div
|
|
23
38
|
className='gm-printer-label'
|
|
24
39
|
style={{
|
|
25
40
|
...style,
|
|
26
|
-
width
|
|
27
|
-
|
|
28
|
-
height:
|
|
29
|
-
type === '-1' ? customizeHeight + 'mm' : pageTypeMap[type].height
|
|
41
|
+
width,
|
|
42
|
+
height
|
|
30
43
|
}}
|
|
31
44
|
>
|
|
32
|
-
<Page
|
|
45
|
+
<Page pageStyle={{ width, height }}>
|
|
33
46
|
{_.map(config.blocks, (block, i) => (
|
|
34
47
|
<Block
|
|
35
48
|
key={i}
|
|
@@ -51,7 +64,9 @@ Printer.propTypes = {
|
|
|
51
64
|
config: PropTypes.object.isRequired,
|
|
52
65
|
data: PropTypes.object.isRequired, // 格式化后的数据
|
|
53
66
|
onReady: PropTypes.func,
|
|
54
|
-
isStation: PropTypes.bool
|
|
67
|
+
isStation: PropTypes.bool,
|
|
68
|
+
/** 放大编辑窗口 */
|
|
69
|
+
doublePageType: PropTypes.bool
|
|
55
70
|
}
|
|
56
71
|
|
|
57
72
|
export default Printer
|