Commit ad3caed1 authored by XieZhiXiong's avatar XieZhiXiong

fix: 解决数值运算精度的问题

parent 30100405
......@@ -51,6 +51,7 @@
"@umijs/test": "^3.2.0",
"antd-img-crop": "^3.12.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"bignumber.js": "^9.0.1",
"bizcharts": "^4.0.14",
"copy-to-clipboard": "^3.3.1",
"crypto-js": "^4.0.0",
......
......@@ -2,14 +2,13 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-05 13:53:58
* @LastEditTime: 2021-01-21 11:29:52
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
import lodash from 'lodash';
import BigNumber from 'bignumber.js';
import { FormEffectHooks, FormPath } from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { PublicApi } from '@/services/api';
const {
onFieldInputChange$,
......@@ -28,7 +27,7 @@ export const useBusinessEffects = (context, actions) => {
// 联动退款金额
onFieldValueChange$('payList.*.refundAmount').subscribe(fieldState => {
const payListValue = getFieldValue('payList');
const amount = payListValue.reduce((pre, now) => +now.refundAmount + pre, 0);
const amount = payListValue.reduce((pre, now) => new BigNumber(+now.refundAmount).plus(pre).toNumber(), 0);
setFieldValue('refundAmount', amount);
});
......@@ -39,7 +38,7 @@ export const useBusinessEffects = (context, actions) => {
const newData = [...getFieldValue('payList')].map(item => {
return {
...item,
refundAmount: +(+value * purchasePriceValue * (item.payRatio / 100)).toFixed(2),
refundAmount: +(new BigNumber(+value).multipliedBy(purchasePriceValue).multipliedBy(new BigNumber(item.payRatio).dividedBy(100))).toFixed(2),
};
});
setFieldValue('payList', newData);
......
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