From 14ddde5c41d8d98fc9b67ebae72b6cdbca73330b Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期五, 25 四月 2025 20:45:10 +0800
Subject: [PATCH] 添加动态字段拦截器

---
 rsf-admin/src/page/orders/wave/WaveEdit.jsx |  145 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 145 insertions(+), 0 deletions(-)

diff --git a/rsf-admin/src/page/orders/wave/WaveEdit.jsx b/rsf-admin/src/page/orders/wave/WaveEdit.jsx
new file mode 100644
index 0000000..899a39f
--- /dev/null
+++ b/rsf-admin/src/page/orders/wave/WaveEdit.jsx
@@ -0,0 +1,145 @@
+import React, { useState, useRef, useEffect, useMemo } from "react";
+import {
+    Edit,
+    SimpleForm,
+    FormDataConsumer,
+    useTranslate,
+    TextInput,
+    NumberInput,
+    BooleanInput,
+    DateInput,
+    SelectInput,
+    ReferenceInput,
+    ReferenceArrayInput,
+    AutocompleteInput,
+    SaveButton,
+    Toolbar,
+    Labeled,
+    NumberField,
+    required,
+    useRecordContext,
+    DeleteButton,
+} from 'react-admin';
+import { useWatch, useFormContext } from "react-hook-form";
+import { Stack, Grid, Box, Typography } from '@mui/material';
+import * as Common from '@/utils/common';
+import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting';
+import EditBaseAside from "../../components/EditBaseAside";
+import CustomerTopToolBar from "../../components/EditTopToolBar";
+import MemoInput from "../../components/MemoInput";
+import StatusSelectInput from "../../components/StatusSelectInput";
+import WaveItemList from "./WaveItemList";
+
+const FormToolbar = () => {
+    const { getValues } = useFormContext();
+
+    return (
+        <Toolbar sx={{ justifyContent: 'space-between' }}>
+            <SaveButton />
+            <DeleteButton mutationMode="optimistic" />
+        </Toolbar>
+    )
+}
+
+const WaveEdit = () => {
+    const translate = useTranslate();
+
+    return (
+        <Box>
+            <Edit
+                redirect="list"
+                mutationMode={EDIT_MODE}
+                actions={<CustomerTopToolBar />}
+                aside={<EditBaseAside />}
+            >
+                <SimpleForm
+                    shouldUnregister
+                    warnWhenUnsavedChanges
+                    toolbar={<FormToolbar />}
+                    mode="onTouched"
+                    defaultValues={{}}
+                // validate={(values) => { }}
+                >
+                    <Grid container width={{ xs: '100%', xl: '100%' }} rowSpacing={3} columnSpacing={3}>
+                        <Grid item xs={16} md={10} sx={{
+                            "& .MuiFormLabel-root.MuiInputLabel-root.Mui-disabled": {
+                                bgcolor: 'white',
+                                WebkitTextFillColor: "rgba(0, 0, 0)"
+                            },
+
+                            "& .MuiInputBase-input.MuiFilledInput-input.Mui-disabled": {
+                                bgcolor: 'white',
+                                WebkitTextFillColor: "rgba(0, 0, 0)"
+                            },
+                            "& .MuiFilledInput-root.MuiInputBase-sizeSmall": {
+                                bgcolor: 'white',
+                            }
+                        }}>
+                            <Typography variant="h6" gutterBottom>
+                                {translate('common.edit.title.main')}
+                            </Typography>
+                            <Stack direction='row' gap={2}>
+                                <TextInput
+                                    label="table.field.wave.code"
+                                    source="code"
+                                    parse={v => v}
+                                    readOnly
+                                />
+                                <SelectInput
+                                    label="table.field.wave.type"
+                                    source="type"
+                                    readOnly
+                                    choices={[
+                                        { id: 0, name: '鎵嬪姩' },
+                                        { id: 1, name: '鑷姩' },
+                                    ]}
+                                    
+                                />
+                                <SelectInput
+                                    label="table.field.wave.exceStatus"
+                                    source="exceStatus"
+                                    readOnly
+                                    choices={[
+                                        { id: 0, name: '鍒濆鍖�' },
+                                        { id: 1, name: '鐢熸垚浠诲姟' },
+                                        { id: 2, name: '浠诲姟鎾' },
+                                        { id: 3, name: '瀹屾垚' },
+                                    ]}
+                                />
+                            </Stack>
+                            <Stack direction='row' gap={2}>
+                                <NumberInput
+                                    label="table.field.wave.anfme"
+                                    readOnly
+                                    source="anfme"
+                                />
+                                <NumberInput
+                                    label="table.field.wave.qty"
+                                    readOnly
+                                    source="qty"
+                                />
+                                <NumberInput
+                                    label="table.field.wave.orderNum"
+                                    readOnly
+                                    source="orderNum"
+                                />
+                            </Stack>
+
+                        </Grid>
+                        <Grid item xs={8} md={2}>
+                            <Typography variant="h6" gutterBottom>
+                                {translate('common.edit.title.common')}
+                            </Typography>
+                            <StatusSelectInput />
+                            <Box mt="2em" />
+                            <MemoInput />
+                        </Grid>
+                    </Grid>
+                </SimpleForm>
+            </Edit >
+            <WaveItemList />
+        </Box>
+    )
+}
+
+export default WaveEdit;

--
Gitblit v1.9.1