no message
This commit is contained in:
151
src/pages/index/index.tsx
Normal file
151
src/pages/index/index.tsx
Normal file
@@ -0,0 +1,151 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
import { PageContainer, ProTable } from '@ant-design/pro-components';
|
||||
import { Card, Col, Row, Statistic, Divider, Tag, Image } from 'antd';
|
||||
import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
|
||||
|
||||
import { statMallStatistics, getAmountAndGoodsCount } from '@/services/home/index'
|
||||
import { Line } from '@ant-design/charts';
|
||||
|
||||
export default () => {
|
||||
const [deviceData, setDeviceData] = useState([]);
|
||||
const [profit, setProfit] = useState([]);
|
||||
const [shop, setShop] = useState([]);
|
||||
const deviceConfig = {
|
||||
data: deviceData,
|
||||
xField: 'name',
|
||||
yField: 'value',
|
||||
seriesField: 'type',
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
},
|
||||
padding: 'auto',
|
||||
legend: { position: 'right-top' },
|
||||
yAxis: {
|
||||
label: {
|
||||
// 数值格式化为千分位
|
||||
formatter: (v) => `${v}`.replace(/\d{1,3}(?=(\d{3})+$)/g, (s) => `${s},`),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
statMallStatistics().then((res) => {
|
||||
setProfit(res.data)
|
||||
})
|
||||
getAmountAndGoodsCount().then((res) => {
|
||||
let list = []
|
||||
res.data.map((item, index) => {
|
||||
list.push({
|
||||
"name": item.createTime,
|
||||
"category": "商品数量",
|
||||
"value": item.goodsCount,
|
||||
"type": 1
|
||||
})
|
||||
list.push({
|
||||
"name": item.createTime,
|
||||
"category": "金额",
|
||||
"value": item.amountCount,
|
||||
"type": 2
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
setDeviceData(list)
|
||||
})
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Divider>充电桩</Divider>
|
||||
<Row gutter={10}>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="今日充电"
|
||||
value={profit?.device_count?.today}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="昨日充电"
|
||||
value={profit?.device_count?.yesterday}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="上周充电"
|
||||
value={profit?.device_count?.week}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="上月充电"
|
||||
value={profit?.device_count?.month}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Divider>商城</Divider>
|
||||
<Row gutter={10}>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="今天成交"
|
||||
value={profit?.todayTransaction}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="昨天成交"
|
||||
value={profit?.yesterdayTransaction}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="上周成交"
|
||||
value={profit?.lastWeekTransaction}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="上月成交"
|
||||
value={profit?.lastMonthTransaction}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Divider>商城(商品数量/金额)-折线图</Divider>
|
||||
<Line {...deviceConfig} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user