| | |
| | | |
| | | const NbChart = (props) => { |
| | | const { orders } = props; |
| | | console.log(orders); |
| | | |
| | | const translate = useTranslate(); |
| | | if (!orders) return null; |
| | | |
| | |
| | | ListItemSecondaryAction, |
| | | ListItemAvatar, |
| | | ListItemText, |
| | | Typography, |
| | | Avatar, |
| | | Box, |
| | | ListItemButton, |
| | | Card, |
| | | CardHeader, |
| | | List, |
| | | Grid, |
| | | } from '@mui/material'; |
| | | import { Link } from 'react-router-dom'; |
| | | |
| | | const NbList = (props) => { |
| | | const { orders = [] } = props; |
| | | const NbList = ({ deadStock }) => { |
| | | const translate = useTranslate(); |
| | | |
| | | return ( |
| | | <Card sx={{ flex: 1 }}> |
| | | <CardHeader title={translate('page.dashboard.list.stock')} /> |
| | | <List dense={true}> |
| | | {orders.map(record => ( |
| | | <PendingOrder key={record.id} order={record} /> |
| | | {deadStock.map(record => ( |
| | | <PendingOrder key={`record?.id + ${Math.random().toString(36).substr(2, 9)} `} order={record} /> |
| | | ))} |
| | | </List> |
| | | </Card> |
| | |
| | | |
| | | export const PendingOrder = (props) => { |
| | | const { order } = props; |
| | | console.log(order); |
| | | const translate = useTranslate(); |
| | | const { referenceRecord: customer, isPending } = useReference({ |
| | | reference: 'customers', |
| | | id: order.customer_id, |
| | | }); |
| | | // const { referenceRecord: customer, isPending } = useReference({ |
| | | // reference: 'customers', |
| | | // id: order.id, |
| | | // }); |
| | | |
| | | return ( |
| | | <ListItem disablePadding> |
| | |
| | | /> |
| | | )} |
| | | </ListItemAvatar> */} |
| | | <ListItemText |
| | | primary={new Date(order.date).toLocaleString('en-GB')} |
| | | {/* <ListItemText |
| | | primary={new Date(order.createTime).toLocaleString('en-GB')} |
| | | secondary={translate('page.dashboard.list.stock', { |
| | | name: order.name |
| | | name: order.maktx |
| | | })} |
| | | /> |
| | | <ListItemSecondaryAction> |
| | | > |
| | | |
| | | </ListItemText> */} |
| | | <Grid container item md={12}> |
| | | <Box sx={{ display: 'flex' }}> |
| | | <Box sx={{ display: 'flex', padding: '1em' }}> |
| | | <Typography color="textSecondary">{translate("table.field.asnOrderItem.matnrCode")}:</Typography> |
| | | <Typography color="textSecondary">{order?.matnrCode}</Typography> |
| | | </Box> |
| | | </Box> |
| | | <Box sx={{ display: 'flex' }}> |
| | | <Box sx={{ display: 'flex', padding: '1em' }}> |
| | | <Typography color="textSecondary">{translate("table.field.asnOrderItem.maktx")}:</Typography> |
| | | <Typography color="textSecondary" maxWidth="200" overflow="hidden">{order?.maktx}</Typography> |
| | | </Box> |
| | | </Box> |
| | | <Box sx={{ display: 'flex' }}> |
| | | <Box sx={{ display: 'flex', padding: '1em' }}> |
| | | <Typography color="textSecondary">{translate("table.field.asnOrderItem.anfme")}:</Typography> |
| | | <Typography color="textSecondary">{order?.anfme}</Typography> |
| | | </Box> |
| | | </Box> |
| | | <Box sx={{ display: 'flex' }}> |
| | | <Box sx={{ display: 'flex', padding: '1em' }}> |
| | | <Typography color="textSecondary">{translate("table.field.locItem.deadTime")}:</Typography> |
| | | <Typography color="textSecondary">{order?.deadTime}</Typography> |
| | | </Box> |
| | | </Box> |
| | | </Grid> |
| | | {/* <ListItemSecondaryAction> |
| | | <Box |
| | | component="span" |
| | | sx={{ |
| | |
| | | color: 'text.primary', |
| | | }} |
| | | > |
| | | {order.total}$ |
| | | {order.deadTime} |
| | | </Box> |
| | | </ListItemSecondaryAction> |
| | | </ListItemSecondaryAction> */} |
| | | </ListItemButton> |
| | | </ListItem> |
| | | ); |
New file |
| | |
| | | |
| | | import * as React from 'react'; |
| | | import { Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'; |
| | | import { Card } from "@mui/material"; |
| | | import { useTranslate } from "react-admin"; |
| | | |
| | | |
| | | const NbPie = ({ deadStock }) => { |
| | | const translate = useTranslate(); |
| | | |
| | | const data01 = [ |
| | | { name: 'Group A', value: 400 }, |
| | | { name: 'Group B', value: 300 }, |
| | | { name: 'Group C', value: 300 }, |
| | | { name: 'Group D', value: 200 }, |
| | | { name: 'Group E', value: 278 }, |
| | | { name: 'Group F', value: 189 }, |
| | | ]; |
| | | |
| | | const data02 = [ |
| | | { name: 'Group A', value: 2400 }, |
| | | { name: 'Group B', value: 4567 }, |
| | | { name: 'Group C', value: 1398 }, |
| | | { name: 'Group D', value: 9800 }, |
| | | { name: 'Group E', value: 3908 }, |
| | | { name: 'Group F', value: 4800 }, |
| | | ]; |
| | | |
| | | return ( |
| | | <> |
| | | <Card> |
| | | <ResponsiveContainer width="100%" height="100%"> |
| | | <PieChart width={400} height={400}> |
| | | <Pie |
| | | dataKey="value" |
| | | isAnimationActive={false} |
| | | data={data01} |
| | | cx="50%" |
| | | cy="50%" |
| | | outerRadius={80} |
| | | fill="#8884d8" |
| | | label |
| | | /> |
| | | <Pie dataKey="value" data={data02} cx={500} cy={200} innerRadius={40} outerRadius={80} fill="#82ca9d" /> |
| | | <Tooltip /> |
| | | </PieChart> |
| | | </ResponsiveContainer> |
| | | </Card> |
| | | </> |
| | | ); |
| | | } |
| | | |
| | | export default NbPie; |
| | |
| | | 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' }, |
| | |
| | | const notify = useNotify(); |
| | | const [statistic, setStatistic] = useState({}); |
| | | const [stock, setStock] = useState([]); |
| | | const [deadStock, setDeadStock] = useState([]); |
| | | |
| | | useEffect(() => { |
| | | getDashBoardHeader() |
| | |
| | | } |
| | | |
| | | const getRecentStocks = async () => { |
| | | await request.post('/asnOrder/dashbord/header').then(res => { |
| | | const { code, msg, data } = res.data?.data; |
| | | await request.post('/locItem/page', { current: 1, pageSize: 10, orderBy: 'create_time asc' }).then(res => { |
| | | const { code, msg, data } = res?.data; |
| | | if (code === 200) { |
| | | setStatistic(data); |
| | | setDeadStock(data?.records); |
| | | } else { |
| | | notify(msg, { type: 'error', messageArgs: { _: msg } }); |
| | | } |
| | |
| | | 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 container md={12} item> |
| | | <Grid item md={8}> |
| | | <Box sx={{ display: "flex" }}> |
| | | <CardWithIcon |
| | |
| | | title={`${statistic?.membersTotalQua}`} |
| | | type={"out"} |
| | | statistic={statistic} |
| | | |
| | | /> |
| | | </Box> |
| | | <Spacer /> |
| | |
| | | <NbChart orders={stock} /> |
| | | </Box> |
| | | <Spacer /> |
| | | <Box> |
| | | <NbList orders={recentOrders} /> |
| | | <Box sx={{ display: 'flex' }}> |
| | | <NbList deadStock={deadStock} /> |
| | | <NbPie /> |
| | | </Box> |
| | | <Spacer /> |
| | | |
| | | </Grid> |
| | | <Grid item md={4}> |
| | | <Box sx={{ display: 'flex' }}> |
| | |
| | | filter: JSON.stringify({ status: 1 }), |
| | | }), |
| | | }} |
| | | list={recentOrders} |
| | | list={deadStock} |
| | | /> |
| | | </Box> |
| | | </Grid> |