gm-printer-label 3.0.9-alpha.0 → 3.0.9-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 +5 -11
- package/src/common/config.js +26 -4
- package/src/printer/block.js +17 -79
- package/src/printer/index.js +3 -85
- package/src/printer/printer.js +5 -16
- package/src/util.js +4 -26
- package/.prettierrc.js +0 -5
- package/src/printer/barcode.js +0 -26
- package/src/printer/batch_printer.js +0 -43
- package/src/printer/qrcode.js +0 -17
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/
|
|
1
|
+
[{"/Volumes/GM/gm-printer-label/src/printer/printer.js":"1","/Volumes/GM/gm-printer-label/src/common/config.js":"2"},{"size":1215,"mtime":1644923048179,"results":"3","hashOfConfig":"4"},{"size":1109,"mtime":1644819243904},{"filePath":"5","messages":"6","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1c5xipd","/Volumes/GM/gm-printer-label/src/printer/printer.js",[]]
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-printer-label",
|
|
3
|
-
"version": "3.0.9-
|
|
3
|
+
"version": "3.0.9-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"precommit": "lint-staged",
|
|
8
|
-
"start": "webpack-dev-server"
|
|
9
|
-
"publish-latest": "npm publish --force-publish --registry https://registry.npmjs.org/",
|
|
10
|
-
"publish-beta": "npm publish --force-publish --dist-tag beta --preid beta --registry https://registry.npmjs.org/",
|
|
11
|
-
"publish-alpha": "npm publish --force-publish --dist-tag alpha --preid alpha --registry https://registry.npmjs.org/"
|
|
8
|
+
"start": "webpack-dev-server"
|
|
12
9
|
},
|
|
13
10
|
"lint-staged": {
|
|
14
11
|
"./src/**/*.js": [
|
|
@@ -32,8 +29,7 @@
|
|
|
32
29
|
"lodash": "^4.17.10",
|
|
33
30
|
"moment": "^2.22.2",
|
|
34
31
|
"react": "^16.8.5",
|
|
35
|
-
"react-dom": "^16.8.5"
|
|
36
|
-
"qrcode.react": "^0.9.2"
|
|
32
|
+
"react-dom": "^16.8.5"
|
|
37
33
|
},
|
|
38
34
|
"dependencies": {
|
|
39
35
|
"clipboard": "^2.0.1",
|
|
@@ -41,8 +37,7 @@
|
|
|
41
37
|
"gm-util": "^5.10.4",
|
|
42
38
|
"mobx": "^4.3.0",
|
|
43
39
|
"mobx-react": "^6.1.1",
|
|
44
|
-
"precss": "^4.0.0"
|
|
45
|
-
"qrcode.react": "^0.9.2"
|
|
40
|
+
"precss": "^4.0.0"
|
|
46
41
|
},
|
|
47
42
|
"devDependencies": {
|
|
48
43
|
"@babel/cli": "^7.6.0",
|
|
@@ -91,7 +86,6 @@
|
|
|
91
86
|
"url-loader": "^1.0.1",
|
|
92
87
|
"webpack": "^4.10.1",
|
|
93
88
|
"webpack-cli": "^3.3.0",
|
|
94
|
-
"webpack-dev-server": "^3.1.4"
|
|
95
|
-
"jsbarcode": "^3.11.0"
|
|
89
|
+
"webpack-dev-server": "^3.1.4"
|
|
96
90
|
}
|
|
97
91
|
}
|
package/src/common/config.js
CHANGED
|
@@ -32,6 +32,31 @@ const pageTypeMap = {
|
|
|
32
32
|
'40X30': {
|
|
33
33
|
width: '40mm',
|
|
34
34
|
height: '28mm'
|
|
35
|
+
},
|
|
36
|
+
// 箱签
|
|
37
|
+
A4: {
|
|
38
|
+
width: '210mm',
|
|
39
|
+
height: '297mm'
|
|
40
|
+
},
|
|
41
|
+
A5: {
|
|
42
|
+
width: '148mm',
|
|
43
|
+
height: '210mm'
|
|
44
|
+
},
|
|
45
|
+
'A4/2': {
|
|
46
|
+
width: '210mm',
|
|
47
|
+
height: '140mm'
|
|
48
|
+
},
|
|
49
|
+
'A4/3': {
|
|
50
|
+
width: '210mm',
|
|
51
|
+
height: '93mm'
|
|
52
|
+
},
|
|
53
|
+
'241x280': {
|
|
54
|
+
width: '241mm',
|
|
55
|
+
height: '280mm'
|
|
56
|
+
},
|
|
57
|
+
'241x140': {
|
|
58
|
+
width: '241mm',
|
|
59
|
+
height: '140mm'
|
|
35
60
|
}
|
|
36
61
|
}
|
|
37
62
|
|
|
@@ -41,7 +66,4 @@ const borderStyleList = [
|
|
|
41
66
|
{ value: 'dotted', text: i18next.t('圆点') }
|
|
42
67
|
]
|
|
43
68
|
|
|
44
|
-
export {
|
|
45
|
-
borderStyleList,
|
|
46
|
-
pageTypeMap
|
|
47
|
-
}
|
|
69
|
+
export { borderStyleList, pageTypeMap }
|
package/src/printer/block.js
CHANGED
|
@@ -2,10 +2,8 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { observer } from 'mobx-react'
|
|
5
|
-
import { getStyleWithDiff, dispatchMsg, template
|
|
5
|
+
import { getStyleWithDiff, dispatchMsg, template } from '../util'
|
|
6
6
|
import TableType from './components/table_type'
|
|
7
|
-
import BarCode from './barcode'
|
|
8
|
-
import QrCode from './qrcode'
|
|
9
7
|
|
|
10
8
|
@observer
|
|
11
9
|
class Block extends React.Component {
|
|
@@ -33,7 +31,7 @@ class Block extends React.Component {
|
|
|
33
31
|
}
|
|
34
32
|
})
|
|
35
33
|
)
|
|
36
|
-
}
|
|
34
|
+
};
|
|
37
35
|
|
|
38
36
|
handleDragEnd = ({ clientX, clientY }) => {
|
|
39
37
|
const { config } = this.props
|
|
@@ -45,7 +43,7 @@ class Block extends React.Component {
|
|
|
45
43
|
dispatchMsg('gm-printer-label-block-style-set', {
|
|
46
44
|
style
|
|
47
45
|
})
|
|
48
|
-
}
|
|
46
|
+
};
|
|
49
47
|
|
|
50
48
|
handleClick = () => {
|
|
51
49
|
const { index } = this.props
|
|
@@ -53,7 +51,7 @@ class Block extends React.Component {
|
|
|
53
51
|
dispatchMsg('gm-printer-label-select', {
|
|
54
52
|
selected: index
|
|
55
53
|
})
|
|
56
|
-
}
|
|
54
|
+
};
|
|
57
55
|
|
|
58
56
|
handleDoubleClick = () => {
|
|
59
57
|
const {
|
|
@@ -69,19 +67,19 @@ class Block extends React.Component {
|
|
|
69
67
|
}
|
|
70
68
|
)
|
|
71
69
|
}
|
|
72
|
-
}
|
|
70
|
+
};
|
|
73
71
|
|
|
74
72
|
handleEditBlur = () => {
|
|
75
73
|
this.setState({
|
|
76
74
|
isEdit: false
|
|
77
75
|
})
|
|
78
|
-
}
|
|
76
|
+
};
|
|
79
77
|
|
|
80
78
|
handleText = (e) => {
|
|
81
79
|
dispatchMsg('gm-printer-label-block-text-set', {
|
|
82
80
|
text: e.target.value
|
|
83
81
|
})
|
|
84
|
-
}
|
|
82
|
+
};
|
|
85
83
|
|
|
86
84
|
render () {
|
|
87
85
|
const {
|
|
@@ -104,7 +102,6 @@ class Block extends React.Component {
|
|
|
104
102
|
},
|
|
105
103
|
data,
|
|
106
104
|
className,
|
|
107
|
-
isStation,
|
|
108
105
|
...rest
|
|
109
106
|
} = this.props
|
|
110
107
|
const { isEdit } = this.state
|
|
@@ -125,11 +122,9 @@ class Block extends React.Component {
|
|
|
125
122
|
} else if (type === 'line') {
|
|
126
123
|
content = null
|
|
127
124
|
} else if (type === 'qrcode') {
|
|
128
|
-
content =
|
|
129
|
-
<QrCode value={template(qrcode, data)} size={parseInt(style.height)}/>
|
|
130
|
-
) : (
|
|
125
|
+
content = (
|
|
131
126
|
<div
|
|
132
|
-
data-qrcode={
|
|
127
|
+
data-qrcode={template(qrcode, data)}
|
|
133
128
|
data-width={style.width}
|
|
134
129
|
data-height={style.height}
|
|
135
130
|
data-name={index}
|
|
@@ -138,12 +133,7 @@ class Block extends React.Component {
|
|
|
138
133
|
/>
|
|
139
134
|
)
|
|
140
135
|
} else if (type === 'order_qrcode') {
|
|
141
|
-
content =
|
|
142
|
-
<QrCode
|
|
143
|
-
value={miniAppLink + template(order_qrcode, data)}
|
|
144
|
-
size={parseInt(style.height)}
|
|
145
|
-
/>
|
|
146
|
-
) : (
|
|
136
|
+
content = (
|
|
147
137
|
<div
|
|
148
138
|
data-orderQrcode={template(order_qrcode, data)}
|
|
149
139
|
data-width={style.width}
|
|
@@ -154,18 +144,7 @@ class Block extends React.Component {
|
|
|
154
144
|
/>
|
|
155
145
|
)
|
|
156
146
|
} else if (type === 'barcode') {
|
|
157
|
-
content =
|
|
158
|
-
<BarCode
|
|
159
|
-
value={template(barcode, data)}
|
|
160
|
-
textMargin={0}
|
|
161
|
-
margin={0}
|
|
162
|
-
height={parseInt(style.height) - 14}
|
|
163
|
-
width={2}
|
|
164
|
-
displayValue={false}
|
|
165
|
-
dataName={barcode}
|
|
166
|
-
background='transparent'
|
|
167
|
-
/>
|
|
168
|
-
) : (
|
|
147
|
+
content = (
|
|
169
148
|
<div
|
|
170
149
|
data-packagecode='验货条形码'
|
|
171
150
|
data-name={index}
|
|
@@ -182,18 +161,7 @@ class Block extends React.Component {
|
|
|
182
161
|
</div>
|
|
183
162
|
)
|
|
184
163
|
} else if (type === 'in_stock_barcode') {
|
|
185
|
-
content =
|
|
186
|
-
<BarCode
|
|
187
|
-
value={template(in_stock_barcode, data)}
|
|
188
|
-
textMargin={0}
|
|
189
|
-
margin={0}
|
|
190
|
-
height={parseInt(style.height) - 14}
|
|
191
|
-
width={2}
|
|
192
|
-
displayValue={false}
|
|
193
|
-
dataName={in_stock_barcode}
|
|
194
|
-
background='transparent'
|
|
195
|
-
/>
|
|
196
|
-
) : (
|
|
164
|
+
content = (
|
|
197
165
|
<div
|
|
198
166
|
data-instockcode='入库条码'
|
|
199
167
|
data-name={index}
|
|
@@ -210,18 +178,7 @@ class Block extends React.Component {
|
|
|
210
178
|
</div>
|
|
211
179
|
)
|
|
212
180
|
} else if (type === 'production_barcode') {
|
|
213
|
-
content =
|
|
214
|
-
<BarCode
|
|
215
|
-
value={template(production_barcode, data)}
|
|
216
|
-
textMargin={0}
|
|
217
|
-
margin={0}
|
|
218
|
-
height={parseInt(style.height) - 14}
|
|
219
|
-
width={2}
|
|
220
|
-
displayValue={false}
|
|
221
|
-
dataName={production_barcode}
|
|
222
|
-
background='transparent'
|
|
223
|
-
/>
|
|
224
|
-
) : (
|
|
181
|
+
content = (
|
|
225
182
|
<div
|
|
226
183
|
data-productionbarcode='商品条码'
|
|
227
184
|
data-name={index}
|
|
@@ -238,12 +195,7 @@ class Block extends React.Component {
|
|
|
238
195
|
</div>
|
|
239
196
|
)
|
|
240
197
|
} else if (type === 'package_id_qrcode') {
|
|
241
|
-
content =
|
|
242
|
-
<QrCode
|
|
243
|
-
value={template(package_id_qrcode, data)}
|
|
244
|
-
size={parseInt(style.height)}
|
|
245
|
-
/>
|
|
246
|
-
) : (
|
|
198
|
+
content = (
|
|
247
199
|
<div
|
|
248
200
|
data-packageqrcode={template(package_id_qrcode, data)}
|
|
249
201
|
data-width={style.width}
|
|
@@ -254,18 +206,7 @@ class Block extends React.Component {
|
|
|
254
206
|
/>
|
|
255
207
|
)
|
|
256
208
|
} else if (type === 'diycode') {
|
|
257
|
-
content =
|
|
258
|
-
<BarCode
|
|
259
|
-
value={template(diycode, data)}
|
|
260
|
-
textMargin={0}
|
|
261
|
-
margin={0}
|
|
262
|
-
height={35}
|
|
263
|
-
width={2}
|
|
264
|
-
displayValue={false}
|
|
265
|
-
dataName={'diycode'}
|
|
266
|
-
background='transparent'
|
|
267
|
-
/>
|
|
268
|
-
) : (
|
|
209
|
+
content = (
|
|
269
210
|
<div
|
|
270
211
|
data-diycode='自定义编码条形码'
|
|
271
212
|
data-name={index}
|
|
@@ -282,9 +223,7 @@ class Block extends React.Component {
|
|
|
282
223
|
</div>
|
|
283
224
|
)
|
|
284
225
|
} else if (type === 'diyqrcode') {
|
|
285
|
-
content =
|
|
286
|
-
<QrCode value={template(text, data)} size={parseInt(style.height)}/>
|
|
287
|
-
) : (
|
|
226
|
+
content = (
|
|
288
227
|
<div
|
|
289
228
|
data-diyqrcode={template(text, data)}
|
|
290
229
|
data-width={style.width}
|
|
@@ -345,8 +284,7 @@ Block.propTypes = {
|
|
|
345
284
|
index: PropTypes.number.isRequired,
|
|
346
285
|
config: PropTypes.object.isRequired,
|
|
347
286
|
data: PropTypes.object.isRequired,
|
|
348
|
-
selected: PropTypes.number
|
|
349
|
-
isStation: PropTypes.bool
|
|
287
|
+
selected: PropTypes.number
|
|
350
288
|
}
|
|
351
289
|
|
|
352
290
|
export default Block
|
package/src/printer/index.js
CHANGED
|
@@ -2,15 +2,11 @@ import React from 'react'
|
|
|
2
2
|
import ReactDOMServer from 'react-dom/server'
|
|
3
3
|
import Printer from './printer'
|
|
4
4
|
import _ from 'lodash'
|
|
5
|
-
import { isZoom } from 'gm-util'
|
|
6
|
-
import ReactDOM from 'react-dom'
|
|
7
|
-
import BatchPrinter from './batch_printer'
|
|
8
5
|
|
|
9
6
|
// eslint-disable-next-line
|
|
10
|
-
import normalizeCSS from
|
|
7
|
+
import normalizeCSS from "css-loader!./normalize.csss";
|
|
11
8
|
// eslint-disable-next-line
|
|
12
|
-
import printerCSS from
|
|
13
|
-
import { afterImgAndSvgLoaded } from '../util'
|
|
9
|
+
import printerCSS from "css-loader!postcss-loader!less-loader!./style.lesss";
|
|
14
10
|
|
|
15
11
|
function getHtml (props) {
|
|
16
12
|
return ReactDOMServer.renderToString(<Printer {...props}/>)
|
|
@@ -30,82 +26,4 @@ function getCSS () {
|
|
|
30
26
|
return normalizeCSS.toString() + printerCSS.toString()
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
let $printer = window.document.getElementById(printerId)
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {boolean} isTest 是否test
|
|
38
|
-
* @param {boolean} isTipZoom zoom的时候是否提示
|
|
39
|
-
*/
|
|
40
|
-
function init ({ isTest, isTipZoom = true } = {}) {
|
|
41
|
-
isTipZoom &&
|
|
42
|
-
isZoom() &&
|
|
43
|
-
window.alert(
|
|
44
|
-
'检测您的浏览器使用了缩放,为了避免影响打印布局,请重置缩放到100%后再进行打印'
|
|
45
|
-
)
|
|
46
|
-
if (!$printer) {
|
|
47
|
-
$printer = window.document.createElement('iframe')
|
|
48
|
-
$printer.id = printerId
|
|
49
|
-
$printer.style.position = 'fixed'
|
|
50
|
-
$printer.style.top = '0'
|
|
51
|
-
$printer.style.width = '100%' // 使移动端可滚动
|
|
52
|
-
if (isTest) {
|
|
53
|
-
// 模板编辑[测试打印],隐藏起来
|
|
54
|
-
// $printer.style.left = '-2000px'
|
|
55
|
-
} else {
|
|
56
|
-
$printer.style.left = '0px'
|
|
57
|
-
$printer.style.height = '100vh'
|
|
58
|
-
}
|
|
59
|
-
window.document.body.appendChild($printer)
|
|
60
|
-
|
|
61
|
-
const idocument = $printer.contentDocument
|
|
62
|
-
idocument.open()
|
|
63
|
-
idocument.write('<!DOCTYPE html><html><head></head><body></body></html>')
|
|
64
|
-
idocument.close()
|
|
65
|
-
|
|
66
|
-
const doc = $printer.contentWindow.document
|
|
67
|
-
|
|
68
|
-
const style = doc.createElement('style')
|
|
69
|
-
style.type = 'text/css'
|
|
70
|
-
style.appendChild(doc.createTextNode(getCSS()))
|
|
71
|
-
doc.head.appendChild(style)
|
|
72
|
-
|
|
73
|
-
const div = doc.createElement('div')
|
|
74
|
-
div.id = 'appContainer'
|
|
75
|
-
|
|
76
|
-
doc.body.appendChild(div)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function doBatchPrint (
|
|
81
|
-
list,
|
|
82
|
-
isTest,
|
|
83
|
-
extraCofnig = { isPrint: true, isTipZoom: true },
|
|
84
|
-
isStation = false
|
|
85
|
-
) {
|
|
86
|
-
init({ isTest, isTipZoom: extraCofnig.isTipZoom })
|
|
87
|
-
|
|
88
|
-
return toDoPrintBatch(list, extraCofnig.isPrint, isStation)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function toDoPrintBatch (list, isPrint = true, isStation = false) {
|
|
92
|
-
return new window.Promise((resolve) => {
|
|
93
|
-
const $app = $printer.contentWindow.document.getElementById('appContainer')
|
|
94
|
-
|
|
95
|
-
ReactDOM.unmountComponentAtNode($app)
|
|
96
|
-
ReactDOM.render(
|
|
97
|
-
<BatchPrinter
|
|
98
|
-
list={list}
|
|
99
|
-
isStation={isStation}
|
|
100
|
-
onReady={() => {
|
|
101
|
-
afterImgAndSvgLoaded(() => {
|
|
102
|
-
isPrint && $printer.contentWindow.print()
|
|
103
|
-
resolve()
|
|
104
|
-
}, $app)
|
|
105
|
-
}}
|
|
106
|
-
/>,
|
|
107
|
-
$app
|
|
108
|
-
)
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
export { getHtml, getBatchHtml, getCSS, Printer, doBatchPrint }
|
|
29
|
+
export { getHtml, getBatchHtml, getCSS, Printer }
|
package/src/printer/printer.js
CHANGED
|
@@ -8,25 +8,17 @@ import { pageTypeMap } from '../common/config'
|
|
|
8
8
|
|
|
9
9
|
@observer
|
|
10
10
|
class Printer extends React.Component {
|
|
11
|
-
componentDidMount () {
|
|
12
|
-
// Printer 不是立马就呈现出最终样式,有个过程。这个过程需要时间,什么 ready,不太清楚,估借 setState 来获取过程结束时刻
|
|
13
|
-
this.setState({}, () => {
|
|
14
|
-
this.props.onReady && this.props.onReady()
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
11
|
render () {
|
|
19
|
-
const { config, selected, data
|
|
12
|
+
const { config, selected, data } = this.props
|
|
20
13
|
const { type, style, customizeWidth, customizeHeight } = config.page
|
|
14
|
+
const isDiy = type === '-1' || type === 'DIY'
|
|
21
15
|
return (
|
|
22
16
|
<div
|
|
23
17
|
className='gm-printer-label'
|
|
24
18
|
style={{
|
|
25
19
|
...style,
|
|
26
|
-
width:
|
|
27
|
-
|
|
28
|
-
height:
|
|
29
|
-
type === '-1' ? customizeHeight + 'mm' : pageTypeMap[type].height
|
|
20
|
+
width: isDiy ? customizeWidth + 'mm' : pageTypeMap[type].width,
|
|
21
|
+
height: isDiy ? customizeHeight + 'mm' : pageTypeMap[type].height
|
|
30
22
|
}}
|
|
31
23
|
>
|
|
32
24
|
<Page config={config.page}>
|
|
@@ -37,7 +29,6 @@ class Printer extends React.Component {
|
|
|
37
29
|
selected={selected}
|
|
38
30
|
config={block}
|
|
39
31
|
data={data}
|
|
40
|
-
isStation={isStation}
|
|
41
32
|
/>
|
|
42
33
|
))}
|
|
43
34
|
</Page>
|
|
@@ -49,9 +40,7 @@ class Printer extends React.Component {
|
|
|
49
40
|
Printer.propTypes = {
|
|
50
41
|
selected: PropTypes.number,
|
|
51
42
|
config: PropTypes.object.isRequired,
|
|
52
|
-
data: PropTypes.object.isRequired
|
|
53
|
-
onReady: PropTypes.func,
|
|
54
|
-
isStation: PropTypes.bool
|
|
43
|
+
data: PropTypes.object.isRequired // 格式化后的数据
|
|
55
44
|
}
|
|
56
45
|
|
|
57
46
|
export default Printer
|
package/src/util.js
CHANGED
|
@@ -35,11 +35,9 @@ function insertCSS (cssString, target) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function dispatchMsg (event, data) {
|
|
38
|
-
window.document.dispatchEvent(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
)
|
|
38
|
+
window.document.dispatchEvent(new window.CustomEvent(event, {
|
|
39
|
+
detail: data
|
|
40
|
+
}))
|
|
43
41
|
}
|
|
44
42
|
function substring (target, start = 0, end) {
|
|
45
43
|
return target.substring(start, end)
|
|
@@ -58,30 +56,10 @@ function template (text, data) {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
let timer
|
|
62
|
-
|
|
63
|
-
function afterImgAndSvgLoaded (callback, $printer) {
|
|
64
|
-
const $imgList = $printer.querySelectorAll('img')
|
|
65
|
-
const $svgList = $printer.querySelectorAll('svg')
|
|
66
|
-
|
|
67
|
-
clearTimeout(timer)
|
|
68
|
-
|
|
69
|
-
const everyThingIsOk =
|
|
70
|
-
_.every($imgList, (img) => img.complete) &&
|
|
71
|
-
_.every($svgList, (svg) => svg.children.length)
|
|
72
|
-
if (everyThingIsOk) {
|
|
73
|
-
callback()
|
|
74
|
-
} else {
|
|
75
|
-
timer = setTimeout(afterImgAndSvgLoaded.bind(this, callback, $printer), 300)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const miniAppLink = 'https://miniapp.guanmai.cn/traceability/?id='
|
|
79
59
|
export {
|
|
80
60
|
pxAdd,
|
|
81
61
|
getStyleWithDiff,
|
|
82
62
|
insertCSS,
|
|
83
63
|
dispatchMsg,
|
|
84
|
-
template
|
|
85
|
-
afterImgAndSvgLoaded,
|
|
86
|
-
miniAppLink
|
|
64
|
+
template
|
|
87
65
|
}
|
package/.prettierrc.js
DELETED
package/src/printer/barcode.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import jsBarcode from 'jsbarcode'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
|
|
5
|
-
class BarCode extends React.Component {
|
|
6
|
-
barcode = React.createRef()
|
|
7
|
-
|
|
8
|
-
componentDidMount () {
|
|
9
|
-
const { value, ...rest } = this.props
|
|
10
|
-
jsBarcode(this.barcode.current, value, {
|
|
11
|
-
...rest
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
render () {
|
|
16
|
-
const { dataName } = this.props
|
|
17
|
-
return <svg data-name={dataName} ref={this.barcode}/>
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
BarCode.propTypes = {
|
|
22
|
-
value: PropTypes.string,
|
|
23
|
-
dataName: PropTypes.string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default BarCode
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import Printer from './printer'
|
|
3
|
-
import _ from 'lodash'
|
|
4
|
-
import PropTypes from 'prop-types'
|
|
5
|
-
|
|
6
|
-
class BatchPrinter extends React.Component {
|
|
7
|
-
constructor (props) {
|
|
8
|
-
super(props)
|
|
9
|
-
this.ready = 0
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
handleReady = () => {
|
|
13
|
-
this.ready++
|
|
14
|
-
if (this.ready === this.props.list.length) {
|
|
15
|
-
this.props.onReady()
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
render () {
|
|
20
|
-
const { list, isStation } = this.props
|
|
21
|
-
return _.map(list, ({ config, data }, i) => (
|
|
22
|
-
<Printer
|
|
23
|
-
key={i}
|
|
24
|
-
data={data}
|
|
25
|
-
config={config}
|
|
26
|
-
onReady={this.handleReady}
|
|
27
|
-
isStation={isStation}
|
|
28
|
-
/>
|
|
29
|
-
))
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
BatchPrinter.propTypes = {
|
|
34
|
-
list: PropTypes.array.isRequired,
|
|
35
|
-
onReady: PropTypes.func,
|
|
36
|
-
isStation: PropTypes.bool
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
BatchPrinter.defaultProps = {
|
|
40
|
-
onReady: _.noop
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default BatchPrinter
|
package/src/printer/qrcode.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import QRCode from 'qrcode.react'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
import _ from 'lodash'
|
|
5
|
-
|
|
6
|
-
const QrCode = props => {
|
|
7
|
-
const { value, size } = props
|
|
8
|
-
return (
|
|
9
|
-
<QRCode renderAs='svg' value={value} size={_.isFinite(size) ? size : 75}/>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
QrCode.propTypes = {
|
|
14
|
-
value: PropTypes.string.isRequired,
|
|
15
|
-
size: PropTypes.number.isRequired
|
|
16
|
-
}
|
|
17
|
-
export default QrCode
|