| | |
| | | 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}', |
| | |
| | | }, |
| | | loadMore: 'Load More Data', |
| | | }, |
| | | msg: { |
| | | confirm: { |
| | | tip: 'Tip', |
| | | desc: 'Are you sure you wanna do this?', |
| | | }, |
| | | }, |
| | | }, |
| | | filters: { |
| | | lastCreated: 'Last created', |
| | |
| | | }, |
| | | loadMore: '加载更多', |
| | | }, |
| | | msg: { |
| | | confirm: { |
| | | tip: '提示', |
| | | desc: '你确定要操作此项吗?', |
| | | }, |
| | | }, |
| | | }, |
| | | filters: { |
| | | lastCreated: '最近创建', |
| | |
| | | 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': { |
| | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | |
| | | const onCancel = (onCancel) => { |
| | | alert(onCancel.busNo); |
| | | const onCancel = (busId) => { |
| | | console.log(busId); |
| | | |
| | | } |
| | | |
| | | return ( |
| | |
| | | <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> |
New file |
| | |
| | | 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; |