gm-printer 10.14.1 → 10.14.2-alpha.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/.eslintcache +1 -1
- package/package.json +1 -1
- package/src/common/editor_edit_field.js +86 -4
- package/src/common/editor_store.js +194 -6
- package/src/components/flex/index.js +72 -43
- package/src/components/flex/style.less +5 -1
- package/src/editor/context_menu.js +18 -2
- package/src/printer/printer.js +5 -1
- package/src/printer/store.js +16 -3
- package/src/printer/style.lesss +3 -0
- package/src/printer/table.js +6 -0
- package/src/printer/table_overallOrder_tr.js +63 -0
- package/src/printer/table_subtotal_tr.js +0 -1
- package/src/util.js +22 -1
- package/yarn-error.log +9663 -0
- package/build/demo.js +0 -54
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
align-items: stretch;
|
|
20
20
|
box-sizing: border-box;
|
|
21
21
|
|
|
22
|
+
&.gm-flex-grow {
|
|
23
|
+
flex-grow: 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
&.gm-flex-wrap {
|
|
23
27
|
flex-wrap: wrap;
|
|
24
28
|
}
|
|
@@ -98,4 +102,4 @@
|
|
|
98
102
|
&.gm-flex-align-content-stretch {
|
|
99
103
|
align-content: stretch;
|
|
100
104
|
}
|
|
101
|
-
}
|
|
105
|
+
}
|
|
@@ -61,7 +61,6 @@ class ContextMenu extends React.Component {
|
|
|
61
61
|
|
|
62
62
|
handleSubtotal = name => {
|
|
63
63
|
const { editStore } = this.props
|
|
64
|
-
|
|
65
64
|
editStore.setSubtotalShow(name)
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -70,6 +69,11 @@ class ContextMenu extends React.Component {
|
|
|
70
69
|
editStore.handleChangeTableData(isAutoFilling)
|
|
71
70
|
}
|
|
72
71
|
|
|
72
|
+
handleOverallOrder = name => {
|
|
73
|
+
const { editStore } = this.props
|
|
74
|
+
editStore.setOverallOrderShow(name)
|
|
75
|
+
}
|
|
76
|
+
|
|
73
77
|
renderOrderActionBtn = name => {
|
|
74
78
|
if (!this.hasSubtotalBtn(name)) {
|
|
75
79
|
return null
|
|
@@ -84,13 +88,18 @@ class ContextMenu extends React.Component {
|
|
|
84
88
|
}
|
|
85
89
|
} = this.props
|
|
86
90
|
const arr = name.split('.')
|
|
87
|
-
const {
|
|
91
|
+
const {
|
|
92
|
+
dataKey,
|
|
93
|
+
subtotal,
|
|
94
|
+
overallOrder
|
|
95
|
+
} = this.props.editStore.config.contents[arr[2]]
|
|
88
96
|
const keyArr = dataKey.split('_')
|
|
89
97
|
|
|
90
98
|
const isMultiActive = keyArr.includes('multi')
|
|
91
99
|
const isThreeActive = keyArr.includes('multi3')
|
|
92
100
|
const isCategoryActive = keyArr.includes('category')
|
|
93
101
|
const isSubtotalActive = subtotal.show
|
|
102
|
+
const isOverallOrder = overallOrder?.show
|
|
94
103
|
|
|
95
104
|
return (
|
|
96
105
|
<>
|
|
@@ -127,6 +136,12 @@ class ContextMenu extends React.Component {
|
|
|
127
136
|
>
|
|
128
137
|
{i18next.t('行数填充')}
|
|
129
138
|
</div>
|
|
139
|
+
<div
|
|
140
|
+
onClick={this.handleOverallOrder.bind(this, name)}
|
|
141
|
+
className={isOverallOrder ? 'active' : ''}
|
|
142
|
+
>
|
|
143
|
+
{i18next.t('整单合计')}
|
|
144
|
+
</div>
|
|
130
145
|
</>
|
|
131
146
|
)
|
|
132
147
|
}
|
|
@@ -147,6 +162,7 @@ class ContextMenu extends React.Component {
|
|
|
147
162
|
config={editStore.config}
|
|
148
163
|
data={editStore.mockData}
|
|
149
164
|
getremainpageHeight={editStore.setRemainPageHeight}
|
|
165
|
+
overallorder={editStore.overallOrderShow}
|
|
150
166
|
/>
|
|
151
167
|
</CommonContextMenu>
|
|
152
168
|
)
|
package/src/printer/printer.js
CHANGED
|
@@ -81,6 +81,9 @@ class Printer extends React.Component {
|
|
|
81
81
|
this.props.printerStore.remainPageHeight
|
|
82
82
|
)
|
|
83
83
|
}
|
|
84
|
+
if (nextProps.overallorder !== this.props.overallorder) {
|
|
85
|
+
this.props.printerStore.setOverallOrder(nextProps.config)
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
componentDidMount() {
|
|
@@ -324,7 +327,8 @@ Printer.propTypes = {
|
|
|
324
327
|
config: PropTypes.object.isRequired,
|
|
325
328
|
onReady: PropTypes.func,
|
|
326
329
|
isSomeSubtotalTr: PropTypes.bool,
|
|
327
|
-
getremainpageHeight: PropTypes.func
|
|
330
|
+
getremainpageHeight: PropTypes.func,
|
|
331
|
+
overallorder: PropTypes.bool
|
|
328
332
|
}
|
|
329
333
|
|
|
330
334
|
Printer.defaultProps = {
|
package/src/printer/store.js
CHANGED
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
getSumTrHeight,
|
|
5
5
|
isMultiTable,
|
|
6
6
|
caclSingleDetailsPageHeight,
|
|
7
|
-
getArrayMid
|
|
7
|
+
getArrayMid,
|
|
8
|
+
getOverallOrderTrHeight
|
|
8
9
|
} from '../util'
|
|
9
10
|
import _ from 'lodash'
|
|
10
11
|
import Big from 'big.js'
|
|
@@ -169,6 +170,11 @@ class PrinterStore {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
@action
|
|
174
|
+
setOverallOrder(config) {
|
|
175
|
+
this.config = config || {}
|
|
176
|
+
}
|
|
177
|
+
|
|
172
178
|
@action
|
|
173
179
|
computedData(dataKey, table, end, currentRemainTableHeight) {
|
|
174
180
|
/** 当前数据 */
|
|
@@ -240,9 +246,13 @@ class PrinterStore {
|
|
|
240
246
|
tableCount++
|
|
241
247
|
// 表格原始的高度和宽度信息
|
|
242
248
|
const table = this.tablesInfo[`contents.table.${index}`]
|
|
243
|
-
const { subtotal, dataKey, summaryConfig } = content
|
|
249
|
+
const { subtotal, dataKey, summaryConfig, overallOrder } = content
|
|
244
250
|
// 如果显示每页合计,那么table高度多预留一行高度
|
|
245
251
|
const subtotalTrHeight = subtotal.show ? getSumTrHeight(subtotal) : 0
|
|
252
|
+
// 如果显示整单合计,那么table高度多预留一行高度
|
|
253
|
+
const overallOrderTrHeight = overallOrder?.show
|
|
254
|
+
? getOverallOrderTrHeight(overallOrder)
|
|
255
|
+
: 0
|
|
246
256
|
// 如果每页合计(新的),那么table高度多预留一行高度
|
|
247
257
|
const pageSummaryTrHeight =
|
|
248
258
|
summaryConfig?.pageSummaryShow && !isMultiTable(dataKey) // 双栏table没有每页合计
|
|
@@ -250,7 +260,10 @@ class PrinterStore {
|
|
|
250
260
|
: 0
|
|
251
261
|
// 每个表格都具有的高度
|
|
252
262
|
const allTableHaveThisHeight =
|
|
253
|
-
table.head.height +
|
|
263
|
+
table.head.height +
|
|
264
|
+
subtotalTrHeight +
|
|
265
|
+
pageSummaryTrHeight +
|
|
266
|
+
overallOrderTrHeight
|
|
254
267
|
/** 当前page页面的最小高度 */
|
|
255
268
|
const currentPageMinimumHeight =
|
|
256
269
|
allPagesHaveThisHeight + allTableHaveThisHeight
|
package/src/printer/style.lesss
CHANGED
package/src/printer/table.js
CHANGED
|
@@ -16,6 +16,7 @@ import { MULTI_SUFFIX } from '../config'
|
|
|
16
16
|
import SpecialTr from './table_special_tr'
|
|
17
17
|
import SubtotalTr from './table_subtotal_tr'
|
|
18
18
|
import PageSummary from './page_summary'
|
|
19
|
+
import OverallOrder from './table_overallOrder_tr'
|
|
19
20
|
|
|
20
21
|
@inject('printerStore')
|
|
21
22
|
@observer
|
|
@@ -290,6 +291,11 @@ class Table extends React.Component {
|
|
|
290
291
|
{this.props.config.subtotal.isCommutationPlace
|
|
291
292
|
? PageSummarySubtotalTr()
|
|
292
293
|
: subtotalTrPageSummary()}
|
|
294
|
+
<OverallOrder
|
|
295
|
+
range={range}
|
|
296
|
+
config={config}
|
|
297
|
+
printerStore={printerStore}
|
|
298
|
+
/>
|
|
293
299
|
</tbody>
|
|
294
300
|
</table>
|
|
295
301
|
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
// import Big from 'big.js'
|
|
5
|
+
import { coverDigit2Uppercase } from '../util'
|
|
6
|
+
import { observer } from 'mobx-react'
|
|
7
|
+
import { Flex } from '../components'
|
|
8
|
+
|
|
9
|
+
const OverallOrder = props => {
|
|
10
|
+
const {
|
|
11
|
+
config: { overallOrder },
|
|
12
|
+
// range,
|
|
13
|
+
printerStore,
|
|
14
|
+
printerStore: {
|
|
15
|
+
data: { common }
|
|
16
|
+
}
|
|
17
|
+
} = props
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
overallOrder?.show &&
|
|
21
|
+
printerStore?.ready && (
|
|
22
|
+
<tr>
|
|
23
|
+
{_.map(overallOrder.fields, (item, index) => {
|
|
24
|
+
return (
|
|
25
|
+
<td colSpan={item.colSpan} key={index}>
|
|
26
|
+
<Flex style={{ ...item.style, display: 'flex' }}>
|
|
27
|
+
{item.name}
|
|
28
|
+
<Flex
|
|
29
|
+
justifyBetween={overallOrder?.isUpperLowerCaseSeparate}
|
|
30
|
+
flexGrow={overallOrder?.isUpperLowerCaseSeparate}
|
|
31
|
+
>
|
|
32
|
+
<span
|
|
33
|
+
className={
|
|
34
|
+
overallOrder?.isUpperCaseBefore
|
|
35
|
+
? 'gm-printer-subtotal-isUpperCaseBefore-inter'
|
|
36
|
+
: ''
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
{common?.[item.valueField] ?? ''}
|
|
40
|
+
</span>
|
|
41
|
+
{overallOrder?.needUpperCase && (
|
|
42
|
+
<span>
|
|
43
|
+
{common?.[item.valueField]
|
|
44
|
+
? coverDigit2Uppercase(common[item.valueField])
|
|
45
|
+
: ''}
|
|
46
|
+
</span>
|
|
47
|
+
)}
|
|
48
|
+
</Flex>
|
|
49
|
+
</Flex>
|
|
50
|
+
</td>
|
|
51
|
+
)
|
|
52
|
+
})}
|
|
53
|
+
</tr>
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
OverallOrder.propTypes = {
|
|
58
|
+
config: PropTypes.object.isRequired,
|
|
59
|
+
range: PropTypes.object.isRequired,
|
|
60
|
+
printerStore: PropTypes.object
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default observer(OverallOrder)
|
package/src/util.js
CHANGED
|
@@ -108,6 +108,14 @@ function getSumTrHeight(SumTr) {
|
|
|
108
108
|
return (parseInt(fontSize) - 12) * 1.5 + 26
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
function getOverallOrderTrHeight(overallOrder) {
|
|
112
|
+
const { fields = [] } = overallOrder
|
|
113
|
+
const fontSize = fields?.[0]?.style?.fontSize || '12px'
|
|
114
|
+
|
|
115
|
+
// 12px => 26, 14px => 29, 16px => 33, ...
|
|
116
|
+
return (parseInt(fontSize) - 12) * 1.5 + 26
|
|
117
|
+
}
|
|
118
|
+
|
|
111
119
|
// eslint-disable-next-line
|
|
112
120
|
const coverDigit2Uppercase = n => {
|
|
113
121
|
if (_.isNil(n) || _.isNaN(n)) {
|
|
@@ -274,6 +282,17 @@ const getArrayMid = arr => {
|
|
|
274
282
|
return majority
|
|
275
283
|
}
|
|
276
284
|
|
|
285
|
+
/**
|
|
286
|
+
* 获取整单合计colSpan合并的个数
|
|
287
|
+
* @param {*} table
|
|
288
|
+
* @returns number
|
|
289
|
+
*/
|
|
290
|
+
const getColSpanLength = table => {
|
|
291
|
+
return /multi/.test(table.dataKey)
|
|
292
|
+
? getMultiNumber(table.dataKey) * table.columns.length
|
|
293
|
+
: table.columns.length
|
|
294
|
+
}
|
|
295
|
+
|
|
277
296
|
export {
|
|
278
297
|
getHeight,
|
|
279
298
|
getWidth,
|
|
@@ -291,5 +310,7 @@ export {
|
|
|
291
310
|
isMultiTable,
|
|
292
311
|
getMultiNumber,
|
|
293
312
|
caclSingleDetailsPageHeight,
|
|
294
|
-
getArrayMid
|
|
313
|
+
getArrayMid,
|
|
314
|
+
getColSpanLength,
|
|
315
|
+
getOverallOrderTrHeight
|
|
295
316
|
}
|