gm-printer 10.13.7-beta.9 → 10.13.7
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/printer/store.js +27 -19
- package/src/printer/table.js +9 -12
- package/src/util.js +19 -3
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js":"1","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js":"2","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js":"3","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js":"4","/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js":"5","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js":"6","/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js":"7","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js":"8","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/do_print.js":"9","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js":"10","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_store.js":"11","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js":"12","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js":"13","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js":"14","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js":"15","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js":"16","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js":"17","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js":"18"},{"size":
|
|
1
|
+
[{"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js":"1","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js":"2","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js":"3","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js":"4","/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js":"5","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js":"6","/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js":"7","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js":"8","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/do_print.js":"9","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js":"10","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_store.js":"11","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js":"12","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js":"13","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js":"14","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js":"15","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js":"16","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js":"17","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js":"18"},{"size":9238,"mtime":1637656903443,"results":"19","hashOfConfig":"20"},{"size":12882,"mtime":1638178010006,"results":"21","hashOfConfig":"20"},{"size":4244,"mtime":1635494969691,"results":"22","hashOfConfig":"20"},{"size":3683,"mtime":1635851060224,"results":"23","hashOfConfig":"20"},{"size":616,"mtime":1621235314060,"results":"24","hashOfConfig":"25"},{"size":9693,"mtime":1621242097206,"results":"26","hashOfConfig":"25"},{"size":7133,"mtime":1637651237275,"results":"27","hashOfConfig":"20"},{"size":8733,"mtime":1635931829112,"results":"28","hashOfConfig":"20"},{"size":3119,"mtime":1634191808754,"results":"29","hashOfConfig":"20"},{"size":1113,"mtime":1635407660514,"results":"30","hashOfConfig":"20"},{"size":3905,"mtime":1635304242763},{"size":861,"mtime":1635246075403,"results":"31","hashOfConfig":"20"},{"size":3260,"mtime":1635334661529,"results":"32","hashOfConfig":"20"},{"size":24504,"mtime":1635908548975,"results":"33","hashOfConfig":"20"},{"size":1907,"mtime":1635492860490,"results":"34","hashOfConfig":"20"},{"size":3548,"mtime":1635409410379,"results":"35","hashOfConfig":"20"},{"size":2989,"mtime":1635495718901,"results":"36","hashOfConfig":"20"},{"size":3465,"mtime":1635495798948,"results":"37","hashOfConfig":"20"},{"filePath":"38","messages":"39","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1j0d8vf",{"filePath":"40","messages":"41","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"42","messages":"43","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"46","messages":"47","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"175njjo",{"filePath":"48","messages":"49","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","errorCount":13,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","errorCount":2,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/do_print.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js",["72","73","74","75","76","77","78","79","80","81","82","83","84"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js",["85","86"],{"ruleId":"87","severity":2,"message":"88","line":47,"column":13,"nodeType":"89","messageId":"90","endLine":47,"endColumn":22},{"ruleId":"87","severity":2,"message":"91","line":48,"column":30,"nodeType":"92","messageId":"90","endLine":48,"endColumn":36},{"ruleId":"87","severity":2,"message":"93","line":49,"column":31,"nodeType":"92","messageId":"90","endLine":49,"endColumn":47},{"ruleId":"87","severity":2,"message":"93","line":50,"column":21,"nodeType":"92","messageId":"90","endLine":50,"endColumn":37},{"ruleId":"87","severity":2,"message":"88","line":56,"column":13,"nodeType":"89","messageId":"90","endLine":56,"endColumn":22},{"ruleId":"87","severity":2,"message":"94","line":59,"column":20,"nodeType":"92","messageId":"90","endLine":59,"endColumn":32},{"ruleId":"87","severity":2,"message":"91","line":61,"column":23,"nodeType":"92","messageId":"90","endLine":61,"endColumn":29},{"ruleId":"87","severity":2,"message":"95","line":61,"column":30,"nodeType":"92","messageId":"90","endLine":61,"endColumn":34},{"ruleId":"87","severity":2,"message":"96","line":63,"column":15,"nodeType":"92","messageId":"90","endLine":63,"endColumn":19},{"ruleId":"87","severity":2,"message":"88","line":67,"column":23,"nodeType":"89","messageId":"90","endLine":67,"endColumn":32},{"ruleId":"87","severity":2,"message":"91","line":70,"column":32,"nodeType":"92","messageId":"90","endLine":70,"endColumn":38},{"ruleId":"87","severity":2,"message":"88","line":78,"column":13,"nodeType":"89","messageId":"90","endLine":78,"endColumn":22},{"ruleId":"87","severity":2,"message":"91","line":84,"column":42,"nodeType":"92","messageId":"90","endLine":84,"endColumn":48},{"ruleId":"97","severity":2,"message":"98","line":64,"column":11,"nodeType":"92","endLine":64,"endColumn":17},{"ruleId":"97","severity":2,"message":"99","line":102,"column":24,"nodeType":"92","endLine":102,"endColumn":32},"react/prop-types","'editStore' is missing in props validation","Property","missingPropType","'editStore.config' is missing in props validation","Identifier","'editStore.config.batchPrintConfig' is missing in props validation","'editStore.originConfig' is missing in props validation","'editStore.config.name' is missing in props validation","'editStore.init' is missing in props validation","no-unused-vars","'keyArr' is assigned a value but never used.","'mockData' is assigned a value but never used."]
|
package/package.json
CHANGED
package/src/printer/store.js
CHANGED
|
@@ -3,7 +3,8 @@ import { action, observable } from 'mobx'
|
|
|
3
3
|
import {
|
|
4
4
|
getSumTrHeight,
|
|
5
5
|
isMultiTable,
|
|
6
|
-
caclSingleDetailsPageHeight
|
|
6
|
+
caclSingleDetailsPageHeight,
|
|
7
|
+
getArrayMid
|
|
7
8
|
} from '../util'
|
|
8
9
|
import _ from 'lodash'
|
|
9
10
|
import Big from 'big.js'
|
|
@@ -78,16 +79,15 @@ class PrinterStore {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
@action
|
|
81
|
-
computedData(dataKey, table,
|
|
82
|
+
computedData(dataKey, table, end, currentRemainTableHeight) {
|
|
82
83
|
/** 当前数据 */
|
|
83
84
|
const tableData = this.data._table[dataKey] || []
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
86
|
+
let count = 0
|
|
87
|
+
_.forEach(Array(end).fill(1), (val, i) => {
|
|
88
|
+
const details = tableData[i]?.__details || []
|
|
89
|
+
count += details.length
|
|
90
|
+
})
|
|
91
91
|
|
|
92
92
|
/** 明细data */
|
|
93
93
|
const detailsData = tableData[end]?.__details
|
|
@@ -97,8 +97,8 @@ class PrinterStore {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
const detailsHeights = table.body.children.slice(
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
count,
|
|
101
|
+
count + detailsData.length
|
|
102
102
|
)
|
|
103
103
|
|
|
104
104
|
const { ranges, detailsPageHeight } = caclSingleDetailsPageHeight(
|
|
@@ -122,7 +122,7 @@ class PrinterStore {
|
|
|
122
122
|
|
|
123
123
|
@action
|
|
124
124
|
computedPages() {
|
|
125
|
-
// 每页必有 页眉header, 页脚footer
|
|
125
|
+
// 每页必有 页眉header, 页脚footer , 签名
|
|
126
126
|
const allPagesHaveThisHeight = this.height.header + this.height.footer
|
|
127
127
|
// 退出计算! 因为页眉 + 页脚 > currentPageHeight,页面装不下其他东西
|
|
128
128
|
if (allPagesHaveThisHeight > this.pageHeight) {
|
|
@@ -147,7 +147,6 @@ class PrinterStore {
|
|
|
147
147
|
tableCount++
|
|
148
148
|
// 表格原始的高度和宽度信息
|
|
149
149
|
const table = this.tablesInfo[`contents.table.${index}`]
|
|
150
|
-
|
|
151
150
|
const { subtotal, dataKey, summaryConfig } = content
|
|
152
151
|
// 如果显示每页合计,那么table高度多预留一行高度
|
|
153
152
|
const subtotalTrHeight = subtotal.show ? getSumTrHeight(subtotal) : 0
|
|
@@ -182,7 +181,7 @@ class PrinterStore {
|
|
|
182
181
|
/** 当前table剩余的高度 */
|
|
183
182
|
let currentRemainTableHeight = 0
|
|
184
183
|
/** 去最小的tr高度,用于下面的计算compare,(避免特殊情况:一般来说最小tr——height = 23, 比23还小的不考虑计算) */
|
|
185
|
-
const minHeight = Math.max(
|
|
184
|
+
const minHeight = Math.max(getArrayMid(table.body.heights), 23)
|
|
186
185
|
|
|
187
186
|
/* 遍历表格每一行,填充表格内容 */
|
|
188
187
|
while (end < table.body.heights.length) {
|
|
@@ -196,24 +195,29 @@ class PrinterStore {
|
|
|
196
195
|
.plus(table.body.heights[end])
|
|
197
196
|
|
|
198
197
|
/**
|
|
199
|
-
* 说明: 1. currentRemainTableHeight
|
|
200
|
-
* 2. table.body.heights[end]至少要是
|
|
198
|
+
* 说明: 1. currentRemainTableHeight至少要是minHeight的 2倍,不然每次到这都进入if,同时留下一点空白距离
|
|
199
|
+
* 2. table.body.heights[end]至少要是currentRemainTableHeight的 1倍,怕出现打印时最后一行文字显示一半的情况
|
|
201
200
|
* 3. table.body.heights[end] 高度超过了 pageAccomodateTableHeight
|
|
202
201
|
*/
|
|
203
202
|
if (
|
|
204
|
-
(currentRemainTableHeight
|
|
205
|
-
table.body.heights[end] /
|
|
203
|
+
(currentRemainTableHeight / minHeight > 1.5 &&
|
|
204
|
+
table.body.heights[end] / currentRemainTableHeight > 1) ||
|
|
206
205
|
table.body.heights[end] > pageAccomodateTableHeight
|
|
207
206
|
) {
|
|
208
207
|
const detailsPageHeight = this.computedData(
|
|
209
208
|
dataKey,
|
|
210
209
|
table,
|
|
211
|
-
|
|
210
|
+
end,
|
|
212
211
|
currentRemainTableHeight
|
|
213
212
|
)
|
|
214
213
|
|
|
214
|
+
// 拆分明细后,同时也要更新body.heights 不能影响后续计算
|
|
215
215
|
if (detailsPageHeight.length > 0) {
|
|
216
|
-
//
|
|
216
|
+
// 比较剩余高度和minHeight的大小,取最大(防止剩余一条明细时,第二页撑开的高度远大于一条明细的高度)
|
|
217
|
+
detailsPageHeight[1] = Math.max(
|
|
218
|
+
minHeight,
|
|
219
|
+
detailsPageHeight[1]
|
|
220
|
+
)
|
|
217
221
|
table.body.heights.splice(end, 1, ...detailsPageHeight)
|
|
218
222
|
end++
|
|
219
223
|
}
|
|
@@ -270,6 +274,10 @@ class PrinterStore {
|
|
|
270
274
|
break
|
|
271
275
|
}
|
|
272
276
|
|
|
277
|
+
// 如果是最后一页,必须要加上sign的高度,否则会重叠
|
|
278
|
+
if (index === this.config.contents.length - 1) {
|
|
279
|
+
currentPageHeight += this.height?.sign
|
|
280
|
+
}
|
|
273
281
|
if (currentPageHeight <= this.pageHeight) {
|
|
274
282
|
// 空间充足,把信息加入 page,并轮下一个contents
|
|
275
283
|
page.push({
|
package/src/printer/table.js
CHANGED
|
@@ -183,26 +183,25 @@ class Table extends React.Component {
|
|
|
183
183
|
</>
|
|
184
184
|
)
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
const getTdStyle = (index, style) => {
|
|
186
|
+
const getTdStyle = (index, style = {}) => {
|
|
188
187
|
const width = thWidths[index]
|
|
189
188
|
const { fontSize } = style
|
|
189
|
+
let tdStyle = {}
|
|
190
190
|
let minWidth = 24
|
|
191
|
-
if (!width) return
|
|
192
|
-
if (fontSize) minWidth = _.parseInt(fontSize) * 2
|
|
193
191
|
|
|
192
|
+
if (!width) return tdStyle
|
|
193
|
+
if (fontSize) minWidth = _.parseInt(fontSize) * 2
|
|
194
194
|
if (width >= 150) {
|
|
195
|
-
|
|
196
|
-
minWidth:
|
|
197
|
-
maxWidth: width
|
|
195
|
+
tdStyle = {
|
|
196
|
+
minWidth: width
|
|
198
197
|
}
|
|
199
198
|
} else {
|
|
200
|
-
|
|
201
|
-
width: width,
|
|
199
|
+
tdStyle = {
|
|
202
200
|
minWidth,
|
|
203
|
-
|
|
201
|
+
width
|
|
204
202
|
}
|
|
205
203
|
}
|
|
204
|
+
return tdStyle
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
return (
|
|
@@ -216,7 +215,6 @@ class Table extends React.Component {
|
|
|
216
215
|
data-name={getTableColumnName(name, col.index)}
|
|
217
216
|
draggable
|
|
218
217
|
style={{
|
|
219
|
-
width: thWidths[i],
|
|
220
218
|
...getTdStyle(i, col.headStyle),
|
|
221
219
|
...col.headStyle
|
|
222
220
|
}}
|
|
@@ -254,7 +252,6 @@ class Table extends React.Component {
|
|
|
254
252
|
key={j}
|
|
255
253
|
data-name={getTableColumnName(name, col.index)}
|
|
256
254
|
style={{
|
|
257
|
-
width: thWidths[j],
|
|
258
255
|
...getTdStyle(j, col.style),
|
|
259
256
|
...col.style
|
|
260
257
|
}}
|
package/src/util.js
CHANGED
|
@@ -220,10 +220,13 @@ const caclSingleDetailsPageHeight = (detailsHeights, curRemainPageHeight) => {
|
|
|
220
220
|
* @param {*} arr
|
|
221
221
|
*/
|
|
222
222
|
const getArrayMid = arr => {
|
|
223
|
+
/** 数组元素出现次数的集合 */
|
|
223
224
|
const mapArr = []
|
|
224
225
|
const map = new Map()
|
|
225
|
-
|
|
226
|
+
let majority = 23
|
|
227
|
+
/** 次数相同的元素集合 */
|
|
226
228
|
const majorityArr = []
|
|
229
|
+
const min = Math.min(...arr)
|
|
227
230
|
|
|
228
231
|
if (arr.length === 0) return majority
|
|
229
232
|
|
|
@@ -240,7 +243,11 @@ const getArrayMid = arr => {
|
|
|
240
243
|
}
|
|
241
244
|
// 如果没有众数,就取最小值
|
|
242
245
|
if (Array.from(new Set(mapArr)).length === 1) {
|
|
243
|
-
|
|
246
|
+
// 如果说min也远远大于23, 就返回23吧
|
|
247
|
+
if (min / 23 > 10) {
|
|
248
|
+
return 23
|
|
249
|
+
}
|
|
250
|
+
return min
|
|
244
251
|
}
|
|
245
252
|
|
|
246
253
|
const maxCount = Math.max(...mapArr)
|
|
@@ -249,8 +256,17 @@ const getArrayMid = arr => {
|
|
|
249
256
|
majorityArr.push(val)
|
|
250
257
|
}
|
|
251
258
|
}
|
|
259
|
+
majority = Math.min(...majorityArr)
|
|
260
|
+
// 如果说取的众数也远远大于min,
|
|
261
|
+
if (majority / min > 3) {
|
|
262
|
+
// 如果说min也远远大于23, 就返回23吧
|
|
263
|
+
if (min / 23 > 10) {
|
|
264
|
+
return 23
|
|
265
|
+
}
|
|
266
|
+
return min
|
|
267
|
+
}
|
|
252
268
|
|
|
253
|
-
return
|
|
269
|
+
return majority
|
|
254
270
|
}
|
|
255
271
|
|
|
256
272
|
export {
|