From e5a2d3c14472d64255d80cef130d83f6e24e591d Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 15 八月 2025 10:49:56 +0800 Subject: [PATCH] 首页功能优化 --- rsf-admin/src/page/dashboard/NbList.jsx | 3 rsf-admin/src/page/components/CardWithIcon.jsx | 2 rsf-admin/src/page/dashboard/NbCard.jsx | 87 ++++++++++++---------------- rsf-admin/src/page/dashboard/index.jsx | 30 ++++++++-- rsf-admin/.env | 2 5 files changed, 66 insertions(+), 58 deletions(-) diff --git a/rsf-admin/.env b/rsf-admin/.env index a3c69b2..f793907 100644 --- a/rsf-admin/.env +++ b/rsf-admin/.env @@ -1,3 +1,3 @@ -VITE_BASE_IP=127.0.0.1 +VITE_BASE_IP=192.168.4.151 # VITE_BASE_IP=47.76.147.249 VITE_BASE_PORT=8080 diff --git a/rsf-admin/src/page/components/CardWithIcon.jsx b/rsf-admin/src/page/components/CardWithIcon.jsx index 5e4b3d0..88a5914 100644 --- a/rsf-admin/src/page/components/CardWithIcon.jsx +++ b/rsf-admin/src/page/components/CardWithIcon.jsx @@ -71,7 +71,7 @@ </Box>} </Box> : <Box> <Typography sx={{ display: 'flex', padding: '1em' }}> - {'鈥�12234'} + { title } </Typography> </Box>} </Box> diff --git a/rsf-admin/src/page/dashboard/NbCard.jsx b/rsf-admin/src/page/dashboard/NbCard.jsx index 4701aef..80c8772 100644 --- a/rsf-admin/src/page/dashboard/NbCard.jsx +++ b/rsf-admin/src/page/dashboard/NbCard.jsx @@ -4,12 +4,15 @@ Box, Button, List, + Grid, ListItem, + Typography, ListItemAvatar, ListItemButton, ListItemText, } from '@mui/material'; import CommentIcon from '@mui/icons-material/Comment'; +import CardWithIcon from '../components/CardWithIcon'; import { Link } from 'react-router-dom'; import { ReferenceField, @@ -18,23 +21,12 @@ useTranslate, useIsDataLoaded, } from 'react-admin'; -import CardWithIcon from '../components/CardWithIcon'; const NbCard = (props) => { - const { list, ...rest } = props; + const { tasks, total, ...rset } = props; const translate = useTranslate(); - const { - data: reviews, - total, - isPending, - } = useGetList('reviews', { - filter: { status: 'pending' }, - sort: { field: 'date', order: 'DESC' }, - pagination: { page: 1, perPage: 100 }, - }); const display = 'display'; - const newList = list.concat(list); return ( <> @@ -42,55 +34,49 @@ icon={CommentIcon} title={translate('page.dashboard.pending_reviews')} subtitle={total} - {...rest} + {...rset} > <List sx={{ display }}> - {newList?.map((record) => ( + {tasks?.map((record) => ( <ListItem key={record.id} disablePadding> <ListItemButton alignItems="flex-start" component={Link} to={`/task/${record.id}`} > - {/* <ListItemAvatar> - <Avatar - sx={{ - // bgcolor: 'primary.main', - bgcolor: '#a2beeaff', - color: 'primary.contrastText', // 閬垮厤鐧藉瓧鐧藉簳 - // width: 40, - // height: 40, - // fontSize: 16, - }} - > - {record.id} - </Avatar> - </ListItemAvatar> */} - - <ListItemText - // primary={ - // <StarRatingField - // record={record} - // source="rating" - // /> - // } - primary={record.date + record.date} - secondary={record.total} - sx={{ - overflowY: 'hidden', - height: '3em', - display: '-webkit-box', - WebkitLineClamp: 2, - WebkitBoxOrient: 'vertical', - paddingRight: 0, - }} - /> + <Grid container item md={12}> + <Box sx={{ display: 'flex' }}> + <Box sx={{ display: 'flex', padding: '1em' }}> + <Typography color="textSecondary">{translate("table.field.task.taskCode")}锛�</Typography> + <Typography color="textSecondary">{record?.taskCode}</Typography> + </Box> + </Box> + <Box sx={{ display: 'flex' }}> + <Box sx={{ display: 'flex', padding: '1em' }}> + <Typography color="textSecondary">{translate("table.field.task.taskType")}锛�</Typography> + <Typography color="textSecondary" maxWidth="200" overflow="hidden">{record?.taskType$}</Typography> + </Box> + </Box> + <Box sx={{ display: 'flex' }}> + <Box sx={{ display: 'flex', padding: '1em' }}> + <Typography color="textSecondary">{translate("table.field.task.taskStatus")}锛�</Typography> + <Typography color="textSecondary">{record?.taskStatus$}</Typography> + </Box> + </Box> + <Box sx={{ display: 'flex' }}> + <Box sx={{ display: 'flex', padding: '1em' }}> + <Typography color="textSecondary">{translate("table.field.task.startTime")}锛�</Typography> + <Typography color="textSecondary">{record?.createTime}</Typography> + </Box> + </Box> + </Grid> </ListItemButton> + <Spacer /> </ListItem> ))} </List> <Box flexGrow={1}> </Box> - <Button + {/* <Button sx={{ borderRadius: 0 }} component={Link} to="/task" @@ -100,10 +86,13 @@ <Box p={1} sx={{ color: 'primary.main' }}> {translate('pos.dashboard.all_reviews')} </Box> - </Button> + </Button> */} </CardWithIcon> </> ); }; +const Spacer = () => <span style={{ width: '1em', }} />; + + export default NbCard; diff --git a/rsf-admin/src/page/dashboard/NbList.jsx b/rsf-admin/src/page/dashboard/NbList.jsx index 4149f63..3794797 100644 --- a/rsf-admin/src/page/dashboard/NbList.jsx +++ b/rsf-admin/src/page/dashboard/NbList.jsx @@ -44,7 +44,8 @@ return ( <ListItem disablePadding> - <ListItemButton component={Link} to={`/orders/${order.id}`}> + {/* component={Link} to={`/locItem/${order.id}`} */} + <ListItemButton > {/* <ListItemAvatar> {isPending ? ( <Avatar /> diff --git a/rsf-admin/src/page/dashboard/index.jsx b/rsf-admin/src/page/dashboard/index.jsx index d47caa1..db9883b 100644 --- a/rsf-admin/src/page/dashboard/index.jsx +++ b/rsf-admin/src/page/dashboard/index.jsx @@ -3,6 +3,7 @@ import React, { useState, useRef, useEffect, useMemo } from "react"; import SensorOccupiedIcon from '@mui/icons-material/SensorOccupied'; import CardWithIcon from '../components/CardWithIcon'; +import CommentIcon from '@mui/icons-material/Comment'; import WifiIcon from '@mui/icons-material/Wifi'; import { useTheme } from '@mui/material/styles'; import { useNavigate } from 'react-router-dom'; @@ -75,18 +76,22 @@ const [stock, setStock] = useState([]); const [deadStock, setDeadStock] = useState([]); const [locUsage, setLocUsages] = useState([]); + const [tasks, setTasks] = useState([]); + const [total, setTotal] = useState(0); + useEffect(() => { getDashBoardHeader() getRecentTrands() getRecentStocks() getRecentUsage() + getExcingTasks() }, []) const getDashBoardHeader = async () => { await request.post('/asnOrder/dashbord/header').then(res => { - const { code, msg, data } = res.data?.data; + const { code, msg, data } = res?.data; if (code === 200) { setStatistic(data); } else { @@ -110,11 +115,23 @@ }) } + const getExcingTasks = async () => { + await request.post('/task/page', { current: 1, pageSize: 100, orderBy: 'sort desc' }).then(res => { + const { code, msg, data } = res?.data; + if (code === 200) { + setTasks(data?.records) + setTotal(data?.total) + } else { + notify(msg, { type: 'error', messageArgs: { _: msg } }); + } + }).catch((error) => { + notify(error.message, { type: 'error', messageArgs: { _: error.message } }); + }) + } + const getRecentUsage = () => { request.post("/loc/pie/list").then(res => { const { code, msg, data } = res?.data; - console.log(data); - console.log(code); if (code === 200) { setLocUsages(data?.data) } else { @@ -177,16 +194,17 @@ <Box sx={{ display: 'flex' }}> <Spacer /> <NbCard - icon={SensorOccupiedIcon} + icon={CommentIcon} subtitle={translate('page.dashboard.header.taskWorkQty')} - title={`${statistic?.membersTotalQua}`} + title={`${statistic?.taskQty}`} + total={total} to={{ pathname: '/task', search: JSON.stringify({ filter: JSON.stringify({ status: 1 }), }), }} - list={deadStock} + tasks={tasks} /> </Box> </Grid> -- Gitblit v1.9.1