From 89ca1eb19972e8f5e0baccbaffcfa7fbb2ae85c3 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期六, 10 一月 2026 15:34:17 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/page/lane/LaneDeleteAllButton.jsx |   55 +++++++++++++++++++++++++++
 zy-acs-flow/src/i18n/en.js                        |    5 ++
 zy-acs-flow/src/page/lane/LaneList.jsx            |   21 ++++++----
 zy-acs-flow/src/i18n/zh.js                        |    5 ++
 zy-acs-flow/src/page/components/ConfirmButton.jsx |   25 ++++++++++--
 5 files changed, 97 insertions(+), 14 deletions(-)

diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js
index aa70865..d19f9b7 100644
--- a/zy-acs-flow/src/i18n/en.js
+++ b/zy-acs-flow/src/i18n/en.js
@@ -654,6 +654,11 @@
                 entryAngle: 'Set the lane entry angle (0-360). -1 means no restriction',
                 maximum: 'Adjust the maximum load capacity. -1 means no restriction',
             },
+            actions: {
+                deleteAll: 'DELETE ALL',
+                deleteAllSuccess: 'Delete all successfully.',
+                deleteAllError: 'Failed to delete all.',
+            },
         },
         agv: {
             show: {
diff --git a/zy-acs-flow/src/i18n/zh.js b/zy-acs-flow/src/i18n/zh.js
index 9195e84..dd26f06 100644
--- a/zy-acs-flow/src/i18n/zh.js
+++ b/zy-acs-flow/src/i18n/zh.js
@@ -654,6 +654,11 @@
                 entryAngle: '璁剧疆杞︿綋杩涘叆宸烽亾瑙掑害 (0-360)锛�-1琛ㄧず鏃犻檺鍒�',
                 maximum: '璋冩暣宸烽亾杞︿綋鎵胯浇閲忥紝-1琛ㄧず鏃犻檺鍒�',
             },
+            actions: {
+                deleteAll: '娓呯┖宸烽亾',
+                deleteAllSuccess: '宸烽亾宸插叏閮ㄥ垹闄�',
+                deleteAllError: '娓呯┖宸烽亾澶辫触',
+            },
         },
         agv: {
             show: {
diff --git a/zy-acs-flow/src/page/components/ConfirmButton.jsx b/zy-acs-flow/src/page/components/ConfirmButton.jsx
index e39fe98..9c245a3 100644
--- a/zy-acs-flow/src/page/components/ConfirmButton.jsx
+++ b/zy-acs-flow/src/page/components/ConfirmButton.jsx
@@ -1,11 +1,11 @@
 import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
 import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
 import {
-    useTranslate,
+    useTranslate
 } from 'react-admin';
 
 const ConfirmButton = (props) => {
-    const { label, onConfirm, data, ...rest } = props;
+    const { label, onConfirm, renderButton, ...rest } = props;
     const translate = useTranslate();
     const buttonRef = useRef(null);
     const [open, setOpen] = useState(false);
@@ -25,8 +25,18 @@
         onConfirm();
     };
 
-    return (
-        <>
+    const buttonElement = renderButton
+        ? renderButton({
+            buttonProps: {
+                ref: buttonRef,
+                onClick: handleClickOpen,
+                'aria-label': translate(label),
+                ...rest,
+            },
+            label,
+            translate,
+        })
+        : (
             <Button
                 ref={buttonRef}
                 onClick={handleClickOpen}
@@ -35,6 +45,11 @@
             >
                 {translate(label)}
             </Button>
+        );
+
+    return (
+        <>
+            {buttonElement}
             <Dialog
                 aria-labelledby="dialog-title"
                 aria-describedby="dialog-description"
@@ -60,4 +75,4 @@
     )
 }
 
-export default ConfirmButton;
\ No newline at end of file
+export default ConfirmButton;
diff --git a/zy-acs-flow/src/page/lane/LaneDeleteAllButton.jsx b/zy-acs-flow/src/page/lane/LaneDeleteAllButton.jsx
new file mode 100644
index 0000000..9e64565
--- /dev/null
+++ b/zy-acs-flow/src/page/lane/LaneDeleteAllButton.jsx
@@ -0,0 +1,55 @@
+import React, { useCallback, useState } from "react";
+import DeleteSweepIcon from '@mui/icons-material/DeleteSweep';
+import {
+    useDataProvider,
+    useNotify,
+    useRefresh,
+    Button as RaButton,
+} from 'react-admin';
+import ConfirmButton from "../components/ConfirmButton";
+
+const LaneDeleteAllButton = () => {
+    const dataProvider = useDataProvider();
+    const notify = useNotify();
+    const refresh = useRefresh();
+    const [loading, setLoading] = useState(false);
+
+    const handleConfirm = useCallback(() => {
+        setLoading(true);
+        dataProvider.delete('lane', {
+            id: '__purge_all__',
+            meta: { deleteAll: true },
+        }).then(() => {
+            notify('page.lane.actions.deleteAllSuccess', { type: 'info' });
+            refresh();
+        }).catch((error) => {
+            console.error(error);
+            notify('page.lane.actions.deleteAllError', { type: 'error' });
+        }).finally(() => {
+            setLoading(false);
+        });
+    }, [dataProvider, notify, refresh]);
+
+    return (
+        <ConfirmButton
+            label="page.lane.actions.deleteAll"
+            onConfirm={handleConfirm}
+            disabled={loading}
+            renderButton={({ buttonProps }) => (
+                <RaButton
+                    {...buttonProps}
+                    label="page.lane.actions.deleteAll"
+                    color="error"
+                    size="small"
+                    startIcon={<DeleteSweepIcon />}
+                    sx={{
+                        fontWeight: 600,
+                        textTransform: 'none',
+                    }}
+                />
+            )}
+        />
+    );
+};
+
+export default LaneDeleteAllButton;
diff --git a/zy-acs-flow/src/page/lane/LaneList.jsx b/zy-acs-flow/src/page/lane/LaneList.jsx
index 994e467..dfea401 100644
--- a/zy-acs-flow/src/page/lane/LaneList.jsx
+++ b/zy-acs-flow/src/page/lane/LaneList.jsx
@@ -43,6 +43,7 @@
 import MyField from "../components/MyField";
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
 import * as Common from '@/utils/common';
+import LaneDeleteAllButton from "./LaneDeleteAllButton";
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -70,18 +71,18 @@
 
 const filters = [
     <SearchInput source="condition" alwaysOn />,
-    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
-    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
+    // <DateInput label='common.time.after' source="timeStart" alwaysOn />,
+    // <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
 
-    <TextInput source="uuid" label="table.field.lane.uuid" />,
+    // <TextInput source="uuid" label="table.field.lane.uuid" />,
     <ReferenceInput source="zoneId" label="table.field.lane.zoneId" reference="zone">
         <AutocompleteInput label="table.field.lane.zoneId" optionText="name" filterToQuery={(val) => ({ name: val })} />
     </ReferenceInput>,
-    <TextInput source="name" label="table.field.lane.name" />,
-    <TextInput source="hashCode" label="table.field.lane.hashCode" />,
-    <TextInput source="codes" label="table.field.lane.codes" />,
-    <NumberInput source="entryAngle" label="table.field.lane.entryAngle" />,
-    <NumberInput source="maximum" label="table.field.lane.maximum" />,
+    // <TextInput source="name" label="table.field.lane.name" />,
+    // <TextInput source="hashCode" label="table.field.lane.hashCode" />,
+    // <TextInput source="codes" label="table.field.lane.codes" />,
+    // <NumberInput source="entryAngle" label="table.field.lane.entryAngle" />,
+    // <NumberInput source="maximum" label="table.field.lane.maximum" />,
 
     <TextInput label="common.field.memo" source="memo" />,
     <SelectInput
@@ -92,6 +93,7 @@
             { id: '0', name: 'common.enums.statusFalse' },
         ]}
         resettable
+        alwaysOn
     />,
 ]
 
@@ -118,8 +120,9 @@
                 sort={{ field: "create_time", order: "desc" }}
                 actions={(
                     <TopToolbar>
-                        <FilterButton />
+                        {/* <FilterButton /> */}
                         {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */}
+                        <LaneDeleteAllButton />
                         <SelectColumnsButton preferenceKey='lane' />
                         <MyExportButton />
                     </TopToolbar>

--
Gitblit v1.9.1