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.
Files changed (73) hide show
  1. package/.eslintrc.js +12 -0
  2. package/.github/workflows/release.yml +46 -0
  3. package/.prettierrc.js +5 -0
  4. package/.stylelintrc +3 -0
  5. package/babel.config.js +7 -0
  6. package/i18n.config.js +9 -0
  7. package/locales/en.json +42 -0
  8. package/locales/index.js +32 -0
  9. package/locales/th.json +42 -0
  10. package/locales/zh-HK.json +43 -0
  11. package/locales/zh.json +1 -0
  12. package/package.json +15 -11
  13. package/postcss.config.js +9 -0
  14. package/src/common/config.js +82 -0
  15. package/src/common/editor_compoents/component.js +481 -0
  16. package/src/common/editor_compoents/config_text.js +47 -0
  17. package/src/common/editor_compoents/context_menu.js +129 -0
  18. package/src/common/editor_compoents/edit.js +106 -0
  19. package/src/common/editor_compoents/edit_add_filed.js +54 -0
  20. package/src/common/editor_compoents/edit_modify_filed.js +199 -0
  21. package/src/common/editor_compoents/edit_select.js +212 -0
  22. package/src/common/editor_compoents/edit_title.js +110 -0
  23. package/src/common/editor_compoents/index.js +10 -0
  24. package/src/common/editor_compoents/store.js +381 -0
  25. package/src/common/editor_compoents/style.less +425 -0
  26. package/src/common/editor_compoents/with_shadow_dom_hoc.js +30 -0
  27. package/src/common/editor_compoents/with_store_hoc.js +92 -0
  28. package/src/components/css/animation.less +95 -0
  29. package/src/components/css/button.less +49 -0
  30. package/src/components/css/distance.less +324 -0
  31. package/src/components/css/text.less +74 -0
  32. package/src/components/css/variables.less +12 -0
  33. package/src/components/dialog/index.js +72 -0
  34. package/src/components/dialog/style.less +64 -0
  35. package/src/components/dropdown/drop_down.js +67 -0
  36. package/src/components/dropdown/drop_down_item.js +37 -0
  37. package/src/components/dropdown/drop_down_items.js +22 -0
  38. package/src/components/dropdown/index.js +9 -0
  39. package/src/components/dropdown/style.less +51 -0
  40. package/src/components/flex/index.js +103 -0
  41. package/src/components/flex/style.less +101 -0
  42. package/src/components/index.js +15 -0
  43. package/src/components/index.less +10 -0
  44. package/src/components/input_number/index.js +158 -0
  45. package/src/components/input_number/style.less +10 -0
  46. package/src/components/select/index.js +7 -0
  47. package/src/components/select/option.js +32 -0
  48. package/src/components/select/select.js +122 -0
  49. package/src/components/select/style.less +79 -0
  50. package/src/components/tip/index.js +48 -0
  51. package/src/components/tip/style.less +22 -0
  52. package/src/editor_label/edit_store.js +3 -0
  53. package/src/editor_label/editor.js +5 -0
  54. package/src/editor_label/editor_with_shadow_dom.js +4 -0
  55. package/src/editor_label/index.js +1 -0
  56. package/src/editor_presorting/edit_store.js +3 -0
  57. package/src/editor_presorting/editor_with_shadow_dom.js +6 -0
  58. package/src/editor_presorting/index.js +1 -0
  59. package/src/index.js +7 -0
  60. package/src/printer/barcode.js +38 -0
  61. package/src/printer/batch_printer.js +43 -0
  62. package/src/printer/block.js +544 -0
  63. package/src/printer/components/table_type.js +46 -0
  64. package/src/printer/index.js +111 -0
  65. package/src/printer/normalize.css +341 -0
  66. package/src/printer/page.js +26 -0
  67. package/src/printer/printer.js +71 -0
  68. package/src/printer/qrcode.js +17 -0
  69. package/src/printer/style.less +28 -0
  70. package/src/util.js +87 -0
  71. package/webpack.config.js +53 -0
  72. package/lib/main.js +0 -27
  73. package/lib/package.json +0 -96
@@ -0,0 +1,381 @@
1
+ import { action, computed, observable } from 'mobx'
2
+ import _ from 'lodash'
3
+ import i18next from '../../../locales'
4
+
5
+ class EditStore {
6
+ @observable
7
+ config = null
8
+
9
+ @observable
10
+ selected = null
11
+
12
+ @observable
13
+ // 载入模板下拉框选中的值
14
+ tempKey = null
15
+
16
+ @observable
17
+ // 初始模板
18
+ originConfig = null
19
+
20
+ @action.bound
21
+ init(config, initDefaultTemp) {
22
+ this.config = this.getHandledConfig(config)
23
+ this.originConfig = this.getHandledConfig(config)
24
+ this.selected = null
25
+ this.tempKey = initDefaultTemp || ''
26
+ }
27
+
28
+ @action.bound
29
+ setConfig(config, value) {
30
+ this.selected = null
31
+ this.config = { ...this.config, ...config }
32
+ this.tempKey = value
33
+ }
34
+
35
+ @action.bound
36
+ setConfigName(name) {
37
+ this.config.name = name
38
+ }
39
+
40
+ @action.bound
41
+ setSizePageType(type) {
42
+ this.config.page.type = type
43
+ }
44
+
45
+ @action.bound
46
+ setCustomizePageSize(name, value) {
47
+ this.config.page[name] = value
48
+ }
49
+
50
+ @action.bound
51
+ setPageName(name) {
52
+ this.config.name = name
53
+ }
54
+
55
+ @action.bound
56
+ setSelected(selected = null) {
57
+ this.selected = selected
58
+ }
59
+
60
+ @action.bound
61
+ setConfigBlockBy(who, value) {
62
+ if (this.selected !== null) {
63
+ this.config.blocks[this.selected][who] = value
64
+ }
65
+ }
66
+
67
+ @action.bound
68
+ addConfigBlock(type, url) {
69
+ switch (type) {
70
+ case '':
71
+ case 'text':
72
+ this.config.blocks.push({
73
+ text: i18next.t('请编辑'),
74
+ style: {
75
+ position: 'absolute',
76
+ fontSize: '14px',
77
+ left: '0px',
78
+ top: '0px',
79
+ },
80
+ })
81
+ break
82
+ case 'line':
83
+ this.config.blocks.push({
84
+ type,
85
+ style: {
86
+ position: 'absolute',
87
+ left: '0px',
88
+ top: '0px',
89
+ borderTopColor: 'black',
90
+ borderTopWidth: '1px',
91
+ borderTopStyle: 'solid',
92
+ width: '100%',
93
+ },
94
+ })
95
+ break
96
+ case 'qrcode':
97
+ this.config.blocks.push({
98
+ type,
99
+ qrcode: i18next.t('{{溯源码}}'),
100
+ style: {
101
+ position: 'absolute',
102
+ left: '0px',
103
+ top: '0px',
104
+ width: '50px',
105
+ height: '50px',
106
+ },
107
+ })
108
+ break
109
+ case 'merchandise_trace_qrcode':
110
+ this.config.blocks.push({
111
+ type,
112
+ merchandise_trace_qrcode: i18next.t('{{商品溯源二维码}}'),
113
+ style: {
114
+ position: 'absolute',
115
+ left: '0px',
116
+ top: '0px',
117
+ width: '50px',
118
+ height: '50px',
119
+ },
120
+ })
121
+ break
122
+ case 'verification_qrcode':
123
+ this.config.blocks.push({
124
+ type,
125
+ verification_qrcode: i18next.t('{{验收二维码}}'),
126
+ style: {
127
+ position: 'absolute',
128
+ left: '0px',
129
+ top: '0px',
130
+ width: '50px',
131
+ height: '50px',
132
+ },
133
+ })
134
+ break
135
+ case 'order_qrcode':
136
+ this.config.blocks.push({
137
+ type,
138
+ order_qrcode: i18next.t('{{订单溯源码}}'),
139
+ style: {
140
+ position: 'absolute',
141
+ left: '0px',
142
+ top: '0px',
143
+ width: '50px',
144
+ height: '50px',
145
+ },
146
+ })
147
+ break
148
+ case 'barcode':
149
+ this.config.blocks.push({
150
+ type,
151
+ barcode: i18next.t('{{商品码}}'),
152
+ style: {
153
+ position: 'absolute',
154
+ left: '0px',
155
+ top: '0px',
156
+ height: '30px',
157
+ width: '165px',
158
+ },
159
+ })
160
+ break
161
+ case 'in_stock_barcode':
162
+ this.config.blocks.push({
163
+ type,
164
+ in_stock_barcode: i18next.t('{{入库条码}}'),
165
+ style: {
166
+ position: 'absolute',
167
+ left: '0px',
168
+ top: '0px',
169
+ height: '30px',
170
+ width: '165px',
171
+ },
172
+ })
173
+ break
174
+ case 'package_id_qrcode':
175
+ this.config.blocks.push({
176
+ type,
177
+ package_id_qrcode: i18next.t('{{商品码}}'),
178
+ style: {
179
+ position: 'absolute',
180
+ left: '0px',
181
+ top: '0px',
182
+ width: '50px',
183
+ height: '50px',
184
+ },
185
+ })
186
+ break
187
+ case 'diycode':
188
+ this.config.blocks.push({
189
+ type,
190
+ diycode: i18next.t('{{自定义编码}}'),
191
+ style: {
192
+ position: 'absolute',
193
+ left: '0px',
194
+ top: '0px',
195
+ height: '30px',
196
+ width: '165px',
197
+ },
198
+ })
199
+ break
200
+ case 'diyqrcode':
201
+ this.config.blocks.push({
202
+ type,
203
+ text: i18next.t('#'),
204
+ diyqrcode: i18next.t('{{自定义二维码}}'),
205
+ style: {
206
+ position: 'absolute',
207
+ left: '0px',
208
+ top: '0px',
209
+ width: '80px',
210
+ height: '80px',
211
+ },
212
+ })
213
+ break
214
+ case 'image':
215
+ this.config.blocks.push({
216
+ type,
217
+ url,
218
+ style: {
219
+ position: 'absolute',
220
+ left: '0px',
221
+ top: '0px',
222
+ height: '100px',
223
+ width: '100px',
224
+ },
225
+ })
226
+ break
227
+ case 'production_barcode':
228
+ this.config.blocks.push({
229
+ type,
230
+ production_barcode: i18next.t('{{商品条码}}'),
231
+ style: {
232
+ position: 'absolute',
233
+ left: '0px',
234
+ top: '0px',
235
+ height: '30px',
236
+ width: '165px',
237
+ },
238
+ })
239
+ break
240
+ case 'new_production_barcode':
241
+ this.config.blocks.push({
242
+ type,
243
+ new_production_barcode: i18next.t('{{新商品条码}}'),
244
+ style: {
245
+ position: 'absolute',
246
+ left: '0px',
247
+ top: '0px',
248
+ height: '30px',
249
+ width: '165px',
250
+ },
251
+ })
252
+ break
253
+ case 'rack_barcode':
254
+ this.config.blocks.push({
255
+ type,
256
+ rack_barcode: i18next.t('{{货位条形码}}'),
257
+ style: {
258
+ position: 'absolute',
259
+ left: '0px',
260
+ top: '0px',
261
+ height: '30px',
262
+ width: '165px',
263
+ },
264
+ })
265
+ break
266
+ case 'customer_barcode':
267
+ this.config.blocks.push({
268
+ type,
269
+ customer_barcode: i18next.t('{{客户码}}'),
270
+ style: {
271
+ position: 'absolute',
272
+ left: '0px',
273
+ top: '0px',
274
+ height: '30px',
275
+ width: '165px',
276
+ },
277
+ })
278
+ break
279
+ case 'delivery_qrcode':
280
+ this.config.blocks.push({
281
+ type,
282
+ delivery_qrcode: i18next.t('{{配送单二维码}}'),
283
+ style: {
284
+ position: 'absolute',
285
+ left: '0px',
286
+ top: '0px',
287
+ height: '80px',
288
+ width: '80px',
289
+ },
290
+ })
291
+ break
292
+ case 'package_order_qrcode':
293
+ this.config.blocks.push({
294
+ type,
295
+ package_order_qrcode: i18next.t('{{验货二维码}}'),
296
+ style: {
297
+ position: 'absolute',
298
+ left: '0px',
299
+ top: '0px',
300
+ width: '60px',
301
+ height: '60px',
302
+ },
303
+ })
304
+ break
305
+ default:
306
+ window.alert(i18next.t('出错啦,未识别类型,此信息不应该出现'))
307
+ break
308
+ }
309
+ }
310
+
311
+ // 删除所选字段
312
+ @action.bound
313
+ removeConfig() {
314
+ if (this.selected !== null) {
315
+ this.config.blocks.splice(this.selected, 1)
316
+ this.selected = null
317
+ }
318
+ }
319
+
320
+ // 添加字段到打印单中 两种 :1-添加到打印的模板中 2-添加到自定义二维码中
321
+ @action.bound
322
+ addFieldToBlocks({ value, key, fieldType }) {
323
+ // 不一定每次打印都传页码过去,为了不出现“页码:”情况,页码前不加前缀
324
+ if (!this.config.blocks[this.selected]?.diyqrcode) {
325
+ key === i18next.t('页码')
326
+ ? this.config.blocks.push({
327
+ text: `${value}`,
328
+ fieldType,
329
+ fieldKey: key,
330
+ style: {
331
+ position: 'absolute',
332
+ left: '0px',
333
+ top: '0px',
334
+ },
335
+ })
336
+ : this.config.blocks.push({
337
+ text: `${key}:${value}`,
338
+ fieldType,
339
+ fieldKey: key,
340
+ style: {
341
+ position: 'absolute',
342
+ left: '0px',
343
+ top: '0px',
344
+ },
345
+ })
346
+ }
347
+ if (this.config.blocks[this.selected]?.diyqrcode) {
348
+ this.config.blocks[this.selected].text += value + ','
349
+ }
350
+ }
351
+
352
+ @computed
353
+ get computedIsTime() {
354
+ if (this.selected !== null) {
355
+ const block = this.config.blocks[this.selected]
356
+ if (
357
+ (!block.type || block.type === 'text') &&
358
+ (_.includes(block.text, '时间') || _.includes(block.text, '日期'))
359
+ ) {
360
+ return true
361
+ }
362
+ }
363
+ return false
364
+ }
365
+
366
+ @action.bound
367
+ getHandledConfig(config) {
368
+ const result = _.cloneDeep(config)
369
+ // 添加自定义尺寸字段
370
+ result.page = {
371
+ ...result.page,
372
+ customizeWidth: result.page.customizeWidth || 100, // 若没有则默认为100
373
+ customizeHeight: result.page.customizeHeight || 100,
374
+ doublePage: result.page.doublePage || false,
375
+ }
376
+
377
+ return result
378
+ }
379
+ }
380
+
381
+ export default EditStore