|
@@ -5,7 +5,7 @@ import React, { useEffect, useState, useMemo } from 'react'
|
|
|
import { apiGetContractSurvey } from './api'
|
|
|
import Content from './components/Content'
|
|
|
import './index.scss'
|
|
|
-
|
|
|
+import { BigNumber } from 'bignumber.js'
|
|
|
type ireturnDate = {
|
|
|
[key: string]: number
|
|
|
}
|
|
@@ -87,9 +87,12 @@ export default function Summary() {
|
|
|
}
|
|
|
|
|
|
const newDualAxes = dualAxes.map(item => {
|
|
|
- return { ...item, count: (isNaN(item.value / totalContractPrice) ? 0 : (parseFloat((item.value / totalContractPrice).toFixed(2))) * 100) }
|
|
|
+
|
|
|
+ return { ...item, count: new BigNumber(item.value).dividedBy(totalContractPrice).multipliedBy(100).toFixed(2) }
|
|
|
})
|
|
|
- const progress = totalPaidPriceShow ? (totalPaidPriceShow / totalContractPrice) : 0
|
|
|
+
|
|
|
+ let progress = parseFloat(new BigNumber(totalPaidPriceShow).dividedBy(totalContractPrice).toFixed(2))
|
|
|
+ isNaN(progress) && (progress = 0)
|
|
|
return { pieData, returnDate: newDualAxes, totalContractPrice, totalContractPriceShow, totalPaidPriceShow, progress }
|
|
|
}, [ state.expenditureData ])
|
|
|
|
|
@@ -119,17 +122,18 @@ export default function Summary() {
|
|
|
}
|
|
|
}
|
|
|
const newDualAxes = dualAxes.map(item => {
|
|
|
- return { ...item, count: (isNaN(item.value / totalContractPrice) ? 0 : (parseFloat((item.value / totalContractPrice).toFixed(2))) * 100) }
|
|
|
+ return { ...item, count: new BigNumber(item.value).dividedBy(totalContractPrice).multipliedBy(100).toFixed(2) }
|
|
|
})
|
|
|
- const progress = totalReturnPriceShow ? (totalReturnPriceShow / totalContractPrice) : 0
|
|
|
+ let progress = parseFloat(new BigNumber(totalReturnPriceShow).dividedBy(totalContractPrice).toFixed(2))
|
|
|
+ isNaN(progress) && (progress = 0)
|
|
|
return { pieData, returnDate: newDualAxes, totalContractPrice, totalContractPriceShow, totalReturnPriceShow, progress }
|
|
|
}, [ state.incomeData ])
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="合同概况" />
|
|
|
<div className="wrap-content p-3 pi-grid pi-col-2 pi-col-space-3">
|
|
|
- <Content data={expenditurePieData} type="expenditure" />
|
|
|
<Content data={incomePieData} type="income" />
|
|
|
+ <Content data={expenditurePieData} type="expenditure" />
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|