cl
4 天以前 450a97460b086663bb07b418b48354b0a3125e85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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;