|
@@ -5,6 +5,8 @@ import { dayjsFormat, formatMoney } from '@/utils/util'
|
|
|
import { Tooltip } from 'antd'
|
|
|
import React, { useMemo } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
+import { BigNumber } from "bignumber.js"
|
|
|
+
|
|
|
interface DetailProps {
|
|
|
contract: iContractState
|
|
|
type: "income" | "expenditure"
|
|
@@ -13,10 +15,12 @@ const Detail:React.FC<DetailProps> = (props) => {
|
|
|
const { contract, type } = props
|
|
|
const type_name = type === ContractType.INCOME ? '回款' : '支付'
|
|
|
const progress = useMemo(() => {
|
|
|
- const i = parseFloat((parseFloat(type === ContractType.INCOME ? contract.returned : contract.paid) / parseFloat(contract.price)).toFixed(2))
|
|
|
- const j: number = 1 - i
|
|
|
+ const i = new BigNumber(type === ContractType.INCOME ? contract.returned : contract.paid).dividedBy(contract.price).toFixed(2)
|
|
|
+ // const i = parseFloat((parseFloat(type === ContractType.INCOME ? contract.returned : contract.paid) / parseFloat()).toFixed(2))
|
|
|
+
|
|
|
+ const j = new BigNumber(1).minus(i)
|
|
|
const k: number = parseFloat(contract.price) - parseFloat(type === ContractType.INCOME ? contract.returned : contract.paid)
|
|
|
- return { returned: isNaN(i) ? '0%' : i * 100 + '%', unReturned: isNaN(j) ? '100%' : j * 100 + '%', unReturnedMoney: k }
|
|
|
+ return { returned: new BigNumber(i).multipliedBy(100) + '%', unReturned: new BigNumber(j).multipliedBy(100) + '%', unReturnedMoney: k }
|
|
|
}, [ contract ])
|
|
|
return contract.id ? (
|
|
|
<div className={styles.detailTab}>
|