gm-printer 10.13.7-beta.6 → 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 +31 -11
- package/src/printer/table.js +9 -13
- package/src/util.js +24 -12
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'
|
|
@@ -81,6 +82,13 @@ class PrinterStore {
|
|
|
81
82
|
computedData(dataKey, table, end, currentRemainTableHeight) {
|
|
82
83
|
/** 当前数据 */
|
|
83
84
|
const tableData = this.data._table[dataKey] || []
|
|
85
|
+
|
|
86
|
+
let count = 0
|
|
87
|
+
_.forEach(Array(end).fill(1), (val, i) => {
|
|
88
|
+
const details = tableData[i]?.__details || []
|
|
89
|
+
count += details.length
|
|
90
|
+
})
|
|
91
|
+
|
|
84
92
|
/** 明细data */
|
|
85
93
|
const detailsData = tableData[end]?.__details
|
|
86
94
|
// 如果没有details 和 明细不换行, 就不用计算了
|
|
@@ -88,9 +96,13 @@ class PrinterStore {
|
|
|
88
96
|
return []
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
const detailsHeights = table.body.children.slice(
|
|
100
|
+
count,
|
|
101
|
+
count + detailsData.length
|
|
102
|
+
)
|
|
103
|
+
|
|
91
104
|
const { ranges, detailsPageHeight } = caclSingleDetailsPageHeight(
|
|
92
|
-
|
|
93
|
-
detailsData,
|
|
105
|
+
detailsHeights,
|
|
94
106
|
currentRemainTableHeight
|
|
95
107
|
)
|
|
96
108
|
|
|
@@ -110,7 +122,7 @@ class PrinterStore {
|
|
|
110
122
|
|
|
111
123
|
@action
|
|
112
124
|
computedPages() {
|
|
113
|
-
// 每页必有 页眉header, 页脚footer
|
|
125
|
+
// 每页必有 页眉header, 页脚footer , 签名
|
|
114
126
|
const allPagesHaveThisHeight = this.height.header + this.height.footer
|
|
115
127
|
// 退出计算! 因为页眉 + 页脚 > currentPageHeight,页面装不下其他东西
|
|
116
128
|
if (allPagesHaveThisHeight > this.pageHeight) {
|
|
@@ -135,7 +147,6 @@ class PrinterStore {
|
|
|
135
147
|
tableCount++
|
|
136
148
|
// 表格原始的高度和宽度信息
|
|
137
149
|
const table = this.tablesInfo[`contents.table.${index}`]
|
|
138
|
-
|
|
139
150
|
const { subtotal, dataKey, summaryConfig } = content
|
|
140
151
|
// 如果显示每页合计,那么table高度多预留一行高度
|
|
141
152
|
const subtotalTrHeight = subtotal.show ? getSumTrHeight(subtotal) : 0
|
|
@@ -170,7 +181,7 @@ class PrinterStore {
|
|
|
170
181
|
/** 当前table剩余的高度 */
|
|
171
182
|
let currentRemainTableHeight = 0
|
|
172
183
|
/** 去最小的tr高度,用于下面的计算compare,(避免特殊情况:一般来说最小tr——height = 23, 比23还小的不考虑计算) */
|
|
173
|
-
const minHeight = Math.max(
|
|
184
|
+
const minHeight = Math.max(getArrayMid(table.body.heights), 23)
|
|
174
185
|
|
|
175
186
|
/* 遍历表格每一行,填充表格内容 */
|
|
176
187
|
while (end < table.body.heights.length) {
|
|
@@ -184,13 +195,13 @@ class PrinterStore {
|
|
|
184
195
|
.plus(table.body.heights[end])
|
|
185
196
|
|
|
186
197
|
/**
|
|
187
|
-
* 说明: 1. currentRemainTableHeight
|
|
188
|
-
* 2. table.body.heights[end]至少要是
|
|
198
|
+
* 说明: 1. currentRemainTableHeight至少要是minHeight的 2倍,不然每次到这都进入if,同时留下一点空白距离
|
|
199
|
+
* 2. table.body.heights[end]至少要是currentRemainTableHeight的 1倍,怕出现打印时最后一行文字显示一半的情况
|
|
189
200
|
* 3. table.body.heights[end] 高度超过了 pageAccomodateTableHeight
|
|
190
201
|
*/
|
|
191
202
|
if (
|
|
192
|
-
(currentRemainTableHeight
|
|
193
|
-
table.body.heights[end] /
|
|
203
|
+
(currentRemainTableHeight / minHeight > 1.5 &&
|
|
204
|
+
table.body.heights[end] / currentRemainTableHeight > 1) ||
|
|
194
205
|
table.body.heights[end] > pageAccomodateTableHeight
|
|
195
206
|
) {
|
|
196
207
|
const detailsPageHeight = this.computedData(
|
|
@@ -200,8 +211,13 @@ class PrinterStore {
|
|
|
200
211
|
currentRemainTableHeight
|
|
201
212
|
)
|
|
202
213
|
|
|
214
|
+
// 拆分明细后,同时也要更新body.heights 不能影响后续计算
|
|
203
215
|
if (detailsPageHeight.length > 0) {
|
|
204
|
-
//
|
|
216
|
+
// 比较剩余高度和minHeight的大小,取最大(防止剩余一条明细时,第二页撑开的高度远大于一条明细的高度)
|
|
217
|
+
detailsPageHeight[1] = Math.max(
|
|
218
|
+
minHeight,
|
|
219
|
+
detailsPageHeight[1]
|
|
220
|
+
)
|
|
205
221
|
table.body.heights.splice(end, 1, ...detailsPageHeight)
|
|
206
222
|
end++
|
|
207
223
|
}
|
|
@@ -258,6 +274,10 @@ class PrinterStore {
|
|
|
258
274
|
break
|
|
259
275
|
}
|
|
260
276
|
|
|
277
|
+
// 如果是最后一页,必须要加上sign的高度,否则会重叠
|
|
278
|
+
if (index === this.config.contents.length - 1) {
|
|
279
|
+
currentPageHeight += this.height?.sign
|
|
280
|
+
}
|
|
261
281
|
if (currentPageHeight <= this.pageHeight) {
|
|
262
282
|
// 空间充足,把信息加入 page,并轮下一个contents
|
|
263
283
|
page.push({
|
package/src/printer/table.js
CHANGED
|
@@ -183,27 +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,
|
|
198
|
-
wordBreak: 'break-all'
|
|
195
|
+
tdStyle = {
|
|
196
|
+
minWidth: width
|
|
199
197
|
}
|
|
200
198
|
} else {
|
|
201
|
-
|
|
202
|
-
width: width,
|
|
199
|
+
tdStyle = {
|
|
203
200
|
minWidth,
|
|
204
|
-
|
|
201
|
+
width
|
|
205
202
|
}
|
|
206
203
|
}
|
|
204
|
+
return tdStyle
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
return (
|
|
@@ -217,7 +215,6 @@ class Table extends React.Component {
|
|
|
217
215
|
data-name={getTableColumnName(name, col.index)}
|
|
218
216
|
draggable
|
|
219
217
|
style={{
|
|
220
|
-
width: thWidths[i],
|
|
221
218
|
...getTdStyle(i, col.headStyle),
|
|
222
219
|
...col.headStyle
|
|
223
220
|
}}
|
|
@@ -255,7 +252,6 @@ class Table extends React.Component {
|
|
|
255
252
|
key={j}
|
|
256
253
|
data-name={getTableColumnName(name, col.index)}
|
|
257
254
|
style={{
|
|
258
|
-
width: thWidths[j],
|
|
259
255
|
...getTdStyle(j, col.style),
|
|
260
256
|
...col.style
|
|
261
257
|
}}
|
package/src/util.js
CHANGED
|
@@ -179,16 +179,12 @@ const getDataKey = (dataKey, arrange) =>
|
|
|
179
179
|
: dataKey
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
* @param {*}
|
|
182
|
+
* @param {*} detailsHeights 当钱明细高度集
|
|
183
183
|
* @param {*} detailsData 当前所有tablelist
|
|
184
184
|
* @param {*} curRemainPageHeight 可容纳table的总高度
|
|
185
185
|
* @returns {ranges, detailsPageHeight} detailsPageHeight 每页高度合集
|
|
186
186
|
*/
|
|
187
|
-
const caclSingleDetailsPageHeight = (
|
|
188
|
-
table,
|
|
189
|
-
detailsData,
|
|
190
|
-
curRemainPageHeight
|
|
191
|
-
) => {
|
|
187
|
+
const caclSingleDetailsPageHeight = (detailsHeights, curRemainPageHeight) => {
|
|
192
188
|
let [end, deadline] = [0, 0]
|
|
193
189
|
const begin = 0
|
|
194
190
|
/** 当前明细高度,默认为tr的border+padding的height */
|
|
@@ -199,13 +195,13 @@ const caclSingleDetailsPageHeight = (
|
|
|
199
195
|
let remainDetailsHeight = 5
|
|
200
196
|
|
|
201
197
|
// 如果当前累计高度高于当前剩余高度,则跳出返回
|
|
202
|
-
while (end <
|
|
203
|
-
const height = currentDetailsMiniHeight +
|
|
198
|
+
while (end < detailsHeights.length) {
|
|
199
|
+
const height = currentDetailsMiniHeight + detailsHeights[end]
|
|
204
200
|
if (height < curRemainPageHeight) {
|
|
205
201
|
currentDetailsMiniHeight = height
|
|
206
202
|
deadline++
|
|
207
203
|
} else {
|
|
208
|
-
remainDetailsHeight +=
|
|
204
|
+
remainDetailsHeight += detailsHeights[end]
|
|
209
205
|
}
|
|
210
206
|
end++
|
|
211
207
|
}
|
|
@@ -224,10 +220,13 @@ const caclSingleDetailsPageHeight = (
|
|
|
224
220
|
* @param {*} arr
|
|
225
221
|
*/
|
|
226
222
|
const getArrayMid = arr => {
|
|
223
|
+
/** 数组元素出现次数的集合 */
|
|
227
224
|
const mapArr = []
|
|
228
225
|
const map = new Map()
|
|
229
|
-
|
|
226
|
+
let majority = 23
|
|
227
|
+
/** 次数相同的元素集合 */
|
|
230
228
|
const majorityArr = []
|
|
229
|
+
const min = Math.min(...arr)
|
|
231
230
|
|
|
232
231
|
if (arr.length === 0) return majority
|
|
233
232
|
|
|
@@ -244,7 +243,11 @@ const getArrayMid = arr => {
|
|
|
244
243
|
}
|
|
245
244
|
// 如果没有众数,就取最小值
|
|
246
245
|
if (Array.from(new Set(mapArr)).length === 1) {
|
|
247
|
-
|
|
246
|
+
// 如果说min也远远大于23, 就返回23吧
|
|
247
|
+
if (min / 23 > 10) {
|
|
248
|
+
return 23
|
|
249
|
+
}
|
|
250
|
+
return min
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
const maxCount = Math.max(...mapArr)
|
|
@@ -253,8 +256,17 @@ const getArrayMid = arr => {
|
|
|
253
256
|
majorityArr.push(val)
|
|
254
257
|
}
|
|
255
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
|
+
}
|
|
256
268
|
|
|
257
|
-
return
|
|
269
|
+
return majority
|
|
258
270
|
}
|
|
259
271
|
|
|
260
272
|
export {
|