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

升级数字精度校验

parent 313f4f89
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
"axios": "^0.19.2", "axios": "^0.19.2",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"echarts": "^4.7.0", "echarts": "^4.7.0",
"element-ui": "^2.14.1", "element-ui": "^2.15.0",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"hs-util-js": "^1.0.23", "hs-util-js": "^1.0.23",
"i": "^0.3.6", "i": "^0.3.6",
"jsoneditor": "^8.6.5", "jsoneditor": "^8.6.5",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"mathjs": "^8.1.0", "mathjs": "^9.0.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"script-loader": "^0.7.2", "script-loader": "^0.7.2",
"sortablejs": "^1.12.0", "sortablejs": "^1.12.0",
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
></i> ></i>
<childItem <childItem
v-else v-else
:disabled='disabled' :disabled='disabled'
:editable='editable' :editable='editable'
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners" v-on="$listeners"
...@@ -315,7 +315,7 @@ import tableTool from './tableColumsTrans' ...@@ -315,7 +315,7 @@ import tableTool from './tableColumsTrans'
import tableToolComponentRow from './tableToolComponentRow' import tableToolComponentRow from './tableToolComponentRow'
import tableToolComponentColumn from './tableToolComponentColumn' import tableToolComponentColumn from './tableToolComponentColumn'
import tableHandleComponent from './tableHandleComponent' import tableHandleComponent from './tableHandleComponent'
import { add } from 'mathjs' // import { add } from 'mathjs'
import _ from 'lodash' import _ from 'lodash'
import tbaleColumsSet from '../../common/tbaleColumsSet' import tbaleColumsSet from '../../common/tbaleColumsSet'
// import utilsExcel from '../../funTools/excel/utils_excel' // import utilsExcel from '../../funTools/excel/utils_excel'
...@@ -323,6 +323,17 @@ import rowTable from './rowTable' ...@@ -323,6 +323,17 @@ import rowTable from './rowTable'
import commonMixins from '../../ucClass/commonMixins' import commonMixins from '../../ucClass/commonMixins'
// import hsUtil from 'hs-util-js' // import hsUtil from 'hs-util-js'
import uuT from './exportExcel' 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 { export default {
mixins: [commonMixins], mixins: [commonMixins],
components: { components: {
...@@ -775,6 +786,9 @@ export default { ...@@ -775,6 +786,9 @@ export default {
// 返回一个二维数组的表尾合计(不要平均值,你就不要在数组中添加) // 返回一个二维数组的表尾合计(不要平均值,你就不要在数组中添加)
return [means] return [means]
}, },
mathFormatAdd(num1, num2) {
return math.format(math.add(math.bignumber(num1), math.bignumber(num2)))
},
getSummaries(param) { getSummaries(param) {
const { columns } = param const { columns } = param
const sums = [] const sums = []
...@@ -791,7 +805,8 @@ export default { ...@@ -791,7 +805,8 @@ export default {
if (item[key]) { if (item[key]) {
// 利用mathjs 来计算精度问题 // 利用mathjs 来计算精度问题
// sumObj[key] = NP.plus(sumObj[key], Number(item[key])) // 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]) // 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