gm-printer 11.0.1 → 11.0.2-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.
- package/build/demo.js +9 -9
- package/package.json +1 -1
- package/src/common/editor_store.js +37 -2
- package/src/common/editor_title.js +10 -4
- package/src/editor/context_menu_config.js +335 -0
- package/src/editor/editor_menu_config.js +140 -0
- package/src/editor/index.js +2 -0
- package/src/editor_settle/editor.js +2 -1
- package/src/examining_report_editor/context_menu.js +94 -0
- package/src/examining_report_editor/editor.js +85 -0
- package/src/examining_report_editor/index.js +4 -0
- package/src/examining_report_editor/store.js +78 -0
- package/src/index.js +5 -1
- package/src/printer/page_summary.js +9 -32
- package/src/printer/printer.js +3 -3
- package/src/printer/store.js +4 -4
- package/src/printer/table_diy_overallOrder_tr.js +7 -21
- package/src/printer/table_diy_summary_tr.js +6 -32
- package/src/printer/table_subtotal_tr.js +34 -42
- package/src/util.js +1 -24
package/package.json
CHANGED
|
@@ -94,13 +94,45 @@ class EditorStore {
|
|
|
94
94
|
|
|
95
95
|
@action
|
|
96
96
|
setSubtotalFieldsCol(arr) {
|
|
97
|
-
// this.overallOrderShow = !this.overallOrderShow
|
|
98
|
-
// 重新计算每页合计的单元格
|
|
99
97
|
const table = this.config.contents[arr[2]]
|
|
98
|
+
if (!table?.subtotal?.show) return
|
|
99
|
+
|
|
100
|
+
const colSpanLength = getColSpanLength(table)
|
|
101
|
+
if (!table.subtotal.fields?.length) {
|
|
102
|
+
set(table.subtotal, {
|
|
103
|
+
fields: [
|
|
104
|
+
{
|
|
105
|
+
name: '每页合计:',
|
|
106
|
+
valueField: 'real_item_price',
|
|
107
|
+
colSpan: colSpanLength
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
const subtotalLength = table.subtotal.fields.length
|
|
101
115
|
table.subtotal.fields[subtotalLength - 1].colSpan += 1
|
|
102
116
|
}
|
|
103
117
|
|
|
118
|
+
@action
|
|
119
|
+
updateSelectedRegionAfterContentInsert(insertIndex) {
|
|
120
|
+
const updateNameIndex = name => {
|
|
121
|
+
if (!name) return name
|
|
122
|
+
const parts = name.split('.')
|
|
123
|
+
if (parts[0] !== 'contents') return name
|
|
124
|
+
const regionIndex = ~~parts[2]
|
|
125
|
+
if (regionIndex >= insertIndex) {
|
|
126
|
+
parts[2] = String(regionIndex + 1)
|
|
127
|
+
return parts.join('.')
|
|
128
|
+
}
|
|
129
|
+
return name
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.selectedRegion = updateNameIndex(this.selectedRegion)
|
|
133
|
+
this.selected = updateNameIndex(this.selected)
|
|
134
|
+
}
|
|
135
|
+
|
|
104
136
|
@action
|
|
105
137
|
setMultiDigitDecimal(bool) {
|
|
106
138
|
this.isMultiDigitDecimal = bool
|
|
@@ -266,6 +298,7 @@ class EditorStore {
|
|
|
266
298
|
{ batchPrintConfig: 1, isFixLastFooter: true },
|
|
267
299
|
config
|
|
268
300
|
)
|
|
301
|
+
this.defaultTableDataKey = config.defaultTableDataKey || 'orders'
|
|
269
302
|
this.originConfig = config
|
|
270
303
|
this.selected = null
|
|
271
304
|
this.selectedRegion = null
|
|
@@ -1205,6 +1238,8 @@ class EditorStore {
|
|
|
1205
1238
|
}
|
|
1206
1239
|
})
|
|
1207
1240
|
}
|
|
1241
|
+
this.updateSelectedRegionAfterContentInsert(index)
|
|
1242
|
+
this.config = toJS(this.config)
|
|
1208
1243
|
}
|
|
1209
1244
|
}
|
|
1210
1245
|
}
|
|
@@ -72,13 +72,15 @@ class EditorTitle extends React.Component {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
handleTestPrint = () => {
|
|
75
|
-
|
|
75
|
+
// 新增结款单每页合计标识,测试打印时原样透传到打印入口
|
|
76
|
+
const { mockData, editStore, isSomeSubtotalTr } = this.props
|
|
76
77
|
doPrint(
|
|
77
78
|
{
|
|
78
79
|
config: toJS(editStore.config),
|
|
79
80
|
data: mockData
|
|
80
81
|
},
|
|
81
|
-
true
|
|
82
|
+
true,
|
|
83
|
+
isSomeSubtotalTr
|
|
82
84
|
)
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -140,10 +142,14 @@ class EditorTitle extends React.Component {
|
|
|
140
142
|
EditorTitle.propTypes = {
|
|
141
143
|
onSave: PropTypes.func.isRequired,
|
|
142
144
|
isPurchase: PropTypes.bool,
|
|
143
|
-
editStore: PropTypes.object
|
|
145
|
+
editStore: PropTypes.object,
|
|
146
|
+
// 标识是否为结款单每页合计场景
|
|
147
|
+
isSomeSubtotalTr: PropTypes.bool
|
|
144
148
|
}
|
|
145
149
|
EditorTitle.defaultProps = {
|
|
146
|
-
isPurchase: false
|
|
150
|
+
isPurchase: false,
|
|
151
|
+
// 默认按非结款单每页合计场景处理
|
|
152
|
+
isSomeSubtotalTr: false
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
EditorTitle.wrappedComponent.propTypes = {
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import i18next from '../../locales'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import CommonContextMenu from '../common/common_context_menu'
|
|
5
|
+
import { inject, observer } from 'mobx-react'
|
|
6
|
+
import _ from 'lodash'
|
|
7
|
+
import { Printer } from '../printer'
|
|
8
|
+
import { isMultiTable } from '../util'
|
|
9
|
+
import { LONG_PRINT } from '../config'
|
|
10
|
+
|
|
11
|
+
const blockTypeList = [
|
|
12
|
+
{ value: '', text: i18next.t('插入文本') },
|
|
13
|
+
{ value: 'line', text: i18next.t('插入线条') },
|
|
14
|
+
{ value: 'image', text: i18next.t('插入图片') },
|
|
15
|
+
{ value: 'counter', text: i18next.t('插入分类汇总') },
|
|
16
|
+
{ value: 'tag', text: i18next.t('插入标签汇总') },
|
|
17
|
+
{ value: 'barcode', text: i18next.t('插入订单条形码') },
|
|
18
|
+
{ value: 'qrcode', text: i18next.t('插入订单溯源二维码') },
|
|
19
|
+
{
|
|
20
|
+
value: 'uniform_social_credit_code',
|
|
21
|
+
text: i18next.t('插入苏州安全监管平台二维码')
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
@inject('editStore')
|
|
26
|
+
@observer
|
|
27
|
+
class ContextMenu extends React.Component {
|
|
28
|
+
componentDidMount() {
|
|
29
|
+
const {
|
|
30
|
+
editStore,
|
|
31
|
+
editStore: {
|
|
32
|
+
config: { autoFillConfig, specialControlConfig }
|
|
33
|
+
}
|
|
34
|
+
} = this.props
|
|
35
|
+
|
|
36
|
+
if (autoFillConfig?.checked) {
|
|
37
|
+
editStore.handleChangeTableData(
|
|
38
|
+
autoFillConfig?.checked,
|
|
39
|
+
autoFillConfig?.dataKey
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
/** 初始化特殊控制的配置 */
|
|
43
|
+
if (specialControlConfig?.multiDigitDecimal) {
|
|
44
|
+
// 多位小数
|
|
45
|
+
editStore.setMultiDigitDecimal(specialControlConfig?.multiDigitDecimal)
|
|
46
|
+
}
|
|
47
|
+
if (specialControlConfig?.taxFreeProductRateDisplay !== undefined) {
|
|
48
|
+
// 免税产品税率显示
|
|
49
|
+
editStore.setTaxFreeProductRateDisplay(
|
|
50
|
+
specialControlConfig?.taxFreeProductRateDisplay || ''
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
isMenuItemEnabled = key => {
|
|
56
|
+
const { menuConfig } = this.props
|
|
57
|
+
if (!menuConfig) return true
|
|
58
|
+
if (Array.isArray(menuConfig)) return menuConfig.includes(key)
|
|
59
|
+
if (typeof menuConfig === 'object') return !!menuConfig[key]
|
|
60
|
+
return true
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 是否存在每页合计按钮,非异常明细才有按钮
|
|
65
|
+
* @param name => ContextMenu 的 this.state.name
|
|
66
|
+
* @return {boolean}
|
|
67
|
+
*/
|
|
68
|
+
hasSubtotalBtn = name => {
|
|
69
|
+
if (!name) return false
|
|
70
|
+
const noSubtotalList = ['abnormal', 'abnormalDetails']
|
|
71
|
+
const arr = name.split('.')
|
|
72
|
+
if (_.includes(arr, 'table')) {
|
|
73
|
+
const dataKey = this.props.editStore.config.contents[arr[2]].dataKey
|
|
74
|
+
return !_.includes(noSubtotalList, dataKey)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
handleChangeTableDataKey = (key, name) => {
|
|
79
|
+
const { editStore } = this.props
|
|
80
|
+
|
|
81
|
+
editStore.changeTableDataKey(name, key)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
handleSubtotal = name => {
|
|
85
|
+
const { editStore } = this.props
|
|
86
|
+
editStore.setSubtotalShow(name)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
handleCategoryConfig = (key, name) => {
|
|
90
|
+
const { editStore } = this.props
|
|
91
|
+
editStore.changeTableDataKey(name, key)
|
|
92
|
+
|
|
93
|
+
editStore.setCategoryConfigShow(name)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
handleChangeTableData = isAutoFilling => {
|
|
97
|
+
const { editStore } = this.props
|
|
98
|
+
editStore.handleChangeTableData(isAutoFilling)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
handleOverallOrder = name => {
|
|
102
|
+
const { editStore } = this.props
|
|
103
|
+
editStore.setOverallOrderShow(name)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
handleDiyOverallOrder = name => {
|
|
107
|
+
const { editStore } = this.props
|
|
108
|
+
editStore.setDiyOverallOrderShow(name)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 通用的自定义合计菜单项处理
|
|
112
|
+
handleDiySummary = (name, configKey) => {
|
|
113
|
+
const { editStore } = this.props
|
|
114
|
+
const methodName = configKey
|
|
115
|
+
.split(/(?=[A-Z])/)
|
|
116
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
117
|
+
.join('')
|
|
118
|
+
|
|
119
|
+
const method = editStore[`set${methodName}Show`]
|
|
120
|
+
|
|
121
|
+
if (configKey === 'diyCategorySubtotal') {
|
|
122
|
+
const arr = name.split('.')
|
|
123
|
+
const dataKey = editStore.config.contents[arr[2]].dataKey
|
|
124
|
+
console.log('dataKey==> handleDiySummary', dataKey)
|
|
125
|
+
|
|
126
|
+
if (!dataKey.split('_').includes('category')) {
|
|
127
|
+
editStore.changeTableDataKey(name, 'category', {
|
|
128
|
+
type: 'diyCategorySubtotal'
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (configKey === 'diyTagSubtotal') {
|
|
133
|
+
const arr = name.split('.')
|
|
134
|
+
const dataKey = editStore.config.contents[arr[2]].dataKey
|
|
135
|
+
console.log('dataKey==> handleDiySummary', dataKey)
|
|
136
|
+
|
|
137
|
+
if (!dataKey.split('_').includes('tag')) {
|
|
138
|
+
editStore.changeTableDataKey(name, 'tag', {
|
|
139
|
+
type: 'diyTagSubtotal'
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (method) {
|
|
144
|
+
method(name)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
renderOrderActionBtn = name => {
|
|
149
|
+
if (!this.hasSubtotalBtn(name)) {
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const {
|
|
154
|
+
editStore: {
|
|
155
|
+
config: {
|
|
156
|
+
page: { type },
|
|
157
|
+
showDiyOverAllOrder
|
|
158
|
+
},
|
|
159
|
+
isAutoFilling
|
|
160
|
+
}
|
|
161
|
+
} = this.props
|
|
162
|
+
const arr = name.split('.')
|
|
163
|
+
const {
|
|
164
|
+
dataKey,
|
|
165
|
+
subtotal,
|
|
166
|
+
overallOrder,
|
|
167
|
+
diySubtotal,
|
|
168
|
+
diyTagSubtotal,
|
|
169
|
+
diyOverallOrder,
|
|
170
|
+
diyCategorySubtotal
|
|
171
|
+
} = this.props.editStore.config.contents[arr[2]]
|
|
172
|
+
const keyArr = dataKey.split('_')
|
|
173
|
+
|
|
174
|
+
const isMultiActive = keyArr.includes('multi')
|
|
175
|
+
const isThreeActive = keyArr.includes('multi3')
|
|
176
|
+
const isCategoryActive = keyArr.includes('category')
|
|
177
|
+
const isTagActive = keyArr.includes('tag')
|
|
178
|
+
const isNewCategoryActive = keyArr.includes('newCategory')
|
|
179
|
+
const isSubtotalActive = subtotal.show
|
|
180
|
+
const isOverallOrder = overallOrder?.show
|
|
181
|
+
const isDiyOverallOrder = diyOverallOrder?.show
|
|
182
|
+
const isDiySubtotal = diySubtotal?.show
|
|
183
|
+
const isDiyTagSubtotal = diyTagSubtotal?.show
|
|
184
|
+
const isDiyCategorySubtotal = diyCategorySubtotal?.show
|
|
185
|
+
|
|
186
|
+
// 长条打印
|
|
187
|
+
const isLongPrint = type === LONG_PRINT
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<>
|
|
191
|
+
{this.isMenuItemEnabled('multi') && !isLongPrint && (
|
|
192
|
+
<div
|
|
193
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
|
|
194
|
+
className={isMultiActive ? 'active' : ''}
|
|
195
|
+
>
|
|
196
|
+
{i18next.t('双栏商品')}
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
{this.isMenuItemEnabled('multi3') && type !== 'A4/3' && !isLongPrint && (
|
|
200
|
+
<div
|
|
201
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'multi3', name)}
|
|
202
|
+
className={isThreeActive ? 'active' : ''}
|
|
203
|
+
>
|
|
204
|
+
{i18next.t('三栏商品')}
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
{this.isMenuItemEnabled('category') && (
|
|
208
|
+
<div
|
|
209
|
+
onClick={this.handleChangeTableDataKey.bind(
|
|
210
|
+
this,
|
|
211
|
+
'category',
|
|
212
|
+
name,
|
|
213
|
+
isCategoryActive
|
|
214
|
+
)}
|
|
215
|
+
className={isCategoryActive ? 'active' : ''}
|
|
216
|
+
>
|
|
217
|
+
{i18next.t('分类小计')}
|
|
218
|
+
</div>
|
|
219
|
+
)}
|
|
220
|
+
{this.isMenuItemEnabled('categoryDiy') && (
|
|
221
|
+
<div
|
|
222
|
+
onClick={this.handleChangeTableDataKey.bind(
|
|
223
|
+
this,
|
|
224
|
+
'categoryDiy',
|
|
225
|
+
name
|
|
226
|
+
)}
|
|
227
|
+
className={isDiyCategorySubtotal ? 'active' : ''}
|
|
228
|
+
>
|
|
229
|
+
{i18next.t('自定义分类小计')}
|
|
230
|
+
</div>
|
|
231
|
+
)}
|
|
232
|
+
{this.isMenuItemEnabled('tag') && (
|
|
233
|
+
<div
|
|
234
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'tag', name)}
|
|
235
|
+
className={isTagActive ? 'active' : ''}
|
|
236
|
+
>
|
|
237
|
+
{i18next.t('标签小计')}
|
|
238
|
+
</div>
|
|
239
|
+
)}
|
|
240
|
+
{this.isMenuItemEnabled('tagDiy') && (
|
|
241
|
+
<div
|
|
242
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'tagDiy', name)}
|
|
243
|
+
className={isDiyTagSubtotal ? 'active' : ''}
|
|
244
|
+
>
|
|
245
|
+
{i18next.t('自定义标签小计')}
|
|
246
|
+
</div>
|
|
247
|
+
)}
|
|
248
|
+
{this.isMenuItemEnabled('newCategory') && (
|
|
249
|
+
<div
|
|
250
|
+
onClick={this.handleCategoryConfig.bind(this, 'newCategory', name)}
|
|
251
|
+
className={isNewCategoryActive ? 'active' : ''}
|
|
252
|
+
>
|
|
253
|
+
{i18next.t('商品分类')}
|
|
254
|
+
</div>
|
|
255
|
+
)}
|
|
256
|
+
{this.isMenuItemEnabled('subtotal') && (
|
|
257
|
+
<div
|
|
258
|
+
onClick={this.handleSubtotal.bind(this, name)}
|
|
259
|
+
className={isSubtotalActive ? 'active' : ''}
|
|
260
|
+
>
|
|
261
|
+
{i18next.t('每页合计')}
|
|
262
|
+
</div>
|
|
263
|
+
)}
|
|
264
|
+
{this.isMenuItemEnabled('diySubtotal') && (
|
|
265
|
+
<div
|
|
266
|
+
onClick={() => this.handleDiySummary(name, 'diySubtotal')}
|
|
267
|
+
className={isDiySubtotal ? 'active' : ''}
|
|
268
|
+
>
|
|
269
|
+
{i18next.t('自定义每页合计')}
|
|
270
|
+
</div>
|
|
271
|
+
)}
|
|
272
|
+
{this.isMenuItemEnabled('autoFill') && (
|
|
273
|
+
<div
|
|
274
|
+
onClick={this.handleChangeTableData.bind(this, !isAutoFilling)}
|
|
275
|
+
className={isAutoFilling ? 'active' : ''}
|
|
276
|
+
>
|
|
277
|
+
{i18next.t('行数填充')}
|
|
278
|
+
</div>
|
|
279
|
+
)}
|
|
280
|
+
{this.isMenuItemEnabled('overallOrder') && (
|
|
281
|
+
<div
|
|
282
|
+
onClick={this.handleOverallOrder.bind(this, name)}
|
|
283
|
+
className={isOverallOrder ? 'active' : ''}
|
|
284
|
+
>
|
|
285
|
+
{i18next.t('整单合计')}
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
{this.isMenuItemEnabled('diyOverallOrder') &&
|
|
289
|
+
!isMultiTable(dataKey) &&
|
|
290
|
+
showDiyOverAllOrder && (
|
|
291
|
+
<div
|
|
292
|
+
onClick={this.handleDiyOverallOrder.bind(this, name)}
|
|
293
|
+
className={isDiyOverallOrder ? 'active' : ''}
|
|
294
|
+
>
|
|
295
|
+
{i18next.t('自定义整单合计')}
|
|
296
|
+
</div>
|
|
297
|
+
)}
|
|
298
|
+
</>
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
render() {
|
|
303
|
+
const { editStore, customTableConfigs } = this.props
|
|
304
|
+
return (
|
|
305
|
+
<CommonContextMenu
|
|
306
|
+
renderTableAction={this.renderOrderActionBtn}
|
|
307
|
+
insertBlockList={blockTypeList}
|
|
308
|
+
customTableConfigs={customTableConfigs}
|
|
309
|
+
>
|
|
310
|
+
<Printer
|
|
311
|
+
key={editStore.computedPrinterKey}
|
|
312
|
+
selected={editStore.selected}
|
|
313
|
+
selectedRegion={editStore.selectedRegion}
|
|
314
|
+
isAutoFilling={editStore.isAutoFilling}
|
|
315
|
+
fillIndex={editStore.fillIndex}
|
|
316
|
+
lineheight={editStore.computedTableCustomerRowHeight}
|
|
317
|
+
config={editStore.config}
|
|
318
|
+
data={editStore.mockData}
|
|
319
|
+
getremainpageHeight={editStore.setRemainPageHeight}
|
|
320
|
+
overallorder={editStore.overallOrderShow}
|
|
321
|
+
/>
|
|
322
|
+
</CommonContextMenu>
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
ContextMenu.propTypes = {
|
|
327
|
+
editStore: PropTypes.object,
|
|
328
|
+
mockData: PropTypes.object,
|
|
329
|
+
customTableConfigs: PropTypes.array,
|
|
330
|
+
menuConfig: PropTypes.oneOfType([
|
|
331
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
332
|
+
PropTypes.object
|
|
333
|
+
])
|
|
334
|
+
}
|
|
335
|
+
export default ContextMenu
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import { Flex, ToolTip } from '../components'
|
|
5
|
+
import { Gap, Title } from '../common/component'
|
|
6
|
+
import editStore from './store'
|
|
7
|
+
import { observer, inject } from 'mobx-react'
|
|
8
|
+
import EditorTitle from '../common/editor_title'
|
|
9
|
+
import EditorSelect from '../common/editor_select'
|
|
10
|
+
import SpecialField from '../common/editor_special_field'
|
|
11
|
+
import SpecialOtherField from '../common/editor_special_other_field'
|
|
12
|
+
import EditorField from '../common/editor_edit_field'
|
|
13
|
+
import EditorAddField from '../common/editor_add_field'
|
|
14
|
+
import EditorPageSummary from '../common/editor_page_summary'
|
|
15
|
+
import EditorCutomizedConfig from '../common/editor_customize_config'
|
|
16
|
+
import ContextMenu from './context_menu_config'
|
|
17
|
+
import i18next from '../../locales'
|
|
18
|
+
import withStore from '../common/hoc_with_store'
|
|
19
|
+
|
|
20
|
+
// ‼️‼️🚸🚸 注意: value的命名不要用下划线! 原因是 computedTableDataKeyOfSelectedRegion 会split('_')下划线做一些事情‼️
|
|
21
|
+
// 📚hasSubtotalBtn 这种表格是否支持 双栏,分类,合计 功能
|
|
22
|
+
const tableDataKeyList = [
|
|
23
|
+
{ value: 'orders', text: i18next.t('全部商品'), hasSubtotalBtn: true },
|
|
24
|
+
{ value: 'abnormal', text: i18next.t('异常商品'), hasSubtotalBtn: false },
|
|
25
|
+
{
|
|
26
|
+
value: 'abnormalDetails',
|
|
27
|
+
text: i18next.t('异常商品(明细)'),
|
|
28
|
+
hasSubtotalBtn: false
|
|
29
|
+
},
|
|
30
|
+
{ value: 'reward', text: i18next.t('积分表格'), hasSubtotalBtn: false },
|
|
31
|
+
{ value: 'combination', text: i18next.t('组合商品'), hasSubtotalBtn: false },
|
|
32
|
+
{ value: 'turnover', text: i18next.t('周转物表格'), hasSubtotalBtn: false }
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
export const noSubtotalBtnTableDataKeySet = new Set(
|
|
36
|
+
tableDataKeyList.filter(v => !v.hasSubtotalBtn).map(o => o.value)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@withStore(editStore)
|
|
40
|
+
@inject('editStore')
|
|
41
|
+
@observer
|
|
42
|
+
class Editor extends React.Component {
|
|
43
|
+
render() {
|
|
44
|
+
const {
|
|
45
|
+
onSave,
|
|
46
|
+
showEditor,
|
|
47
|
+
addFields,
|
|
48
|
+
showNewDate,
|
|
49
|
+
mockData,
|
|
50
|
+
mergeClassificationAndLabel,
|
|
51
|
+
customTableConfigs,
|
|
52
|
+
menuConfig
|
|
53
|
+
} = this.props
|
|
54
|
+
return (
|
|
55
|
+
<div className='gm-printer-edit'>
|
|
56
|
+
<Flex className='gm-printer-edit-title-fixed'>
|
|
57
|
+
<Title
|
|
58
|
+
title={i18next.t('模板预览')}
|
|
59
|
+
text={
|
|
60
|
+
<span className='gm-text-desc gm-padding-left-5'>
|
|
61
|
+
{i18next.t(
|
|
62
|
+
'说明:选中内容进行编辑,可拖动字段移动位置,右键使用更多功能'
|
|
63
|
+
)}
|
|
64
|
+
{/* <a
|
|
65
|
+
href='https://v.qq.com/x/page/t08044292dd.html'
|
|
66
|
+
target='_blank'
|
|
67
|
+
className='btn-link'
|
|
68
|
+
rel='noopener noreferrer'
|
|
69
|
+
>
|
|
70
|
+
{i18next.t('查看视频教程')}
|
|
71
|
+
</a> */}
|
|
72
|
+
</span>
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
</Flex>
|
|
76
|
+
|
|
77
|
+
{showEditor && (
|
|
78
|
+
<div className='gm-printer-edit-zone'>
|
|
79
|
+
<EditorTitle onSave={onSave} />
|
|
80
|
+
<Gap height='10px' />
|
|
81
|
+
<>
|
|
82
|
+
<>{i18next.t('模版类型')}</>
|
|
83
|
+
<ToolTip text='表示该模板是针对单一商户的配送单模板(商户配送单),或是账户合并打印配送单(账户配送单)的模板。' />
|
|
84
|
+
<span>{':' + i18next.t('商户配送单')}</span>
|
|
85
|
+
</>
|
|
86
|
+
<Gap height='10px' />
|
|
87
|
+
<EditorSelect />
|
|
88
|
+
<Gap height='5px' />
|
|
89
|
+
<SpecialField addFields={addFields} mockData={mockData} />
|
|
90
|
+
<SpecialOtherField addFields={addFields} mockData={mockData} />
|
|
91
|
+
<EditorCutomizedConfig />
|
|
92
|
+
<Gap height='5px' />
|
|
93
|
+
<EditorField
|
|
94
|
+
tableDataKeyList={tableDataKeyList}
|
|
95
|
+
showNewDate={showNewDate}
|
|
96
|
+
mergeClassificationAndLabel={mergeClassificationAndLabel}
|
|
97
|
+
/>
|
|
98
|
+
<Gap height='5px' />
|
|
99
|
+
<EditorAddField addFields={addFields} />
|
|
100
|
+
<Gap height='5px' />
|
|
101
|
+
<EditorPageSummary summaryFields={addFields.summaryFields} />
|
|
102
|
+
|
|
103
|
+
<div id='gm-printer-tip' />
|
|
104
|
+
|
|
105
|
+
<div id='gm-printer-modal' />
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
<div className='gm-printer-edit-wrap'>
|
|
110
|
+
<ContextMenu
|
|
111
|
+
customTableConfigs={customTableConfigs}
|
|
112
|
+
menuConfig={menuConfig}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Editor.propTypes = {
|
|
121
|
+
config: PropTypes.object.isRequired,
|
|
122
|
+
onSave: PropTypes.func,
|
|
123
|
+
showEditor: PropTypes.bool,
|
|
124
|
+
mockData: PropTypes.object.isRequired,
|
|
125
|
+
addFields: PropTypes.object.isRequired,
|
|
126
|
+
showNewDate: PropTypes.bool,
|
|
127
|
+
mergeClassificationAndLabel: PropTypes.bool,
|
|
128
|
+
customTableConfigs: PropTypes.array,
|
|
129
|
+
menuConfig: PropTypes.oneOfType([
|
|
130
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
131
|
+
PropTypes.object
|
|
132
|
+
])
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Editor.defaultProps = {
|
|
136
|
+
onSave: _.noop,
|
|
137
|
+
showNewDate: false
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default Editor
|
package/src/editor/index.js
CHANGED
|
@@ -42,7 +42,8 @@ class Editor extends React.Component {
|
|
|
42
42
|
|
|
43
43
|
{showEditor && (
|
|
44
44
|
<div className='gm-printer-edit-zone'>
|
|
45
|
-
|
|
45
|
+
{/* 透传结款单每页合计标识给标题区,用于测试打印时走对应逻辑 */}
|
|
46
|
+
<EditorTitle onSave={onSave} isSomeSubtotalTr={isSomeSubtotalTr} />
|
|
46
47
|
<Gap height='10px' />
|
|
47
48
|
<EditorSelect />
|
|
48
49
|
<Gap height='5px' />
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import i18next from '../../locales'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import CommonContextMenu from '../common/common_context_menu'
|
|
5
|
+
import { inject, observer } from 'mobx-react'
|
|
6
|
+
import _ from 'lodash'
|
|
7
|
+
import { Printer } from '../printer'
|
|
8
|
+
|
|
9
|
+
const blockTypeList = [
|
|
10
|
+
{ value: '', text: i18next.t('插入文本') },
|
|
11
|
+
{ value: 'line', text: i18next.t('插入线条') },
|
|
12
|
+
{ value: 'image', text: i18next.t('插入图片') }
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
@inject(stores => ({
|
|
16
|
+
editStore: stores.editStore,
|
|
17
|
+
mockData: stores.mockData
|
|
18
|
+
}))
|
|
19
|
+
@observer
|
|
20
|
+
class ContextMenu extends React.Component {
|
|
21
|
+
isMenuItemEnabled = key => {
|
|
22
|
+
const { menuConfig } = this.props
|
|
23
|
+
if (!menuConfig) return true
|
|
24
|
+
if (Array.isArray(menuConfig)) return menuConfig.includes(key)
|
|
25
|
+
if (typeof menuConfig === 'object') return !!menuConfig[key]
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
hasSubtotalBtn = name => {
|
|
30
|
+
if (!name) return false
|
|
31
|
+
const arr = name.split('.')
|
|
32
|
+
if (!_.includes(arr, 'table')) return false
|
|
33
|
+
const dataKey = this.props.editStore.config.contents[arr[2]].dataKey
|
|
34
|
+
return dataKey === 'examiningDetail' || dataKey.startsWith('examiningDetail_')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
handleChangeTableDataKey = (key, name) => {
|
|
38
|
+
const { editStore } = this.props
|
|
39
|
+
editStore.changeTableDataKey(name, key)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
renderTableAction = name => {
|
|
43
|
+
if (!this.hasSubtotalBtn(name)) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const arr = name.split('.')
|
|
48
|
+
const { dataKey } = this.props.editStore.config.contents[arr[2]]
|
|
49
|
+
const keyArr = dataKey.split('_')
|
|
50
|
+
const isMultiActive = keyArr.includes('multi')
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{this.isMenuItemEnabled('multi') && (
|
|
55
|
+
<div
|
|
56
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
|
|
57
|
+
className={isMultiActive ? 'active' : ''}
|
|
58
|
+
>
|
|
59
|
+
{i18next.t('双栏商品')}
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
render() {
|
|
67
|
+
const { editStore, mockData } = this.props
|
|
68
|
+
return (
|
|
69
|
+
<CommonContextMenu
|
|
70
|
+
renderTableAction={this.renderTableAction}
|
|
71
|
+
insertBlockList={blockTypeList}
|
|
72
|
+
>
|
|
73
|
+
<Printer
|
|
74
|
+
key={editStore.computedPrinterKey}
|
|
75
|
+
selected={editStore.selected}
|
|
76
|
+
selectedRegion={editStore.selectedRegion}
|
|
77
|
+
config={editStore.config}
|
|
78
|
+
data={mockData}
|
|
79
|
+
/>
|
|
80
|
+
</CommonContextMenu>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ContextMenu.propTypes = {
|
|
86
|
+
editStore: PropTypes.object,
|
|
87
|
+
mockData: PropTypes.object,
|
|
88
|
+
menuConfig: PropTypes.oneOfType([
|
|
89
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
90
|
+
PropTypes.object
|
|
91
|
+
])
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default ContextMenu
|