From 43f2fe7fa6ec90b957d3182730e5c726b7158ced Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 23 九月 2024 14:49:49 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/page/bus/BusList.jsx                                                  |   37 +++++++++++-------
 zy-acs-flow/src/utils/color-util.js                                                   |   37 ++++++++++++++++++
 zy-acs-framework/src/main/resources/templates/react-admin/ReactCreate.txt             |    4 +-
 zy-acs-flow/src/i18n/en.js                                                            |    2 
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/BusController.java |    1 
 zy-acs-flow/src/page/bus/BusPanel.jsx                                                 |    2 
 zy-acs-flow/src/page/agv/show/AgvShowTask.jsx                                         |    2 
 zy-acs-flow/src/utils/common.js                                                       |   19 ---------
 8 files changed, 65 insertions(+), 39 deletions(-)

diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js
index b0e8e6d..fd48ed5 100644
--- a/zy-acs-flow/src/i18n/en.js
+++ b/zy-acs-flow/src/i18n/en.js
@@ -427,7 +427,7 @@
                 busSts: "bus status",
                 phase: "phase",
                 taskList: "task list",
-                tasksNum: "number of tasks",
+                tasksNum: "tasks number",
             },
             task: {
                 uuid: "uuid",
diff --git a/zy-acs-flow/src/page/agv/show/AgvShowTask.jsx b/zy-acs-flow/src/page/agv/show/AgvShowTask.jsx
index 4c479bc..fb7af4a 100644
--- a/zy-acs-flow/src/page/agv/show/AgvShowTask.jsx
+++ b/zy-acs-flow/src/page/agv/show/AgvShowTask.jsx
@@ -23,7 +23,7 @@
 import { formatDistance } from 'date-fns';
 import request from '@/utils/request';
 import { useTheme } from '@mui/material/styles';
-import { getTaskStsColor } from '@/utils/common';
+import { getTaskStsColor } from '@/utils/color-util';
 import ListEmptyTip from "../../components/ListEmptyTip";
 
 const TaskItem = ({ record, now }) => {
diff --git a/zy-acs-flow/src/page/bus/BusList.jsx b/zy-acs-flow/src/page/bus/BusList.jsx
index 66f853e..d7c7ec2 100644
--- a/zy-acs-flow/src/page/bus/BusList.jsx
+++ b/zy-acs-flow/src/page/bus/BusList.jsx
@@ -30,8 +30,9 @@
     ReferenceArrayInput,
     AutocompleteInput,
     DeleteButton,
+    FunctionField,
 } from 'react-admin';
-import { Box, Typography, Card, Stack } from '@mui/material';
+import { Box, Typography, Card, Chip } from '@mui/material';
 import { styled } from '@mui/material/styles';
 import BusCreate from "./BusCreate";
 import BusPanel from "./BusPanel";
@@ -43,6 +44,7 @@
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE } from '@/config/setting';
 import * as Common from '@/utils/common';
 import BusListAside from "./BusListAside";
+import { getBusStsColor } from '@/utils/color-util';
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -70,18 +72,14 @@
 
 const filters = [
     // <SearchInput source="condition" alwaysOn />,
-    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
-    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
-
-    // <TextInput source="uuid" label="table.field.bus.uuid" />,
     <TextInput source="busNo" label="table.field.bus.busNo" alwaysOn resettable />,
-    <DateInput source="startTime" label="table.field.bus.startTime" />,
-    <DateInput source="endTime" label="table.field.bus.endTime" />,
+    // <DateInput source="startTime" label="table.field.bus.startTime" />,
+    // <DateInput source="endTime" label="table.field.bus.endTime" />,
     <ReferenceInput source="busSts" label="table.field.bus.busSts" reference="busSts" alwaysOn>
         <AutocompleteInput label="table.field.bus.busSts" optionText="name" filterToQuery={(val) => ({ name: val })} />
     </ReferenceInput>,
-    <TextInput source="phase" label="table.field.bus.phase" />,
-
+    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
+    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
     <TextInput label="common.field.memo" source="memo" />,
     <SelectInput
         label="common.field.status"
@@ -123,12 +121,12 @@
                     </TopToolbar>
                 )}
                 perPage={25}
-                aside={<BusListAside />}
+            // aside={<BusListAside />}
             >
                 <StyledDatagrid
                     preferenceKey='bus'
-                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
-                    rowClick={(id, resource, record) => false}
+                    bulkActionButtons={false}
+                    rowClick={'expand'}
                     expand={() => <BusPanel />}
                     expandSingle={true}
                     omit={['id', 'uuid', 'phase', 'updateBy', 'updateTime', 'createTime', 'createBy']}
@@ -137,11 +135,20 @@
                     <TextField source="uuid" label="table.field.bus.uuid" />
                     <TextField source="busNo" label="table.field.bus.busNo" />
                     <ReferenceField source="busSts" label="table.field.bus.busSts" reference="busSts" link={false} sortable={false}>
-                        <TextField source="name" />
+                        <FunctionField render={record => (
+                            <Chip
+                                label={record.name}
+                                variant="outlined"
+                                size="small"
+                                color={getBusStsColor(record.name)}
+                                sx={{ fontSize: '0.75rem' }}
+                            />
+                        )} />
+                        {/* <TextField source="name" /> */}
                     </ReferenceField>
                     <NumberField source="tasksNum" label="table.field.bus.tasksNum" sortable={false} />
                     <DateField source="startTime" label="table.field.bus.startTime" showTime />
-                    <DateField source="endTime" label="table.field.bus.endTime" showTime />
+                    <DateField source="endTime" label="table.field.bus.endTime" showTime emptyText="-" />
                     <TextField source="phase" label="table.field.bus.phase" sortable={false} />
 
                     <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
@@ -153,7 +160,7 @@
                     </ReferenceField>
                     <DateField source="createTime" label="common.field.createTime" showTime />
                     {/* <BooleanField source="statusBool" label="common.field.status" sortable={false} /> */}
-                    <TextField source="memo" label="common.field.memo" sortable={false} />
+                    <TextField source="memo" label="common.field.memo" sortable={false} emptyText="-" />
                     <WrapperField cellClassName="opt" label="common.field.opt">
                         <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
                         <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
diff --git a/zy-acs-flow/src/page/bus/BusPanel.jsx b/zy-acs-flow/src/page/bus/BusPanel.jsx
index 937db12..6cee8d5 100644
--- a/zy-acs-flow/src/page/bus/BusPanel.jsx
+++ b/zy-acs-flow/src/page/bus/BusPanel.jsx
@@ -36,7 +36,7 @@
 
     return (
         <>
-            <Card sx={{ maxWidth: '80%', 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' }}>
diff --git a/zy-acs-flow/src/utils/color-util.js b/zy-acs-flow/src/utils/color-util.js
new file mode 100644
index 0000000..3eaad52
--- /dev/null
+++ b/zy-acs-flow/src/utils/color-util.js
@@ -0,0 +1,37 @@
+import * as Colors from '@mui/material/colors';
+
+export const getTaskStsColor = (taskStatus) => {
+    if (!taskStatus) {
+        return Colors.grey[500];
+    }
+    switch (taskStatus) {
+        case '绛夊緟涓�':
+            return Colors.deepPurple[500];
+        case '宸插垎閰�':
+            return Colors.lightBlue[600];
+        case '杩涜涓�':
+            return Colors.teal[700];
+        case '宸插畬鎴�':
+            return Colors.blueGrey[500];
+        default:
+            return Colors.amber[500];
+    }
+}
+
+export const getBusStsColor = (busStatus) => {
+    if (!busStatus) {
+        return 'default';
+    }
+    switch (busStatus) {
+        case '宸叉帴鏀�':
+            return 'secondary';
+        case '杩涜涓�':
+            return 'success';
+        case '宸插畬鎴�':
+            return 'default';
+        case '宸插彇娑�':
+            return 'error';
+        default:
+            return 'default';
+    }
+}
\ No newline at end of file
diff --git a/zy-acs-flow/src/utils/common.js b/zy-acs-flow/src/utils/common.js
index b3ee583..2083ca8 100644
--- a/zy-acs-flow/src/utils/common.js
+++ b/zy-acs-flow/src/utils/common.js
@@ -1,4 +1,3 @@
-import * as Colors from '@mui/material/colors';
 
 export const extractNavMenus = (data) => {
     if (!data) {
@@ -51,21 +50,3 @@
     });
     return result;
 };
-
-export const getTaskStsColor = (taskStatus) => {
-    if (!taskStatus) {
-        return Colors.grey[500];
-    }
-    switch (taskStatus) {
-        case '绛夊緟涓�':
-            return Colors.deepPurple[500];
-        case '宸插垎閰�':
-            return Colors.lightBlue[600];
-        case '杩涜涓�':
-            return Colors.teal[700];
-        case '宸插畬鎴�':
-            return Colors.blueGrey[500];
-        default:
-            return Colors.amber[500];
-    }
-}
\ No newline at end of file
diff --git a/zy-acs-framework/src/main/resources/templates/react-admin/ReactCreate.txt b/zy-acs-framework/src/main/resources/templates/react-admin/ReactCreate.txt
index 17b9497..d461fb6 100644
--- a/zy-acs-framework/src/main/resources/templates/react-admin/ReactCreate.txt
+++ b/zy-acs-framework/src/main/resources/templates/react-admin/ReactCreate.txt
@@ -48,8 +48,8 @@
         notify('common.response.success');
     };
 
-    const handleError = async (data) => {
-        notify('common.response.fail');
+    const handleError = async (error) => {
+        notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } });
     };
 
     return (
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/BusController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/BusController.java
index a714c47..c7e937f 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/BusController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/BusController.java
@@ -50,6 +50,7 @@
             List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBusId, record.getId()));
             if (!Cools.isEmpty(tasks)) {
                 record.setTaskIds(tasks.stream().map(Task::getId).collect(Collectors.toList()));
+                record.setTasksNum(tasks.size());
             }
         }
         return R.ok().add(page);

--
Gitblit v1.9.1