gm-printer-label 3.3.6-beta.0 → 3.3.6-beta.2
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/.eslintrc.js +12 -0
- package/.github/workflows/release.yml +46 -0
- package/.prettierrc.js +5 -0
- package/.stylelintrc +3 -0
- package/babel.config.js +7 -0
- package/i18n.config.js +9 -0
- package/locales/en.json +42 -0
- package/locales/index.js +32 -0
- package/locales/th.json +42 -0
- package/locales/zh-HK.json +43 -0
- package/locales/zh.json +1 -0
- package/package.json +15 -11
- package/postcss.config.js +9 -0
- package/src/common/config.js +82 -0
- package/src/common/editor_compoents/component.js +481 -0
- package/src/common/editor_compoents/config_text.js +47 -0
- package/src/common/editor_compoents/context_menu.js +129 -0
- package/src/common/editor_compoents/edit.js +106 -0
- package/src/common/editor_compoents/edit_add_filed.js +54 -0
- package/src/common/editor_compoents/edit_modify_filed.js +199 -0
- package/src/common/editor_compoents/edit_select.js +212 -0
- package/src/common/editor_compoents/edit_title.js +110 -0
- package/src/common/editor_compoents/index.js +10 -0
- package/src/common/editor_compoents/store.js +381 -0
- package/src/common/editor_compoents/style.less +425 -0
- package/src/common/editor_compoents/with_shadow_dom_hoc.js +30 -0
- package/src/common/editor_compoents/with_store_hoc.js +92 -0
- package/src/components/css/animation.less +95 -0
- package/src/components/css/button.less +49 -0
- package/src/components/css/distance.less +324 -0
- package/src/components/css/text.less +74 -0
- package/src/components/css/variables.less +12 -0
- package/src/components/dialog/index.js +72 -0
- package/src/components/dialog/style.less +64 -0
- package/src/components/dropdown/drop_down.js +67 -0
- package/src/components/dropdown/drop_down_item.js +37 -0
- package/src/components/dropdown/drop_down_items.js +22 -0
- package/src/components/dropdown/index.js +9 -0
- package/src/components/dropdown/style.less +51 -0
- package/src/components/flex/index.js +103 -0
- package/src/components/flex/style.less +101 -0
- package/src/components/index.js +15 -0
- package/src/components/index.less +10 -0
- package/src/components/input_number/index.js +158 -0
- package/src/components/input_number/style.less +10 -0
- package/src/components/select/index.js +7 -0
- package/src/components/select/option.js +32 -0
- package/src/components/select/select.js +122 -0
- package/src/components/select/style.less +79 -0
- package/src/components/tip/index.js +48 -0
- package/src/components/tip/style.less +22 -0
- package/src/editor_label/edit_store.js +3 -0
- package/src/editor_label/editor.js +5 -0
- package/src/editor_label/editor_with_shadow_dom.js +4 -0
- package/src/editor_label/index.js +1 -0
- package/src/editor_presorting/edit_store.js +3 -0
- package/src/editor_presorting/editor_with_shadow_dom.js +6 -0
- package/src/editor_presorting/index.js +1 -0
- package/src/index.js +7 -0
- package/src/printer/barcode.js +38 -0
- package/src/printer/batch_printer.js +43 -0
- package/src/printer/block.js +544 -0
- package/src/printer/components/table_type.js +46 -0
- package/src/printer/index.js +111 -0
- package/src/printer/normalize.css +341 -0
- package/src/printer/page.js +26 -0
- package/src/printer/printer.js +71 -0
- package/src/printer/qrcode.js +17 -0
- package/src/printer/style.less +28 -0
- package/src/util.js +87 -0
- package/webpack.config.js +53 -0
- package/lib/main.js +0 -27
- package/lib/package.json +0 -96
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import { Printer } from '../../printer'
|
|
5
|
+
import { inject, observer } from 'mobx-react'
|
|
6
|
+
import EditModifyFiled from './edit_modify_filed'
|
|
7
|
+
import EditTitle from './edit_title'
|
|
8
|
+
import EditSelect from './edit_select'
|
|
9
|
+
import EditAddFiled from './edit_add_filed'
|
|
10
|
+
import { Gap, Title } from './component'
|
|
11
|
+
import { Flex } from '../../components'
|
|
12
|
+
import i18next from '../../../locales'
|
|
13
|
+
import ContextMenu from './context_menu'
|
|
14
|
+
|
|
15
|
+
@inject('editStore')
|
|
16
|
+
@observer
|
|
17
|
+
class Edit extends React.Component {
|
|
18
|
+
handleCancel = (e) => {
|
|
19
|
+
if (e.target === e.currentTarget) {
|
|
20
|
+
this.props.editStore.setSelected(null)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render () {
|
|
25
|
+
const {
|
|
26
|
+
data,
|
|
27
|
+
initDefaultTemp,
|
|
28
|
+
defaultTempList,
|
|
29
|
+
addFields,
|
|
30
|
+
onSave,
|
|
31
|
+
editStore,
|
|
32
|
+
insertBlocksConfig,
|
|
33
|
+
uploadQiniuImage,
|
|
34
|
+
showDoublePage,
|
|
35
|
+
doublePageType
|
|
36
|
+
} = this.props
|
|
37
|
+
return (
|
|
38
|
+
<div className='gm-printer-label-edit'>
|
|
39
|
+
<Flex className='gm-printer-label-edit-title-fixed'>
|
|
40
|
+
<Title
|
|
41
|
+
title={i18next.t('模板预览')}
|
|
42
|
+
text={
|
|
43
|
+
<span className='gm-text-desc gm-padding-left-5'>
|
|
44
|
+
{i18next.t(
|
|
45
|
+
'说明:单击选中内容,双击编辑,可拖动以摆放位置,可方向键细调位置,可点击右键删除'
|
|
46
|
+
)}
|
|
47
|
+
</span>
|
|
48
|
+
}
|
|
49
|
+
/>
|
|
50
|
+
</Flex>
|
|
51
|
+
|
|
52
|
+
<div className='gm-printer-label-edit-header'>
|
|
53
|
+
<EditTitle onSave={onSave} initDefaultTemp={initDefaultTemp}/>
|
|
54
|
+
<Gap height='10px'/>
|
|
55
|
+
<EditSelect
|
|
56
|
+
insertBlocksConfig={insertBlocksConfig}
|
|
57
|
+
initDefaultTemp={initDefaultTemp}
|
|
58
|
+
defaultTempList={defaultTempList}
|
|
59
|
+
uploadQiniuImage={uploadQiniuImage}
|
|
60
|
+
showDoublePage={showDoublePage}
|
|
61
|
+
/>
|
|
62
|
+
<Gap height='5px'/>
|
|
63
|
+
<EditModifyFiled/>
|
|
64
|
+
<Gap height='5px'/>
|
|
65
|
+
<EditAddFiled data={addFields}/>
|
|
66
|
+
|
|
67
|
+
{/* 挂载shadow down中的Dialog组件 */}
|
|
68
|
+
<div id='gm-printer-label-modal'/>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div
|
|
72
|
+
className='gm-printer-label-edit-content'
|
|
73
|
+
onClick={this.handleCancel}
|
|
74
|
+
>
|
|
75
|
+
<ContextMenu>
|
|
76
|
+
<Printer
|
|
77
|
+
selected={editStore.selected}
|
|
78
|
+
config={editStore.config}
|
|
79
|
+
data={data}
|
|
80
|
+
onChange={this.handleChange}
|
|
81
|
+
doublePageType={doublePageType}
|
|
82
|
+
/>
|
|
83
|
+
</ContextMenu>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
Edit.propTypes = {
|
|
91
|
+
editStore: PropTypes.object,
|
|
92
|
+
data: PropTypes.object.isRequired,
|
|
93
|
+
config: PropTypes.object.isRequired,
|
|
94
|
+
onSave: PropTypes.func,
|
|
95
|
+
initDefaultTemp: PropTypes.string,
|
|
96
|
+
defaultTempList: PropTypes.object,
|
|
97
|
+
addFields: PropTypes.object.isRequired,
|
|
98
|
+
insertBlocksConfig: PropTypes.array.isRequired,
|
|
99
|
+
showDoublePage: PropTypes.bool
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Edit.deaultProps = {
|
|
103
|
+
onSave: _.noop
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default Edit
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { Fragment } from 'react'
|
|
2
|
+
import { inject, observer } from 'mobx-react'
|
|
3
|
+
import i18next from '../../../locales'
|
|
4
|
+
import { FieldBtn, Gap, SubTitle, Title } from './component'
|
|
5
|
+
import { Flex } from '../../components'
|
|
6
|
+
import _ from 'lodash'
|
|
7
|
+
|
|
8
|
+
class FieldList extends React.Component {
|
|
9
|
+
render () {
|
|
10
|
+
const { fields, handleAddField } = this.props
|
|
11
|
+
return (
|
|
12
|
+
<div>
|
|
13
|
+
<Title title={i18next.t('添加字段')}/>
|
|
14
|
+
<Gap/>
|
|
15
|
+
{_.map(fields, (arr, groupName) => {
|
|
16
|
+
return (
|
|
17
|
+
<Fragment key={groupName}>
|
|
18
|
+
<SubTitle text={groupName}/>
|
|
19
|
+
<Flex wrap>
|
|
20
|
+
{_.map(arr, o => <FieldBtn key={o.key} name={o.key}
|
|
21
|
+
onClick={handleAddField.bind(this,
|
|
22
|
+
o)}/>)}
|
|
23
|
+
</Flex>
|
|
24
|
+
</Fragment>
|
|
25
|
+
)
|
|
26
|
+
})}
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@inject('editStore')
|
|
33
|
+
@observer
|
|
34
|
+
class EditAddFiled extends React.Component {
|
|
35
|
+
handleAddFiled = (o) => {
|
|
36
|
+
const { editStore } = this.props
|
|
37
|
+
|
|
38
|
+
editStore.addFieldToBlocks(o)
|
|
39
|
+
// 是自定义二维码就return
|
|
40
|
+
// 特殊情况处理:添加了自定义二维码后又添加其他的码,再次选中自定义二维码后,进行编辑字段时,自定义二维码的编辑字段会隐藏
|
|
41
|
+
if (editStore.config.blocks[editStore.selected]?.type === 'diyqrcode') return
|
|
42
|
+
editStore.setSelected(editStore.config.blocks.length - 1)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
render () {
|
|
46
|
+
const { data } = this.props
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<FieldList fields={data} handleAddField={this.handleAddFiled}/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default EditAddFiled
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { inject, observer } from 'mobx-react'
|
|
3
|
+
import {
|
|
4
|
+
Fonter,
|
|
5
|
+
Gap,
|
|
6
|
+
Line,
|
|
7
|
+
Position,
|
|
8
|
+
Separator,
|
|
9
|
+
Size,
|
|
10
|
+
TextAlign,
|
|
11
|
+
Textarea,
|
|
12
|
+
TipInfo,
|
|
13
|
+
Title,
|
|
14
|
+
} from './component'
|
|
15
|
+
import i18next from '../../../locales'
|
|
16
|
+
import _ from 'lodash'
|
|
17
|
+
import { DiyTimeType } from '../config'
|
|
18
|
+
|
|
19
|
+
@inject('editStore')
|
|
20
|
+
@observer
|
|
21
|
+
class EditModifyFiled extends React.Component {
|
|
22
|
+
handleChangeBlock = (who, value) => {
|
|
23
|
+
const { editStore } = this.props
|
|
24
|
+
if (editStore.selected === null) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
editStore.setConfigBlockBy(who, value)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handleRotateBarcode = () => {
|
|
31
|
+
const { editStore } = this.props
|
|
32
|
+
|
|
33
|
+
const { style } = editStore.config.blocks[editStore.selected]
|
|
34
|
+
const newStyle = _.has(style, 'transform')
|
|
35
|
+
? _.omit(style, 'transform')
|
|
36
|
+
: {
|
|
37
|
+
...style,
|
|
38
|
+
transform: 'rotate(90deg)',
|
|
39
|
+
}
|
|
40
|
+
this.handleChangeBlock('style', newStyle)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
renderBlocks() {
|
|
44
|
+
const { editStore } = this.props
|
|
45
|
+
|
|
46
|
+
const { type, text, style } = editStore.config.blocks[editStore.selected]
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<React.Fragment>
|
|
50
|
+
<Title title={i18next.t('编辑字段')} />
|
|
51
|
+
<Gap />
|
|
52
|
+
<Position
|
|
53
|
+
style={style}
|
|
54
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
55
|
+
/>
|
|
56
|
+
<Gap />
|
|
57
|
+
|
|
58
|
+
{(!type || type === 'text') && (
|
|
59
|
+
<div>
|
|
60
|
+
<Fonter
|
|
61
|
+
style={style}
|
|
62
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
63
|
+
/>
|
|
64
|
+
<Separator />
|
|
65
|
+
<TextAlign
|
|
66
|
+
style={style}
|
|
67
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
68
|
+
/>
|
|
69
|
+
<Gap />
|
|
70
|
+
|
|
71
|
+
<Textarea
|
|
72
|
+
value={text}
|
|
73
|
+
placeholder='请输入填充内容'
|
|
74
|
+
onChange={this.handleChangeBlock.bind(this, 'text')}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
)}
|
|
78
|
+
{type === 'line' && (
|
|
79
|
+
<Line
|
|
80
|
+
style={style}
|
|
81
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
{(type === 'qrcode' ||
|
|
85
|
+
type === 'order_qrcode' ||
|
|
86
|
+
type === 'package_id_qrcode' ||
|
|
87
|
+
type === 'image' ||
|
|
88
|
+
type === 'rack_barcode' ||
|
|
89
|
+
type === 'customer_barcode' ||
|
|
90
|
+
type === 'delivery_qrcode' ||
|
|
91
|
+
type === 'merchandise_trace_qrcode' ||
|
|
92
|
+
type === 'verification_qrcode' ||
|
|
93
|
+
type === 'package_order_qrcode') && (
|
|
94
|
+
<div>
|
|
95
|
+
<Size
|
|
96
|
+
style={style}
|
|
97
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
{type === 'production_barcode' && (
|
|
102
|
+
<Size
|
|
103
|
+
withoutWidth
|
|
104
|
+
style={style}
|
|
105
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
{type === 'new_production_barcode' && (
|
|
109
|
+
<Size
|
|
110
|
+
withoutWidth
|
|
111
|
+
style={style}
|
|
112
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
{type === 'diyqrcode' && (
|
|
116
|
+
<div>
|
|
117
|
+
<Size
|
|
118
|
+
style={style}
|
|
119
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
120
|
+
/>
|
|
121
|
+
<Textarea
|
|
122
|
+
value={text}
|
|
123
|
+
placeholder='请输入填充内容'
|
|
124
|
+
onChange={this.handleChangeBlock.bind(this, 'text')}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
{type === 'barcode' && (
|
|
129
|
+
<div>
|
|
130
|
+
<Size
|
|
131
|
+
style={style}
|
|
132
|
+
withoutWidth
|
|
133
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
134
|
+
/>
|
|
135
|
+
<div>
|
|
136
|
+
<button onClick={this.handleRotateBarcode}>
|
|
137
|
+
{i18next.t('旋转')}
|
|
138
|
+
</button>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
{type === 'in_stock_barcode' && (
|
|
143
|
+
<div>
|
|
144
|
+
<Size
|
|
145
|
+
style={style}
|
|
146
|
+
withoutWidth
|
|
147
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
148
|
+
/>
|
|
149
|
+
<div>
|
|
150
|
+
<button onClick={this.handleRotateBarcode}>
|
|
151
|
+
{i18next.t('旋转')}
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
{type === 'diycode' && (
|
|
157
|
+
<div>
|
|
158
|
+
<Size
|
|
159
|
+
style={style}
|
|
160
|
+
withoutWidth
|
|
161
|
+
onChange={this.handleChangeBlock.bind(this, 'style')}
|
|
162
|
+
/>
|
|
163
|
+
<div>
|
|
164
|
+
<button onClick={this.handleRotateBarcode}>
|
|
165
|
+
{i18next.t('旋转')}
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
)}
|
|
170
|
+
<TipInfo
|
|
171
|
+
text={i18next.t('说明:请勿修改{}中的内容,避免出现数据异常')}
|
|
172
|
+
/>
|
|
173
|
+
{editStore.computedIsTime && (
|
|
174
|
+
<div>
|
|
175
|
+
<TipInfo
|
|
176
|
+
text={i18next.t('注:可通过修改“{{}}”中的内容更改时间格式。')}
|
|
177
|
+
/>
|
|
178
|
+
{_.map(DiyTimeType, (v, k) => (
|
|
179
|
+
<TipInfo text={`${k + 1}。${v.text}`} />
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
</React.Fragment>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
render() {
|
|
188
|
+
let content = null
|
|
189
|
+
const { editStore } = this.props
|
|
190
|
+
|
|
191
|
+
if (editStore.selected !== null) {
|
|
192
|
+
content = this.renderBlocks()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return <div>{content}</div>
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export default EditModifyFiled
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { inject, observer } from 'mobx-react'
|
|
4
|
+
import { pageTypeMap } from '../config'
|
|
5
|
+
import { Flex, InputNumber, Option, Select } from '../../components'
|
|
6
|
+
import { Gap, ImageUploader } from './component'
|
|
7
|
+
import _ from 'lodash'
|
|
8
|
+
|
|
9
|
+
import i18next from '../../../locales'
|
|
10
|
+
|
|
11
|
+
@inject('editStore')
|
|
12
|
+
@observer
|
|
13
|
+
class EditSelect extends React.Component {
|
|
14
|
+
constructor (props) {
|
|
15
|
+
super(props)
|
|
16
|
+
if (props.initDefaultTemp) {
|
|
17
|
+
this.handleInsertTemp(props.initDefaultTemp)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
handleInsert = (type, e) => {
|
|
22
|
+
e.target.blur()
|
|
23
|
+
const { editStore } = this.props
|
|
24
|
+
|
|
25
|
+
editStore.addConfigBlock(type)
|
|
26
|
+
editStore.setSelected(editStore.config.blocks.length - 1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
handleInsertTemp = (value) => {
|
|
30
|
+
const { editStore } = this.props
|
|
31
|
+
|
|
32
|
+
const config = _.find(
|
|
33
|
+
this.props.defaultTempList,
|
|
34
|
+
(config, group) => group === value
|
|
35
|
+
)
|
|
36
|
+
editStore.setConfig(config, value)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handlePageName = (e) => {
|
|
40
|
+
const { editStore } = this.props
|
|
41
|
+
|
|
42
|
+
editStore.setPageName(e.target.value)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
handlePageType = (e) => {
|
|
46
|
+
const { editStore } = this.props
|
|
47
|
+
|
|
48
|
+
editStore.setSizePageType(e)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handleInsertBlock = (type, link) => {
|
|
52
|
+
const { editStore } = this.props
|
|
53
|
+
|
|
54
|
+
editStore.addConfigBlock(type, link)
|
|
55
|
+
editStore.setSelected(editStore.config.blocks.length - 1)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
handleChangeCustomizeSize = (name, value) => {
|
|
59
|
+
const { editStore } = this.props
|
|
60
|
+
editStore.setCustomizePageSize(name, value)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render () {
|
|
64
|
+
const {
|
|
65
|
+
defaultTempList,
|
|
66
|
+
editStore,
|
|
67
|
+
insertBlocksConfig,
|
|
68
|
+
uploadQiniuImage,
|
|
69
|
+
showDoublePage
|
|
70
|
+
} = this.props
|
|
71
|
+
const {
|
|
72
|
+
tempKey,
|
|
73
|
+
config: { name, page }
|
|
74
|
+
} = editStore
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
<div>
|
|
79
|
+
{defaultTempList && _.size(defaultTempList) ? (
|
|
80
|
+
<div>
|
|
81
|
+
{i18next.t('载入模板:')}
|
|
82
|
+
<Select
|
|
83
|
+
style={{ width: '190px' }}
|
|
84
|
+
value={tempKey}
|
|
85
|
+
onChange={this.handleInsertTemp}
|
|
86
|
+
>
|
|
87
|
+
<Option value=''>{i18next.t('请选择')}</Option>
|
|
88
|
+
{_.map(defaultTempList, (config, group) => (
|
|
89
|
+
<Option key={group} value={group}>
|
|
90
|
+
{group}
|
|
91
|
+
</Option>
|
|
92
|
+
))}
|
|
93
|
+
</Select>
|
|
94
|
+
</div>
|
|
95
|
+
) : null}
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
99
|
+
<div>{i18next.t('模板名称')}:</div>
|
|
100
|
+
<input
|
|
101
|
+
className='gm-printer-label-edit-input-custom'
|
|
102
|
+
type='text'
|
|
103
|
+
value={name}
|
|
104
|
+
onChange={this.handlePageName}
|
|
105
|
+
/>
|
|
106
|
+
</Flex>
|
|
107
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
108
|
+
<div>{i18next.t('标签尺寸')}:</div>
|
|
109
|
+
<Select
|
|
110
|
+
style={{ width: '190px' }}
|
|
111
|
+
className='gm-printer-label-edit-select'
|
|
112
|
+
value={page.type}
|
|
113
|
+
onChange={this.handlePageType}
|
|
114
|
+
>
|
|
115
|
+
{_.map(pageTypeMap, (v, k) => (
|
|
116
|
+
<Option key={k} value={k}>
|
|
117
|
+
{k}
|
|
118
|
+
</Option>
|
|
119
|
+
))}
|
|
120
|
+
{/* 格式不同,单独处理 */}
|
|
121
|
+
<Option key='-1' value='-1'>
|
|
122
|
+
{i18next.t('自定义尺寸')}
|
|
123
|
+
</Option>
|
|
124
|
+
</Select>
|
|
125
|
+
</Flex>
|
|
126
|
+
{page.type === '-1' && (
|
|
127
|
+
<Flex column>
|
|
128
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
129
|
+
<div>{i18next.t('宽度')}:</div>
|
|
130
|
+
<InputNumber
|
|
131
|
+
className='gm-printer-label-edit-input-custom'
|
|
132
|
+
value={page.customizeWidth}
|
|
133
|
+
onChange={this.handleChangeCustomizeSize.bind(
|
|
134
|
+
this,
|
|
135
|
+
'customizeWidth'
|
|
136
|
+
)}
|
|
137
|
+
/>
|
|
138
|
+
</Flex>
|
|
139
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
140
|
+
<div>{i18next.t('高度')}:</div>
|
|
141
|
+
<InputNumber
|
|
142
|
+
className='gm-printer-label-edit-input-custom'
|
|
143
|
+
value={page.customizeHeight}
|
|
144
|
+
onChange={this.handleChangeCustomizeSize.bind(
|
|
145
|
+
this,
|
|
146
|
+
'customizeHeight'
|
|
147
|
+
)}
|
|
148
|
+
/>
|
|
149
|
+
</Flex>
|
|
150
|
+
</Flex>
|
|
151
|
+
)}
|
|
152
|
+
{showDoublePage && (
|
|
153
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
154
|
+
<div>{i18next.t('预览区域放大展示')}:</div>
|
|
155
|
+
<input
|
|
156
|
+
type='checkbox'
|
|
157
|
+
checked={page.doublePage === true}
|
|
158
|
+
onChange={(v) =>
|
|
159
|
+
this.handleChangeCustomizeSize.bind(
|
|
160
|
+
this,
|
|
161
|
+
'doublePage'
|
|
162
|
+
)(v.target.checked)
|
|
163
|
+
}
|
|
164
|
+
/>
|
|
165
|
+
</Flex>
|
|
166
|
+
)}
|
|
167
|
+
<Gap height='10px'/>
|
|
168
|
+
|
|
169
|
+
<Flex alignCenter style={{ flexWrap: 'wrap' }}>
|
|
170
|
+
<div style={{ margin: '0 14px 14px 0' }}>{i18next.t('插入')}</div>
|
|
171
|
+
{_.map(insertBlocksConfig, (v) => {
|
|
172
|
+
return v.value === 'image' ? (
|
|
173
|
+
<button
|
|
174
|
+
style={{ margin: '0 14px 14px 0' }}
|
|
175
|
+
className='btn btn-default btn-sm'
|
|
176
|
+
key={v.value}
|
|
177
|
+
>
|
|
178
|
+
<ImageUploader
|
|
179
|
+
onSuccess={(imgURL) =>
|
|
180
|
+
this.handleInsertBlock('image', imgURL)
|
|
181
|
+
}
|
|
182
|
+
key={v.value}
|
|
183
|
+
text={v.text}
|
|
184
|
+
uploadQiniuImage={uploadQiniuImage}
|
|
185
|
+
/>
|
|
186
|
+
</button>
|
|
187
|
+
) : (
|
|
188
|
+
<button
|
|
189
|
+
className='btn btn-default btn-sm'
|
|
190
|
+
key={v.value}
|
|
191
|
+
style={{ margin: '0 14px 14px 0' }}
|
|
192
|
+
onClick={this.handleInsert.bind(this, v.value)}
|
|
193
|
+
>
|
|
194
|
+
{v.text}
|
|
195
|
+
</button>
|
|
196
|
+
)
|
|
197
|
+
})}
|
|
198
|
+
</Flex>
|
|
199
|
+
</div>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
EditSelect.propTypes = {
|
|
205
|
+
editStore: PropTypes.object,
|
|
206
|
+
initDefaultTemp: PropTypes.string,
|
|
207
|
+
defaultTempList: PropTypes.object,
|
|
208
|
+
insertBlocksConfig: PropTypes.array.isRequired,
|
|
209
|
+
showDoublePage: PropTypes.bool
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default EditSelect
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { inject, observer } from 'mobx-react'
|
|
4
|
+
import {
|
|
5
|
+
Dialog,
|
|
6
|
+
DropDown,
|
|
7
|
+
DropDownItem,
|
|
8
|
+
DropDownItems,
|
|
9
|
+
Flex
|
|
10
|
+
} from '../../components'
|
|
11
|
+
import { Title } from './component'
|
|
12
|
+
import i18next from '../../../locales'
|
|
13
|
+
import { toJS } from 'mobx'
|
|
14
|
+
|
|
15
|
+
const DialogChildren = observer((props) => {
|
|
16
|
+
const { config: { name } } = props.editStore
|
|
17
|
+
|
|
18
|
+
const handleConfigName = (e) => {
|
|
19
|
+
props.editStore.setConfigName(e.target.value)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Flex alignCenter>
|
|
24
|
+
<div>{i18next.t('模板名称')}:</div>
|
|
25
|
+
<input className='gm-printer-label-edit-input-custom' type='text'
|
|
26
|
+
value={name} onChange={handleConfigName}/>
|
|
27
|
+
</Flex>
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
@inject('editStore')
|
|
32
|
+
@observer
|
|
33
|
+
class EditTitle extends React.Component {
|
|
34
|
+
handlePrint = () => {
|
|
35
|
+
window.print()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
handleReset = () => {
|
|
39
|
+
const { initDefaultTemp } = this.props
|
|
40
|
+
const { editStore } = this.props
|
|
41
|
+
|
|
42
|
+
// 进行深拷贝
|
|
43
|
+
const newConfig = JSON.parse(JSON.stringify(editStore.originConfig))
|
|
44
|
+
|
|
45
|
+
// 重置模板配置,但是保留原来模板名字
|
|
46
|
+
const config = {
|
|
47
|
+
...newConfig,
|
|
48
|
+
name: editStore.config.name
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
editStore.init(config, initDefaultTemp)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
handleSaveAs = () => {
|
|
55
|
+
const { editStore } = this.props
|
|
56
|
+
|
|
57
|
+
Dialog.render({
|
|
58
|
+
title: i18next.t('另存为'),
|
|
59
|
+
children: <DialogChildren editStore={editStore}/>,
|
|
60
|
+
onOK: async () => {
|
|
61
|
+
// 传true参数 用来区分“另存为”是新建模板,不是编辑模板
|
|
62
|
+
this.props.onSave(toJS(editStore.config), true)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
handleSave = () => {
|
|
68
|
+
const { editStore, onSave } = this.props
|
|
69
|
+
|
|
70
|
+
onSave(toJS(editStore.config))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
render () {
|
|
74
|
+
return (
|
|
75
|
+
<div className='gm-printer-label-edit-header-top'>
|
|
76
|
+
<Flex justifyBetween>
|
|
77
|
+
<Title title={i18next.t('基本信息')}/>
|
|
78
|
+
<div>
|
|
79
|
+
<button className='btn btn-default btn-sm'
|
|
80
|
+
onClick={this.handlePrint}>{i18next.t('测试打印')}
|
|
81
|
+
</button>
|
|
82
|
+
<div className='gm-gap-10'/>
|
|
83
|
+
<button className='btn btn-default btn-sm'
|
|
84
|
+
onClick={this.handleReset}>{i18next.t('重置')}
|
|
85
|
+
</button>
|
|
86
|
+
<div className='gm-gap-10'/>
|
|
87
|
+
<DropDown
|
|
88
|
+
popup={(
|
|
89
|
+
<DropDownItems>
|
|
90
|
+
<DropDownItem onClick={this.handleSaveAs}>{i18next.t(
|
|
91
|
+
'另存为')}</DropDownItem>
|
|
92
|
+
</DropDownItems>
|
|
93
|
+
)}
|
|
94
|
+
>
|
|
95
|
+
<button className='btn btn-primary btn-sm'
|
|
96
|
+
onClick={this.handleSave}>{i18next.t('保存')}</button>
|
|
97
|
+
</DropDown>
|
|
98
|
+
</div>
|
|
99
|
+
</Flex>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
EditTitle.propTypes = {
|
|
106
|
+
editStore: PropTypes.object,
|
|
107
|
+
onSave: PropTypes.func.isRequired
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default EditTitle
|