From 6dadc459ce52921f2784b16063deffd0da2bde23 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 10 十月 2024 16:17:54 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/settings/MapSettings.jsx |  181 +++++++++++++++++++++++++++++----------------
 1 files changed, 116 insertions(+), 65 deletions(-)

diff --git a/zy-acs-flow/src/map/settings/MapSettings.jsx b/zy-acs-flow/src/map/settings/MapSettings.jsx
index 1e40325..7acf00b 100644
--- a/zy-acs-flow/src/map/settings/MapSettings.jsx
+++ b/zy-acs-flow/src/map/settings/MapSettings.jsx
@@ -12,14 +12,17 @@
     InputLabel,
     FormControl,
     Stack,
+    Divider,
 } from '@mui/material';
+import MuiInput from '@mui/material/Input';
+import { styled } from '@mui/material/styles';
 import { useTranslate } from 'react-admin';
 
 const MapSettings = (props) => {
     const { sprite, onSubmit } = props;
     const translate = useTranslate();
 
-    const { control, handleSubmit, reset, watch, setValue } = useForm({
+    const { control, handleSubmit, reset, watch } = useForm({
         defaultValues: {
             x: sprite?.position.x || 0,
             y: sprite?.position.y || 0,
@@ -79,14 +82,16 @@
 
     return (
         <Box component="form" onSubmit={handleSubmit(onFormSubmit)} noValidate sx={{ mt: 0 }}>
-            <Grid container spacing={1}>
-                {/* 浣嶇疆 */}
+            <Grid container spacing={2}>
+                {/* position */}
                 <Grid item xs={12}>
-                    <Typography variant="button">
+                    <Typography variant="inherit">
                         {translate('page.map.settings.map.base.position')}
                     </Typography>
                 </Grid>
-                <Grid item xs={6}>
+                <Grid item xs={6} pt={0} sx={{
+                    paddingTop: '8px !important',
+                }}>
                     <Controller
                         name="x"
                         control={control}
@@ -97,14 +102,19 @@
                                 type="number"
                                 fullWidth
                                 onChange={(e) => {
+                                    const value = parseFloat(e.target.value);
                                     field.onChange(e);
-                                    updateSprite({ ...watchAllFields, x: parseFloat(e.target.value) });
+                                    if (!isNaN(value)) {
+                                        updateSprite({ ...watchAllFields, x: value });
+                                    }
                                 }}
                             />
                         )}
                     />
                 </Grid>
-                <Grid item xs={6}>
+                <Grid item xs={6} sx={{
+                    paddingTop: '8px !important',
+                }}>
                     <Controller
                         name="y"
                         control={control}
@@ -115,113 +125,150 @@
                                 type="number"
                                 fullWidth
                                 onChange={(e) => {
+                                    const value = parseFloat(e.target.value);
                                     field.onChange(e);
-                                    updateSprite({ ...watchAllFields, y: parseFloat(e.target.value) });
+                                    if (!isNaN(value)) {
+                                        updateSprite({ ...watchAllFields, y: value });
+                                    }
                                 }}
                             />
                         )}
                     />
                 </Grid>
 
-                {/* 缂╂斁 */}
+                {/* scale */}
                 <Grid item xs={12}>
-                    <Typography variant="button">
+                    <Typography variant="inherit">
                         {translate('page.map.settings.map.base.scale')}
                     </Typography>
                 </Grid>
-                <Grid item xs={6}>
+                <Grid item xs={6} sx={{
+                    paddingTop: '8px !important',
+                }}>
                     <Controller
                         name="scaleX"
                         control={control}
                         render={({ field }) => (
                             <TextField
                                 {...field}
-                                label="Scale X"
+                                label="X"
                                 type="number"
                                 fullWidth
                                 inputProps={{ step: 0.1, min: 0.1, max: 10 }}
                                 onChange={(e) => {
+                                    const value = parseFloat(e.target.value);
                                     field.onChange(e);
-                                    updateSprite({ ...watchAllFields, scaleX: parseFloat(e.target.value) });
+                                    if (!isNaN(value)) {
+                                        updateSprite({ ...watchAllFields, scaleX: value });
+                                    }
                                 }}
                             />
                         )}
                     />
                 </Grid>
-                <Grid item xs={6}>
+                <Grid item xs={6} sx={{
+                    paddingTop: '8px !important',
+                }}>
                     <Controller
                         name="scaleY"
                         control={control}
                         render={({ field }) => (
                             <TextField
                                 {...field}
-                                label="Scale Y"
+                                label="Y"
                                 type="number"
                                 fullWidth
                                 inputProps={{ step: 0.1, min: 0.1, max: 10 }}
                                 onChange={(e) => {
+                                    const value = parseFloat(e.target.value);
                                     field.onChange(e);
-                                    updateSprite({ ...watchAllFields, scaleY: parseFloat(e.target.value) });
+                                    if (!isNaN(value)) {
+                                        updateSprite({ ...watchAllFields, scaleY: value });
+                                    }
                                 }}
                             />
                         )}
                     />
                 </Grid>
 
-                {/* 鏃嬭浆 */}
+                {/* rotation */}
                 <Grid item xs={12}>
-                    <Typography variant="button">
+                    <Typography variant="inherit">
                         {translate('page.map.settings.map.base.rotation')}
                     </Typography>
                 </Grid>
-                <Grid item xs={8}>
-                    <Controller
-                        name="rotation"
-                        control={control}
-                        render={({ field }) => (
-                            <Slider
-                                {...field}
-                                min={0}
-                                max={360}
-                                step={1}
-                                marks={rotationMarks}
-                                valueLabelDisplay="auto"
-                                valueLabelFormat={(value) => `${value}掳`}
-                                onChange={(e, value) => {
-                                    field.onChange(value);
-                                    updateSprite({ ...watchAllFields, rotation: value });
-                                }}
+                <Grid item xs={12}>
+                    <Box display="flex" alignItems="center">
+                        <Box flex={1} mr={3}>
+                            <Controller
+                                name="rotation"
+                                control={control}
+                                render={({ field }) => (
+                                    <Slider
+                                        {...field}
+                                        // size="small"
+                                        min={0}
+                                        max={360}
+                                        step={1}
+                                        valueLabelDisplay="auto"
+                                        valueLabelFormat={(value) => `${value}掳`}
+                                        onChange={(e, value) => {
+                                            field.onChange(value);
+                                            updateSprite({ ...watchAllFields, rotation: value });
+                                        }}
+                                    />
+                                )}
                             />
-                        )}
-                    />
+                        </Box>
+                        <Box >
+                            <Controller
+                                name="rotation"
+                                control={control}
+                                render={({ field }) => (
+                                    <MuiInput
+                                        {...field}
+                                        size="small"
+                                        value={field.value}
+                                        onChange={(e) => {
+                                            const value = e.target.value === '' ? 0 : Number(e.target.value);
+                                            if (!isNaN(value)) {
+                                                field.onChange(value);
+                                                updateSprite({ ...watchAllFields, rotation: value });
+                                            }
+                                        }}
+                                        onBlur={() => {
+                                            if (field.value < 0) {
+                                                field.onChange(0);
+                                            } else if (field.value > 360) {
+                                                field.onChange(360);
+                                            }
+                                        }}
+                                        inputProps={{
+                                            step: 1,
+                                            min: 0,
+                                            max: 360,
+                                            type: 'number',
+                                            'aria-labelledby': 'input-slider',
+                                        }}
+                                    />
+                                )}
+                            />
+                        </Box>
+                    </Box>
                 </Grid>
-                <Grid item xs={4}>
-                    <Controller
-                        name="rotation"
-                        control={control}
-                        render={({ field }) => (
-                            <TextField
-                                {...field}
-                                label={`${translate('page.map.settings.map.base.rotation')} (掳)`}
-                                type="number"
-                                fullWidth
-                                inputProps={{ min: 0, max: 360 }}
-                                onChange={(e) => {
-                                    field.onChange(e);
-                                    updateSprite({ ...watchAllFields, rotation: parseFloat(e.target.value) });
-                                }}
-                            />
-                        )}
-                    />
+                <Grid item xs={12}>
+                    <Divider />
                 </Grid>
 
-                {/* 澶嶅埗 */}
+                {/* copy */}
                 <Grid item xs={12}>
-                    <Typography variant="button">
+                    <Typography variant="inherit">
                         {translate('page.map.settings.map.copy.title')}
                     </Typography>
                 </Grid>
-                <Grid item xs={6}>
+                <Grid item xs={6} sx={{
+                    paddingTop: '8px !important',
+                }}>
                     <Controller
                         name="copyDirection"
                         control={control}
@@ -251,7 +298,9 @@
                         )}
                     />
                 </Grid>
-                <Grid item xs={6}>
+                <Grid item xs={6} sx={{
+                    paddingTop: '8px !important',
+                }}>
                     <Controller
                         name="copyCount"
                         control={control}
@@ -267,14 +316,16 @@
                     />
                 </Grid>
 
-                {/* 鎻愪氦鎸夐挳 */}
+                {/* more */}
+                <Grid item xs={12}>
+                    <Typography variant="inherit">
+                        {translate('page.map.settings.map.more.title')}
+                    </Typography>
+                </Grid>
                 <Grid item xs={12}>
                     <Stack direction="row" spacing={2}>
-                        <Button type="submit" variant="contained" color="primary">
-                            {translate('ra.action.confirm')}
-                        </Button>
-                        <Button variant="outlined" color="secondary" onClick={() => reset()}>
-                            {translate('common.action.reset')}
+                        <Button variant="outlined" color="error">
+                            {translate('ra.action.delete')}
                         </Button>
                     </Stack>
                 </Grid>

--
Gitblit v1.9.1