From fd02009741fbc7bc520000edb0c19afb6c27f29e Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 07 一月 2026 15:46:49 +0800
Subject: [PATCH] #
---
rsf-admin/src/page/menuPda/MenuPdaEdit.jsx | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 225 insertions(+), 0 deletions(-)
diff --git a/rsf-admin/src/page/menuPda/MenuPdaEdit.jsx b/rsf-admin/src/page/menuPda/MenuPdaEdit.jsx
new file mode 100644
index 0000000..3560161
--- /dev/null
+++ b/rsf-admin/src/page/menuPda/MenuPdaEdit.jsx
@@ -0,0 +1,225 @@
+import React, { useState, useRef, useEffect, useMemo } from "react";
+import {
+ CreateBase,
+ useTranslate,
+ TextInput,
+ NumberInput,
+ BooleanInput,
+ DateInput,
+ SaveButton,
+ SelectInput,
+ ReferenceInput,
+ ReferenceArrayInput,
+ AutocompleteInput,
+ Toolbar,
+ required,
+ useNotify,
+ Form,
+ useUpdate,
+ useCreate,
+ useCreateContext,
+} from 'react-admin';
+import {
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogTitle,
+ Stack,
+ Grid,
+ Box,
+} from '@mui/material';
+import DialogCloseButton from "@/page/components/DialogCloseButton";
+import StatusSelectInput from "@/page/components/StatusSelectInput";
+import MemoInput from "@/page/components/MemoInput";
+import TreeSelectInput from "@/page/components/TreeSelectInput";
+
+const EditContent = ({ editRecord }) => {
+ const { resource } = useCreateContext();
+ return (
+ <Grid container rowSpacing={2} columnSpacing={2}>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TreeSelectInput
+ label="table.field.menu.parentName"
+ value={editRecord?.parentId}
+ isTranslate
+ resource={resource}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TextInput
+ label="table.field.menu.name"
+ source="name"
+ parse={v => v}
+ validate={required()}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TextInput
+ label="table.field.menu.route"
+ source="route"
+ validate={required()}
+ parse={v => v}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TextInput
+ label="table.field.menu.component"
+ source="component"
+ parse={v => v}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <SelectInput
+ label="table.field.menu.type"
+ source="type"
+ validate={required()}
+ choices={[
+ { id: 0, name: 'table.field.menu.enums.menu' },
+ { id: 1, name: 'table.field.menu.enums.button' },
+ ]}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TextInput
+ label="table.field.menu.authority"
+ source="authority"
+ parse={v => v}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TextInput
+ label="table.field.menu.icon"
+ source="icon"
+ parse={v => v}
+ />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <NumberInput
+ label="table.field.menu.sort"
+ source="sort"
+ />
+ </Grid>
+
+ <Grid item xs={6} display="flex" gap={1}>
+ <StatusSelectInput />
+ </Grid>
+ <Grid item xs={6} display="flex" gap={1}>
+ <TextInput
+ label="common.field.memo"
+ source="memo"
+ parse={v => v}
+ fullWidth
+ multiline
+ minRows={2}
+ autoFocus
+ />
+ </Grid>
+ </Grid>
+ )
+}
+
+const MenuPdaEdit = (props) => {
+ const { editRecord, open, setOpen, callback, resource } = props;
+
+ const translate = useTranslate();
+ const notify = useNotify();
+
+ const [update] = useUpdate();
+ const [create] = useCreate();
+
+ const handleClose = (event, reason) => {
+ if (reason !== "backdropClick") {
+ setOpen(false);
+ }
+ };
+
+ const handleSuccess = async (data) => {
+ setOpen(false);
+ callback();
+ notify('common.response.success', { type: 'info' });
+ };
+
+ const handleError = async (data) => {
+ notify('common.response.fail', { type: 'error' });
+ };
+
+ const onSubmit = (data) => {
+ const _params = { ...data };
+ if (editRecord) {
+ if (_params.parentId === editRecord.id) {
+ notify('common.response.dataError', { type: 'error' });
+ return;
+ }
+ update(
+ resource,
+ {
+ id: editRecord.id,
+ data: _params,
+ },
+ {
+ onSuccess: () => {
+ handleSuccess();
+ },
+ onError: (error) => {
+ handleError();
+ },
+ }
+ );
+ } else {
+ create(
+ resource,
+ { data: _params },
+ {
+ onSuccess: () => {
+ handleSuccess();
+ },
+ onError: (error) => {
+ handleError();
+ },
+ }
+ );
+ }
+ };
+
+ return (
+ <>
+ <CreateBase>
+ <Dialog
+ open={open}
+ onClose={handleClose}
+ aria-labelledby="form-dialog-title"
+ fullWidth
+ disableRestoreFocus
+ maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl'
+ >
+ <Form record={editRecord} onSubmit={onSubmit}>
+ <DialogTitle id="form-dialog-title" sx={{
+ position: 'sticky',
+ top: 0,
+ backgroundColor: 'background.paper',
+ zIndex: 1000
+ }}
+ >
+ {editRecord ? translate('update.title') : translate('create.title')}
+ <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}>
+ <DialogCloseButton onClose={handleClose} />
+ </Box>
+ </DialogTitle>
+ <DialogContent sx={{ mt: 2 }}>
+ <EditContent
+ editRecord={editRecord}
+ />
+ </DialogContent>
+ <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}>
+ <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} >
+ <SaveButton />
+ </Toolbar>
+ </DialogActions>
+ </Form>
+ </Dialog>
+ </CreateBase>
+ </>
+ )
+}
+
+export default MenuPdaEdit;
--
Gitblit v1.9.1