From 82dadf2e9fbd30756ccd419a17cda9d41c6a032b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 24 九月 2024 14:50:58 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/page/bus/BusList.jsx |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/zy-acs-flow/src/page/bus/BusList.jsx b/zy-acs-flow/src/page/bus/BusList.jsx
index fb3d176..da2a17a 100644
--- a/zy-acs-flow/src/page/bus/BusList.jsx
+++ b/zy-acs-flow/src/page/bus/BusList.jsx
@@ -32,6 +32,7 @@
     DeleteButton,
     FunctionField,
     Pagination,
+    useNotify,
 } from 'react-admin';
 import { Box, Typography, Button, Chip } from '@mui/material';
 import { styled } from '@mui/material/styles';
@@ -47,6 +48,8 @@
 import BusListAside from "./BusListAside";
 import { getBusStsColor } from '@/utils/color-util';
 import CancelIcon from '@mui/icons-material/Cancel';
+import request from '@/utils/request';
+import ConfirmButton from "../components/ConfirmButton";
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -95,12 +98,19 @@
 
 const BusList = () => {
     const translate = useTranslate();
-
+    const notify = useNotify();
     const [createDialog, setCreateDialog] = useState(false);
     const [drawerVal, setDrawerVal] = useState(false);
 
-    const onCancel = (onCancel) => {
-        alert(onCancel.busNo);
+    const onCancel = (busId) => {
+        request.get("/bus/cancel/" + busId).then(res => {
+            const { code, msg, data } = res.data;
+            if (code === 200) {
+                notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } });
+            } else {
+                notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } });
+            }
+        })
     }
 
     return (
@@ -170,19 +180,17 @@
                     <TextField source="memo" label="common.field.memo" sortable={false} emptyText="-" />
                     <FunctionField label="common.field.opt" cellClassName="opt" render={record => (
                         (record.busSts === 15 || true) && (
-                            // <DeleteButton label="" sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
-                            <Button
+                            <ConfirmButton
+                                label="ra.action.cancel"
                                 size="small"
                                 color="error"
                                 startIcon={<CancelIcon />}
                                 sx={{ padding: '1px', fontSize: '.75rem' }}
-                                onClick={(event) => {
-                                    event.stopPropagation();
-                                    onCancel(record);
+                                data={record.busNo}
+                                onConfirm={() => {
+                                    onCancel(record.id);
                                 }}
-                            >
-                                {translate('ra.action.cancel')}
-                            </Button>
+                            />
                         )
                     )} />
                 </StyledDatagrid>

--
Gitblit v1.9.1