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/agv/show/AgvShowDetail.jsx |   60 +++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/zy-acs-flow/src/page/agv/show/AgvShowDetail.jsx b/zy-acs-flow/src/page/agv/show/AgvShowDetail.jsx
index 7ddd82d..6df36d8 100644
--- a/zy-acs-flow/src/page/agv/show/AgvShowDetail.jsx
+++ b/zy-acs-flow/src/page/agv/show/AgvShowDetail.jsx
@@ -25,23 +25,28 @@
 const GRID_CONTAINER_MAX_WIDTH = '100%';
 
 export const AgvShowDetail = (props) => {
-    const { agvId } = props;
+    const { agvId, setOnline } = props;
     const [record, setRecord] = useState(null);
     const resource = useResourceContext();
 
     useEffect(() => {
         const http = async (agvId) => {
-            const res = await request.get(resource + '/' + agvId);
-            const { code, msg, data } = res.data;
-            if (code === 200) {
-                setRecord(data);
-            } else {
-                setRecord(null);
+            if (agvId) {
+                const res = await request.get(resource + '/' + agvId);
+                const { code, msg, data } = res.data;
+                if (code === 200) {
+                    setOnline(data.online);
+                    setRecord(data);
+                } else {
+                    setRecord(null);
+                }
             }
         }
-        if (agvId) {
+        const intervalId = setInterval(() => {
             http(agvId);
-        }
+        }, 1000);
+        http(agvId);
+        return () => clearInterval(intervalId);
     }, [agvId]);
 
     if (!record) {
@@ -82,26 +87,29 @@
     )
 }
 
-const DetailTitle = ({ title }) => {
+const DetailTitle = ({ title, ...rest }) => {
     const translate = useTranslate();
     return (
         <Typography
             color="textSecondary"
             variant="caption"
+            {...rest}
         >
             {translate(title)}
         </Typography>
     )
 }
 
-const DetailValue = ({ value }) => {
+const DetailValue = ({ value, fontBold = false }) => {
     return (
         <Typography
             variant="body2"
+            color={fontBold ? 'textSecondary' : 'textPrimary'}
             width='80%'
             sx={{
                 wordWrap: 'break-word',
                 whiteSpace: 'normal',
+                fontWeight: fontBold && 'bold',
             }}
         >
             {value}
@@ -111,8 +119,21 @@
 
 
 const AgvMainDetail = ({ record }) => {
+    const translate = useTranslate();
     return (
         <Grid container spacing={1} sx={{ maxWidth: GRID_CONTAINER_MAX_WIDTH }}>
+            <Grid item xs={ITEM_COL}>
+                <DetailTitle title='common.field.status' />
+                <DetailValue fontBold value={record.agvDetail.statusDesc} />
+            </Grid>
+            <Grid item xs={ITEM_COL}>
+                <DetailTitle title='table.field.agvDetail.pos' />
+                <DetailValue value={record.agvDetail.pos === 1 ? translate('common.enums.true') : translate('common.enums.false')} />
+            </Grid >
+            <Grid item xs={ITEM_COL}>
+                <DetailTitle title='table.field.agvDetail.code' />
+                <DetailValue value={record.agvDetail.code$} />
+            </Grid>
             <Grid item xs={ITEM_COL}>
                 <DetailTitle title='table.field.agv.ip' />
                 <DetailValue value={record.ip} />
@@ -125,14 +146,7 @@
     const translate = useTranslate();
     return (
         <Grid container spacing={1} sx={{ maxWidth: GRID_CONTAINER_MAX_WIDTH }}>
-            <Grid item xs={ITEM_COL}>
-                <DetailTitle title='table.field.agvDetail.pos' />
-                <DetailValue value={record.agvDetail.pos === 1 ? translate('common.enums.true') : translate('common.enums.false')} />
-            </Grid >
-            <Grid item xs={ITEM_COL}>
-                <DetailTitle title='table.field.agvDetail.code' />
-                <DetailValue value={record.agvDetail.code$} />
-            </Grid>
+
             <Grid item xs={ITEM_COL}>
                 <DetailTitle title='table.field.agvDetail.agvAngle' />
                 <DetailValue value={record.agvDetail.agvAngle} />
@@ -175,10 +189,6 @@
                 <DetailTitle title='table.field.agvDetail.workDistance' />
                 <DetailValue value={record.agvDetail.workDistance} />
             </Grid>
-            <Grid item xs={ITEM_COL}>
-                <DetailTitle title='common.field.status' />
-                <DetailValue value={record.agvDetail.statusDesc} />
-            </Grid>
         </Grid >
     )
 }
@@ -188,7 +198,7 @@
         <Grid container spacing={1} sx={{ maxWidth: GRID_CONTAINER_MAX_WIDTH }}>
             <Grid item xs={ITEM_COL}>
                 <DetailTitle title='table.field.agvModel.name' />
-                <DetailValue value={record.agvModelData.name} />
+                <DetailValue fontBold value={record.agvModelData.name} />
             </Grid>
             <Grid item xs={ITEM_COL}>
                 <DetailTitle title='table.field.agvModel.length' />
@@ -232,7 +242,7 @@
             </Grid>
             <Grid item xs={ITEM_COL}>
                 <DetailTitle title='table.field.agvModel.allDirection' />
-                <DetailValue value={record.agvModelData.allDirection} />
+                <DetailValue value={record.agvModelData.allDirection === 1 ? translate('common.enums.true') : translate('common.enums.false')} />
             </Grid>
             <Grid item xs={ITEM_COL}>
                 <DetailTitle title='table.field.agvModel.protocol' />

--
Gitblit v1.9.1