Dawn1Ocean 2024-04-16 19:30:44 +08:00
parent a6d435a22f
commit 0ea7eff03d
5 changed files with 47 additions and 9 deletions

View File

@ -1,15 +1,19 @@
import conclusionlist from './conclusionlist.json';
import loglist from './loglist.json';
import reportlist from './reportlist.json';
import sheet from './sheet.json';
import sheetlist from './sheetlist.json';
import reportlist from './reportlist.json';
import conclusionlist from './conclusionlist.json';
module.exports = {
'GET /admin/stats': {
'GET /stats': {
success: true,
data: {
notInOreo: 114,
total: 514,
todayPT: 114, // 今日预填写工单总数
totalPT: 514, // 所有预填写工单
oreo: 93, // 加入 Oreo 工单数
report: 8, // 今日反馈数
allSuccess: 1919, // 所有成功工单(包括 Oreo 内)
all: 2024, // 所有工单(包括 Oreo 内)
},
},
'POST /admin/sheet/update': {

View File

@ -154,9 +154,6 @@ export default {
access = '';
res.send({ data: {}, success: true });
},
'POST /api/register': (req: Request, res: Response) => {
res.send({ status: 'ok', currentAuthority: 'user', success: true });
},
'GET /api/500': (req: Request, res: Response) => {
res.status(500).send({
timestamp: 1513932555104,

View File

@ -1,9 +1,10 @@
import { getStat } from '@/services/api';
import type { TinyRingConfig } from '@ant-design/charts';
import { Tiny } from '@ant-design/charts';
import { PageContainer, ProCard, StatisticCard } from '@ant-design/pro-components';
import { Card, Statistic } from 'antd';
import RcResizeObserver from 'rc-resize-observer';
import { useState } from 'react';
import { useLayoutEffect, useState } from 'react';
const percentRing = (percent: number, frontColor: string): React.JSX.Element => {
const TinyRing = Tiny.Ring as (props: TinyRingConfig) => JSX.Element;
@ -50,6 +51,24 @@ const indexData: IndexData = {
const Logs: React.FC = () => {
const [responsive, setResponsive] = useState(false);
const [todayPT, setTodayPT] = useState(0);
const [report, setReport] = useState(0);
const [oreo, setOreo] = useState(0);
const [totalPT, setTotalPT] = useState(0);
const [allSuccess, setAllSuccess] = useState(0);
const [all, setAll] = useState(0);
useLayoutEffect(() => {
getStat().then((res) => {
const data = res.data;
setTodayPT(data.todayPT);
setReport(data.report);
setOreo(data.oreo);
setTotalPT(data.totalPT);
setAllSuccess(data.allSuccess);
setAll(data.all);
})
});
return (
<PageContainer>
<Card style={{ color: '#f5f5f5' }}>

View File

@ -32,3 +32,13 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
...(options || {}),
});
}
/** 获取首页信息 GET /admin/stat */
export async function getStat(options?: { [key: string]: any }) {
return request<{
data: API.Stat;
}>('/stat', {
method: 'GET',
...(options || {}),
});
}

View File

@ -54,4 +54,12 @@ declare namespace API {
size: number;
data: LogsItem[];
};
type Stat = {
todayPT: number;
totalPT: number;
oreo: number;
report: number;
allSuccess: number;
all: number;
};
}