You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
225 lines
6.9 KiB
225 lines
6.9 KiB
import { Column } from '@ant-design/plots';
|
|
import { Button, Card, Col, DatePicker, Row, Tabs } from 'antd';
|
|
import type { RangePickerProps } from 'antd/es/date-picker';
|
|
import numeral from 'numeral';
|
|
import type { DataItem } from '../data.d';
|
|
import useStyles from '../style.style';
|
|
|
|
export type TimeType = 'today' | 'week' | 'month' | 'year';
|
|
const { RangePicker } = DatePicker;
|
|
|
|
const rankingListData: {
|
|
title: string;
|
|
total: number;
|
|
}[] = [];
|
|
|
|
for (let i = 0; i < 7; i += 1) {
|
|
rankingListData.push({
|
|
title: `工专路 ${i} 号店`,
|
|
total: 323234,
|
|
});
|
|
}
|
|
|
|
const SalesCard = ({
|
|
rangePickerValue,
|
|
salesData,
|
|
isActive,
|
|
handleRangePickerChange,
|
|
loading,
|
|
selectDate,
|
|
}: {
|
|
rangePickerValue: RangePickerProps['value'];
|
|
isActive: (key: TimeType) => string;
|
|
salesData: DataItem[];
|
|
loading: boolean;
|
|
handleRangePickerChange: RangePickerProps['onChange'];
|
|
selectDate: (key: TimeType) => void;
|
|
}) => {
|
|
const { styles } = useStyles();
|
|
return (
|
|
<Card
|
|
loading={loading}
|
|
variant="borderless"
|
|
styles={{
|
|
body: {
|
|
padding: loading ? 24 : 0,
|
|
},
|
|
}}
|
|
>
|
|
<Tabs
|
|
className={styles.salesCard}
|
|
tabBarExtraContent={
|
|
<div className={styles.salesExtraWrap}>
|
|
<div className={styles.salesExtra}>
|
|
<Button
|
|
type="text"
|
|
className={isActive('today')}
|
|
onClick={() => selectDate('today')}
|
|
>
|
|
今日
|
|
</Button>
|
|
<Button
|
|
type="text"
|
|
className={isActive('week')}
|
|
onClick={() => selectDate('week')}
|
|
>
|
|
本周
|
|
</Button>
|
|
<Button
|
|
type="text"
|
|
className={isActive('month')}
|
|
onClick={() => selectDate('month')}
|
|
>
|
|
本月
|
|
</Button>
|
|
<Button
|
|
type="text"
|
|
className={isActive('year')}
|
|
onClick={() => selectDate('year')}
|
|
>
|
|
本年
|
|
</Button>
|
|
</div>
|
|
<RangePicker
|
|
value={rangePickerValue}
|
|
onChange={handleRangePickerChange}
|
|
variant="filled"
|
|
style={{
|
|
width: 256,
|
|
}}
|
|
/>
|
|
</div>
|
|
}
|
|
size="large"
|
|
tabBarStyle={{
|
|
marginBottom: 24,
|
|
}}
|
|
items={[
|
|
{
|
|
key: 'sales',
|
|
label: '销售额',
|
|
children: (
|
|
<Row>
|
|
<Col xl={16} lg={12} md={12} sm={24} xs={24}>
|
|
<div className={styles.salesBar}>
|
|
<Column
|
|
height={300}
|
|
data={salesData}
|
|
xField="x"
|
|
yField="y"
|
|
paddingBottom={12}
|
|
axis={{
|
|
x: {
|
|
title: false,
|
|
},
|
|
y: {
|
|
title: false,
|
|
gridLineDash: null,
|
|
gridStroke: '#ccc',
|
|
},
|
|
}}
|
|
scale={{
|
|
x: { paddingInner: 0.4 },
|
|
}}
|
|
tooltip={{
|
|
name: '销售量',
|
|
channel: 'y',
|
|
}}
|
|
/>
|
|
</div>
|
|
</Col>
|
|
<Col xl={8} lg={12} md={12} sm={24} xs={24}>
|
|
<div className={styles.salesRank}>
|
|
<h4 className={styles.rankingTitle}>门店销售额排名</h4>
|
|
<ul className={styles.rankingList}>
|
|
{rankingListData.map((item, i) => (
|
|
<li key={item.title}>
|
|
<span
|
|
className={`${styles.rankingItemNumber} ${
|
|
i < 3 ? styles.rankingItemNumberActive : ''
|
|
}`}
|
|
>
|
|
{i + 1}
|
|
</span>
|
|
<span
|
|
className={styles.rankingItemTitle}
|
|
title={item.title}
|
|
>
|
|
{item.title}
|
|
</span>
|
|
<span>{numeral(item.total).format('0,0')}</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
</Col>
|
|
</Row>
|
|
),
|
|
},
|
|
{
|
|
key: 'views',
|
|
label: '访问量',
|
|
children: (
|
|
<Row>
|
|
<Col xl={16} lg={12} md={12} sm={24} xs={24}>
|
|
<div className={styles.salesBar}>
|
|
<Column
|
|
height={300}
|
|
data={salesData}
|
|
xField="x"
|
|
yField="y"
|
|
paddingBottom={12}
|
|
axis={{
|
|
x: {
|
|
title: false,
|
|
},
|
|
y: {
|
|
title: false,
|
|
},
|
|
}}
|
|
scale={{
|
|
x: { paddingInner: 0.4 },
|
|
}}
|
|
tooltip={{
|
|
name: '访问量',
|
|
channel: 'y',
|
|
}}
|
|
/>
|
|
</div>
|
|
</Col>
|
|
<Col xl={8} lg={12} md={12} sm={24} xs={24}>
|
|
<div className={styles.salesRank}>
|
|
<h4 className={styles.rankingTitle}>门店访问量排名</h4>
|
|
<ul className={styles.rankingList}>
|
|
{rankingListData.map((item, i) => (
|
|
<li key={item.title}>
|
|
<span
|
|
className={`${
|
|
i < 3
|
|
? styles.rankingItemNumberActive
|
|
: styles.rankingItemNumber
|
|
}`}
|
|
>
|
|
{i + 1}
|
|
</span>
|
|
<span
|
|
className={styles.rankingItemTitle}
|
|
title={item.title}
|
|
>
|
|
{item.title}
|
|
</span>
|
|
<span>{numeral(item.total).format('0,0')}</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
</Col>
|
|
</Row>
|
|
),
|
|
},
|
|
]}
|
|
/>
|
|
</Card>
|
|
);
|
|
};
|
|
export default SalesCard;
|
|
|