From 7f70cb15d035f0c233b9e62b9e43aa985317c908 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 04 十一月 2024 10:22:45 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/page/bus/BusPanel.jsx |  140 +++++++++++++++++++++++++++++++---------------
 1 files changed, 93 insertions(+), 47 deletions(-)

diff --git a/zy-acs-flow/src/page/bus/BusPanel.jsx b/zy-acs-flow/src/page/bus/BusPanel.jsx
index d24532f..8ec27c4 100644
--- a/zy-acs-flow/src/page/bus/BusPanel.jsx
+++ b/zy-acs-flow/src/page/bus/BusPanel.jsx
@@ -1,32 +1,56 @@
 import React, { useState, useRef, useEffect, useMemo } from "react";
-import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material';
+import {
+    Box,
+    Card,
+    CardContent,
+    Grid,
+    Typography,
+    Tooltip,
+    Table,
+    TableBody,
+    TableCell,
+    TableHead,
+    TableRow,
+} from '@mui/material';
 import {
     useTranslate,
     useRecordContext,
+    useGetMany,
+    Link,
 } from 'react-admin';
 import PanelTypography from "../components/PanelTypography";
-import * as Common from '@/utils/common'
+import * as Common from '@/utils/common';
+import { styled } from '@mui/material/styles';
+import { format } from 'date-fns';
 
 const BusPanel = () => {
     const record = useRecordContext();
-    if (!record) return null;
     const translate = useTranslate();
+    const taskIds = record ? record.taskIds : [];
+    const { isPending, data: tasks } = useGetMany(
+        'tasks',
+        { ids: taskIds },
+        { enabled: !!record }
+    );
+
+    if (isPending || !record) return null;
+
     return (
         <>
-            <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}>
+            <Card sx={{ maxWidth: '80%', margin: 'auto', mt: .5, mb: .5 }}>
                 <CardContent>
                     <Grid container spacing={2}>
                         <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}>
-                            <Typography variant="h6" gutterBottom align="left" sx={{
+                            <Typography variant="h5" gutterBottom align="left" sx={{
                                 maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' },
                                 whiteSpace: 'nowrap',
                                 overflow: 'hidden',
                                 textOverflow: 'ellipsis',
                             }}>
-                                {Common.camelToPascalWithSpaces(translate('table.field.bus.seqNum'))}: {record.seqNum}
+                                {Common.camelToPascalWithSpaces(translate('table.field.bus.busNo'))}: {record.busNo}
                             </Typography>
                             {/*  inherit, primary, secondary, textPrimary, textSecondary, error */}
-                            <Typography variant="h6" gutterBottom align="right" >
+                            <Typography variant="h5" gutterBottom align="right" >
                                 ID: {record.id}
                             </Typography>
                         </Grid>
@@ -38,50 +62,72 @@
                             </Typography>
                         </Grid>
                     </Grid>
-                    <Box height={20}>&nbsp;</Box>
-                    <Grid container spacing={2}>
-                        <Grid item xs={6}>
-                            <PanelTypography
-                                title="table.field.bus.uuid" 
-                                property={record.uuid}
-                            />
-                        </Grid>
-                        <Grid item xs={6}>
-                            <PanelTypography
-                                title="table.field.bus.seqNum" 
-                                property={record.seqNum}
-                            />
-                        </Grid>
-                        <Grid item xs={6}>
-                            <PanelTypography
-                                title="table.field.bus.startTime" 
-                                property={record.startTime$}
-                            />
-                        </Grid>
-                        <Grid item xs={6}>
-                            <PanelTypography
-                                title="table.field.bus.endTime" 
-                                property={record.endTime$}
-                            />
-                        </Grid>
-                        <Grid item xs={6}>
-                            <PanelTypography
-                                title="table.field.bus.busSts" 
-                                property={record.busSts$}
-                            />
-                        </Grid>
-                        <Grid item xs={6}>
-                            <PanelTypography
-                                title="table.field.bus.phase" 
-                                property={record.phase}
-                            />
-                        </Grid>
-
-                    </Grid>
+                    <Box height={10}>&nbsp;</Box>
+                    <Box>
+                        <Table size="small">
+                            <TableHead>
+                                <TableRow>
+                                    <TableCell>
+                                        {translate('table.field.task.seqNum')}
+                                    </TableCell>
+                                    <TableCellRight>
+                                        {translate('table.field.task.taskType')}
+                                    </TableCellRight>
+                                    <TableCellRight>
+                                        {translate('table.field.task.taskSts')}
+                                    </TableCellRight>
+                                    <TableCellRight>
+                                        {translate('table.field.task.agvId')}
+                                    </TableCellRight>
+                                    <TableCellRight>
+                                        {translate('table.field.task.ioTime')}
+                                    </TableCellRight>
+                                    <TableCellRight>
+                                        {translate('table.field.task.oriDesc')}
+                                    </TableCellRight>
+                                    <TableCellRight>
+                                        {translate('table.field.task.destDesc')}
+                                    </TableCellRight>
+                                </TableRow>
+                            </TableHead>
+                            <TableBody>
+                                {tasks.map((task) => (
+                                    <TableRow key={task.id}>
+                                        <TableCell>
+                                            <Link to={`/task/${task.id}`}>
+                                               
+                                            </Link>
+                                            {task.seqNum}
+                                        </TableCell>
+                                        <TableCellRight>
+                                            {task.taskType$}
+                                        </TableCellRight>
+                                        <TableCellRight>
+                                            {task.taskSts$}
+                                        </TableCellRight>
+                                        <TableCellRight>
+                                            {task.agvId$}
+                                        </TableCellRight>
+                                        <TableCellRight>
+                                            {format(new Date(task.ioTime), 'yyyy-MM-dd HH:mm:ss')}
+                                        </TableCellRight>
+                                        <TableCellRight>
+                                            {task.oriDesc}
+                                        </TableCellRight>
+                                        <TableCellRight>
+                                            {task.destDesc}
+                                        </TableCellRight>
+                                    </TableRow>
+                                ))}
+                            </TableBody>
+                        </Table>
+                    </Box>
                 </CardContent>
             </Card >
         </>
     );
 };
 
+const TableCellRight = styled(TableCell)({ textAlign: 'right' });
+
 export default BusPanel;

--
Gitblit v1.9.1