gm-printer-label 3.0.14 → 3.0.16-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 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":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",[]]
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","/Volumes/gm-project/gm-printer-label/src/common/editor_compoents/edit_select.js":"10"},{"size":180,"mtime":1658462117054,"results":"11","hashOfConfig":"12"},{"size":4629,"mtime":1658462013375},{"size":1699,"mtime":1658461960259},{"size":7294,"mtime":1661759246118,"results":"13","hashOfConfig":"12"},{"size":1937,"mtime":1661225223156,"results":"14","hashOfConfig":"12"},{"size":1793,"mtime":1661759246118,"results":"15","hashOfConfig":"12"},{"size":411,"mtime":1660567552793},{"size":10456,"mtime":1661225238153},{"size":2928,"mtime":1661759246116},{"size":6103,"mtime":1661761013061},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"17s6x9q",{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer-label",
3
- "version": "3.0.14",
3
+ "version": "3.0.16-beta.1",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -22,28 +22,41 @@ class Edit extends React.Component {
22
22
  }
23
23
 
24
24
  render () {
25
- const { data, initDefaultTemp, defaultTempList, addFields, onSave, editStore, insertBlocksConfig, uploadQiniuImage } = this.props
25
+ const {
26
+ data,
27
+ initDefaultTemp,
28
+ defaultTempList,
29
+ addFields,
30
+ onSave,
31
+ editStore,
32
+ insertBlocksConfig,
33
+ uploadQiniuImage,
34
+ showDoublePage
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 title={i18next.t('模板预览')}
31
- text={<span className='gm-text-desc gm-padding-left-5'>
32
- {i18next.t('说明:单击选中内容,双击编辑,可拖动以摆放位置,可方向键细调位置,可点击右键删除')}
33
- </span>}/>
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}
44
56
  initDefaultTemp={initDefaultTemp}
45
57
  defaultTempList={defaultTempList}
46
58
  uploadQiniuImage={uploadQiniuImage}
59
+ showDoublePage={showDoublePage}
47
60
  />
48
61
  <Gap height='5px'/>
49
62
  <EditModifyFiled/>
@@ -52,11 +65,12 @@ class Edit extends React.Component {
52
65
 
53
66
  {/* 挂载shadow down中的Dialog组件 */}
54
67
  <div id='gm-printer-label-modal'/>
55
-
56
68
  </div>
57
69
 
58
- <div className='gm-printer-label-edit-content'
59
- onClick={this.handleCancel}>
70
+ <div
71
+ className='gm-printer-label-edit-content'
72
+ onClick={this.handleCancel}
73
+ >
60
74
  <ContextMenu>
61
75
  <Printer
62
76
  selected={editStore.selected}
@@ -79,7 +93,8 @@ 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
+ showDoublePage: PropTypes.bool
83
98
  }
84
99
 
85
100
  Edit.deaultProps = {
@@ -57,12 +57,17 @@ class EditSelect extends React.Component {
57
57
 
58
58
  handleChangeCustomizeSize = (name, value) => {
59
59
  const { editStore } = this.props
60
-
61
60
  editStore.setCustomizePageSize(name, value)
62
61
  }
63
62
 
64
63
  render () {
65
- const { defaultTempList, editStore, insertBlocksConfig, uploadQiniuImage } = this.props
64
+ const {
65
+ defaultTempList,
66
+ editStore,
67
+ insertBlocksConfig,
68
+ uploadQiniuImage,
69
+ showDoublePage
70
+ } = this.props
66
71
  const {
67
72
  tempKey,
68
73
  config: { name, page }
@@ -113,7 +118,9 @@ class EditSelect extends React.Component {
113
118
  </Option>
114
119
  ))}
115
120
  {/* 格式不同,单独处理 */}
116
- <Option key='-1' value='-1'>{i18next.t('自定义尺寸')}</Option>
121
+ <Option key='-1' value='-1'>
122
+ {i18next.t('自定义尺寸')}
123
+ </Option>
117
124
  </Select>
118
125
  </Flex>
119
126
  {page.type === '-1' && (
@@ -122,27 +129,41 @@ class EditSelect extends React.Component {
122
129
  <div>{i18next.t('宽度')}:</div>
123
130
  <InputNumber
124
131
  className='gm-printer-label-edit-input-custom'
125
- value={
126
- page.customizeWidth
127
- }
128
- onChange={this.handleChangeCustomizeSize.bind(this,
129
- 'customizeWidth')}
132
+ value={page.customizeWidth}
133
+ onChange={this.handleChangeCustomizeSize.bind(
134
+ this,
135
+ 'customizeWidth'
136
+ )}
130
137
  />
131
138
  </Flex>
132
139
  <Flex alignCenter className='gm-padding-top-5'>
133
140
  <div>{i18next.t('高度')}:</div>
134
141
  <InputNumber
135
142
  className='gm-printer-label-edit-input-custom'
136
- value={
137
- page.customizeHeight
138
- }
139
- onChange={this.handleChangeCustomizeSize.bind(this,
140
- 'customizeHeight')}
143
+ value={page.customizeHeight}
144
+ onChange={this.handleChangeCustomizeSize.bind(
145
+ this,
146
+ 'customizeHeight'
147
+ )}
141
148
  />
142
149
  </Flex>
143
150
  </Flex>
144
151
  )}
145
-
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
+ )}
146
167
  <Gap height='10px'/>
147
168
 
148
169
  <Flex alignCenter style={{ flexWrap: 'wrap' }}>
@@ -184,7 +205,8 @@ EditSelect.propTypes = {
184
205
  editStore: PropTypes.object,
185
206
  initDefaultTemp: PropTypes.string,
186
207
  defaultTempList: PropTypes.object,
187
- insertBlocksConfig: PropTypes.array.isRequired
208
+ insertBlocksConfig: PropTypes.array.isRequired,
209
+ showDoublePage: PropTypes.bool
188
210
  }
189
211
 
190
212
  export default EditSelect
@@ -289,11 +289,11 @@ class EditStore {
289
289
  getHandledConfig (config) {
290
290
  const result = _.cloneDeep(config)
291
291
  // 添加自定义尺寸字段
292
-
293
292
  result.page = {
294
293
  ...result.page,
295
294
  customizeWidth: result.page.customizeWidth || 100, // 若没有则默认为100
296
- customizeHeight: result.page.customizeHeight || 100
295
+ customizeHeight: result.page.customizeHeight || 100,
296
+ doublePage: result.page.doublePage || false
297
297
  }
298
298
 
299
299
  return result
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { DiyTimeType } from './common/config'
1
+ export { DiyTimeType, pageTypeMap } from './common/config'
2
2
 
3
3
  export * from './printer'
4
4
  export { setLocale } from '../locales'
@@ -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
- content = template(text, data)
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}
@@ -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 {config: {type, customizeWidth, customizeHeight}, children} = this.props
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: type === '-1' ? customizeWidth + 'mm' : pageTypeMap[type].width,
15
- height: type === '-1' ? customizeHeight + 'mm' : pageTypeMap[type].height
16
+ width,
17
+ height,
16
18
  }}
17
19
  >
18
20
  {children}
@@ -17,19 +17,31 @@ class Printer extends React.Component {
17
17
 
18
18
  render () {
19
19
  const { config, selected, data, isStation } = this.props
20
- const { type, style, customizeWidth, customizeHeight } = config.page
20
+ const { type, style, customizeWidth, customizeHeight, doublePage } =
21
+ config.page
22
+ const ratio = doublePage ? 2 : 1
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'
21
35
  return (
22
36
  <div
23
37
  className='gm-printer-label'
24
38
  style={{
25
39
  ...style,
26
- width:
27
- type === '-1' ? customizeWidth + 'mm' : pageTypeMap[type].width,
28
- height:
29
- type === '-1' ? customizeHeight + 'mm' : pageTypeMap[type].height
40
+ width,
41
+ height
30
42
  }}
31
43
  >
32
- <Page config={config.page}>
44
+ <Page pageStyle={{ width, height }}>
33
45
  {_.map(config.blocks, (block, i) => (
34
46
  <Block
35
47
  key={i}