gm-printer 10.14.1-alpha.8 → 10.14.1
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/package.json +1 -1
- package/src/editor_purchase/context_menu.js +0 -1
- package/src/editor_settle/context_menu.js +1 -0
- package/src/printer/do_print.js +4 -3
- package/src/printer/page.js +0 -1
- package/src/printer/printer.js +3 -1
- package/src/printer/table.js +6 -2
- package/src/printer/table_subtotal_tr.js +80 -50
- package/src/util.js +9 -4
package/package.json
CHANGED
package/src/printer/do_print.js
CHANGED
|
@@ -53,12 +53,13 @@ function init({ isTest, isTipZoom = true } = {}) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function toDoPrint({ data, config }) {
|
|
56
|
+
function toDoPrint({ data, config }, isSomeSubtotalTr) {
|
|
57
57
|
return new window.Promise(resolve => {
|
|
58
58
|
const $app = $printer.contentWindow.document.getElementById('appContainer')
|
|
59
59
|
ReactDOM.unmountComponentAtNode($app)
|
|
60
60
|
ReactDOM.render(
|
|
61
61
|
<Printer
|
|
62
|
+
isSomeSubtotalTr={isSomeSubtotalTr} // 每页合计是否需要展示多个字段
|
|
62
63
|
config={config}
|
|
63
64
|
data={data}
|
|
64
65
|
onReady={() => {
|
|
@@ -112,10 +113,10 @@ function toDoPrintFinanceBatch(list, isPrint = true) {
|
|
|
112
113
|
})
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
function doPrint({ data, config }, isTest) {
|
|
116
|
+
function doPrint({ data, config }, isTest, isSomeSubtotalTr) {
|
|
116
117
|
init({ isTest })
|
|
117
118
|
|
|
118
|
-
return toDoPrint({ data, config })
|
|
119
|
+
return toDoPrint({ data, config }, isSomeSubtotalTr)
|
|
119
120
|
}
|
|
120
121
|
function doBatchPrint(
|
|
121
122
|
list,
|
package/src/printer/page.js
CHANGED
package/src/printer/printer.js
CHANGED
|
@@ -159,7 +159,7 @@ class Printer extends React.Component {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
renderPage() {
|
|
162
|
-
const { printerStore } = this.props
|
|
162
|
+
const { printerStore, isSomeSubtotalTr } = this.props
|
|
163
163
|
const { config, remainPageHeight, isAutoFilling } = printerStore
|
|
164
164
|
return (
|
|
165
165
|
<>
|
|
@@ -195,6 +195,7 @@ class Printer extends React.Component {
|
|
|
195
195
|
}}
|
|
196
196
|
placeholder={`${i18next.t('区域')} ${panel.index}`}
|
|
197
197
|
pageIndex={i}
|
|
198
|
+
isSomeSubtotalTr={isSomeSubtotalTr}
|
|
198
199
|
/>
|
|
199
200
|
)
|
|
200
201
|
|
|
@@ -322,6 +323,7 @@ Printer.propTypes = {
|
|
|
322
323
|
data: PropTypes.object.isRequired,
|
|
323
324
|
config: PropTypes.object.isRequired,
|
|
324
325
|
onReady: PropTypes.func,
|
|
326
|
+
isSomeSubtotalTr: PropTypes.bool,
|
|
325
327
|
getremainpageHeight: PropTypes.func
|
|
326
328
|
}
|
|
327
329
|
|
package/src/printer/table.js
CHANGED
|
@@ -146,7 +146,8 @@ class Table extends React.Component {
|
|
|
146
146
|
name,
|
|
147
147
|
range,
|
|
148
148
|
pageIndex,
|
|
149
|
-
printerStore
|
|
149
|
+
printerStore,
|
|
150
|
+
isSomeSubtotalTr
|
|
150
151
|
} = this.props
|
|
151
152
|
|
|
152
153
|
// 数据
|
|
@@ -165,6 +166,7 @@ class Table extends React.Component {
|
|
|
165
166
|
range={range}
|
|
166
167
|
config={config}
|
|
167
168
|
printerStore={printerStore}
|
|
169
|
+
isSomeSubtotalTr={isSomeSubtotalTr}
|
|
168
170
|
/>
|
|
169
171
|
<PageSummary {...this.props} />
|
|
170
172
|
</>
|
|
@@ -179,6 +181,7 @@ class Table extends React.Component {
|
|
|
179
181
|
range={range}
|
|
180
182
|
config={config}
|
|
181
183
|
printerStore={printerStore}
|
|
184
|
+
isSomeSubtotalTr={isSomeSubtotalTr}
|
|
182
185
|
/>
|
|
183
186
|
</>
|
|
184
187
|
)
|
|
@@ -337,7 +340,8 @@ Table.propTypes = {
|
|
|
337
340
|
range: PropTypes.object.isRequired,
|
|
338
341
|
pageIndex: PropTypes.number.isRequired,
|
|
339
342
|
placeholder: PropTypes.string,
|
|
340
|
-
printerStore: PropTypes.object
|
|
343
|
+
printerStore: PropTypes.object,
|
|
344
|
+
isSomeSubtotalTr: PropTypes.bool
|
|
341
345
|
}
|
|
342
346
|
|
|
343
347
|
export default Table
|
|
@@ -2,13 +2,11 @@ import React from 'react'
|
|
|
2
2
|
import i18next from '../../locales'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import _ from 'lodash'
|
|
5
|
-
import { MULTI_SUFFIX } from '../config'
|
|
5
|
+
import { MULTI_SUFFIX, MULTI_SUFFIX3 } from '../config'
|
|
6
6
|
import Big from 'big.js'
|
|
7
7
|
import { coverDigit2Uppercase, getDataKey } from '../util'
|
|
8
8
|
import { observer } from 'mobx-react'
|
|
9
9
|
import { get } from 'mobx'
|
|
10
|
-
import { Flex } from '../components'
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* 每页合计组件,分页计算后,根据range来统计每页合计数据
|
|
14
12
|
* @param props
|
|
@@ -35,7 +33,8 @@ const SubtotalTr = props => {
|
|
|
35
33
|
}
|
|
36
34
|
},
|
|
37
35
|
range,
|
|
38
|
-
printerStore
|
|
36
|
+
printerStore,
|
|
37
|
+
isSomeSubtotalTr
|
|
39
38
|
} = props
|
|
40
39
|
|
|
41
40
|
const tableData = printerStore.data._table[getDataKey(dataKey, arrange)] || []
|
|
@@ -48,11 +47,15 @@ const SubtotalTr = props => {
|
|
|
48
47
|
|
|
49
48
|
const _origin = b._origin || {}
|
|
50
49
|
const _origin2 = b['_origin' + MULTI_SUFFIX] || {}
|
|
50
|
+
const _origin3 = b['_origin' + MULTI_SUFFIX3] || {}
|
|
51
51
|
|
|
52
52
|
result = a.plus(_origin[field] || 0)
|
|
53
53
|
if (_origin2[field]) {
|
|
54
54
|
result = result.plus(_origin2[field])
|
|
55
55
|
}
|
|
56
|
+
if (_origin3[field]) {
|
|
57
|
+
result = result.plus(_origin3[field])
|
|
58
|
+
}
|
|
56
59
|
return result
|
|
57
60
|
},
|
|
58
61
|
Big(0)
|
|
@@ -73,64 +76,91 @@ const SubtotalTr = props => {
|
|
|
73
76
|
// 定义每页小记的左右两侧内容
|
|
74
77
|
let subtotalLeftContent
|
|
75
78
|
let subtotalRightContent
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
subtotalRightContent = `${price}`
|
|
79
|
+
let subtotalStr = ''
|
|
80
|
+
// 结款单
|
|
81
|
+
if (isSomeSubtotalTr) {
|
|
82
|
+
for (const name in sum) {
|
|
83
|
+
const price = sum[name]
|
|
84
|
+
const priceUpperCase = get(subtotal, 'needUpperCase') // needUpperCase在初始模板中undefined,所以必须用这个方法
|
|
85
|
+
? '大写:' + coverDigit2Uppercase(price)
|
|
86
|
+
: ''
|
|
87
|
+
if (displayName) {
|
|
88
|
+
subtotalStr += `${name} ${price} ${priceUpperCase} `
|
|
87
89
|
} else {
|
|
88
|
-
|
|
89
|
-
subtotalRightContent = `${name} ${priceUpperCase}`
|
|
90
|
+
subtotalStr += `${price} ${priceUpperCase} `
|
|
90
91
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<tr>
|
|
96
|
+
<td
|
|
97
|
+
colSpan={99}
|
|
98
|
+
style={{ fontWeight: 'bold', ...style }}
|
|
99
|
+
dangerouslySetInnerHTML={{
|
|
100
|
+
__html: `${i18next.t('每页合计')}:${subtotalStr}`
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
</tr>
|
|
104
|
+
)
|
|
105
|
+
} else {
|
|
106
|
+
for (const name in sum) {
|
|
107
|
+
const price = sum[name]
|
|
108
|
+
const priceUpperCase = get(subtotal, 'needUpperCase') // needUpperCase在初始模板中undefined,所以必须用这个方法
|
|
109
|
+
? '大写:' + coverDigit2Uppercase(price)
|
|
110
|
+
: ''
|
|
111
|
+
if (displayName) {
|
|
112
|
+
// 大写金额是否在前
|
|
113
|
+
if (isUpperCaseBefore) {
|
|
114
|
+
subtotalLeftContent = `${name}${priceUpperCase}`
|
|
115
|
+
subtotalRightContent = `${price}`
|
|
116
|
+
} else {
|
|
117
|
+
subtotalLeftContent = `${price}`
|
|
118
|
+
subtotalRightContent = `${name} ${priceUpperCase}`
|
|
119
|
+
}
|
|
95
120
|
} else {
|
|
96
|
-
|
|
97
|
-
|
|
121
|
+
if (isUpperCaseBefore) {
|
|
122
|
+
subtotalLeftContent = `${priceUpperCase}`
|
|
123
|
+
subtotalRightContent = `${price}`
|
|
124
|
+
} else {
|
|
125
|
+
subtotalLeftContent = `${price}`
|
|
126
|
+
subtotalRightContent = `${priceUpperCase}`
|
|
127
|
+
}
|
|
98
128
|
}
|
|
99
129
|
}
|
|
100
|
-
}
|
|
101
130
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
>
|
|
111
|
-
{/* 大写金额和小写金额分开在表格的两侧,通过控制类名实现,添加类名后,覆盖原来的居中、靠右靠左 */}
|
|
112
|
-
<div
|
|
113
|
-
className={
|
|
114
|
-
isUpperLowerCaseSeparate
|
|
115
|
-
? 'gm-printer-subtotal-UpperLowerCaseSeparate-outer'
|
|
116
|
-
: ''
|
|
117
|
-
}
|
|
131
|
+
return (
|
|
132
|
+
<tr>
|
|
133
|
+
<td
|
|
134
|
+
colSpan={99}
|
|
135
|
+
style={{ fontWeight: 'bold', ...style }}
|
|
136
|
+
// dangerouslySetInnerHTML={{
|
|
137
|
+
// __html: `${i18next.t('每页合计')}:${subtotalStr}`
|
|
138
|
+
// }}flex-grow: 1
|
|
118
139
|
>
|
|
119
|
-
{
|
|
120
|
-
<
|
|
140
|
+
{/* 大写金额和小写金额分开在表格的两侧,通过控制类名实现,添加类名后,覆盖原来的居中、靠右靠左 */}
|
|
141
|
+
<div
|
|
121
142
|
className={
|
|
122
143
|
isUpperLowerCaseSeparate
|
|
123
|
-
? 'gm-printer-subtotal-UpperLowerCaseSeparate-
|
|
144
|
+
? 'gm-printer-subtotal-UpperLowerCaseSeparate-outer'
|
|
124
145
|
: ''
|
|
125
146
|
}
|
|
126
147
|
>
|
|
127
|
-
|
|
128
|
-
<span
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
148
|
+
{i18next.t('每页合计')}:
|
|
149
|
+
<span
|
|
150
|
+
className={
|
|
151
|
+
isUpperLowerCaseSeparate
|
|
152
|
+
? 'gm-printer-subtotal-UpperLowerCaseSeparate-inter'
|
|
153
|
+
: ''
|
|
154
|
+
}
|
|
155
|
+
>
|
|
156
|
+
<span> {subtotalLeftContent} </span>
|
|
157
|
+
<span> {subtotalRightContent} </span>
|
|
158
|
+
</span>
|
|
159
|
+
</div>
|
|
160
|
+
</td>
|
|
161
|
+
</tr>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
134
164
|
} else {
|
|
135
165
|
return null
|
|
136
166
|
}
|
package/src/util.js
CHANGED
|
@@ -141,7 +141,12 @@ const coverDigit2Uppercase = n => {
|
|
|
141
141
|
)
|
|
142
142
|
] + fraction[i]
|
|
143
143
|
}
|
|
144
|
+
// 1.06 --- 壹元零陆分
|
|
144
145
|
right = right.replace(/(零分)/, '').replace(/(零角)/, '零')
|
|
146
|
+
// 1.00 --- 壹元整
|
|
147
|
+
right = right === '零' ? '整' : right
|
|
148
|
+
// 1.60 --- 壹元陆角整 1.66 --- 壹元陆角陆分
|
|
149
|
+
right = /角$/.test(right) ? right + '整' : right
|
|
145
150
|
n = Math.floor(n)
|
|
146
151
|
|
|
147
152
|
for (i = 0; i < unit[0].length && n > 0; i++) {
|
|
@@ -155,10 +160,10 @@ const coverDigit2Uppercase = n => {
|
|
|
155
160
|
|
|
156
161
|
return (
|
|
157
162
|
head +
|
|
158
|
-
(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
)
|
|
163
|
+
(left.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零') + right).replace(
|
|
164
|
+
/^整$/,
|
|
165
|
+
'零元整'
|
|
166
|
+
)
|
|
162
167
|
)
|
|
163
168
|
}
|
|
164
169
|
|