From beb003f8e8cd5ae31a0ac55d0624ed2b2ad862bb Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期四, 14 八月 2025 11:21:49 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop

---
 rsf-admin/src/page/dashboard/index.jsx |  219 ++++++++++++++++++++++++------------------------------
 1 files changed, 96 insertions(+), 123 deletions(-)

diff --git a/rsf-admin/src/page/dashboard/index.jsx b/rsf-admin/src/page/dashboard/index.jsx
index d8694e0..c2f7fd8 100644
--- a/rsf-admin/src/page/dashboard/index.jsx
+++ b/rsf-admin/src/page/dashboard/index.jsx
@@ -1,24 +1,26 @@
-import React, { useState, useRef, useEffect, useMemo } from "react";
-import { useNavigate } from 'react-router-dom';
-import { useTheme } from '@mui/material/styles';
 import { useTranslate, useAuthProvider, Title, useNotify } from 'react-admin';
-import { WordEffect } from './WordEffect';
-import { getSystemDicts } from '@/api/auth'
-import Welcome from "./Welcome";
-import CardWithIcon from '../components/CardWithIcon';
+import { Box, Typography, LinearProgress, Stack, Grid } from '@mui/material';
+import React, { useState, useRef, useEffect, useMemo } from "react";
 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 { useNavigate } from 'react-router-dom';
+import { getSystemDicts } from '@/api/auth'
+import { WordEffect } from './WordEffect';
 import request from '@/utils/request';
-import { Box, Typography, LinearProgress, Stack } from '@mui/material';
+import Welcome from "./Welcome";
 import NbChart from "./NbChart";
 import NbList from "./NbList";
 import NbCard from "./NbCard";
+import { orderBy } from 'lodash';
+import NbPie from './NbPie';
 
 const styles = {
     flex: { display: 'flex' },
     flexColumn: { display: 'flex', flexDirection: 'column' },
-    leftCol: { flex: 1, marginRight: '0.5em' },
-    rightCol: { flex: 1, marginLeft: '0.5em' },
+    leftCol: { flex: 1, },
+    rightCol: { flex: 1, },
     singleCol: { marginTop: '1em', marginBottom: '1em' },
 };
 
@@ -70,139 +72,110 @@
 const DashboardSummaryView = () => {
     const translate = useTranslate();
     const notify = useNotify();
-    const [statistic, setStatistic] = useState(null);
+    const [statistic, setStatistic] = useState({});
+    const [stock, setStock] = useState([]);
+    const [deadStock, setDeadStock] = useState([]);
 
     useEffect(() => {
-        request.get('/dashboard/member/statistic', {
-            params: {}
-        }).then(res => {
-            const { code, msg, data } = res.data;
+        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 } });
+                notify(msg, { type: 'error', messageArgs: { _: msg } });
             }
         }).catch((error) => {
-            // notify(error.message, { type: 'error', messageArgs: { _: error.message } });
-            console.error(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
-        },
-        {
-            id: 2,
-            name: 'b',
-            date: "2025-08-03T07:45:00.304Z",
-            total: 214.66
-        },
-        {
-            id: 3,
-            name: 'c',
-            date: "2025-07-28T00:20:10.968Z",
-            total: 68.19
-        },
-        {
-            id: 4,
-            name: 'd',
-            date: "2025-07-22T20:39:00.293Z",
-            total: 36.56
-        },
-        {
-            id: 5,
-            name: 'e',
-            date: "2025-07-16T17:40:24.791Z",
-            total: 100.82
-        },
-    ]
+    const getRecentStocks = async () => {
+        await request.post('/locItem/page', { current: 1, pageSize: 10, orderBy: 'create_time asc' }).then(res => {
+            const { code, msg, data } = res?.data;
+            if (code === 200) {
+                setDeadStock(data?.records);
+            } 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 } });
+        })
+    }
 
     return (
         <>
-            <div style={styles.flex}>
-                <div style={styles.leftCol}>
-                    <div style={styles.flex}>
+            <Grid container md={12} item>
+                <Grid item md={8}>
+                    <Box sx={{ display: "flex" }}>
                         <CardWithIcon
                             icon={WifiIcon}
-                            title={translate('page.member.header.onlineMembers')}
-                            subtitle={`${statistic?.membersOnlineQua}`}
+                            subtitle={translate('page.dashboard.header.inStockQty')}
+                            title={`${statistic?.inAnf}`}
+                            type={"in"}
+                            statistic={statistic}
                         />
                         <Spacer />
                         <CardWithIcon
                             icon={SensorOccupiedIcon}
-                            title={translate('page.member.header.totalMembers')}
-                            subtitle={`${statistic?.membersTotalQua}`}
+                            subtitle={translate('page.dashboard.header.outStockQty')}
+                            title={`${statistic?.membersTotalQua}`}
+                            type={"out"}
+                            statistic={statistic}
                         />
-                    </div>
-                    <div style={styles.singleCol}>
-                        <NbChart orders={recentOrders} />
-                    </div>
-                    <div style={styles.singleCol}>
-                        <NbList orders={recentOrders} />
-                    </div>
-                </div>
-                <div style={styles.rightCol}>
-                    <div style={styles.flex}>
-                        <NbCard
-                            icon={WifiIcon}
-                            title={translate('page.member.header.onlineMembers')}
-                            subtitle={`${statistic?.membersOnlineQua}`}
-                            to={{
-                                pathname: '/task',
-                                search: JSON.stringify({
-                                    filter: JSON.stringify({ status: 1 }),
-                                }),
-                            }}
-                            list={recentOrders}
-                        />
-                        <Spacer />
-                        <NbCard
-                            icon={SensorOccupiedIcon}
-                            title={translate('page.member.header.totalMembers')}
-                            subtitle={`${statistic?.membersTotalQua}`}
-                            to={{
-                                pathname: '/task',
-                                search: JSON.stringify({
-                                    filter: JSON.stringify({ status: 1 }),
-                                }),
-                            }}
-                            list={recentOrders}
-                        />
-                    </div>
-                </div>
-            </div>
+                    </Box>
+                    <Spacer />
+                    <Box>
+                        <NbChart orders={stock} />
+                    </Box>
+                    <Spacer />
+                    <Box sx={{ display: 'flex' }}>
+                        <NbList deadStock={deadStock} />
+                        <NbPie />
+                    </Box>
+                    <Spacer />
 
-            {/* <Box sx={{
-                display: 'flex',
-                mt: 2,
-                gap: 2,
-                justifyContent: 'space-between',
-            }}>
-                <CardWithIcon
-                    icon={WifiIcon}
-                    title={translate('page.member.header.onlineMembers')}
-                    subtitle={`${statistic?.membersOnlineQua}`}
-                />
-                <CardWithIcon
-                    icon={SensorOccupiedIcon}
-                    title={translate('page.member.header.totalMembers')}
-                    subtitle={`${statistic?.membersTotalQua}`}
-                />
-                <CardWithIcon
-                    icon={WifiIcon}
-                    title={translate('page.member.header.onlineMembers')}
-                    subtitle={`${statistic?.membersOnlineQua}`}
-                />
-                <CardWithIcon
-                    icon={SensorOccupiedIcon}
-                    title={translate('page.member.header.totalMembers')}
-                    subtitle={`${statistic?.membersTotalQua}`}
-                />
-            </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={deadStock}
+                        />
+                    </Box>
+                </Grid>
+            </Grid>
         </>
     )
 }

--
Gitblit v1.9.1