gm-printer 10.28.4-beta.4 → 10.28.4
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/.github/workflows/release.yml +4 -5
- package/package.json +1 -1
- package/src/common/editor_customize_config.js +2 -47
- package/src/common/editor_select.js +2 -1
- package/src/common/editor_store.js +5 -63
- package/src/components/index.js +0 -3
- package/src/editor/context_menu.js +0 -2
- package/src/printer/printer.js +15 -47
- package/src/printer/store.js +19 -63
- package/src/printer/table.js +6 -8
- package/build/demo.js +0 -54
- package/build/index.html +0 -1
- package/src/components/radio/Radio.js +0 -76
- package/src/components/radio/RadioGroup.js +0 -52
- package/src/components/radio/index.js +0 -4
- package/src/components/radio/style.less +0 -63
|
@@ -22,7 +22,10 @@ jobs:
|
|
|
22
22
|
node-version: 16.x
|
|
23
23
|
registry-url: 'https://registry.npmjs.org'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
- name: ChangeLog
|
|
26
|
+
run: npx changelogithub
|
|
27
|
+
env:
|
|
28
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
26
29
|
|
|
27
30
|
- name: Setup
|
|
28
31
|
run: npm i -g @antfu/ni
|
|
@@ -44,7 +47,3 @@ jobs:
|
|
|
44
47
|
fi
|
|
45
48
|
env:
|
|
46
49
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
47
|
-
# - name: ChangeLog
|
|
48
|
-
# run: npx changelogithub
|
|
49
|
-
# env:
|
|
50
|
-
# GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
package/package.json
CHANGED
|
@@ -2,25 +2,13 @@ import i18next from '../../locales'
|
|
|
2
2
|
import { inject, observer } from 'mobx-react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { Flex, Switch
|
|
6
|
-
import _ from 'lodash'
|
|
7
|
-
|
|
8
|
-
const initOptionsList = [
|
|
9
|
-
{ name: i18next.t('自适应'), value: 0 },
|
|
10
|
-
{ name: i18next.t('20行'), value: 20 },
|
|
11
|
-
{ name: i18next.t('30行'), value: 30 },
|
|
12
|
-
{ name: i18next.t('40行'), value: 40 }
|
|
13
|
-
]
|
|
5
|
+
import { Flex, Switch } from '../components'
|
|
14
6
|
|
|
15
7
|
@inject('editStore')
|
|
16
8
|
@observer
|
|
17
9
|
class EditorCutomizedConfig extends React.Component {
|
|
18
10
|
handleAutoFilling = value => {
|
|
19
11
|
const { editStore } = this.props
|
|
20
|
-
editStore.setFillRowValue(0)
|
|
21
|
-
if (!value) {
|
|
22
|
-
editStore.setFillIndex(false)
|
|
23
|
-
}
|
|
24
12
|
editStore.handleChangeTableData(value)
|
|
25
13
|
}
|
|
26
14
|
|
|
@@ -29,21 +17,10 @@ class EditorCutomizedConfig extends React.Component {
|
|
|
29
17
|
editStore.setMultiDigitDecimal(value)
|
|
30
18
|
}
|
|
31
19
|
|
|
32
|
-
handleFillRowValue = value => {
|
|
33
|
-
const { editStore } = this.props
|
|
34
|
-
editStore.setFillRowValue(value)
|
|
35
|
-
editStore.handleChangeTableData(true)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
handleFillIndex = value => {
|
|
39
|
-
const { editStore } = this.props
|
|
40
|
-
editStore.setFillIndex(value)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
20
|
render() {
|
|
44
21
|
const {
|
|
45
22
|
editStore,
|
|
46
|
-
editStore: { isAutoFilling, isMultiDigitDecimal
|
|
23
|
+
editStore: { isAutoFilling, isMultiDigitDecimal }
|
|
47
24
|
} = this.props
|
|
48
25
|
// 是table
|
|
49
26
|
if (editStore.computedRegionIsTable) {
|
|
@@ -52,29 +29,7 @@ class EditorCutomizedConfig extends React.Component {
|
|
|
52
29
|
<Flex alignCenter className='gm-padding-top-5'>
|
|
53
30
|
<div>{i18next.t('行数是否自动填充')}:</div>
|
|
54
31
|
<Switch checked={isAutoFilling} onChange={this.handleAutoFilling} />
|
|
55
|
-
{isAutoFilling && (
|
|
56
|
-
<Select
|
|
57
|
-
value={fillRowValue}
|
|
58
|
-
onChange={this.handleFillRowValue}
|
|
59
|
-
options={initOptionsList}
|
|
60
|
-
>
|
|
61
|
-
{_.map(initOptionsList, (v, k) => (
|
|
62
|
-
<Option key={k} value={v.value}>
|
|
63
|
-
{v.name}
|
|
64
|
-
</Option>
|
|
65
|
-
))}
|
|
66
|
-
</Select>
|
|
67
|
-
)}
|
|
68
|
-
</Flex>
|
|
69
|
-
|
|
70
|
-
<Flex className='gm-padding-top-5 '>
|
|
71
|
-
<div>{i18next.t('行数是否空白行是否填充序号')}:</div>
|
|
72
|
-
<Switch
|
|
73
|
-
checked={fillIndex || false}
|
|
74
|
-
onChange={this.handleFillIndex}
|
|
75
|
-
/>
|
|
76
32
|
</Flex>
|
|
77
|
-
|
|
78
33
|
<Flex className='gm-padding-top-5 gm-text-red' column>
|
|
79
34
|
{i18next.t('注意:填充仅支持单栏数据使用')}
|
|
80
35
|
</Flex>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import i18next from '../../locales'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { observer, inject } from 'mobx-react'
|
|
4
|
-
import { Flex, Option, Select
|
|
4
|
+
import { Flex, Option, Select } from '../components'
|
|
5
|
+
import { RadioGroup, Radio } from '@gmfe/react'
|
|
5
6
|
import { InputWithUnit } from '../common/component'
|
|
6
7
|
import { pageTypeMap, printDirectionList, LONG_PRINT } from '../config'
|
|
7
8
|
import _ from 'lodash'
|
|
@@ -22,12 +22,6 @@ class EditorStore {
|
|
|
22
22
|
@observable
|
|
23
23
|
remainPageHeihgt = 0
|
|
24
24
|
|
|
25
|
-
@observable
|
|
26
|
-
fillRowValue = 0
|
|
27
|
-
|
|
28
|
-
@observable
|
|
29
|
-
fillIndex = 0
|
|
30
|
-
|
|
31
25
|
// 初始模板
|
|
32
26
|
originConfig = null
|
|
33
27
|
|
|
@@ -65,44 +59,6 @@ class EditorStore {
|
|
|
65
59
|
// 默认table的dataKey
|
|
66
60
|
setTableDataKeyEffect() {} // 改变dataKey后,做的副作用操作
|
|
67
61
|
|
|
68
|
-
@action
|
|
69
|
-
setFillRowValue(value) {
|
|
70
|
-
const { autoFillConfig } = this.config
|
|
71
|
-
if (!this.selectedRegion && !autoFillConfig?.checked) return
|
|
72
|
-
this.fillRowValue = value
|
|
73
|
-
const dataKey =
|
|
74
|
-
this.computedTableSpecialConfig?.dataKey || autoFillConfig?.dataKey
|
|
75
|
-
set(this.config, {
|
|
76
|
-
autoFillConfig: {
|
|
77
|
-
region: this.selectedRegion || autoFillConfig?.region,
|
|
78
|
-
dataKey,
|
|
79
|
-
checked: this.isAutoFilling,
|
|
80
|
-
// 填充行数字段
|
|
81
|
-
fillRowValue: this.fillRowValue,
|
|
82
|
-
fillIndex: this.fillIndex
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@action
|
|
88
|
-
setFillIndex(value) {
|
|
89
|
-
const { autoFillConfig } = this.config
|
|
90
|
-
if (!this.selectedRegion && !autoFillConfig?.checked) return
|
|
91
|
-
this.fillIndex = value
|
|
92
|
-
const dataKey =
|
|
93
|
-
this.computedTableSpecialConfig?.dataKey || autoFillConfig?.dataKey
|
|
94
|
-
set(this.config, {
|
|
95
|
-
autoFillConfig: {
|
|
96
|
-
region: this.selectedRegion || autoFillConfig?.region,
|
|
97
|
-
dataKey,
|
|
98
|
-
checked: this.isAutoFilling,
|
|
99
|
-
// 填充行数字段
|
|
100
|
-
fillRowValue: this.fillRowValue,
|
|
101
|
-
fillIndex: value
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
62
|
defaultTableSubtotal = { show: false }
|
|
107
63
|
|
|
108
64
|
@action
|
|
@@ -209,14 +165,9 @@ class EditorStore {
|
|
|
209
165
|
getFilledTableData(tableData) {
|
|
210
166
|
const { autoFillConfig } = this.config
|
|
211
167
|
if (!this.selectedRegion && !autoFillConfig?.checked) return []
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.remainPageHeihgt / this.computedTableCustomerRowHeight
|
|
216
|
-
)
|
|
217
|
-
} else {
|
|
218
|
-
tr_count = this.fillRowValue
|
|
219
|
-
}
|
|
168
|
+
const tr_count = Math.floor(
|
|
169
|
+
this.remainPageHeihgt / this.computedTableCustomerRowHeight
|
|
170
|
+
)
|
|
220
171
|
|
|
221
172
|
const filledData = {
|
|
222
173
|
_isEmptyData: true // 表示是填充的空白数据
|
|
@@ -233,27 +184,20 @@ class EditorStore {
|
|
|
233
184
|
if (!this.selectedRegion && !autoFillConfig?.checked) return
|
|
234
185
|
const dataKey =
|
|
235
186
|
this.computedTableSpecialConfig?.dataKey || autoFillConfig?.dataKey
|
|
236
|
-
// 每次都更新一下?
|
|
237
187
|
const table = this.mockData._table[dataKey]
|
|
238
|
-
// 赋值一下
|
|
239
188
|
this.setAutoFillingConfig(isAutoFilling)
|
|
240
|
-
|
|
241
|
-
this.setFillIndex(autoFillConfig?.fillIndex || false)
|
|
189
|
+
|
|
242
190
|
set(this.config, {
|
|
243
191
|
autoFillConfig: {
|
|
244
192
|
region: this.selectedRegion || autoFillConfig?.region,
|
|
245
193
|
dataKey,
|
|
246
|
-
checked: isAutoFilling
|
|
247
|
-
// 填充行数字段
|
|
248
|
-
fillRowValue: this.fillRowValue,
|
|
249
|
-
fillIndex: this.fillIndex
|
|
194
|
+
checked: isAutoFilling
|
|
250
195
|
}
|
|
251
196
|
})
|
|
252
197
|
|
|
253
198
|
const hasHadEmptyData = _.some(table, data => data?._isEmptyData)
|
|
254
199
|
|
|
255
200
|
// 开关打开,且之前数组不包含空数据,再进行填充
|
|
256
|
-
|
|
257
201
|
if (isAutoFilling && !hasHadEmptyData) {
|
|
258
202
|
table.push(...this.getFilledTableData(table))
|
|
259
203
|
}
|
|
@@ -283,8 +227,6 @@ class EditorStore {
|
|
|
283
227
|
this.insertPanel = 'header'
|
|
284
228
|
this.mockData = data
|
|
285
229
|
this.isAutoFilling = false
|
|
286
|
-
this.fillRowValue = 0
|
|
287
|
-
this.fillIndex = false
|
|
288
230
|
this.isMultiDigitDecimal = false
|
|
289
231
|
}
|
|
290
232
|
|
package/src/components/index.js
CHANGED
|
@@ -5,12 +5,9 @@ import { DropDown, DropDownItem, DropDownItems } from './dropdown'
|
|
|
5
5
|
import Dialog from './dialog'
|
|
6
6
|
import Switch from './switch'
|
|
7
7
|
import ToolTip from './tooltip'
|
|
8
|
-
import { RadioGroup, Radio } from './radio'
|
|
9
8
|
|
|
10
9
|
export {
|
|
11
10
|
Flex,
|
|
12
|
-
RadioGroup,
|
|
13
|
-
Radio,
|
|
14
11
|
Select,
|
|
15
12
|
Option,
|
|
16
13
|
Tip,
|
|
@@ -199,8 +199,6 @@ class ContextMenu extends React.Component {
|
|
|
199
199
|
selected={editStore.selected}
|
|
200
200
|
selectedRegion={editStore.selectedRegion}
|
|
201
201
|
isAutoFilling={editStore.isAutoFilling}
|
|
202
|
-
fillRowValue={editStore.fillRowValue}
|
|
203
|
-
fillIndex={editStore.fillIndex}
|
|
204
202
|
lineheight={editStore.computedTableCustomerRowHeight}
|
|
205
203
|
config={editStore.config}
|
|
206
204
|
data={editStore.mockData}
|
package/src/printer/printer.js
CHANGED
|
@@ -11,7 +11,6 @@ import Table from './table'
|
|
|
11
11
|
import LongPrintTable from './long_print_table'
|
|
12
12
|
import MergePage from './merge_page'
|
|
13
13
|
import { LONG_PRINT } from '../config'
|
|
14
|
-
import Big from 'big.js'
|
|
15
14
|
|
|
16
15
|
// Header Sign Footer 相对特殊,要单独处理
|
|
17
16
|
const Header = props => (
|
|
@@ -73,26 +72,12 @@ class Printer extends React.Component {
|
|
|
73
72
|
if (nextProps.selectedRegion !== this.props.selectedRegion) {
|
|
74
73
|
this.props.printerStore.setSelectedRegion(nextProps.selectedRegion)
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
nextProps.isAutoFilling !== this.props.isAutoFilling ||
|
|
79
|
-
nextProps.fillRowValue !== this.props.printerStore.fillRowValue ||
|
|
80
|
-
nextProps.fillIndex !== this.props.printerStore.fillIndex
|
|
81
|
-
) {
|
|
75
|
+
if (nextProps.isAutoFilling !== this.props.isAutoFilling) {
|
|
82
76
|
await this.props.printerStore.setAutofillConfig(nextProps.isAutoFilling)
|
|
83
|
-
await this.props.printerStore.setFillRowValue(nextProps.fillRowValue)
|
|
84
|
-
await this.props.printerStore.setFillIndex(nextProps.fillIndex)
|
|
85
77
|
await this.props.printerStore.setData(nextProps.data)
|
|
86
78
|
await this.props.printerStore.setReady(true)
|
|
87
|
-
if (nextProps.fillRowValue === 0) {
|
|
88
|
-
// 自适应要先reset一下 在计算高度
|
|
89
|
-
await this.props.printerStore.resetTableData()
|
|
90
|
-
await this.props.printerStore.computedPages()
|
|
91
|
-
}
|
|
92
|
-
await this.props.printerStore.changeTableData()
|
|
93
79
|
await this.props.printerStore.computedPages()
|
|
94
80
|
}
|
|
95
|
-
|
|
96
81
|
if (nextProps.lineheight !== this.props.lineheight) {
|
|
97
82
|
await this.props.getremainpageHeight(
|
|
98
83
|
this.props.printerStore.remainPageHeight
|
|
@@ -111,30 +96,19 @@ class Printer extends React.Component {
|
|
|
111
96
|
// didMount 代表第一次渲染完成
|
|
112
97
|
printerStore.setReady(true)
|
|
113
98
|
|
|
99
|
+
// 开始计算,获取各种数据
|
|
100
|
+
printerStore.computedPages()
|
|
101
|
+
|
|
114
102
|
if (config.autoFillConfig?.checked) {
|
|
115
103
|
this.props.printerStore.setAutofillConfig(
|
|
116
104
|
config.autoFillConfig?.checked || false
|
|
117
105
|
)
|
|
118
|
-
this.props.printerStore.
|
|
119
|
-
config.autoFillConfig?.fillRowValue || 0
|
|
120
|
-
)
|
|
121
|
-
this.props.printerStore.setFillIndex(
|
|
122
|
-
config.autoFillConfig?.fillIndex || false
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
// 开始计算,获取各种数据
|
|
126
|
-
// 如果是自适应要先计算高度,在算出行数 不是自适应就先计算行数 在计算高度
|
|
127
|
-
if (config.autoFillConfig?.fillRowValue === 0) {
|
|
128
|
-
printerStore.computedPages()
|
|
129
|
-
printerStore.changeTableData()
|
|
130
|
-
} else {
|
|
131
|
-
printerStore.changeTableData()
|
|
132
|
-
printerStore.computedPages()
|
|
106
|
+
this.props.printerStore.changeTableData()
|
|
133
107
|
}
|
|
108
|
+
|
|
134
109
|
// 获取剩余空白高度,传到editor
|
|
135
110
|
getremainpageHeight && getremainpageHeight(printerStore.remainPageHeight)
|
|
136
111
|
}
|
|
137
|
-
|
|
138
112
|
// Printer 不是立马就呈现出最终样式,有个过程。这个过程需要时间,什么 ready,不太清楚,估借 setState 来获取过程结束时刻
|
|
139
113
|
this.setState({}, () => {
|
|
140
114
|
this.props.onReady()
|
|
@@ -246,19 +220,16 @@ class Printer extends React.Component {
|
|
|
246
220
|
|
|
247
221
|
renderPage() {
|
|
248
222
|
const { printerStore, isSomeSubtotalTr } = this.props
|
|
249
|
-
const {
|
|
250
|
-
config,
|
|
251
|
-
remainPageHeight,
|
|
252
|
-
isAutoFilling,
|
|
253
|
-
fillRowValue
|
|
254
|
-
} = printerStore
|
|
223
|
+
const { config, remainPageHeight, isAutoFilling } = printerStore
|
|
255
224
|
return (
|
|
256
225
|
<>
|
|
257
226
|
{_.map(printerStore.pages, (page, i) => {
|
|
258
227
|
const isLastPage = i === printerStore.pages.length - 1
|
|
228
|
+
|
|
259
229
|
return (
|
|
260
230
|
<Page key={i}>
|
|
261
231
|
<Header config={config.header} pageIndex={i} />
|
|
232
|
+
|
|
262
233
|
{_.map(page, (panel, ii) => {
|
|
263
234
|
const content = config.contents[panel.index]
|
|
264
235
|
const autoFillConfig = config?.autoFillConfig || {}
|
|
@@ -266,16 +237,15 @@ class Printer extends React.Component {
|
|
|
266
237
|
isLastPage &&
|
|
267
238
|
isAutoFilling &&
|
|
268
239
|
panel.end &&
|
|
269
|
-
content?.dataKey === autoFillConfig?.dataKey
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
?
|
|
240
|
+
content?.dataKey === autoFillConfig?.dataKey
|
|
241
|
+
|
|
242
|
+
const end = isAutofillConfig
|
|
243
|
+
? panel.end +
|
|
244
|
+
Math.floor(
|
|
273
245
|
remainPageHeight /
|
|
274
246
|
printerStore.computedTableCustomerRowHeight
|
|
275
247
|
)
|
|
276
|
-
:
|
|
277
|
-
const end = +Big(panel?.end || 0).add(endList)
|
|
278
|
-
|
|
248
|
+
: panel.end
|
|
279
249
|
switch (panel.type) {
|
|
280
250
|
case 'table':
|
|
281
251
|
return (
|
|
@@ -421,8 +391,6 @@ Printer.propTypes = {
|
|
|
421
391
|
selected: PropTypes.string,
|
|
422
392
|
selectedRegion: PropTypes.string,
|
|
423
393
|
isAutoFilling: PropTypes.bool,
|
|
424
|
-
fillRowValue: PropTypes.number,
|
|
425
|
-
fillIndex: PropTypes.number,
|
|
426
394
|
lineheight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
427
395
|
data: PropTypes.object.isRequired,
|
|
428
396
|
config: PropTypes.object.isRequired,
|
package/src/printer/store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i18next from '../../locales'
|
|
2
|
-
import { action, observable, computed
|
|
2
|
+
import { action, observable, computed } from 'mobx'
|
|
3
3
|
import {
|
|
4
4
|
getSumTrHeight,
|
|
5
5
|
isMultiTable,
|
|
@@ -48,14 +48,6 @@ class PrinterStore {
|
|
|
48
48
|
@observable
|
|
49
49
|
isAutoFilling = false
|
|
50
50
|
|
|
51
|
-
// 是否自动行数填充
|
|
52
|
-
@observable
|
|
53
|
-
fillRowValue = 0
|
|
54
|
-
|
|
55
|
-
// 是否自动行数填充
|
|
56
|
-
@observable
|
|
57
|
-
fillIndex = 0
|
|
58
|
-
|
|
59
51
|
/** 是否开启多位小数,默认不开启,取两位 */
|
|
60
52
|
@observable
|
|
61
53
|
isMultiDigitDecimal = false
|
|
@@ -80,21 +72,6 @@ class PrinterStore {
|
|
|
80
72
|
@action
|
|
81
73
|
setAutofillConfig(bol) {
|
|
82
74
|
this.isAutoFilling = bol
|
|
83
|
-
if (!bol) {
|
|
84
|
-
this.pages = []
|
|
85
|
-
this.fillIndex = false
|
|
86
|
-
this.fillRowValue = 0
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@action
|
|
91
|
-
setFillRowValue(value) {
|
|
92
|
-
this.fillRowValue = value
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@action
|
|
96
|
-
setFillIndex(value) {
|
|
97
|
-
this.fillIndex = value
|
|
98
75
|
}
|
|
99
76
|
|
|
100
77
|
@action
|
|
@@ -133,11 +110,11 @@ class PrinterStore {
|
|
|
133
110
|
return tableConfig
|
|
134
111
|
}
|
|
135
112
|
|
|
136
|
-
@computed
|
|
137
113
|
get tableData() {
|
|
138
114
|
if (!this.tableConfig) return []
|
|
139
115
|
const { autoFillConfig } = this.config
|
|
140
116
|
const { dataKey } = this.tableConfig
|
|
117
|
+
|
|
141
118
|
if (autoFillConfig?.region) {
|
|
142
119
|
/** 当前数据 */
|
|
143
120
|
return this.data._table[dataKey] || []
|
|
@@ -148,7 +125,7 @@ class PrinterStore {
|
|
|
148
125
|
return this.data._table[dataKey] || []
|
|
149
126
|
}
|
|
150
127
|
|
|
151
|
-
|
|
128
|
+
// 空数据的长度
|
|
152
129
|
get filledTableLen() {
|
|
153
130
|
const filledData = this.tableData.filter(x => x._isEmptyData)
|
|
154
131
|
return filledData.length
|
|
@@ -181,12 +158,15 @@ class PrinterStore {
|
|
|
181
158
|
|
|
182
159
|
getNormalTableBodyHeights(heights, dataKey) {
|
|
183
160
|
if (!this.tableConfig) return heights
|
|
161
|
+
|
|
184
162
|
const len = this.tableData.length
|
|
185
163
|
// 如果是已经开了填充配置,回显的heights包括了填充的表格部分,关闭配置时,这种情况就要去掉填充的
|
|
186
164
|
if (_.gt(heights.length, len)) return heights.slice(0, len)
|
|
165
|
+
|
|
187
166
|
const hasEmptyData = this.tableData.some(x => x._isEmptyData)
|
|
188
167
|
const isOrderCategroy = dataKey === this.config?.autoFillConfig?.dataKey
|
|
189
168
|
const { customerRowHeight = TR_BASE_HEIGHT } = this.tableConfig
|
|
169
|
+
|
|
190
170
|
if (hasEmptyData && !this.isAutoFilling && isOrderCategroy) {
|
|
191
171
|
// 如果tableData有填充的空数据, 则去掉
|
|
192
172
|
return heights.slice(0, -this.filledTableLen)
|
|
@@ -214,6 +194,7 @@ class PrinterStore {
|
|
|
214
194
|
computedData(dataKey, table, end, currentRemainTableHeight) {
|
|
215
195
|
/** 当前数据 */
|
|
216
196
|
const tableData = this.data._table[dataKey] || []
|
|
197
|
+
|
|
217
198
|
let count = 0
|
|
218
199
|
_.forEach(Array(end).fill(1), (val, i) => {
|
|
219
200
|
const details = tableData[i]?.__details || []
|
|
@@ -245,7 +226,7 @@ class PrinterStore {
|
|
|
245
226
|
|
|
246
227
|
// 分局明细拆分后的数据
|
|
247
228
|
const splitTableData = _.map(
|
|
248
|
-
_.filter(ranges, i
|
|
229
|
+
_.filter(ranges, i[0] !== i[1] || (!i[0] && !i[1])), // 过滤掉 {[0,3],[3,3]}这周情况
|
|
249
230
|
range => {
|
|
250
231
|
const _tableData = Object.assign({}, tableData[end])
|
|
251
232
|
_tableData.__details = data.slice(...range)
|
|
@@ -257,9 +238,11 @@ class PrinterStore {
|
|
|
257
238
|
return _tableData
|
|
258
239
|
}
|
|
259
240
|
)
|
|
241
|
+
|
|
260
242
|
// 插入原table数据中
|
|
261
243
|
tableData.splice(end, 1, ...splitTableData)
|
|
262
244
|
this.data._table[dataKey] = tableData
|
|
245
|
+
|
|
263
246
|
return detailsPageHeight
|
|
264
247
|
}
|
|
265
248
|
|
|
@@ -317,6 +300,7 @@ class PrinterStore {
|
|
|
317
300
|
let pageAccomodateTableHeight = +new Big(this.pageHeight)
|
|
318
301
|
.minus(currentPageHeight)
|
|
319
302
|
.toFixed(2)
|
|
303
|
+
|
|
320
304
|
const heights = this.getNormalTableBodyHeights(
|
|
321
305
|
table.body.heights,
|
|
322
306
|
dataKey
|
|
@@ -336,6 +320,7 @@ class PrinterStore {
|
|
|
336
320
|
let currentRemainTableHeight = 0
|
|
337
321
|
/** 去最小的tr高度,用于下面的计算compare,(避免特殊情况:一般来说最小tr——height = 23, 比23还小的不考虑计算) */
|
|
338
322
|
const minHeight = Math.max(getArrayMid(heights), 23)
|
|
323
|
+
|
|
339
324
|
/* 遍历表格每一行,填充表格内容 */
|
|
340
325
|
while (end < heights.length) {
|
|
341
326
|
currentTableHeight += heights[end]
|
|
@@ -431,7 +416,6 @@ class PrinterStore {
|
|
|
431
416
|
if (index === this.config.contents.length - 1) {
|
|
432
417
|
currentPageHeight += this.height?.sign
|
|
433
418
|
}
|
|
434
|
-
|
|
435
419
|
if (currentPageHeight <= this.pageHeight) {
|
|
436
420
|
// 空间充足,把信息加入 page,并轮下一个contents
|
|
437
421
|
page.push({
|
|
@@ -451,6 +435,7 @@ class PrinterStore {
|
|
|
451
435
|
}
|
|
452
436
|
}
|
|
453
437
|
this.pages.push(page)
|
|
438
|
+
|
|
454
439
|
this.remainPageHeight = +Big(this.pageHeight - currentPageHeight).toFixed(0)
|
|
455
440
|
}
|
|
456
441
|
|
|
@@ -514,17 +499,14 @@ class PrinterStore {
|
|
|
514
499
|
// 做好保护,出错就返回 text
|
|
515
500
|
try {
|
|
516
501
|
let list = this.data._table[dataKey] || this.data._table.orders
|
|
517
|
-
|
|
518
502
|
// 采购任务打印存在两个表格,第二表格没有明细,数据需要做去重
|
|
519
503
|
if (dataKey === 'purchase_no_detail') {
|
|
520
504
|
list = _.uniqBy(list, '序号')
|
|
521
505
|
}
|
|
522
|
-
|
|
523
506
|
return _.template(text, {
|
|
524
507
|
interpolate: /{{([\s\S]+?)}}/g
|
|
525
508
|
})({
|
|
526
509
|
...this.data.common,
|
|
527
|
-
|
|
528
510
|
[i18next.t('列')]: list[index],
|
|
529
511
|
[i18next.t('当前页码')]: pageIndex + 1,
|
|
530
512
|
[i18next.t('页码总数')]: this.pages.length,
|
|
@@ -598,21 +580,16 @@ class PrinterStore {
|
|
|
598
580
|
getFilledTableData(tableData) {
|
|
599
581
|
const { autoFillConfig } = this.config
|
|
600
582
|
if (!this.selectedRegion && !autoFillConfig?.checked) return []
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
)
|
|
606
|
-
} else {
|
|
607
|
-
tr_count = this.fillRowValue
|
|
608
|
-
}
|
|
583
|
+
const tr_count = Math.floor(
|
|
584
|
+
this.remainPageHeight / this.computedTableCustomerRowHeight
|
|
585
|
+
)
|
|
586
|
+
|
|
609
587
|
const filledData = {
|
|
610
588
|
_isEmptyData: true // 表示是填充的空白数据
|
|
611
589
|
}
|
|
612
590
|
_.map(tableData[0], (val, key) => {
|
|
613
591
|
filledData[key] = ''
|
|
614
592
|
})
|
|
615
|
-
|
|
616
593
|
return Array(tr_count).fill(filledData)
|
|
617
594
|
}
|
|
618
595
|
|
|
@@ -621,32 +598,11 @@ class PrinterStore {
|
|
|
621
598
|
const { autoFillConfig } = this.config
|
|
622
599
|
if (!this.isAutoFilling) return
|
|
623
600
|
const dataKey = autoFillConfig?.dataKey
|
|
624
|
-
const table = this.data._table[dataKey]
|
|
601
|
+
const table = this.data._table[dataKey]
|
|
625
602
|
|
|
626
|
-
|
|
627
|
-
console.log(lastKey, 'lastKey=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-')
|
|
628
|
-
const fillList = _.map(this.getFilledTableData(table), (item, index) => {
|
|
629
|
-
if (this.fillIndex) {
|
|
630
|
-
return { ...item, 序号: index + lastKey }
|
|
631
|
-
} else {
|
|
632
|
-
return { ...item }
|
|
633
|
-
}
|
|
634
|
-
})
|
|
635
|
-
table.push(...fillList)
|
|
603
|
+
table.push(...this.getFilledTableData(table))
|
|
636
604
|
this.data._table[dataKey] = table
|
|
637
605
|
}
|
|
638
|
-
|
|
639
|
-
@action.bound
|
|
640
|
-
resetTableData() {
|
|
641
|
-
const { autoFillConfig } = this.config
|
|
642
|
-
if (!this.isAutoFilling) return
|
|
643
|
-
const dataKey = autoFillConfig?.dataKey
|
|
644
|
-
const table = this.data._table[dataKey]?.filter(item => !item._isEmptyData)
|
|
645
|
-
const restTable = _.map(table, item => {
|
|
646
|
-
return { ...item }
|
|
647
|
-
})
|
|
648
|
-
this.data._table[dataKey] = restTable
|
|
649
|
-
}
|
|
650
606
|
}
|
|
651
607
|
|
|
652
608
|
export default PrinterStore
|
package/src/printer/table.js
CHANGED
|
@@ -19,7 +19,6 @@ import SubtotalTr from './table_subtotal_tr'
|
|
|
19
19
|
import PageSummary from './page_summary'
|
|
20
20
|
import OverallOrder from './table_overallOrder_tr'
|
|
21
21
|
import DiyOverallOrder from './table_diy_overallOrder_tr'
|
|
22
|
-
import { toJS } from 'mobx'
|
|
23
22
|
|
|
24
23
|
@inject('printerStore')
|
|
25
24
|
@observer
|
|
@@ -41,7 +40,7 @@ class Table extends React.Component {
|
|
|
41
40
|
const ths = tHead.querySelectorAll('th') || []
|
|
42
41
|
const trs = $table.querySelectorAll('tbody tr') || []
|
|
43
42
|
const detailsDiv = $table.querySelectorAll('tr td .b-table-details')
|
|
44
|
-
|
|
43
|
+
|
|
45
44
|
printerStore.setHeight(name, getHeight($table))
|
|
46
45
|
|
|
47
46
|
printerStore.setTable(name, {
|
|
@@ -169,9 +168,11 @@ class Table extends React.Component {
|
|
|
169
168
|
printerStore,
|
|
170
169
|
isSomeSubtotalTr
|
|
171
170
|
} = this.props
|
|
171
|
+
|
|
172
172
|
// 数据
|
|
173
173
|
dataKey = getDataKey(dataKey, arrange)
|
|
174
174
|
const tableData = printerStore.data._table[dataKey] || []
|
|
175
|
+
|
|
175
176
|
// 列
|
|
176
177
|
const columns = this.getColumns()
|
|
177
178
|
// 列宽固定(避免跳页bug)
|
|
@@ -224,6 +225,7 @@ class Table extends React.Component {
|
|
|
224
225
|
}
|
|
225
226
|
return tdStyle
|
|
226
227
|
}
|
|
228
|
+
|
|
227
229
|
return (
|
|
228
230
|
<table
|
|
229
231
|
style={{
|
|
@@ -259,7 +261,6 @@ class Table extends React.Component {
|
|
|
259
261
|
))}
|
|
260
262
|
</tr>
|
|
261
263
|
</thead>
|
|
262
|
-
|
|
263
264
|
<tbody>
|
|
264
265
|
{_.map(_.range(range.begin, range.end), i => {
|
|
265
266
|
const _special = tableData[i] && tableData[i]._special
|
|
@@ -270,14 +271,11 @@ class Table extends React.Component {
|
|
|
270
271
|
return <SpecialTr key={i} config={config} data={_special} />
|
|
271
272
|
// 如果项为空对象展现一个占满一行的td
|
|
272
273
|
const isItemNone = !_.keys(tableData[i]).length
|
|
274
|
+
|
|
273
275
|
return (
|
|
274
276
|
<tr style={{ height: `${customerRowHeight}px` }} key={i}>
|
|
275
277
|
{isItemNone ? (
|
|
276
|
-
|
|
277
|
-
<td colSpan='99' />
|
|
278
|
-
) : (
|
|
279
|
-
<></>
|
|
280
|
-
)
|
|
278
|
+
<td colSpan='99' />
|
|
281
279
|
) : (
|
|
282
280
|
_.map(columns, (col, j) => {
|
|
283
281
|
return (
|