fix: welcome page layout

mgy
Dawn1Ocean 2024-04-04 04:09:17 +08:00
parent 29fa1341d8
commit 29704a6197
2 changed files with 71 additions and 48 deletions

View File

@ -42,8 +42,10 @@ data:
{ {
"success": true, "success": true,
"data": { "data": {
"notInOreo": 114, "todayPT": 114, // 今日预填写工单总数
"totalPT": 514, // 所有预填写工单 "totalPT": 514, // 所有预填写工单
"oreo": 93, // 加入 Oreo 工单数
"report": 8, // 今日反馈数
"allSuccess": 1919, // 所有成功工单(包括 Oreo 内) "allSuccess": 1919, // 所有成功工单(包括 Oreo 内)
"all": 2024 // 所有工单(包括 Oreo 内) "all": 2024 // 所有工单(包括 Oreo 内)
} }

View File

@ -4,11 +4,9 @@ import { Card, Statistic } from 'antd';
import RcResizeObserver from 'rc-resize-observer'; import RcResizeObserver from 'rc-resize-observer';
import { useState } from 'react'; import { useState } from 'react';
const { Divider } = ProCard;
const percentRing = (percent: number, frontColor: string): React.JSX.Element => { const percentRing = (percent: number, frontColor: string): React.JSX.Element => {
const config = { const config = {
percent, percent: percent / 100,
width: 120, width: 120,
height: 120, height: 120,
color: ['#E8EFF5', frontColor], color: ['#E8EFF5', frontColor],
@ -16,7 +14,7 @@ const percentRing = (percent: number, frontColor: string): React.JSX.Element =>
{ {
type: 'text', type: 'text',
style: { style: {
text: `${percent * 100}%`, text: `${percent}%`,
x: '50%', x: '50%',
y: '50%', y: '50%',
textAlign: 'center', textAlign: 'center',
@ -30,6 +28,24 @@ const percentRing = (percent: number, frontColor: string): React.JSX.Element =>
return <Tiny.Ring {...config} />; return <Tiny.Ring {...config} />;
}; };
interface IndexData {
todayPT: number;
report: number;
oreo: number;
totalPT: number;
allSuccess: number;
all: number;
}
const indexData: IndexData = {
todayPT: 14,
report: 8,
oreo: 93,
totalPT: 1145,
allSuccess: 1818,
all: 1919,
};
const Logs: React.FC = () => { const Logs: React.FC = () => {
const [responsive, setResponsive] = useState(false); const [responsive, setResponsive] = useState(false);
return ( return (
@ -41,51 +57,56 @@ const Logs: React.FC = () => {
setResponsive(offset.width < 596); setResponsive(offset.width < 596);
}} }}
> >
<ProCard.Group direction={responsive ? 'column' : 'row'}> <ProCard split={responsive ? 'horizontal' : 'vertical'}>
<ProCard> <ProCard title="左侧详情" colSpan="48%">
<Statistic title="今日预填写工单数" value={13} />
</ProCard> </ProCard>
<Divider type={responsive ? 'horizontal' : 'vertical'} /> <ProCard colSpan="20%">
<StatisticCard <StatisticCard
chart={percentRing(0.372, '#00CC66')} style={{ marginTop: '2vh' }}
statistic={{ statistic={{
title: '加入 Oreo 工单数', title: '今日预填写工单数',
value: 93, value: indexData.todayPT,
description: ( description: (
<> <Statistic
<Statistic title="预填写工单总数" value={1145} /> style={{ marginTop: '15vh' }}
</> title="今日反馈数"
), value={indexData.report}
}} />
chartPlacement="left" ),
/> }}
</ProCard.Group> />
</RcResizeObserver>
<RcResizeObserver
key="resize-observer"
onResize={(offset) => {
setResponsive(offset.width < 596);
}}
>
<StatisticCard.Group direction={responsive ? 'column' : 'row'}>
<ProCard>
<Statistic title="今日反馈数" value={8} />
</ProCard> </ProCard>
<Divider type={responsive ? 'horizontal' : 'vertical'} /> <ProCard>
<StatisticCard <StatisticCard.Group direction={responsive ? 'row' : 'column'}>
chart={percentRing(0.642, '#66AFF4')} <StatisticCard
statistic={{ chart={percentRing(
title: '维修成功次数', Math.round(((indexData.oreo / indexData.totalPT) * 1000) / 10),
value: 1818, '#00CC66',
description: ( )}
<> statistic={{
<Statistic title="Oreo、ETA 总工单数" value={1919} /> title: '加入 Oreo 工单数',
</> value: indexData.oreo,
), description: <Statistic title="预填写工单总数" value={indexData.totalPT} />,
}} }}
chartPlacement="left" chartPlacement="left"
/> />
</StatisticCard.Group> <StatisticCard
style={{ marginTop: '3vh' }}
chart={percentRing(
Math.round((indexData.allSuccess / indexData.all) * 1000) / 10,
'#66AFF4',
)}
statistic={{
title: '维修成功次数',
value: indexData.allSuccess,
description: <Statistic title="Oreo、ETA 总工单数" value={indexData.all} />,
}}
chartPlacement="left"
/>
</StatisticCard.Group>
</ProCard>
</ProCard>
</RcResizeObserver> </RcResizeObserver>
</Card> </Card>
</PageContainer> </PageContainer>