You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dashboard/src/views/Home.jsx

79 lines
2.3 KiB
React

import { useContext, useEffect } from 'react';
import { observer } from 'mobx-react';
import { Row, Col, Spin, Card, Statistic, Progress } from 'antd';
import { stores_Context } from '../config';
import { useNavigate } from 'react-router-dom';
import { SlackOutlined, SketchOutlined, AntCloudOutlined, RedditOutlined, GithubOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons';
2 years ago
import { empty } from './../utils/commons';
import './home.css';
3 years ago
2 years ago
export default observer(() => {
const navigate = useNavigate();
const { TradeStore } = useContext(stores_Context);
2 years ago
const { sideData, summaryData, topData } = TradeStore;
3 years ago
useEffect(() => {
2 years ago
if (empty(summaryData.dataSource)) {
TradeStore.fetchSummaryData();
2 years ago
TradeStore.fetchTradeDataByMonth();
2 years ago
TradeStore.fetchTradeDataByType('Country');
TradeStore.fetchTradeDataByType('Area');
}
return () => {};
}, []);
3 years ago
const StatisticCard = (props) => {
const valueStyle = { color: props.VSrate < 0 ? '#cf1322' : '#3f8600' };
const VSIcon = () => (props.VSrate < 0 ? <ArrowDownOutlined /> : <ArrowUpOutlined />);
3 years ago
return (
<Card>
<Statistic
className={'__hn-sta-wrapper'}
valueStyle={valueStyle}
suffix={
props.VSrate && (
<>
<VSIcon />
<span>{props.VSrate}</span>
<span>%</span>
</>
)
}
{...props}
/>
{props.showProgress !== false && <Progress percent={props.KPIrate} size="small" format={(percent) => `${props.KPIrate}%`} />}
</Card>
3 years ago
);
};
3 years ago
2 years ago
const layoutProps = {
gutter: { xs: 8, sm: 8, lg: 16 },
lg: { span: 6 },
sm: { span: 12 },
xs: { span: 24 },
};
return (
<>
<h2>年度业绩</h2>
<section>
<Spin spinning={summaryData.loading}>
2 years ago
<Row gutter={layoutProps.gutter}>
{summaryData.dataSource.map(item =>
<Col {...layoutProps} key={item.title}>
<StatisticCard {...item} showProgress={(item.hasKPI)} />
</Col>
2 years ago
)}
</Row>
</Spin>
</section>
2 years ago
<h3>市场进度</h3>
<section>
2 years ago
<Spin spinning={sideData.loading}></Spin>
</section>
2 years ago
<h3>TOP</h3>
<section></section>
</>
);
2 years ago
});