import React from "react";
|
import {
|
CreateBase,
|
TextInput,
|
NumberInput,
|
SelectInput,
|
Toolbar,
|
Form,
|
SaveButton,
|
required,
|
useNotify,
|
useTranslate,
|
} from 'react-admin';
|
import { Dialog, DialogContent, DialogTitle, Grid, Box } from '@mui/material';
|
import DialogCloseButton from "@/page/components/DialogCloseButton";
|
|
const HttpAuditSysConfigCreate = (props) => {
|
const { open, setOpen } = props;
|
const notify = useNotify();
|
const translate = useTranslate();
|
|
const handleClose = (event, reason) => {
|
if (reason !== "backdropClick") setOpen(false);
|
};
|
|
const handleSuccess = () => {
|
setOpen(false);
|
notify('新增成功');
|
};
|
|
const handleError = (error) => {
|
notify(error?.message || '新增失败', { type: 'error' });
|
};
|
|
return (
|
<CreateBase
|
resource="httpAuditSysConfig"
|
record={{ enabled: 1, sortOrder: 0 }}
|
mutationOptions={{ onSuccess: handleSuccess, onError: handleError }}
|
>
|
<Dialog
|
open={open}
|
onClose={handleClose}
|
fullWidth
|
disableRestoreFocus
|
maxWidth="md"
|
>
|
<Form>
|
<DialogTitle sx={{ position: 'sticky', top: 0, backgroundColor: 'background.paper', zIndex: 1000 }}>
|
{translate('resources.httpAuditSysConfig.createTitle')}
|
<Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}>
|
<DialogCloseButton onClose={handleClose} />
|
</Box>
|
</DialogTitle>
|
<DialogContent sx={{ mt: 2 }}>
|
<Grid container rowSpacing={2} columnSpacing={2}>
|
<Grid item xs={12}>
|
<TextInput source="configKey" label="table.field.httpAuditSysConfig.configKey" validate={required()} fullWidth />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="configVal" label="table.field.httpAuditSysConfig.configVal" fullWidth multiline minRows={4} />
|
</Grid>
|
<Grid item xs={12} sm={6}>
|
<SelectInput
|
source="enabled"
|
label="table.field.httpAuditSysConfig.enabled"
|
choices={[
|
{ id: 1, name: translate('table.field.httpAuditSysConfig.enabledOn') },
|
{ id: 0, name: translate('table.field.httpAuditSysConfig.enabledOff') },
|
]}
|
fullWidth
|
/>
|
</Grid>
|
<Grid item xs={12} sm={6}>
|
<NumberInput source="sortOrder" label="table.field.httpAuditSysConfig.sortOrder" fullWidth />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="remark" label="table.field.httpAuditSysConfig.remark" fullWidth multiline minRows={2} />
|
</Grid>
|
</Grid>
|
</DialogContent>
|
<Toolbar sx={{ justifyContent: 'flex-end', px: 2, pb: 2 }}>
|
<SaveButton label="ra.action.save" type="button" />
|
</Toolbar>
|
</Form>
|
</Dialog>
|
</CreateBase>
|
);
|
};
|
|
export default HttpAuditSysConfigCreate;
|