gm-printer 10.42.3-beta.4 → 10.42.4-beta.0
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/build/demo.js +9 -9
- package/locales/en.json +0 -3
- package/locales/th.json +0 -3
- package/locales/zh-HK.json +0 -3
- package/package.json +1 -1
- package/src/common/common_context_menu.js +4 -6
- package/src/common/component.js +8 -64
- package/src/common/editor_edit_field.js +1 -6
- package/src/common/editor_sort_setting.js +153 -0
- package/src/common/editor_store.js +34 -36
- package/src/common/hoc_with_store.js +0 -9
- package/src/common/style.lesss +0 -43
- package/src/editor/editor.js +3 -0
- package/src/editor/store.js +0 -13
- package/src/editor_account/editor.js +2 -0
- package/src/finance_voucher/components/table_subtotal_tr.js +18 -12
- package/src/index.js +0 -2
- package/src/printer/block.js +4 -154
- package/src/printer/compute_pages.js +1 -2
- package/src/printer/multi_column.js +1 -1
- package/src/printer/page_summary.js +1 -3
- package/src/printer/printer.js +1 -8
- package/src/printer/store.js +38 -129
- package/src/printer/table_diy_overallOrder_tr.js +15 -8
- package/src/printer/table_diy_summary_tr.js +35 -18
- package/src/printer/table_subtotal_tr.js +16 -13
- package/src/util.js +1 -20
- package/yarn-error.log +152 -372
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
|
"编辑字段": "",
|
package/locales/zh-HK.json
CHANGED
|
@@ -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
|
@@ -109,7 +109,7 @@ class CommonContextMenu extends React.Component {
|
|
|
109
109
|
})
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
handleInsertBlock = (type, link
|
|
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 =
|
|
165
|
-
this.handleInsertBlock('image', imgURL
|
|
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
|
package/src/common/component.js
CHANGED
|
@@ -391,26 +391,12 @@ Line.propTypes = {
|
|
|
391
391
|
|
|
392
392
|
class Size extends React.Component {
|
|
393
393
|
handleChange = (type, value) => {
|
|
394
|
-
const { onChange, style
|
|
394
|
+
const { onChange, style } = this.props
|
|
395
395
|
|
|
396
|
-
|
|
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 (
|
|
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=
|
|
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
|
|
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
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import { observer, inject } from 'mobx-react'
|
|
5
|
+
import i18next from '../../locales'
|
|
6
|
+
import { Flex, Select, Option } from '../components'
|
|
7
|
+
import { Title, Gap, Radio } from './component'
|
|
8
|
+
|
|
9
|
+
// 排序方式常量,与宿主 sort_setting_util / 后端 parse_sort_setting 对齐
|
|
10
|
+
// product_row_sort.field:'' 不排序 / tax_rate 税率 / box_num 箱号 / custom 行号(自定义字段)
|
|
11
|
+
const SORT_FIELD_LIST = [
|
|
12
|
+
{ value: '', text: i18next.t('不排序') },
|
|
13
|
+
{ value: 'tax_rate', text: i18next.t('税率') },
|
|
14
|
+
{ value: 'box_num', text: i18next.t('箱号') },
|
|
15
|
+
{ value: 'custom', text: i18next.t('行号') }
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const SORT_DIRECTION_LIST = [
|
|
19
|
+
{ value: 'asc', text: i18next.t('升序') },
|
|
20
|
+
{ value: 'desc', text: i18next.t('降序') }
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
// order_sort.type:仅商户配送单模板提供(账户模板不渲染该组)
|
|
24
|
+
const ORDER_SORT_LIST = [
|
|
25
|
+
{ value: 'none', text: i18next.t('不排序') },
|
|
26
|
+
{ value: 'asc', text: i18next.t('按订单时间升序') },
|
|
27
|
+
{ value: 'desc', text: i18next.t('按订单时间降序') }
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 「排序方式」配置类:归集「商品行排序」「单据内订单顺序」两组子配置
|
|
32
|
+
* 读写 editStore.config.sort_setting(mobx4 读取不存在的键不建立依赖,
|
|
33
|
+
* 宿主传入 config 前需保证 sort_setting 键存在,无配置时为 null)
|
|
34
|
+
*/
|
|
35
|
+
@inject('editStore')
|
|
36
|
+
@observer
|
|
37
|
+
class SortSettingField extends React.Component {
|
|
38
|
+
getProductRowSort() {
|
|
39
|
+
return this.props.editStore.config.sort_setting?.product_row_sort || {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getOrderSortType() {
|
|
43
|
+
return this.props.editStore.config.sort_setting?.order_sort?.type || 'none'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setSortSetting(sortSetting) {
|
|
47
|
+
this.props.editStore.config.sort_setting = sortSetting
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
handleFieldChange = field => {
|
|
51
|
+
const productRowSort = { ...this.getProductRowSort(), field }
|
|
52
|
+
if (field !== 'custom') {
|
|
53
|
+
// 切离行号排序时清掉脏数据
|
|
54
|
+
delete productRowSort.custom_field_key
|
|
55
|
+
} else if (!productRowSort.custom_field_key) {
|
|
56
|
+
// 选中「行号」默认取第一个自定义字段(行号 1)
|
|
57
|
+
const customFields =
|
|
58
|
+
(this.props.addFields && this.props.addFields.sortCustomFields) || []
|
|
59
|
+
productRowSort.custom_field_key = customFields[0] && customFields[0].id
|
|
60
|
+
}
|
|
61
|
+
this.setSortSetting({
|
|
62
|
+
...this.props.editStore.config.sort_setting,
|
|
63
|
+
product_row_sort: {
|
|
64
|
+
...productRowSort,
|
|
65
|
+
direction: productRowSort.direction || 'asc'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleDirectionChange = direction => {
|
|
71
|
+
this.setSortSetting({
|
|
72
|
+
...this.props.editStore.config.sort_setting,
|
|
73
|
+
product_row_sort: { ...this.getProductRowSort(), direction }
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
handleOrderSortChange = type => {
|
|
78
|
+
this.setSortSetting({
|
|
79
|
+
...this.props.editStore.config.sort_setting,
|
|
80
|
+
order_sort: { type }
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
const { showOrderSort } = this.props
|
|
86
|
+
const productRowSort = this.getProductRowSort()
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div>
|
|
90
|
+
<Title title={i18next.t('排序方式')} />
|
|
91
|
+
<Gap height='5px' />
|
|
92
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
93
|
+
<div>{i18next.t('商品行排序')}:</div>
|
|
94
|
+
<Select
|
|
95
|
+
className='gm-printer-edit-select'
|
|
96
|
+
value={productRowSort.field || ''}
|
|
97
|
+
onChange={this.handleFieldChange}
|
|
98
|
+
>
|
|
99
|
+
{_.map(SORT_FIELD_LIST, v => (
|
|
100
|
+
<Option key={v.value} value={v.value}>
|
|
101
|
+
{v.text}
|
|
102
|
+
</Option>
|
|
103
|
+
))}
|
|
104
|
+
</Select>
|
|
105
|
+
</Flex>
|
|
106
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
107
|
+
<div>{i18next.t('排序方向')}:</div>
|
|
108
|
+
<Select
|
|
109
|
+
className='gm-printer-edit-select'
|
|
110
|
+
value={productRowSort.direction || 'asc'}
|
|
111
|
+
onChange={this.handleDirectionChange}
|
|
112
|
+
>
|
|
113
|
+
{_.map(SORT_DIRECTION_LIST, v => (
|
|
114
|
+
<Option key={v.value} value={v.value}>
|
|
115
|
+
{v.text}
|
|
116
|
+
</Option>
|
|
117
|
+
))}
|
|
118
|
+
</Select>
|
|
119
|
+
</Flex>
|
|
120
|
+
{showOrderSort && (
|
|
121
|
+
<>
|
|
122
|
+
<div className='gm-padding-top-5'>
|
|
123
|
+
{i18next.t('单据内订单顺序')}:
|
|
124
|
+
</div>
|
|
125
|
+
{_.map(ORDER_SORT_LIST, v => (
|
|
126
|
+
<Radio
|
|
127
|
+
key={v.value}
|
|
128
|
+
id={`sort_setting_order_${v.value}`}
|
|
129
|
+
value={v.text}
|
|
130
|
+
inputName='sort_setting_order_sort'
|
|
131
|
+
checked={this.getOrderSortType() === v.value}
|
|
132
|
+
radioChecked={this.handleOrderSortChange.bind(this, v.value)}
|
|
133
|
+
/>
|
|
134
|
+
))}
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
137
|
+
<Gap />
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
SortSettingField.propTypes = {
|
|
144
|
+
addFields: PropTypes.object.isRequired,
|
|
145
|
+
showOrderSort: PropTypes.bool,
|
|
146
|
+
editStore: PropTypes.object
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
SortSettingField.defaultProps = {
|
|
150
|
+
showOrderSort: false
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default SortSettingField
|
|
@@ -38,10 +38,6 @@ class EditorStore {
|
|
|
38
38
|
@observable
|
|
39
39
|
tableCustomStyle = 'default'
|
|
40
40
|
|
|
41
|
-
// 插入图片增强配置(电子签章),null 时保持旧行为(500Kb/image/*)
|
|
42
|
-
// { maxSize, maxSizeLabel, accept, acceptHint, resizable }
|
|
43
|
-
imageConfig = null
|
|
44
|
-
|
|
45
41
|
@observable
|
|
46
42
|
emptyTableData = []
|
|
47
43
|
|
|
@@ -242,7 +238,7 @@ class EditorStore {
|
|
|
242
238
|
}
|
|
243
239
|
}).join('/')
|
|
244
240
|
} else {
|
|
245
|
-
return v.style ? v.style.height : ''
|
|
241
|
+
return v && v.style ? v.style.height : ''
|
|
246
242
|
}
|
|
247
243
|
}).join('_')
|
|
248
244
|
}
|
|
@@ -263,6 +259,24 @@ class EditorStore {
|
|
|
263
259
|
this.remainPageHeihgt = remainHeight
|
|
264
260
|
}
|
|
265
261
|
|
|
262
|
+
@action
|
|
263
|
+
getFilledTableData(tableData) {
|
|
264
|
+
const { autoFillConfig } = this.config
|
|
265
|
+
if (!this.selectedRegion && !autoFillConfig?.checked) return []
|
|
266
|
+
let tr_count = 0
|
|
267
|
+
|
|
268
|
+
tr_count = Math.floor(
|
|
269
|
+
this.remainPageHeihgt / this.computedTableCustomerRowHeight
|
|
270
|
+
)
|
|
271
|
+
if (tr_count <= 0) return []
|
|
272
|
+
|
|
273
|
+
const sample = (tableData || []).find(item => item && !item._isEmptyData)
|
|
274
|
+
const dataKey =
|
|
275
|
+
this.computedTableSpecialConfig?.dataKey || autoFillConfig?.dataKey
|
|
276
|
+
const colNumber = detectColNumber(dataKey, tableData)
|
|
277
|
+
return createEmptyRows(tr_count, sample, colNumber)
|
|
278
|
+
}
|
|
279
|
+
|
|
266
280
|
/** 多栏表缺失时(如双栏切三栏),从单栏/双栏源表现场打包到 mockData */
|
|
267
281
|
@action
|
|
268
282
|
ensureMockMultiTable(dataKey) {
|
|
@@ -327,14 +341,18 @@ class EditorStore {
|
|
|
327
341
|
this.ensureMockMultiTable(getDataKey(dataKey, 'vertical'))
|
|
328
342
|
}
|
|
329
343
|
|
|
330
|
-
// 开启时不在编辑器侧预推空行:预推依赖挂载时上报的剩余高度,布局(纸张/表格/
|
|
331
|
-
// 排列)变化后会过期,第一次开启填充会按旧基准多推,把已渲染完的表格撑到下一页。
|
|
332
|
-
// 空行统一由 Printer 侧「先分页拿基准 → 补空 → 重分页」写入(见 printer.js)
|
|
333
344
|
const syncEmptyRows = key => {
|
|
334
345
|
if (!this.mockData._table?.[key]) return
|
|
346
|
+
const list = this.mockData._table[key]
|
|
347
|
+
const hasHadEmptyData = _.some(list, data => data?._isEmptyData)
|
|
348
|
+
if (isAutoFilling && !hasHadEmptyData) {
|
|
349
|
+
list.push(...this.getFilledTableData(list))
|
|
350
|
+
}
|
|
335
351
|
if (!isAutoFilling) {
|
|
336
352
|
this.clearExtraTableData(key)
|
|
353
|
+
return
|
|
337
354
|
}
|
|
355
|
+
this.mockData._table[key] = list
|
|
338
356
|
}
|
|
339
357
|
|
|
340
358
|
const numberEmptyRows = key => {
|
|
@@ -363,12 +381,13 @@ class EditorStore {
|
|
|
363
381
|
const baseRowCount = sourceItems.length
|
|
364
382
|
? Math.max(1, Math.ceil(sourceItems.length / colNumber))
|
|
365
383
|
: 0
|
|
366
|
-
// 钉死总行:repack 后 _isEmptyData 会变少,不能再用 emptyTable.length
|
|
367
|
-
// 无空行时不预推,交由 Printer 按当前分页基准补
|
|
384
|
+
// 钉死总行:repack 后 _isEmptyData 会变少,不能再用 emptyTable.length
|
|
368
385
|
const emptyCount = resolveVerticalEmptyCount(
|
|
369
386
|
list.length,
|
|
370
387
|
baseRowCount,
|
|
371
|
-
emptyTable.length
|
|
388
|
+
emptyTable.length > 0
|
|
389
|
+
? emptyTable.length
|
|
390
|
+
: this.getFilledTableData(list).length,
|
|
372
391
|
emptyTable.length > 0
|
|
373
392
|
)
|
|
374
393
|
const dataRows = baseRowCount
|
|
@@ -474,11 +493,6 @@ class EditorStore {
|
|
|
474
493
|
@action.bound
|
|
475
494
|
setPageSize(field, value) {
|
|
476
495
|
this.config.page.size[field] = value
|
|
477
|
-
// 页面几何变化会让预览 Printer 重挂载;行数填充开启时清掉按旧页高算出的空行,
|
|
478
|
-
// 重挂载后按新几何重补(对齐切换商品排列时的处理,见 setTableDataKeyEffect)
|
|
479
|
-
if (this.isAutoFilling || this.config?.autoFillConfig?.checked) {
|
|
480
|
-
this.clearAllTableEmptyData()
|
|
481
|
-
}
|
|
482
496
|
}
|
|
483
497
|
|
|
484
498
|
@computed
|
|
@@ -530,10 +544,6 @@ class EditorStore {
|
|
|
530
544
|
height: size.width
|
|
531
545
|
}
|
|
532
546
|
}
|
|
533
|
-
// 可用页高变了,行数填充开启时清掉按旧方向算出的空行,重挂载后重补
|
|
534
|
-
if (this.isAutoFilling || this.config?.autoFillConfig?.checked) {
|
|
535
|
-
this.clearAllTableEmptyData()
|
|
536
|
-
}
|
|
537
547
|
}
|
|
538
548
|
}
|
|
539
549
|
|
|
@@ -574,12 +584,6 @@ class EditorStore {
|
|
|
574
584
|
gap,
|
|
575
585
|
name
|
|
576
586
|
}
|
|
577
|
-
// 纸张类型/内边距变了,可用页高随之变化;行数填充开启时清掉按旧纸张算出的
|
|
578
|
-
// 空行(fillTableEmptyIndex 对已有空行沿用旧数量不重算,旧数量会把同页后续
|
|
579
|
-
// 表格挤到下一页),交给 Printer 重挂载后按新页高重补
|
|
580
|
-
if (this.isAutoFilling || this.config?.autoFillConfig?.checked) {
|
|
581
|
-
this.clearAllTableEmptyData()
|
|
582
|
-
}
|
|
583
587
|
}
|
|
584
588
|
|
|
585
589
|
@action
|
|
@@ -726,7 +730,7 @@ class EditorStore {
|
|
|
726
730
|
}
|
|
727
731
|
|
|
728
732
|
@action
|
|
729
|
-
addConfigBlock(name, type, pos = {}, link = ''
|
|
733
|
+
addConfigBlock(name, type, pos = {}, link = '') {
|
|
730
734
|
let blocks
|
|
731
735
|
const arr = name.split('.')
|
|
732
736
|
|
|
@@ -766,25 +770,19 @@ class EditorStore {
|
|
|
766
770
|
}
|
|
767
771
|
})
|
|
768
772
|
break
|
|
769
|
-
case 'image':
|
|
770
|
-
// 有原始比例时按比例初始化高度,避免插入即变形;无 ratio(降级/旧链路)保持 100x100
|
|
771
|
-
const w = 100
|
|
772
|
-
const h = ratio ? Math.round(w / ratio) : w
|
|
773
|
+
case 'image':
|
|
773
774
|
blocks.push({
|
|
774
775
|
type: 'image',
|
|
775
776
|
link: link,
|
|
776
|
-
// 电子签章:记录原图宽高比,锁比例用;旧数据无此字段则不锁
|
|
777
|
-
ratio: ratio,
|
|
778
777
|
style: {
|
|
779
778
|
position: 'absolute',
|
|
780
779
|
left: pos.left || '0px',
|
|
781
780
|
top: pos.top || '0px',
|
|
782
|
-
width:
|
|
783
|
-
height:
|
|
781
|
+
width: '100px',
|
|
782
|
+
height: '100px'
|
|
784
783
|
}
|
|
785
784
|
})
|
|
786
785
|
break
|
|
787
|
-
}
|
|
788
786
|
case 'counter':
|
|
789
787
|
blocks.push({
|
|
790
788
|
type: 'counter',
|
|
@@ -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() {
|
package/src/common/style.lesss
CHANGED
|
@@ -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 {
|
package/src/editor/editor.js
CHANGED
|
@@ -9,6 +9,7 @@ import EditorTitle from '../common/editor_title'
|
|
|
9
9
|
import EditorSelect from '../common/editor_select'
|
|
10
10
|
import SpecialField from '../common/editor_special_field'
|
|
11
11
|
import SpecialOtherField from '../common/editor_special_other_field'
|
|
12
|
+
import SortSettingField from '../common/editor_sort_setting'
|
|
12
13
|
import EditorField from '../common/editor_edit_field'
|
|
13
14
|
import EditorAddField from '../common/editor_add_field'
|
|
14
15
|
import EditorPageSummary from '../common/editor_page_summary'
|
|
@@ -88,6 +89,8 @@ class Editor extends React.Component {
|
|
|
88
89
|
<Gap height='5px' />
|
|
89
90
|
<SpecialField addFields={addFields} mockData={mockData} />
|
|
90
91
|
<SpecialOtherField addFields={addFields} mockData={mockData} />
|
|
92
|
+
<Gap height='5px' />
|
|
93
|
+
<SortSettingField addFields={addFields} showOrderSort />
|
|
91
94
|
<EditorCutomizedConfig />
|
|
92
95
|
<Gap height='5px' />
|
|
93
96
|
<EditorField
|
package/src/editor/store.js
CHANGED
|
@@ -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) {
|
|
@@ -7,6 +7,7 @@ import editStore from './store'
|
|
|
7
7
|
import { observer, inject } from 'mobx-react'
|
|
8
8
|
import EditorTitle from '../common/editor_title'
|
|
9
9
|
import EditorSelect from '../common/editor_select'
|
|
10
|
+
import SortSettingField from '../common/editor_sort_setting'
|
|
10
11
|
import EditorField from '../common/editor_edit_field'
|
|
11
12
|
import EditorAddField from '../common/editor_add_field'
|
|
12
13
|
import EditorCutomizedConfig from '../common/editor_customize_config'
|
|
@@ -55,6 +56,7 @@ class Editor extends React.Component {
|
|
|
55
56
|
<Gap height='10px' />
|
|
56
57
|
<EditorSelect />
|
|
57
58
|
<Gap height='5px' />
|
|
59
|
+
<SortSettingField addFields={addFields} />
|
|
58
60
|
<EditorCutomizedConfig />
|
|
59
61
|
<Gap height='5px' />
|
|
60
62
|
<EditorField showNewDate={showNewDate} />
|