|
@@ -1,6 +1,6 @@
|
|
|
import React, { memo } from 'react'
|
|
|
import './index.scss'
|
|
|
-import { Pie, G2, DualAxes } from '@ant-design/charts'
|
|
|
+import { Pie, G2, DualAxes } from '@ant-design/charts'
|
|
|
import { PieConfig } from '@ant-design/charts/es/pie'
|
|
|
import './index.scss'
|
|
|
import { dayjsFormat, formatMoney } from '@/utils/util'
|
|
@@ -29,14 +29,13 @@ interface iContentData {
|
|
|
type iDualAxes = {
|
|
|
month: string
|
|
|
value: number
|
|
|
+ count: number
|
|
|
}[]
|
|
|
interface iContentProps {
|
|
|
data: iContentData
|
|
|
type: 'expenditure' | 'income'
|
|
|
}
|
|
|
const Content:React.FC<iContentProps> = ({ data, type }) => {
|
|
|
- console.log(data.progress)
|
|
|
-
|
|
|
const pieConfig:PieConfig = {
|
|
|
data: data.pieData,
|
|
|
autoFit: true,
|
|
@@ -61,12 +60,81 @@ const Content:React.FC<iContentProps> = ({ data, type }) => {
|
|
|
theme: 'custom-pie'
|
|
|
}
|
|
|
|
|
|
- // const dualAxesConfig: DualAxesConfig = {
|
|
|
-
|
|
|
- // }
|
|
|
+ const dualAxesConfig: DualAxesConfig = {
|
|
|
+ data: [ data.returnDate, data.returnDate ],
|
|
|
+ autoFit: true,
|
|
|
+ padding: 'auto',
|
|
|
+ xField: 'month',
|
|
|
+ yField: [ 'value', 'count' ],
|
|
|
+ slider: true,
|
|
|
+ xAxis: {
|
|
|
+ label: {
|
|
|
+ formatter: (val) => dayjsFormat(val, 'YYYY年M月')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ value: {
|
|
|
+ label: {
|
|
|
+ formatter:(val) => `${val} 元`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ count: {
|
|
|
+ label: {
|
|
|
+ formatter: (val) => `${val} %`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ formatter: datum => {
|
|
|
+ const obj = { name: '', value: formatMoney(datum.value) }
|
|
|
+ if (datum.count || datum.count === 0) {
|
|
|
+ obj.name = '占总金额比例'
|
|
|
+ obj.value = datum.count + '%'
|
|
|
+ return obj
|
|
|
+ }
|
|
|
+ if (type === 'expenditure') {
|
|
|
+ obj.name = '回款金额'
|
|
|
+ } else {
|
|
|
+ obj.name = '支付金额'
|
|
|
+ }
|
|
|
+ return obj
|
|
|
+ }
|
|
|
+ },
|
|
|
+ geometryOptions: [
|
|
|
+ {
|
|
|
+ geometry: 'column',
|
|
|
+ seriesField: 'value',
|
|
|
+ columnWidthRatio: 0.4,
|
|
|
+ color: type === 'expenditure' ? '#B5C4B1' : '#A27E7E'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ geometry: 'line',
|
|
|
+ color: type === 'expenditure' ? '#965454' : '#8C8C8C',
|
|
|
+ isStack: true,
|
|
|
+ isPercent: true
|
|
|
+ // smooth: true
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ legend: {
|
|
|
+ custom: true,
|
|
|
+ position: 'top',
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ value: 'value',
|
|
|
+ name: '回款金额',
|
|
|
+ marker: { symbol: 'square', style: { fill: type === 'expenditure' ? '#B5C4B1' : '#A27E7E', r: 5 } }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'count',
|
|
|
+ name: '占总金额比例',
|
|
|
+ marker: { symbol: 'square', style: { fill: type === 'expenditure' ? '#965454' : '#8C8C8C', r: 5 } }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
|
- <div className="pi-flex-column">
|
|
|
+ <div className="pi-flex-column pi-justify-between">
|
|
|
<div className="card-body card-border">
|
|
|
<h5 className="card-title">{type === 'expenditure' ? '收入' : '支出'}合同结算进度</h5>
|
|
|
<div className="mb-0">
|
|
@@ -105,9 +173,9 @@ const Content:React.FC<iContentProps> = ({ data, type }) => {
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className="card-body card-border">
|
|
|
- <h5 className="">{type === 'expenditure' ? '收入' : '支出'}合同结算趋势</h5>
|
|
|
- {/* <DualAxes></DualAxes> */}
|
|
|
+ <div className="card-body card-border dual-axes-content pi-mg-bottom-32">
|
|
|
+ {/* <h5>{type === 'expenditure' ? '收入' : '支出'}合同结算趋势</h5> */}
|
|
|
+ <DualAxes {...dualAxesConfig}></DualAxes>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|