From 351f8191a009e12b66e1215eaac70f3857a9b504 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 24 九月 2024 12:51:45 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/page/bus/BusList.jsx | 32 +++++++++++----
zy-acs-flow/src/i18n/core/chineseMessages.js | 4 +-
zy-acs-flow/src/i18n/en.js | 6 +++
zy-acs-flow/src/i18n/zh.js | 6 +++
zy-acs-flow/src/page/components/ConfirmButton.jsx | 55 +++++++++++++++++++++++++++
5 files changed, 92 insertions(+), 11 deletions(-)
diff --git a/zy-acs-flow/src/i18n/core/chineseMessages.js b/zy-acs-flow/src/i18n/core/chineseMessages.js
index 04ce7db..44e656d 100644
--- a/zy-acs-flow/src/i18n/core/chineseMessages.js
+++ b/zy-acs-flow/src/i18n/core/chineseMessages.js
@@ -89,11 +89,11 @@
bulk_delete_content:
'Are you sure you want to delete this %{name}? |||| Are you sure you want to delete these %{smart_count} items?',
bulk_delete_title:
- '鍒犻櫎 %{name} |||| Delete %{smart_count} %{name}',
+ '鍒犻櫎 %{name} |||| 鍒犻櫎 %{smart_count} %{name}',
bulk_update_content:
'Are you sure you want to update this %{name}? |||| Are you sure you want to update these %{smart_count} items?',
bulk_update_title:
- 'Update %{name} |||| Update %{smart_count} %{name}',
+ '淇敼 %{name} |||| 淇敼 %{smart_count} %{name}',
clear_array_input: 'Are you sure you want to clear the whole list?',
delete_content: '鎮ㄧ‘瀹炶鍒犻櫎姝ら」鍚楋紵',
delete_title: '鍒犻櫎 %{name} #%{id}',
diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js
index fd48ed5..afa0a4d 100644
--- a/zy-acs-flow/src/i18n/en.js
+++ b/zy-acs-flow/src/i18n/en.js
@@ -64,6 +64,12 @@
},
loadMore: 'Load More Data',
},
+ msg: {
+ confirm: {
+ tip: 'Tip',
+ desc: 'Are you sure you wanna do this?',
+ },
+ },
},
filters: {
lastCreated: 'Last created',
diff --git a/zy-acs-flow/src/i18n/zh.js b/zy-acs-flow/src/i18n/zh.js
index 85339d6..cc73255 100644
--- a/zy-acs-flow/src/i18n/zh.js
+++ b/zy-acs-flow/src/i18n/zh.js
@@ -64,6 +64,12 @@
},
loadMore: '鍔犺浇鏇村',
},
+ msg: {
+ confirm: {
+ tip: '鎻愮ず',
+ desc: '浣犵‘瀹氳鎿嶄綔姝ら」鍚�?',
+ },
+ },
},
filters: {
lastCreated: '鏈�杩戝垱寤�',
diff --git a/zy-acs-flow/src/page/bus/BusList.jsx b/zy-acs-flow/src/page/bus/BusList.jsx
index fb3d176..ab39add 100644
--- a/zy-acs-flow/src/page/bus/BusList.jsx
+++ b/zy-acs-flow/src/page/bus/BusList.jsx
@@ -47,6 +47,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': {
@@ -99,8 +101,9 @@
const [createDialog, setCreateDialog] = useState(false);
const [drawerVal, setDrawerVal] = useState(false);
- const onCancel = (onCancel) => {
- alert(onCancel.busNo);
+ const onCancel = (busId) => {
+ console.log(busId);
+
}
return (
@@ -171,18 +174,29 @@
<FunctionField label="common.field.opt" cellClassName="opt" render={record => (
(record.busSts === 15 || true) && (
// <DeleteButton label="" sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
- <Button
+ // <Button
+ // size="small"
+ // color="error"
+ // startIcon={<CancelIcon />}
+ // sx={{ padding: '1px', fontSize: '.75rem' }}
+ // onClick={(event) => {
+ // event.stopPropagation();
+ // onCancel(record);
+ // }}
+ // >
+ // {translate('ra.action.cancel')}
+ // </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>
diff --git a/zy-acs-flow/src/page/components/ConfirmButton.jsx b/zy-acs-flow/src/page/components/ConfirmButton.jsx
new file mode 100644
index 0000000..595c6fd
--- /dev/null
+++ b/zy-acs-flow/src/page/components/ConfirmButton.jsx
@@ -0,0 +1,55 @@
+import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
+import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
+import {
+ useTranslate,
+} from 'react-admin';
+
+const ConfirmButton = (props) => {
+ const { label, onConfirm, data, ...rest } = props;
+ const translate = useTranslate();
+ const [open, setOpen] = useState(false);
+
+ const handleClickOpen = (event) => {
+ event.stopPropagation();
+ setOpen(true);
+ };
+
+ const handleClose = (event) => {
+ event.stopPropagation();
+ setOpen(false);
+ };
+
+ const handleConfirm = (event) => {
+ handleClose(event);
+ onConfirm();
+ };
+
+ return (
+ <>
+ <Button
+ onClick={handleClickOpen}
+ {...rest}
+ >
+ {translate(label)}
+ </Button>
+ <Dialog open={open} onClose={handleClose}>
+ <DialogTitle>{translate('common.msg.confirm.tip')}</DialogTitle>
+ <DialogContent>
+ <DialogContentText>
+ {translate('common.msg.confirm.desc')}
+ </DialogContentText>
+ </DialogContent>
+ <DialogActions>
+ <Button onClick={handleClose} color="primary">
+ {translate('ra.action.cancel')}
+ </Button>
+ <Button onClick={handleConfirm} color="primary">
+ {translate('ra.action.confirm')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ </>
+ )
+}
+
+export default ConfirmButton;
\ No newline at end of file
--
Gitblit v1.9.1