Commit 5bdf6d73 authored by 何虹's avatar 何虹 💬

升级数字精度校验

parent 313f4f89
......@@ -20,13 +20,13 @@
"axios": "^0.19.2",
"core-js": "^3.6.4",
"echarts": "^4.7.0",
"element-ui": "^2.14.1",
"element-ui": "^2.15.0",
"file-saver": "^2.0.5",
"hs-util-js": "^1.0.23",
"i": "^0.3.6",
"jsoneditor": "^8.6.5",
"lodash": "^4.17.15",
"mathjs": "^8.1.0",
"mathjs": "^9.0.0",
"moment": "^2.24.0",
"script-loader": "^0.7.2",
"sortablejs": "^1.12.0",
......
......@@ -315,7 +315,7 @@ import tableTool from './tableColumsTrans'
import tableToolComponentRow from './tableToolComponentRow'
import tableToolComponentColumn from './tableToolComponentColumn'
import tableHandleComponent from './tableHandleComponent'
import { add } from 'mathjs'
// import { add } from 'mathjs'
import _ from 'lodash'
import tbaleColumsSet from '../../common/tbaleColumsSet'
// import utilsExcel from '../../funTools/excel/utils_excel'
......@@ -323,6 +323,17 @@ import rowTable from './rowTable'
import commonMixins from '../../ucClass/commonMixins'
// import hsUtil from 'hs-util-js'
import uuT from './exportExcel'
import { create, all } from 'mathjs'
const config = {
epsilon: 1e-12,
matrix: 'Matrix',
number: 'number', // 可选值:number BigNumber
precision: 64,
predictable: false,
randomSeed: null
}
const math = create(all, config)
export default {
mixins: [commonMixins],
components: {
......@@ -775,6 +786,9 @@ export default {
// 返回一个二维数组的表尾合计(不要平均值,你就不要在数组中添加)
return [means]
},
mathFormatAdd(num1, num2) {
return math.format(math.add(math.bignumber(num1), math.bignumber(num2)))
},
getSummaries(param) {
const { columns } = param
const sums = []
......@@ -791,7 +805,8 @@ export default {
if (item[key]) {
// 利用mathjs 来计算精度问题
// sumObj[key] = NP.plus(sumObj[key], Number(item[key]))
sumObj[key] = add(sumObj[key], Number(item[key]))
sumObj[key] = this.mathFormatAdd(sumObj[key], item[key])
//math.add(sumObj[key], Number(item[key]))
// sumObj[key] += Number(item[key])
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment