gm-printer-label 3.0.12 → 3.0.15
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 +38 -22
- package/src/common/editor_compoents/edit_modify_filed.js +2 -1
- package/src/common/editor_compoents/store.js +2 -2
- package/src/index.js +1 -1
- package/src/printer/block.js +10 -2
- package/src/printer/page.js +7 -5
- package/src/printer/printer.js +22 -7
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"},{"size":180,"mtime":1658462117054,"results":"
|
|
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":1937,"mtime":1661225223156,"results":"13","hashOfConfig":"11"},{"size":1859,"mtime":1661225223156,"results":"14","hashOfConfig":"11"},{"size":411,"mtime":1660567552793},{"size":10456,"mtime":1661225238153},{"size":2958,"mtime":1660567552792},{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"17s6x9q",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"21","messages":"22","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",[],"/Volumes/gm-project/gm-printer-label/src/util.js",[],"/Volumes/gm-project/gm-printer-label/src/printer/printer.js",[]]
|
package/package.json
CHANGED
|
@@ -21,48 +21,62 @@ class Edit extends React.Component {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
render
|
|
25
|
-
const {
|
|
24
|
+
render() {
|
|
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
|
-
|
|
39
|
-
initDefaultTemp={initDefaultTemp}
|
|
40
|
-
/>
|
|
41
|
-
<Gap height='10px'/>
|
|
52
|
+
<EditTitle onSave={onSave} initDefaultTemp={initDefaultTemp} />
|
|
53
|
+
<Gap height='10px' />
|
|
42
54
|
<EditSelect
|
|
43
55
|
insertBlocksConfig={insertBlocksConfig}
|
|
44
56
|
initDefaultTemp={initDefaultTemp}
|
|
45
57
|
defaultTempList={defaultTempList}
|
|
46
58
|
uploadQiniuImage={uploadQiniuImage}
|
|
47
59
|
/>
|
|
48
|
-
<Gap height='5px'/>
|
|
49
|
-
<EditModifyFiled/>
|
|
50
|
-
<Gap height='5px'/>
|
|
51
|
-
<EditAddFiled data={addFields}/>
|
|
60
|
+
<Gap height='5px' />
|
|
61
|
+
<EditModifyFiled />
|
|
62
|
+
<Gap height='5px' />
|
|
63
|
+
<EditAddFiled data={addFields} />
|
|
52
64
|
|
|
53
65
|
{/* 挂载shadow down中的Dialog组件 */}
|
|
54
|
-
<div id='gm-printer-label-modal'/>
|
|
55
|
-
|
|
66
|
+
<div id='gm-printer-label-modal' />
|
|
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,11 +93,13 @@ 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 = {
|
|
86
|
-
onSave: _.noop
|
|
102
|
+
onSave: _.noop,
|
|
87
103
|
}
|
|
88
104
|
|
|
89
105
|
export default Edit
|
|
@@ -84,7 +84,8 @@ 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 === 'merchandise_trace_qrcode') && (
|
|
88
89
|
<div>
|
|
89
90
|
<Size
|
|
90
91
|
style={style}
|
package/src/index.js
CHANGED
package/src/printer/block.js
CHANGED
|
@@ -110,6 +110,7 @@ class Block extends React.Component {
|
|
|
110
110
|
} = this.props
|
|
111
111
|
const { isEdit } = this.state
|
|
112
112
|
let content = null
|
|
113
|
+
|
|
113
114
|
if (!type || type === 'text') {
|
|
114
115
|
if (fieldType === 'table') {
|
|
115
116
|
// 字段类型为表格
|
|
@@ -121,7 +122,14 @@ class Block extends React.Component {
|
|
|
121
122
|
/>
|
|
122
123
|
)
|
|
123
124
|
} else {
|
|
124
|
-
|
|
125
|
+
/** 渲染一个html */
|
|
126
|
+
const value = text.split(':')?.[1]
|
|
127
|
+
const isHtml = value && value.indexOf('_html') !== -1
|
|
128
|
+
content = isHtml ? (
|
|
129
|
+
<div dangerouslySetInnerHTML={{ __html: template(value, data) }}/>
|
|
130
|
+
) : (
|
|
131
|
+
template(text, data)
|
|
132
|
+
)
|
|
125
133
|
}
|
|
126
134
|
} else if (type === 'line') {
|
|
127
135
|
content = null
|
|
@@ -331,8 +339,8 @@ class Block extends React.Component {
|
|
|
331
339
|
/>
|
|
332
340
|
)
|
|
333
341
|
}
|
|
334
|
-
|
|
335
342
|
const active = index === selected
|
|
343
|
+
|
|
336
344
|
return (
|
|
337
345
|
<div
|
|
338
346
|
{...rest}
|
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
|