gm-printer 10.41.6-beta.2 → 10.41.7

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/locales/en.json CHANGED
@@ -16,9 +16,6 @@
16
16
  "粗细": "",
17
17
  "高": "",
18
18
  "图片大小不能超过500Kb": "",
19
- "图片大小不能超过2M": "Image size cannot exceed 2M",
20
- "仅支持jpg、jpeg、png格式的图片": "Only JPG, JPEG, and PNG images are supported",
21
- "支持插入2M以内的jpg、jpeg、png格式图片": "Support inserting JPG, JPEG, or PNG images within 2M",
22
19
  "配送单特殊控制": "",
23
20
  "添加字段": "",
24
21
  "编辑字段": "",
package/locales/th.json CHANGED
@@ -16,9 +16,6 @@
16
16
  "粗细": "",
17
17
  "高": "",
18
18
  "图片大小不能超过500Kb": "",
19
- "图片大小不能超过2M": "ขนาดรูปภาพต้องไม่เกิน 2M",
20
- "仅支持jpg、jpeg、png格式的图片": "รองรับเฉพาะรูปภาพรูปแบบ jpg, jpeg, png",
21
- "支持插入2M以内的jpg、jpeg、png格式图片": "รองรับการแทรกรูปภาพ jpg, jpeg, png ขนาดไม่เกิน 2M",
22
19
  "配送单特殊控制": "",
23
20
  "添加字段": "",
24
21
  "编辑字段": "",
@@ -16,9 +16,6 @@
16
16
  "粗细": "粗細",
17
17
  "高": "高",
18
18
  "图片大小不能超过500Kb": "圖片大小不能超過500Kb",
19
- "图片大小不能超过2M": "圖片大小不能超過2M",
20
- "仅支持jpg、jpeg、png格式的图片": "僅支持jpg、jpeg、png格式的圖片",
21
- "支持插入2M以内的jpg、jpeg、png格式图片": "支持插入2M以內的jpg、jpeg、png格式圖片",
22
19
  "添加字段": "添加字段",
23
20
  "编辑字段": "編輯字段",
24
21
  "配送单特殊控制": "配送单特殊控制",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.41.6-beta.2",
3
+ "version": "10.41.7",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -109,7 +109,7 @@ class CommonContextMenu extends React.Component {
109
109
  })
110
110
  }
111
111
 
112
- handleInsertBlock = (type, link, ratio) => {
112
+ handleInsertBlock = (type, link) => {
113
113
  const { editStore } = this.props
114
114
  const { name, block } = this.state
115
115
 
@@ -120,8 +120,7 @@ class CommonContextMenu extends React.Component {
120
120
  left: block.left + 'px',
121
121
  top: block.top + 'px'
122
122
  },
123
- link,
124
- ratio
123
+ link
125
124
  )
126
125
 
127
126
  this.setState({
@@ -161,8 +160,8 @@ class CommonContextMenu extends React.Component {
161
160
  })
162
161
  }
163
162
 
164
- handleInsertImage = (imgURL, ratio) => {
165
- this.handleInsertBlock('image', imgURL, ratio)
163
+ handleInsertImage = imgURL => {
164
+ this.handleInsertBlock('image', imgURL)
166
165
  }
167
166
 
168
167
  handleRemove = () => {
@@ -328,7 +327,6 @@ class CommonContextMenu extends React.Component {
328
327
  onSuccess={this.handleInsertImage}
329
328
  key={v.value}
330
329
  text={v.text}
331
- imageConfig={this.props.editStore.imageConfig}
332
330
  />
333
331
  ) : (
334
332
  <div
@@ -391,26 +391,12 @@ Line.propTypes = {
391
391
 
392
392
  class Size extends React.Component {
393
393
  handleChange = (type, value) => {
394
- const { onChange, style, ratio } = this.props
394
+ const { onChange, style } = this.props
395
395
 
396
- const next = {
396
+ onChange({
397
397
  ...style,
398
398
  [type]: value
399
- }
400
-
401
- // 电子签章:有原始比例时宽高联动,不允许拉变形
402
- if (ratio && value !== '' && !value.endsWith('%')) {
403
- const num = parseFloat(value)
404
- if (!_.isNaN(num) && num > 0) {
405
- if (type === 'width') {
406
- next.height = Math.round(num / ratio) + 'px'
407
- } else {
408
- next.width = Math.round(num * ratio) + 'px'
409
- }
410
- }
411
- }
412
-
413
- onChange(next)
399
+ })
414
400
  }
415
401
 
416
402
  render() {
@@ -434,8 +420,7 @@ class Size extends React.Component {
434
420
 
435
421
  Size.propTypes = {
436
422
  style: PropTypes.object.isRequired,
437
- onChange: PropTypes.func.isRequired,
438
- ratio: PropTypes.number
423
+ onChange: PropTypes.func.isRequired
439
424
  }
440
425
 
441
426
  class ImageUploader extends React.Component {
@@ -452,26 +437,7 @@ class ImageUploader extends React.Component {
452
437
  : event.target.files
453
438
  const file = droppedFiles[0]
454
439
 
455
- if (!file) return
456
-
457
- const { imageConfig } = this.props
458
-
459
- if (imageConfig) {
460
- // 增强模式(电子签章):校验类型与大小,提示文案由配置方给出
461
- const acceptTypes = imageConfig.acceptTypes || [
462
- 'image/jpeg',
463
- 'image/jpg',
464
- 'image/png'
465
- ]
466
- if (!_.includes(acceptTypes, file.type)) {
467
- Tip.warning(imageConfig.wrongTypeTip)
468
- return
469
- }
470
- if (file.size > imageConfig.maxSize) {
471
- Tip.warning(imageConfig.overSizeTip)
472
- return
473
- }
474
- } else if (file.size > 512 * 1024) {
440
+ if (file.size > 512 * 1024) {
475
441
  Tip.warning(i18next.t('图片大小不能超过500Kb'))
476
442
  return
477
443
  }
@@ -497,21 +463,7 @@ class ImageUploader extends React.Component {
497
463
  .post()
498
464
  .then(json => {
499
465
  const imgURL = `${url.imgUrl}/${json.data.img_path_id}`
500
-
501
- // 增强模式下加载原图尺寸,记录原始比例供锁比例使用
502
- if (imageConfig) {
503
- const img = document.createElement('img')
504
- img.onload = () => {
505
- this.props.onSuccess(imgURL, img.naturalWidth / img.naturalHeight)
506
- }
507
- img.onerror = () => {
508
- // 拿不到尺寸时降级:只插入不锁比例
509
- this.props.onSuccess(imgURL)
510
- }
511
- img.src = imgURL
512
- } else {
513
- this.props.onSuccess(imgURL)
514
- }
466
+ this.props.onSuccess(imgURL)
515
467
  })
516
468
  }
517
469
 
@@ -521,23 +473,16 @@ class ImageUploader extends React.Component {
521
473
  }
522
474
 
523
475
  render() {
524
- const { imageConfig } = this.props
525
-
526
476
  return (
527
477
  <>
528
478
  <div onClick={this.handleClick} onDrop={this.handleUpload}>
529
479
  {this.props.text}
530
- {imageConfig && imageConfig.acceptHint && (
531
- <div className='gm-printer-contextmenu-hint'>
532
- {imageConfig.acceptHint}
533
- </div>
534
- )}
535
480
  </div>
536
481
  <input
537
482
  style={{ display: 'none' }}
538
483
  type='file'
539
484
  ref={this.input}
540
- accept={(imageConfig && imageConfig.accept) || 'image/*'}
485
+ accept='image/*'
541
486
  onChange={this.handleUpload}
542
487
  />
543
488
  </>
@@ -547,8 +492,7 @@ class ImageUploader extends React.Component {
547
492
 
548
493
  ImageUploader.propTypes = {
549
494
  onSuccess: PropTypes.func.isRequired,
550
- text: PropTypes.string.isRequired,
551
- imageConfig: PropTypes.object
495
+ text: PropTypes.string.isRequired
552
496
  }
553
497
 
554
498
  class InputWithUnit extends React.Component {
@@ -100,7 +100,7 @@ class EditorField extends React.Component {
100
100
 
101
101
  renderBlocks() {
102
102
  const { editStore, showNewDate } = this.props
103
- const { type, text, style, link, ratio } = editStore.computedSelectedInfo
103
+ const { type, text, style, link } = editStore.computedSelectedInfo
104
104
 
105
105
  return (
106
106
  <div>
@@ -149,11 +149,6 @@ class EditorField extends React.Component {
149
149
  <Size
150
150
  style={style}
151
151
  onChange={this.handleChangeBlock.bind(this, 'style')}
152
- ratio={
153
- editStore.imageConfig && editStore.imageConfig.resizable
154
- ? ratio
155
- : undefined
156
- }
157
152
  />
158
153
  <Gap />
159
154
 
@@ -17,10 +17,6 @@ class EditorStore {
17
17
  @observable
18
18
  tableCustomStyle = 'default'
19
19
 
20
- // 插入图片增强配置(电子签章),null 时保持旧行为(500Kb/image/*)
21
- // { maxSize, maxSizeLabel, accept, acceptHint, resizable }
22
- imageConfig = null
23
-
24
20
  @observable
25
21
  emptyTableData = []
26
22
 
@@ -560,7 +556,7 @@ class EditorStore {
560
556
  }
561
557
 
562
558
  @action
563
- addConfigBlock(name, type, pos = {}, link = '', ratio) {
559
+ addConfigBlock(name, type, pos = {}, link = '') {
564
560
  let blocks
565
561
  const arr = name.split('.')
566
562
 
@@ -604,8 +600,6 @@ class EditorStore {
604
600
  blocks.push({
605
601
  type: 'image',
606
602
  link: link,
607
- // 电子签章:记录原图宽高比,锁比例用;旧数据无此字段则不锁
608
- ratio: ratio,
609
603
  style: {
610
604
  position: 'absolute',
611
605
  left: pos.left || '0px',
@@ -1,22 +1,13 @@
1
1
  import React from 'react'
2
- import PropTypes from 'prop-types'
3
2
  import { Provider } from 'mobx-react'
4
3
  import { getStyleWithDiff } from '../util'
5
4
 
6
5
  const withStore = store => WrapComponent =>
7
6
  class extends React.Component {
8
- static propTypes = {
9
- config: PropTypes.object,
10
- mockData: PropTypes.object,
11
- imageConfig: PropTypes.object
12
- }
13
-
14
7
  constructor(props) {
15
8
  super(props)
16
9
  this.store = store
17
10
  this.store.init(props.config, props.mockData)
18
- // 插入图片增强配置(电子签章):由业务侧 props 传入,不传为 null 保持旧行为
19
- this.store.imageConfig = props.imageConfig || null
20
11
  }
21
12
 
22
13
  componentDidMount() {
@@ -166,18 +166,6 @@
166
166
  color: white;
167
167
  background: rgb(82, 146, 247);
168
168
  }
169
-
170
- // 电子签章:插入图片菜单项下的格式提示小字
171
- .gm-printer-contextmenu-hint {
172
- font-size: 10px;
173
- color: #f5222d;
174
- line-height: 1.4;
175
- padding: 0;
176
- &:hover {
177
- color: #f5222d;
178
- background: transparent;
179
- }
180
- }
181
169
  }
182
170
  }
183
171
 
@@ -256,37 +244,6 @@
256
244
  outline: 1px solid rgb(82, 146, 247);
257
245
  z-index: 11;
258
246
  }
259
-
260
- // 电子签章:图片四角黑色加粗拖拽手柄
261
- .gm-printer-resize-handle {
262
- position: absolute;
263
- width: 10px;
264
- height: 10px;
265
- background: #000;
266
- border: 2px solid #fff;
267
- z-index: 12;
268
-
269
- &.gm-printer-resize-lt {
270
- left: -6px;
271
- top: -6px;
272
- cursor: nwse-resize;
273
- }
274
- &.gm-printer-resize-rt {
275
- right: -6px;
276
- top: -6px;
277
- cursor: nesw-resize;
278
- }
279
- &.gm-printer-resize-lb {
280
- left: -6px;
281
- bottom: -6px;
282
- cursor: nesw-resize;
283
- }
284
- &.gm-printer-resize-rb {
285
- right: -6px;
286
- bottom: -6px;
287
- cursor: nwse-resize;
288
- }
289
- }
290
247
  }
291
248
 
292
249
  .gm-printer-table {
@@ -1,19 +1,6 @@
1
1
  import EditorStore from '../common/editor_store'
2
2
  import i18next from '../../locales'
3
3
 
4
- // 配送单"电子签章"插入图片增强预设(1056076):2M/指定格式/锁比例/四角拖拽
5
- // 由业务侧显式传入 <Editor imageConfig={imageConfigDelivery} /> 才生效,不传保持旧行为
6
- export const imageConfigDelivery = {
7
- maxSize: 2 * 1024 * 1024,
8
- maxSizeLabel: '2M',
9
- accept: 'image/jpeg,image/jpg,image/png',
10
- acceptTypes: ['image/jpeg', 'image/jpg', 'image/png'],
11
- acceptHint: i18next.t('支持插入2M以内的jpg、jpeg、png格式图片'),
12
- overSizeTip: i18next.t('图片大小不能超过2M'),
13
- wrongTypeTip: i18next.t('仅支持jpg、jpeg、png格式的图片'),
14
- resizable: true
15
- }
16
-
17
4
  class Store extends EditorStore {
18
5
  // 复写父类方法
19
6
  setTableDataKeyEffect(target, dataKey) {
package/src/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // ‼️优先初始化语言设置(必须先初始化语言)
2
2
  import '../locales'
3
3
  import Editor, { Editor2 } from './editor'
4
- import { imageConfigDelivery } from './editor/store'
5
4
 
6
5
  import EditorPurchase from './editor_purchase'
7
6
  import EditorExaminingReport from './examining_report_editor'
@@ -31,7 +30,6 @@ export { setLocale } from '../locales'
31
30
  export {
32
31
  Editor,
33
32
  Editor2,
34
- imageConfigDelivery,
35
33
  EditorStockIn,
36
34
  EditorStockOut,
37
35
  EditorPurchase,
@@ -8,12 +8,7 @@ import BarCode from './barcode'
8
8
  import QrCode from './qrcode'
9
9
  import Tag from './tag'
10
10
 
11
- // editStore 用函数形式注入:打印态(do_print 的 iframe)没有 editStore Provider,
12
- // 字符串形式的 inject 会直接抛错,这里降级为 null 关闭编辑能力
13
- @inject(({ printerStore, editStore }) => ({
14
- printerStore,
15
- editStore: editStore || null
16
- }))
11
+ @inject('printerStore')
17
12
  @observer
18
13
  class Block extends React.Component {
19
14
  constructor(props) {
@@ -21,10 +16,8 @@ class Block extends React.Component {
21
16
  this.state = {
22
17
  clientX: null,
23
18
  clientY: null,
24
- isEdit: false,
25
- isResizing: false
19
+ isEdit: false
26
20
  }
27
- this.resizeState = null
28
21
  }
29
22
 
30
23
  componentDidMount() {
@@ -39,7 +32,6 @@ class Block extends React.Component {
39
32
  'gm-printer-block-edit',
40
33
  this.handleBlockEdit
41
34
  )
42
- this.teardownResize()
43
35
  }
44
36
 
45
37
  handleBlockEdit = e => {
@@ -120,118 +112,6 @@ class Block extends React.Component {
120
112
  })
121
113
  }
122
114
 
123
- // 电子签章:图片四角等比例拖拽缩放
124
- handleResizeStart = (direction, e) => {
125
- // 阻止触发块的选中/拖动
126
- e.stopPropagation()
127
- e.preventDefault()
128
-
129
- const {
130
- config: { style, ratio }
131
- } = this.props
132
-
133
- const initW = parseFloat(style.width) || 0
134
- const initH = parseFloat(style.height) || 0
135
- // 旧模板无 ratio 时按当前显示宽高锁定;宽或高缺失(存量块无 width)时退回 1,
136
- // 避免比例算出 0 导致高度 Infinity
137
- const fallbackRatio = initW > 0 && initH > 0 ? initW / initH : 1
138
- this.resizeState = {
139
- direction,
140
- startX: e.clientX,
141
- startY: e.clientY,
142
- initW,
143
- initH,
144
- initL: parseFloat(style.left) || 0,
145
- initT: parseFloat(style.top) || 0,
146
- // ratio = 原始宽/高
147
- ratio: ratio || fallbackRatio,
148
- baseStyle: style
149
- }
150
-
151
- this.setState({
152
- isResizing: true
153
- })
154
-
155
- window.addEventListener('mousemove', this.handleResizeMove)
156
- window.addEventListener('mouseup', this.handleResizeEnd)
157
- }
158
-
159
- handleResizeMove = e => {
160
- if (!this.resizeState) return
161
-
162
- // rAF 节流,避免高频 mousemove 打爆渲染
163
- if (this.resizePending) return
164
- this.resizePending = e
165
- window.requestAnimationFrame(() => {
166
- const evt = this.resizePending
167
- this.resizePending = null
168
- if (!evt || !this.resizeState) return
169
- this.doResize(evt)
170
- })
171
- }
172
-
173
- doResize = e => {
174
- const {
175
- direction,
176
- startX,
177
- initW,
178
- initH,
179
- initL,
180
- initT,
181
- ratio,
182
- baseStyle
183
- } = this.resizeState
184
- const dx = e.clientX - startX
185
-
186
- // 右侧角向右放大,左侧角向左放大
187
- let width =
188
- direction === 'rb' || direction === 'rt' ? initW + dx : initW - dx
189
- // 最小尺寸兜底,防止翻转
190
- width = Math.max(width, 10)
191
- const height = Math.round(width / ratio)
192
- width = Math.round(width)
193
-
194
- // 锚定对角:左向角拖拽时右/下边不动,上向角拖拽时下边不动
195
- let left = initL
196
- let top = initT
197
- if (direction === 'lb' || direction === 'lt') {
198
- left = initL + initW - width
199
- }
200
- if (direction === 'rt' || direction === 'lt') {
201
- top = initT + initH - height
202
- }
203
-
204
- dispatchMsg('gm-printer-block-style-set', {
205
- style: {
206
- ...baseStyle,
207
- width: width + 'px',
208
- height: height + 'px',
209
- left: left + 'px',
210
- top: top + 'px'
211
- }
212
- })
213
- }
214
-
215
- handleResizeEnd = () => {
216
- // 先 flush 掉节流里排队中的最后一帧,避免松手回退
217
- if (this.resizePending) {
218
- const evt = this.resizePending
219
- this.resizePending = null
220
- this.doResize(evt)
221
- }
222
- this.teardownResize()
223
- this.setState({
224
- isResizing: false
225
- })
226
- }
227
-
228
- teardownResize = () => {
229
- window.removeEventListener('mousemove', this.handleResizeMove)
230
- window.removeEventListener('mouseup', this.handleResizeEnd)
231
- this.resizeState = null
232
- this.resizePending = null
233
- }
234
-
235
115
  render() {
236
116
  let {
237
117
  name,
@@ -239,7 +119,6 @@ class Block extends React.Component {
239
119
  pageIndex,
240
120
  className,
241
121
  printerStore,
242
- editStore,
243
122
  ...rest
244
123
  } = this.props
245
124
  const { isEdit } = this.state
@@ -307,14 +186,6 @@ class Block extends React.Component {
307
186
  }
308
187
 
309
188
  const active = name === printerStore.selected
310
- const { isResizing } = this.state
311
- const showResizeHandles = !!(
312
- active &&
313
- type === 'image' &&
314
- editStore &&
315
- editStore.imageConfig &&
316
- editStore.imageConfig.resizable
317
- )
318
189
 
319
190
  return (
320
191
  <div
@@ -322,7 +193,7 @@ class Block extends React.Component {
322
193
  className={classNames('gm-printer-block', className, {
323
194
  active
324
195
  })}
325
- draggable={!isResizing}
196
+ draggable
326
197
  onDragStart={this.handleDragStart}
327
198
  onDragEnd={this.handleDragEnd}
328
199
  onClick={this.handleClick}
@@ -350,26 +221,6 @@ class Block extends React.Component {
350
221
  />
351
222
  )}
352
223
  {content}
353
- {showResizeHandles && (
354
- <>
355
- <div
356
- className='gm-printer-resize-handle gm-printer-resize-lt'
357
- onMouseDown={this.handleResizeStart.bind(this, 'lt')}
358
- />
359
- <div
360
- className='gm-printer-resize-handle gm-printer-resize-rt'
361
- onMouseDown={this.handleResizeStart.bind(this, 'rt')}
362
- />
363
- <div
364
- className='gm-printer-resize-handle gm-printer-resize-lb'
365
- onMouseDown={this.handleResizeStart.bind(this, 'lb')}
366
- />
367
- <div
368
- className='gm-printer-resize-handle gm-printer-resize-rb'
369
- onMouseDown={this.handleResizeStart.bind(this, 'rb')}
370
- />
371
- </>
372
- )}
373
224
  </div>
374
225
  )
375
226
  }
@@ -380,8 +231,7 @@ Block.propTypes = {
380
231
  config: PropTypes.object.isRequired,
381
232
  pageIndex: PropTypes.number.isRequired,
382
233
  className: PropTypes.string,
383
- printerStore: PropTypes.object,
384
- editStore: PropTypes.object
234
+ printerStore: PropTypes.object
385
235
  }
386
236
 
387
237
  export default Block
@@ -333,7 +333,15 @@ class Printer extends React.Component {
333
333
 
334
334
  return (
335
335
  <MergePage>
336
- <Header config={config.header} pageIndex={0} />
336
+ {/* 批量连续打印(不留白)模式下分页交给浏览器:表头区含绝对定位文字,
337
+ 若表头自身或表头与表格的接缝骑在分页边界,Chrome 对 absolute 元素的
338
+ fragmentation 渲染会使表头文字错位/重复,叠到其他单据内容上。
339
+ 故禁止表头跨页(breakInside)、并让表头与后续表格同页(breakAfter) */}
340
+ <Header
341
+ config={config.header}
342
+ pageIndex={0}
343
+ style={{ breakInside: 'avoid', breakAfter: 'avoid' }}
344
+ />
337
345
  {_.map(config.contents, (content, index) => {
338
346
  switch (content.type) {
339
347
  case 'table':