From 7b1922131a91d253597ca764dfe5bb0648c57794 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 13 八月 2025 12:06:47 +0800
Subject: [PATCH] 首页修改

---
 rsf-admin/src/page/dashboard/index.jsx |  185 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 179 insertions(+), 6 deletions(-)

diff --git a/rsf-admin/src/page/dashboard/index.jsx b/rsf-admin/src/page/dashboard/index.jsx
index 977c941..b832f8d 100644
--- a/rsf-admin/src/page/dashboard/index.jsx
+++ b/rsf-admin/src/page/dashboard/index.jsx
@@ -1,8 +1,26 @@
+import { useTranslate, useAuthProvider, Title, useNotify } from 'react-admin';
+import { Box, Typography, LinearProgress, Stack, Grid } from '@mui/material';
 import React, { useState, useRef, useEffect, useMemo } from "react";
-import { useNavigate } from 'react-router-dom';
+import SensorOccupiedIcon from '@mui/icons-material/SensorOccupied';
+import CardWithIcon from '../components/CardWithIcon';
+import WifiIcon from '@mui/icons-material/Wifi';
 import { useTheme } from '@mui/material/styles';
-import { useTranslate, useAuthProvider } from 'react-admin';
-import { WordEffect } from './WordEffect'
+import { useNavigate } from 'react-router-dom';
+import { getSystemDicts } from '@/api/auth'
+import { WordEffect } from './WordEffect';
+import request from '@/utils/request';
+import Welcome from "./Welcome";
+import NbChart from "./NbChart";
+import NbList from "./NbList";
+import NbCard from "./NbCard";
+
+const styles = {
+    flex: { display: 'flex' },
+    flexColumn: { display: 'flex', flexDirection: 'column' },
+    leftCol: { flex: 1, },
+    rightCol: { flex: 1, },
+    singleCol: { marginTop: '1em', marginBottom: '1em' },
+};
 
 const Dashboard = () => {
     const authProvider = useAuthProvider();
@@ -13,11 +31,17 @@
     useEffect(() => {
         authProvider.checkAuth().catch(() => {
             navigate('/login');
-        });
+        })
+        getSystemDicts().then((data) => {
+            localStorage.setItem("sys_dicts", JSON.stringify(data));
+        })
     }, [authProvider, navigate]);
 
     return (
         <>
+            <Title title={"menu.dashboard"} />
+            <Welcome />
+            <DashboardSummaryView />
             <div
                 style={{
                     boxSizing: 'border-box',
@@ -30,17 +54,166 @@
                     padding: '2rem 1rem',
                 }}
             >
-                <WordEffect
+                {/* <WordEffect
                     words={translate('page.welcome.index')}
                     color={theme.palette.mode === 'light' ? '#666' : '#eeeeee'}
                 />
                 <WordEffect
                     words={translate('page.welcome.tech')}
                     color={theme.palette.mode === 'light' ? '#666' : '#eeeeee'}
-                />
+                /> */}
             </div>
         </>
     )
 }
 
+const DashboardSummaryView = () => {
+    const translate = useTranslate();
+    const notify = useNotify();
+    const [statistic, setStatistic] = useState({});
+    const [stock, setStock] = useState([]);
+
+    useEffect(() => {
+        getDashBoardHeader()
+        getRecentTrands()
+        getRecentStocks()
+
+    }, [])
+
+    const getDashBoardHeader = async () => {
+        await request.post('/asnOrder/dashbord/header').then(res => {
+            const { code, msg, data } = res.data?.data;
+            if (code === 200) {
+                setStatistic(data);
+            } else {
+                notify(msg, { type: 'error', messageArgs: { _: msg } });
+            }
+        }).catch((error) => {
+            notify(error.message, { type: 'error', messageArgs: { _: error.message } });
+        })
+    }
+
+    const getRecentStocks = async () => {
+        await request.post('/asnOrder/dashbord/header').then(res => {
+            const { code, msg, data } = res.data?.data;
+            if (code === 200) {
+                setStatistic(data);
+            } else {
+                notify(msg, { type: 'error', messageArgs: { _: msg } });
+            }
+        }).catch((error) => {
+            notify(error.message, { type: 'error', messageArgs: { _: error.message } });
+        })
+    }
+
+
+    /**
+     * 鑾峰彇搴撹繎涓�涓湀鍑哄叆搴撲俊鎭�
+     */
+    const getRecentTrands = async () => {
+        await request.post('/asnOrder/stock/trand').then(res => {
+            const { code, msg, data } = res.data?.data;
+            if (code === 200) {
+                setStock(data)
+            } else {
+                notify(msg, { type: 'error', messageArgs: { _: msg } });
+            }
+        }).catch((error) => {
+            notify(error.message, { type: 'error', messageArgs: { _: error.message } });
+        })
+    }
+
+    const recentOrders = [
+        {
+            id: 1,
+            name: 'a',
+            date: "2025-08-10T12:23:56.959Z",
+            total: 138.94,
+            inTotal: 254,
+        },
+        {
+            id: 2,
+            name: 'b',
+            date: "2025-08-03T07:45:00.304Z",
+            total: 214.66,
+            inTotal: 258,
+        },
+        {
+            id: 3,
+            name: 'c',
+            date: "2025-07-28T00:20:10.968Z",
+            total: 68.19,
+            inTotal: 154,
+        },
+        {
+            id: 4,
+            name: 'd',
+            date: "2025-07-22T20:39:00.293Z",
+            total: 36.56,
+            inTotal: 124,
+        },
+        {
+            id: 5,
+            name: 'e',
+            date: "2025-07-16T17:40:24.791Z",
+            total: 100.82,
+            inTotal: 354,
+        },
+    ]
+
+    return (
+        <>
+            <Grid container md={12}>
+                <Grid item md={8}>
+                    <Box sx={{ display: "flex" }}>
+                        <CardWithIcon
+                            icon={WifiIcon}
+                            subtitle={translate('page.dashboard.header.inStockQty')}
+                            title={`${statistic?.inAnf}`}
+                            type={"in"}
+                            statistic={statistic}
+                        />
+                        <Spacer />
+                        <CardWithIcon
+                            icon={SensorOccupiedIcon}
+                            subtitle={translate('page.dashboard.header.outStockQty')}
+                            title={`${statistic?.membersTotalQua}`}
+                            type={"out"}
+                            statistic={statistic}
+
+                        />
+                    </Box>
+                    <Spacer />
+                    <Box>
+                        <NbChart orders={stock} />
+                    </Box>
+                    <Spacer />
+                    <Box>
+                        <NbList orders={recentOrders} />
+                    </Box>
+                </Grid>
+                <Grid item md={4}>
+                    <Box sx={{ display: 'flex' }}>
+                        <Spacer />
+                        <NbCard
+                            icon={SensorOccupiedIcon}
+                            subtitle={translate('page.dashboard.header.taskWorkQty')}
+                            title={`${statistic?.membersTotalQua}`}
+                            to={{
+                                pathname: '/task',
+                                search: JSON.stringify({
+                                    filter: JSON.stringify({ status: 1 }),
+                                }),
+                            }}
+                            list={recentOrders}
+                        />
+                    </Box>
+                </Grid>
+            </Grid>
+        </>
+    )
+}
+
+const Spacer = () => <span style={{ width: '1em' }} />;
+
 export default Dashboard;
\ No newline at end of file

--
Gitblit v1.9.1