|
|
@ -1,6 +1,5 @@ |
|
|
import { Pie } from '@ant-design/plots'; |
|
|
import { Pie } from '@ant-design/plots'; |
|
|
import { Card, Radio, Typography } from 'antd'; |
|
|
import { Card, Segmented, Typography } from 'antd'; |
|
|
import type { RadioChangeEvent } from 'antd/es/radio'; |
|
|
|
|
|
import numeral from 'numeral'; |
|
|
import numeral from 'numeral'; |
|
|
import React from 'react'; |
|
|
import React from 'react'; |
|
|
import type { DataItem } from '../data.d'; |
|
|
import type { DataItem } from '../data.d'; |
|
|
@ -18,14 +17,14 @@ const ProportionSales = ({ |
|
|
dropdownGroup: React.ReactNode; |
|
|
dropdownGroup: React.ReactNode; |
|
|
salesType: 'all' | 'online' | 'stores'; |
|
|
salesType: 'all' | 'online' | 'stores'; |
|
|
salesPieData: DataItem[]; |
|
|
salesPieData: DataItem[]; |
|
|
handleChangeSalesType?: (e: RadioChangeEvent) => void; |
|
|
handleChangeSalesType?: (value: 'all' | 'online' | 'stores') => void; |
|
|
}) => { |
|
|
}) => { |
|
|
const { styles } = useStyles(); |
|
|
const { styles } = useStyles(); |
|
|
return ( |
|
|
return ( |
|
|
<Card |
|
|
<Card |
|
|
loading={loading} |
|
|
loading={loading} |
|
|
className={styles.salesCard} |
|
|
className={styles.salesCard} |
|
|
bordered={false} |
|
|
variant="borderless" |
|
|
title="销售额类别占比" |
|
|
title="销售额类别占比" |
|
|
style={{ |
|
|
style={{ |
|
|
height: '100%', |
|
|
height: '100%', |
|
|
@ -33,17 +32,20 @@ const ProportionSales = ({ |
|
|
extra={ |
|
|
extra={ |
|
|
<div className={styles.salesCardExtra}> |
|
|
<div className={styles.salesCardExtra}> |
|
|
{dropdownGroup} |
|
|
{dropdownGroup} |
|
|
<div className={styles.salesTypeRadio}> |
|
|
<Segmented |
|
|
<Radio.Group value={salesType} onChange={handleChangeSalesType}> |
|
|
className={styles.salesTypeRadio} |
|
|
<Radio.Button value="all">全部渠道</Radio.Button> |
|
|
value={salesType} |
|
|
<Radio.Button value="online">线上</Radio.Button> |
|
|
onChange={handleChangeSalesType} |
|
|
<Radio.Button value="stores">门店</Radio.Button> |
|
|
options={[ |
|
|
</Radio.Group> |
|
|
{ label: '全部渠道', value: 'all' }, |
|
|
</div> |
|
|
{ label: '线上', value: 'online' }, |
|
|
|
|
|
{ label: '门店', value: 'stores' }, |
|
|
|
|
|
]} |
|
|
|
|
|
size="middle" |
|
|
|
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
} |
|
|
} |
|
|
> |
|
|
> |
|
|
<div> |
|
|
|
|
|
<Text>销售额</Text> |
|
|
<Text>销售额</Text> |
|
|
<Pie |
|
|
<Pie |
|
|
height={340} |
|
|
height={340} |
|
|
@ -55,12 +57,10 @@ const ProportionSales = ({ |
|
|
legend={false} |
|
|
legend={false} |
|
|
label={{ |
|
|
label={{ |
|
|
position: 'spider', |
|
|
position: 'spider', |
|
|
text: (item: { x: number; y: number }) => { |
|
|
text: (item: { x: number; y: number }) => |
|
|
return `${item.x}: ${numeral(item.y).format('0,0')}`; |
|
|
`${item.x}: ${numeral(item.y).format('0,0')}`, |
|
|
}, |
|
|
|
|
|
}} |
|
|
}} |
|
|
/> |
|
|
/> |
|
|
</div> |
|
|
|
|
|
</Card> |
|
|
</Card> |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|
|