gm-printer 10.34.0 → 10.35.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/.vscode/settings.json +8 -0
- package/build/demo.js +9 -9
- package/package.json +1 -1
- package/src/common/diy_summary_helper.js +223 -0
- package/src/common/editor_edit_field.js +180 -4
- package/src/common/editor_store.js +270 -15
- package/src/editor/context_menu.js +81 -2
- package/src/printer/store.js +16 -2
- package/src/printer/table.js +95 -8
- package/src/printer/table_diy_overallOrder_tr.js +110 -39
- package/src/printer/table_diy_summary_tr.js +127 -0
- package/src/util.js +42 -0
|
@@ -5,6 +5,7 @@ import _ from 'lodash'
|
|
|
5
5
|
import { dispatchMsg, getBlockName, exchange, getColSpanLength } from '../util'
|
|
6
6
|
import { accountRadioList } from './util'
|
|
7
7
|
import React from 'react'
|
|
8
|
+
import { createDiySummaryStoreMethods } from './diy_summary_helper'
|
|
8
9
|
|
|
9
10
|
class EditorStore {
|
|
10
11
|
@observable
|
|
@@ -785,7 +786,8 @@ class EditorStore {
|
|
|
785
786
|
valueField: '{{列.出库金额}}',
|
|
786
787
|
style: {
|
|
787
788
|
fontWeight: 'bold'
|
|
788
|
-
}
|
|
789
|
+
},
|
|
790
|
+
rightName: '自定义整单合计:'
|
|
789
791
|
}
|
|
790
792
|
]
|
|
791
793
|
}
|
|
@@ -804,14 +806,17 @@ class EditorStore {
|
|
|
804
806
|
}
|
|
805
807
|
|
|
806
808
|
@action
|
|
807
|
-
changeTableDataKey(name, key) {
|
|
809
|
+
changeTableDataKey(name, key, options = {}) {
|
|
808
810
|
const arr = name.split('.')
|
|
811
|
+
const table = this.config.contents[arr[2]]
|
|
809
812
|
const {
|
|
810
813
|
dataKey,
|
|
811
814
|
overallOrder,
|
|
812
815
|
subtotal,
|
|
813
|
-
diyOverallOrder
|
|
814
|
-
|
|
816
|
+
diyOverallOrder,
|
|
817
|
+
diyCategorySubtotal,
|
|
818
|
+
diyTagSubtotal
|
|
819
|
+
} = table
|
|
815
820
|
const keyArr = dataKey.split('_')
|
|
816
821
|
let newDataKey
|
|
817
822
|
// 当前有这个key则去掉
|
|
@@ -827,19 +832,54 @@ class EditorStore {
|
|
|
827
832
|
newDataKey = _.without(newDataKey, 'multi3')
|
|
828
833
|
}
|
|
829
834
|
// 标签小计和分类小计互斥
|
|
830
|
-
if (
|
|
831
|
-
newDataKey
|
|
832
|
-
|
|
833
|
-
|
|
835
|
+
if (
|
|
836
|
+
newDataKey.includes('category') &&
|
|
837
|
+
(key === 'tag' || key === 'tagDiy')
|
|
838
|
+
) {
|
|
839
|
+
newDataKey = _.without(newDataKey, 'category', 'categoryDiy')
|
|
840
|
+
|
|
841
|
+
if (diyCategorySubtotal?.show) {
|
|
842
|
+
set(diyCategorySubtotal, { show: false })
|
|
843
|
+
set(table, { isDiyCategorySubtotal: false })
|
|
844
|
+
}
|
|
845
|
+
} else if (
|
|
846
|
+
newDataKey.includes('tag') &&
|
|
847
|
+
(key === 'category' || key === 'categoryDiy')
|
|
848
|
+
) {
|
|
849
|
+
newDataKey = _.without(newDataKey, 'tag', 'tagDiy')
|
|
850
|
+
|
|
851
|
+
if (diyTagSubtotal?.show) {
|
|
852
|
+
set(diyTagSubtotal, { show: false })
|
|
853
|
+
set(table, { isDiyTagSubtotal: false })
|
|
854
|
+
}
|
|
834
855
|
}
|
|
835
856
|
// 标签小计和商品分类互斥
|
|
836
|
-
if (
|
|
857
|
+
if (
|
|
858
|
+
newDataKey.includes('newCategory') &&
|
|
859
|
+
(key === 'tag' || key === 'tagDiy')
|
|
860
|
+
) {
|
|
837
861
|
newDataKey = _.without(newDataKey, 'newCategory')
|
|
838
|
-
} else if (
|
|
839
|
-
newDataKey
|
|
862
|
+
} else if (
|
|
863
|
+
(newDataKey.includes('tag') || newDataKey.includes('tagDiy')) &&
|
|
864
|
+
key === 'newCategory'
|
|
865
|
+
) {
|
|
866
|
+
newDataKey = _.without(newDataKey, 'tag', 'tagDiy')
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (newDataKey.includes('categoryDiy')) {
|
|
870
|
+
this.setDiyCategorySubtotalShow(name, true)
|
|
871
|
+
} else {
|
|
872
|
+
this.setDiyCategorySubtotalShow(name, false)
|
|
873
|
+
}
|
|
874
|
+
if (newDataKey.includes('tagDiy')) {
|
|
875
|
+
this.setDiyTagSubtotalShow(name, true)
|
|
876
|
+
} else {
|
|
877
|
+
this.setDiyTagSubtotalShow(name, false)
|
|
840
878
|
}
|
|
841
879
|
|
|
842
880
|
newDataKey = _.sortBy(newDataKey, [
|
|
881
|
+
o => o === 'tagDiy',
|
|
882
|
+
o => o === 'categoryDiy',
|
|
843
883
|
o => o === 'tag',
|
|
844
884
|
o => o === 'multi3',
|
|
845
885
|
o => o === 'multi',
|
|
@@ -849,6 +889,7 @@ class EditorStore {
|
|
|
849
889
|
])
|
|
850
890
|
|
|
851
891
|
this.config.contents[arr[2]].dataKey = newDataKey.join('_')
|
|
892
|
+
|
|
852
893
|
// 整单合计不显示
|
|
853
894
|
if (overallOrder?.show) overallOrder.show = false
|
|
854
895
|
// 每页合计不显示
|
|
@@ -1980,7 +2021,7 @@ class EditorStore {
|
|
|
1980
2021
|
|
|
1981
2022
|
// 整单合计自定义单元格文本输入
|
|
1982
2023
|
@action.bound
|
|
1983
|
-
setDiyOverallOrderFields(value) {
|
|
2024
|
+
setDiyOverallOrderFields(value, fieldIndex = 0) {
|
|
1984
2025
|
if (this.selectedRegion) {
|
|
1985
2026
|
this.overallOrderShow = !this.overallOrderShow
|
|
1986
2027
|
const arr = this.selectedRegion.split('.')
|
|
@@ -1988,9 +2029,15 @@ class EditorStore {
|
|
|
1988
2029
|
const diyOverallOrderConfig = table?.diyOverallOrder
|
|
1989
2030
|
|
|
1990
2031
|
const oldValueField = diyOverallOrderConfig.fields?.[0]
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2032
|
+
if (fieldIndex === 0) {
|
|
2033
|
+
set(oldValueField, {
|
|
2034
|
+
name: value
|
|
2035
|
+
})
|
|
2036
|
+
} else if (fieldIndex === 1) {
|
|
2037
|
+
set(oldValueField, {
|
|
2038
|
+
rightName: value
|
|
2039
|
+
})
|
|
2040
|
+
}
|
|
1994
2041
|
}
|
|
1995
2042
|
}
|
|
1996
2043
|
|
|
@@ -2051,6 +2098,214 @@ class EditorStore {
|
|
|
2051
2098
|
this.setAutoFillingConfig(false)
|
|
2052
2099
|
}
|
|
2053
2100
|
}
|
|
2101
|
+
|
|
2102
|
+
// ========== 自定义每页合计方法 ==========
|
|
2103
|
+
@action.bound
|
|
2104
|
+
setDiySubtotalShow(name) {
|
|
2105
|
+
const methods = createDiySummaryStoreMethods(
|
|
2106
|
+
'diySubtotal',
|
|
2107
|
+
'自定义每页合计'
|
|
2108
|
+
)
|
|
2109
|
+
return methods.setDiySubtotalShow.call(this, name)
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
@action.bound
|
|
2113
|
+
setDiySubtotalStyle(value) {
|
|
2114
|
+
const methods = createDiySummaryStoreMethods(
|
|
2115
|
+
'diySubtotal',
|
|
2116
|
+
'自定义每页合计'
|
|
2117
|
+
)
|
|
2118
|
+
return methods.setDiySubtotalStyle.call(this, value)
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
@action.bound
|
|
2122
|
+
setDiySubtotalUpperCase() {
|
|
2123
|
+
const methods = createDiySummaryStoreMethods(
|
|
2124
|
+
'diySubtotal',
|
|
2125
|
+
'自定义每页合计'
|
|
2126
|
+
)
|
|
2127
|
+
return methods.setDiySubtotalUpperCase.call(this)
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
@action.bound
|
|
2131
|
+
setDiySubtotalUpperCaseBefore() {
|
|
2132
|
+
const methods = createDiySummaryStoreMethods(
|
|
2133
|
+
'diySubtotal',
|
|
2134
|
+
'自定义每页合计'
|
|
2135
|
+
)
|
|
2136
|
+
return methods.setDiySubtotalUpperCaseBefore.call(this)
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
@action.bound
|
|
2140
|
+
setDiySubtotalUpperLowerCaseSeparate() {
|
|
2141
|
+
const methods = createDiySummaryStoreMethods(
|
|
2142
|
+
'diySubtotal',
|
|
2143
|
+
'自定义每页合计'
|
|
2144
|
+
)
|
|
2145
|
+
return methods.setDiySubtotalUpperLowerCaseSeparate.call(this)
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
@action.bound
|
|
2149
|
+
setDiySubtotalValueField(value) {
|
|
2150
|
+
const methods = createDiySummaryStoreMethods(
|
|
2151
|
+
'diySubtotal',
|
|
2152
|
+
'自定义每页合计'
|
|
2153
|
+
)
|
|
2154
|
+
return methods.setDiySubtotalValueField.call(this, value)
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
@action.bound
|
|
2158
|
+
setDiySubtotalFields(value, fieldIndex = 0) {
|
|
2159
|
+
const methods = createDiySummaryStoreMethods(
|
|
2160
|
+
'diySubtotal',
|
|
2161
|
+
'自定义每页合计'
|
|
2162
|
+
)
|
|
2163
|
+
return methods.setDiySubtotalFields.call(this, value, fieldIndex)
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
// ========== 自定义分类小计方法 ==========
|
|
2167
|
+
@action.bound
|
|
2168
|
+
setDiyCategorySubtotalShow(name, show) {
|
|
2169
|
+
const methods = createDiySummaryStoreMethods(
|
|
2170
|
+
'diyCategorySubtotal',
|
|
2171
|
+
'自定义分类小计'
|
|
2172
|
+
)
|
|
2173
|
+
methods.setDiyCategorySubtotalShow.call(this, name, show)
|
|
2174
|
+
|
|
2175
|
+
if (this.selectedRegion) {
|
|
2176
|
+
const arr = this.selectedRegion.split('.')
|
|
2177
|
+
const table = this.config.contents[arr[2]]
|
|
2178
|
+
if (table?.diyCategorySubtotal?.show && table?.diyTagSubtotal?.show) {
|
|
2179
|
+
set(table.diyTagSubtotal, { show: false })
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
@action.bound
|
|
2185
|
+
setDiyCategorySubtotalStyle(value) {
|
|
2186
|
+
const methods = createDiySummaryStoreMethods(
|
|
2187
|
+
'diyCategorySubtotal',
|
|
2188
|
+
'自定义分类小计'
|
|
2189
|
+
)
|
|
2190
|
+
return methods.setDiyCategorySubtotalStyle.call(this, value)
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
@action.bound
|
|
2194
|
+
setDiyCategorySubtotalUpperCase() {
|
|
2195
|
+
const methods = createDiySummaryStoreMethods(
|
|
2196
|
+
'diyCategorySubtotal',
|
|
2197
|
+
'自定义分类小计'
|
|
2198
|
+
)
|
|
2199
|
+
return methods.setDiyCategorySubtotalUpperCase.call(this)
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
@action.bound
|
|
2203
|
+
setDiyCategorySubtotalUpperCaseBefore() {
|
|
2204
|
+
const methods = createDiySummaryStoreMethods(
|
|
2205
|
+
'diyCategorySubtotal',
|
|
2206
|
+
'自定义分类小计'
|
|
2207
|
+
)
|
|
2208
|
+
return methods.setDiyCategorySubtotalUpperCaseBefore.call(this)
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
@action.bound
|
|
2212
|
+
setDiyCategorySubtotalUpperLowerCaseSeparate() {
|
|
2213
|
+
const methods = createDiySummaryStoreMethods(
|
|
2214
|
+
'diyCategorySubtotal',
|
|
2215
|
+
'自定义分类小计'
|
|
2216
|
+
)
|
|
2217
|
+
return methods.setDiyCategorySubtotalUpperLowerCaseSeparate.call(this)
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
@action.bound
|
|
2221
|
+
setDiyCategorySubtotalValueField(value) {
|
|
2222
|
+
const methods = createDiySummaryStoreMethods(
|
|
2223
|
+
'diyCategorySubtotal',
|
|
2224
|
+
'自定义分类小计'
|
|
2225
|
+
)
|
|
2226
|
+
return methods.setDiyCategorySubtotalValueField.call(this, value)
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
@action.bound
|
|
2230
|
+
setDiyCategorySubtotalFields(value, fieldIndex = 0) {
|
|
2231
|
+
const methods = createDiySummaryStoreMethods(
|
|
2232
|
+
'diyCategorySubtotal',
|
|
2233
|
+
'自定义分类小计'
|
|
2234
|
+
)
|
|
2235
|
+
return methods.setDiyCategorySubtotalFields.call(this, value, fieldIndex)
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// ========== 自定义标签小计方法 ==========
|
|
2239
|
+
@action.bound
|
|
2240
|
+
setDiyTagSubtotalShow(name, show) {
|
|
2241
|
+
const methods = createDiySummaryStoreMethods(
|
|
2242
|
+
'diyTagSubtotal',
|
|
2243
|
+
'自定义标签小计'
|
|
2244
|
+
)
|
|
2245
|
+
methods.setDiyTagSubtotalShow.call(this, name, show)
|
|
2246
|
+
|
|
2247
|
+
if (this.selectedRegion) {
|
|
2248
|
+
const arr = this.selectedRegion.split('.')
|
|
2249
|
+
const table = this.config.contents[arr[2]]
|
|
2250
|
+
if (table?.diyTagSubtotal?.show && table?.diyCategorySubtotal?.show) {
|
|
2251
|
+
set(table.diyCategorySubtotal, { show: false })
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
@action.bound
|
|
2257
|
+
setDiyTagSubtotalStyle(value) {
|
|
2258
|
+
const methods = createDiySummaryStoreMethods(
|
|
2259
|
+
'diyTagSubtotal',
|
|
2260
|
+
'自定义标签小计'
|
|
2261
|
+
)
|
|
2262
|
+
return methods.setDiyTagSubtotalStyle.call(this, value)
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
@action.bound
|
|
2266
|
+
setDiyTagSubtotalUpperCase() {
|
|
2267
|
+
const methods = createDiySummaryStoreMethods(
|
|
2268
|
+
'diyTagSubtotal',
|
|
2269
|
+
'自定义标签小计'
|
|
2270
|
+
)
|
|
2271
|
+
return methods.setDiyTagSubtotalUpperCase.call(this)
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
@action.bound
|
|
2275
|
+
setDiyTagSubtotalUpperCaseBefore() {
|
|
2276
|
+
const methods = createDiySummaryStoreMethods(
|
|
2277
|
+
'diyTagSubtotal',
|
|
2278
|
+
'自定义标签小计'
|
|
2279
|
+
)
|
|
2280
|
+
return methods.setDiyTagSubtotalUpperCaseBefore.call(this)
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
@action.bound
|
|
2284
|
+
setDiyTagSubtotalUpperLowerCaseSeparate() {
|
|
2285
|
+
const methods = createDiySummaryStoreMethods(
|
|
2286
|
+
'diyTagSubtotal',
|
|
2287
|
+
'自定义标签小计'
|
|
2288
|
+
)
|
|
2289
|
+
return methods.setDiyTagSubtotalUpperLowerCaseSeparate.call(this)
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
@action.bound
|
|
2293
|
+
setDiyTagSubtotalValueField(value) {
|
|
2294
|
+
const methods = createDiySummaryStoreMethods(
|
|
2295
|
+
'diyTagSubtotal',
|
|
2296
|
+
'自定义标签小计'
|
|
2297
|
+
)
|
|
2298
|
+
return methods.setDiyTagSubtotalValueField.call(this, value)
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
@action.bound
|
|
2302
|
+
setDiyTagSubtotalFields(value, fieldIndex = 0) {
|
|
2303
|
+
const methods = createDiySummaryStoreMethods(
|
|
2304
|
+
'diyTagSubtotal',
|
|
2305
|
+
'自定义标签小计'
|
|
2306
|
+
)
|
|
2307
|
+
return methods.setDiyTagSubtotalFields.call(this, value, fieldIndex)
|
|
2308
|
+
}
|
|
2054
2309
|
}
|
|
2055
2310
|
|
|
2056
2311
|
export default EditorStore
|
|
@@ -100,6 +100,43 @@ class ContextMenu extends React.Component {
|
|
|
100
100
|
editStore.setDiyOverallOrderShow(name)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
// 通用的自定义合计菜单项处理
|
|
104
|
+
handleDiySummary = (name, configKey) => {
|
|
105
|
+
const { editStore } = this.props
|
|
106
|
+
const methodName = configKey
|
|
107
|
+
.split(/(?=[A-Z])/)
|
|
108
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
109
|
+
.join('')
|
|
110
|
+
|
|
111
|
+
const method = editStore[`set${methodName}Show`]
|
|
112
|
+
|
|
113
|
+
if (configKey === 'diyCategorySubtotal') {
|
|
114
|
+
const arr = name.split('.')
|
|
115
|
+
const dataKey = editStore.config.contents[arr[2]].dataKey
|
|
116
|
+
console.log('dataKey==> handleDiySummary', dataKey)
|
|
117
|
+
|
|
118
|
+
if (!dataKey.split('_').includes('category')) {
|
|
119
|
+
editStore.changeTableDataKey(name, 'category', {
|
|
120
|
+
type: 'diyCategorySubtotal'
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (configKey === 'diyTagSubtotal') {
|
|
125
|
+
const arr = name.split('.')
|
|
126
|
+
const dataKey = editStore.config.contents[arr[2]].dataKey
|
|
127
|
+
console.log('dataKey==> handleDiySummary', dataKey)
|
|
128
|
+
|
|
129
|
+
if (!dataKey.split('_').includes('tag')) {
|
|
130
|
+
editStore.changeTableDataKey(name, 'tag', {
|
|
131
|
+
type: 'diyTagSubtotal'
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (method) {
|
|
136
|
+
method(name)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
103
140
|
renderOrderActionBtn = name => {
|
|
104
141
|
if (!this.hasSubtotalBtn(name)) {
|
|
105
142
|
return null
|
|
@@ -119,7 +156,10 @@ class ContextMenu extends React.Component {
|
|
|
119
156
|
dataKey,
|
|
120
157
|
subtotal,
|
|
121
158
|
overallOrder,
|
|
122
|
-
|
|
159
|
+
diySubtotal,
|
|
160
|
+
diyTagSubtotal,
|
|
161
|
+
diyOverallOrder,
|
|
162
|
+
diyCategorySubtotal
|
|
123
163
|
} = this.props.editStore.config.contents[arr[2]]
|
|
124
164
|
const keyArr = dataKey.split('_')
|
|
125
165
|
|
|
@@ -131,6 +171,10 @@ class ContextMenu extends React.Component {
|
|
|
131
171
|
const isSubtotalActive = subtotal.show
|
|
132
172
|
const isOverallOrder = overallOrder?.show
|
|
133
173
|
const isDiyOverallOrder = diyOverallOrder?.show
|
|
174
|
+
const isDiySubtotal = diySubtotal?.show
|
|
175
|
+
const isDiyTagSubtotal = diyTagSubtotal?.show
|
|
176
|
+
const isDiyCategorySubtotal = diyCategorySubtotal?.show
|
|
177
|
+
|
|
134
178
|
// 长条打印
|
|
135
179
|
const isLongPrint = type === LONG_PRINT
|
|
136
180
|
|
|
@@ -154,17 +198,46 @@ class ContextMenu extends React.Component {
|
|
|
154
198
|
</div>
|
|
155
199
|
)}
|
|
156
200
|
<div
|
|
157
|
-
onClick={this.handleChangeTableDataKey.bind(
|
|
201
|
+
onClick={this.handleChangeTableDataKey.bind(
|
|
202
|
+
this,
|
|
203
|
+
'category',
|
|
204
|
+
name,
|
|
205
|
+
isCategoryActive
|
|
206
|
+
)}
|
|
158
207
|
className={isCategoryActive ? 'active' : ''}
|
|
159
208
|
>
|
|
160
209
|
{i18next.t('分类小计')}
|
|
161
210
|
</div>
|
|
211
|
+
<div
|
|
212
|
+
// onClick={() =>
|
|
213
|
+
// this.handleDiySummary(
|
|
214
|
+
// name,
|
|
215
|
+
// 'diyCategorySubtotal',
|
|
216
|
+
// isDiyCategorySubtotal
|
|
217
|
+
// )
|
|
218
|
+
// }
|
|
219
|
+
onClick={this.handleChangeTableDataKey.bind(
|
|
220
|
+
this,
|
|
221
|
+
'categoryDiy',
|
|
222
|
+
name
|
|
223
|
+
)}
|
|
224
|
+
className={isDiyCategorySubtotal ? 'active' : ''}
|
|
225
|
+
>
|
|
226
|
+
{i18next.t('自定义分类小计')}
|
|
227
|
+
</div>
|
|
162
228
|
<div
|
|
163
229
|
onClick={this.handleChangeTableDataKey.bind(this, 'tag', name)}
|
|
164
230
|
className={isTagActive ? 'active' : ''}
|
|
165
231
|
>
|
|
166
232
|
{i18next.t('标签小计')}
|
|
167
233
|
</div>
|
|
234
|
+
<div
|
|
235
|
+
// onClick={() => this.handleDiySummary(name, 'diyTagSubtotal')}
|
|
236
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'tagDiy', name)}
|
|
237
|
+
className={isDiyTagSubtotal ? 'active' : ''}
|
|
238
|
+
>
|
|
239
|
+
{i18next.t('自定义标签小计')}
|
|
240
|
+
</div>
|
|
168
241
|
<div
|
|
169
242
|
onClick={this.handleCategoryConfig.bind(this, 'newCategory', name)}
|
|
170
243
|
className={isNewCategoryActive ? 'active' : ''}
|
|
@@ -177,6 +250,12 @@ class ContextMenu extends React.Component {
|
|
|
177
250
|
>
|
|
178
251
|
{i18next.t('每页合计')}
|
|
179
252
|
</div>
|
|
253
|
+
<div
|
|
254
|
+
onClick={() => this.handleDiySummary(name, 'diySubtotal')}
|
|
255
|
+
className={isDiySubtotal ? 'active' : ''}
|
|
256
|
+
>
|
|
257
|
+
{i18next.t('自定义每页合计')}
|
|
258
|
+
</div>
|
|
180
259
|
<div
|
|
181
260
|
onClick={this.handleChangeTableData.bind(this, !isAutoFilling)}
|
|
182
261
|
className={isAutoFilling ? 'active' : ''}
|
package/src/printer/store.js
CHANGED
|
@@ -294,7 +294,13 @@ class PrinterStore {
|
|
|
294
294
|
tableCount++
|
|
295
295
|
// 表格原始的高度和宽度信息
|
|
296
296
|
const table = this.tablesInfo[`contents.table.${index}`]
|
|
297
|
-
const {
|
|
297
|
+
const {
|
|
298
|
+
subtotal,
|
|
299
|
+
dataKey,
|
|
300
|
+
summaryConfig,
|
|
301
|
+
overallOrder,
|
|
302
|
+
diySubtotal
|
|
303
|
+
} = content
|
|
298
304
|
// 如果显示每页合计,那么table高度多预留一行高度
|
|
299
305
|
const subtotalTrHeight = subtotal.show ? getSumTrHeight(subtotal) : 0
|
|
300
306
|
// 如果显示整单合计,那么table高度多预留一行高度
|
|
@@ -306,12 +312,20 @@ class PrinterStore {
|
|
|
306
312
|
summaryConfig?.pageSummaryShow && !isMultiTable(dataKey) // 双栏table没有每页合计
|
|
307
313
|
? getSumTrHeight(summaryConfig)
|
|
308
314
|
: 0
|
|
315
|
+
|
|
316
|
+
// 如果显示自定义每页合计,那么table高度多预留一行高度
|
|
317
|
+
const diySubtotalTrHeight = diySubtotal?.show
|
|
318
|
+
? getOverallOrderTrHeight(diySubtotal) // 使用相同的计算方式
|
|
319
|
+
: 0
|
|
320
|
+
|
|
309
321
|
// 每个表格都具有的高度
|
|
310
322
|
const allTableHaveThisHeight =
|
|
311
323
|
table.head.height +
|
|
312
324
|
subtotalTrHeight +
|
|
313
325
|
pageSummaryTrHeight +
|
|
314
|
-
overallOrderTrHeight
|
|
326
|
+
overallOrderTrHeight +
|
|
327
|
+
diySubtotalTrHeight
|
|
328
|
+
|
|
315
329
|
/** 当前page页面的最小高度 */
|
|
316
330
|
const currentPageMinimumHeight =
|
|
317
331
|
allPagesHaveThisHeight + allTableHaveThisHeight
|
package/src/printer/table.js
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
getMultiNumber,
|
|
9
9
|
getTableColumnName,
|
|
10
10
|
getWidth,
|
|
11
|
-
isMultiTable
|
|
11
|
+
isMultiTable,
|
|
12
|
+
collectGroups
|
|
12
13
|
} from '../util'
|
|
13
14
|
import { inject, observer } from 'mobx-react'
|
|
14
15
|
import classNames from 'classnames'
|
|
@@ -19,6 +20,7 @@ import SubtotalTr from './table_subtotal_tr'
|
|
|
19
20
|
import PageSummary from './page_summary'
|
|
20
21
|
import OverallOrder from './table_overallOrder_tr'
|
|
21
22
|
import DiyOverallOrder from './table_diy_overallOrder_tr'
|
|
23
|
+
import DiySummary from './table_diy_summary_tr'
|
|
22
24
|
// import { toJS } from 'mobx'
|
|
23
25
|
|
|
24
26
|
@inject('printerStore')
|
|
@@ -171,6 +173,7 @@ class Table extends React.Component {
|
|
|
171
173
|
} = this.props
|
|
172
174
|
// 数据
|
|
173
175
|
dataKey = getDataKey(dataKey, arrange)
|
|
176
|
+
|
|
174
177
|
const tableData = printerStore.data._table[dataKey] || []
|
|
175
178
|
// 列
|
|
176
179
|
const columns = this.getColumns()
|
|
@@ -234,6 +237,14 @@ class Table extends React.Component {
|
|
|
234
237
|
return col.head
|
|
235
238
|
}
|
|
236
239
|
|
|
240
|
+
const needDiyCategory = dataKey.includes('categoryDiy')
|
|
241
|
+
const diyCategoryGroups = needDiyCategory
|
|
242
|
+
? collectGroups(tableData, range)
|
|
243
|
+
: []
|
|
244
|
+
|
|
245
|
+
const needDiyTag = config.diyTagSubtotal?.show && dataKey.includes('tagDiy')
|
|
246
|
+
const diyTagGroups = needDiyTag ? collectGroups(tableData, range) : []
|
|
247
|
+
|
|
237
248
|
return (
|
|
238
249
|
<table
|
|
239
250
|
style={{
|
|
@@ -272,14 +283,76 @@ class Table extends React.Component {
|
|
|
272
283
|
|
|
273
284
|
<tbody>
|
|
274
285
|
{_.map(_.range(range.begin, range.end), i => {
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
const
|
|
286
|
+
const row = tableData[i]
|
|
287
|
+
const _special = row && row._special
|
|
288
|
+
const _specialText = row && row._specialText
|
|
289
|
+
const _customTr = row && row._customTr
|
|
290
|
+
const _diyCategorySubtotal = row && row._diyCategorySubtotal
|
|
291
|
+
const _diyTagSubtotal = row && row._diyTagSubtotal
|
|
292
|
+
|
|
293
|
+
if (_specialText) {
|
|
294
|
+
return (
|
|
295
|
+
<CategoryTr
|
|
296
|
+
key={`category_${i}`}
|
|
297
|
+
config={config}
|
|
298
|
+
data={_specialText}
|
|
299
|
+
/>
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
if (_special) {
|
|
303
|
+
return (
|
|
304
|
+
<SpecialTr
|
|
305
|
+
key={`special_${i}`}
|
|
306
|
+
config={config}
|
|
307
|
+
data={_special}
|
|
308
|
+
/>
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
// 分类小计 & 自定义分类小计
|
|
312
|
+
if (_diyCategorySubtotal) {
|
|
313
|
+
const groupInfo = diyCategoryGroups.find(
|
|
314
|
+
g => g.specialIndex === i
|
|
315
|
+
)
|
|
278
316
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
317
|
+
if (groupInfo && printerStore?.ready) {
|
|
318
|
+
return (
|
|
319
|
+
<DiySummary
|
|
320
|
+
key={`diy_category_${i}`}
|
|
321
|
+
configKey='diyCategorySubtotal'
|
|
322
|
+
config={config}
|
|
323
|
+
printerStore={printerStore}
|
|
324
|
+
pageIndex={pageIndex}
|
|
325
|
+
range={{ begin: groupInfo.begin, end: groupInfo.end }}
|
|
326
|
+
getTableData={(store, key, arrange) => {
|
|
327
|
+
const all =
|
|
328
|
+
store.data._table[getDataKey(key, arrange)] || []
|
|
329
|
+
return all.slice(groupInfo.begin, groupInfo.end)
|
|
330
|
+
}}
|
|
331
|
+
/>
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (_diyTagSubtotal) {
|
|
337
|
+
const groupInfo = diyTagGroups.find(g => g.specialIndex === i)
|
|
338
|
+
|
|
339
|
+
if (groupInfo && printerStore?.ready) {
|
|
340
|
+
return (
|
|
341
|
+
<DiySummary
|
|
342
|
+
key={`diy_tag_${i}`}
|
|
343
|
+
configKey='diyTagSubtotal'
|
|
344
|
+
config={config}
|
|
345
|
+
printerStore={printerStore}
|
|
346
|
+
range={{ begin: groupInfo.begin, end: groupInfo.end }}
|
|
347
|
+
getTableData={(store, key, arrange) => {
|
|
348
|
+
const all =
|
|
349
|
+
store.data._table[getDataKey(key, arrange)] || []
|
|
350
|
+
return all.slice(groupInfo.begin, groupInfo.end)
|
|
351
|
+
}}
|
|
352
|
+
/>
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
283
356
|
|
|
284
357
|
if (_customTr) {
|
|
285
358
|
return <tr dangerouslySetInnerHTML={{ __html: _customTr }} />
|
|
@@ -354,6 +427,20 @@ class Table extends React.Component {
|
|
|
354
427
|
{this.props.config.subtotal.isCommutationPlace
|
|
355
428
|
? PageSummarySubtotalTr()
|
|
356
429
|
: subtotalTrPageSummary()}
|
|
430
|
+
{/* 自定义每页合计 */}
|
|
431
|
+
<DiySummary
|
|
432
|
+
key={`diy_subtotal_${pageIndex}`}
|
|
433
|
+
configKey='diySubtotal'
|
|
434
|
+
config={config}
|
|
435
|
+
printerStore={printerStore}
|
|
436
|
+
range={range}
|
|
437
|
+
pageIndex={pageIndex}
|
|
438
|
+
getTableData={(store, key, arrange, range) => {
|
|
439
|
+
const tableData =
|
|
440
|
+
store.data._table[getDataKey(key, arrange)] || []
|
|
441
|
+
return tableData.slice(range.begin, range.end)
|
|
442
|
+
}}
|
|
443
|
+
/>
|
|
357
444
|
<OverallOrder
|
|
358
445
|
range={range}
|
|
359
446
|
config={config}
|