From 64fb3ce826cd086463824844a9ee82977a763236 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 11 十月 2024 11:21:08 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/settings/MapSettings.jsx | 105 +++++++++++++++++++++++++++++-----------------------
1 files changed, 58 insertions(+), 47 deletions(-)
diff --git a/zy-acs-flow/src/map/settings/MapSettings.jsx b/zy-acs-flow/src/map/settings/MapSettings.jsx
index f482e67..6a24546 100644
--- a/zy-acs-flow/src/map/settings/MapSettings.jsx
+++ b/zy-acs-flow/src/map/settings/MapSettings.jsx
@@ -15,15 +15,12 @@
Divider,
} from '@mui/material';
import MuiInput from '@mui/material/Input';
-import { styled } from '@mui/material/styles';
import { useTranslate } from 'react-admin';
-
-const Input = styled(MuiInput)`
- width: 42px;
-`;
+import * as Tool from '../tool';
+import ConfirmButton from '../../page/components/ConfirmButton';
const MapSettings = (props) => {
- const { sprite, onSubmit } = props;
+ const { sprite, setSpriteSettings, onSubmit } = props;
const translate = useTranslate();
const { control, handleSubmit, reset, watch } = useForm({
@@ -35,11 +32,9 @@
rotation: (sprite?.rotation * 180) / Math.PI || 0,
copyDirection: 'right',
copyCount: 1,
- // 鍏朵粬榛樿鍊�...
},
});
- // 鐩戝惉鎵�鏈夊瓧娈电殑鍙樺寲
const watchAllFields = watch();
useEffect(() => {
@@ -50,12 +45,10 @@
scaleX: sprite.scale.x,
scaleY: sprite.scale.y,
rotation: (sprite.rotation * 180) / Math.PI,
- // 璁剧疆鍏朵粬瀛楁鐨勫垵濮嬪��
});
}
}, [sprite, reset]);
- // 鏇存柊绮剧伒灞炴�х殑鍑芥暟
const updateSprite = (data) => {
if (sprite) {
sprite.position.x = data.x;
@@ -63,11 +56,9 @@
sprite.scale.x = data.scaleX;
sprite.scale.y = data.scaleY;
sprite.rotation = (data.rotation * Math.PI) / 180;
- // 鏇存柊鍏朵粬灞炴��...
}
};
- // 澶勭悊琛ㄥ崟鎻愪氦
const onFormSubmit = (data) => {
updateSprite(data);
if (onSubmit) {
@@ -75,19 +66,10 @@
}
};
- // 鏃嬭浆婊戝潡鐨勫埢搴�
- const rotationMarks = [
- { value: 0, label: '0掳' },
- { value: 90, label: '90掳' },
- { value: 180, label: '180掳' },
- { value: 270, label: '270掳' },
- { value: 360, label: '360掳' },
- ];
-
return (
<Box component="form" onSubmit={handleSubmit(onFormSubmit)} noValidate sx={{ mt: 0 }}>
- <Grid container spacing={2}>
- {/* 浣嶇疆 */}
+ <Grid container spacing={1.4}>
+ {/* position */}
<Grid item xs={12}>
<Typography variant="inherit">
{translate('page.map.settings.map.base.position')}
@@ -95,7 +77,6 @@
</Grid>
<Grid item xs={6} pt={0} sx={{
paddingTop: '8px !important',
- paddingLeft: '8px !important',
}}>
<Controller
name="x"
@@ -119,7 +100,6 @@
</Grid>
<Grid item xs={6} sx={{
paddingTop: '8px !important',
- paddingLeft: '8px !important',
}}>
<Controller
name="y"
@@ -142,7 +122,7 @@
/>
</Grid>
- {/* 缂╂斁 */}
+ {/* scale */}
<Grid item xs={12}>
<Typography variant="inherit">
{translate('page.map.settings.map.base.scale')}
@@ -150,7 +130,6 @@
</Grid>
<Grid item xs={6} sx={{
paddingTop: '8px !important',
- paddingLeft: '8px !important',
}}>
<Controller
name="scaleX"
@@ -175,7 +154,6 @@
</Grid>
<Grid item xs={6} sx={{
paddingTop: '8px !important',
- paddingLeft: '8px !important',
}}>
<Controller
name="scaleY"
@@ -199,7 +177,7 @@
/>
</Grid>
- {/* 鏃嬭浆 */}
+ {/* rotation */}
<Grid item xs={12}>
<Typography variant="inherit">
{translate('page.map.settings.map.base.rotation')}
@@ -207,14 +185,14 @@
</Grid>
<Grid item xs={12}>
<Box display="flex" alignItems="center">
- <Box flex={1} mr={2}>
+ <Box flex={1} mr={3}>
<Controller
name="rotation"
control={control}
render={({ field }) => (
<Slider
{...field}
- size="small"
+ // size="small"
min={0}
max={360}
step={1}
@@ -228,23 +206,35 @@
)}
/>
</Box>
- <Box width={80}>
+ <Box >
<Controller
name="rotation"
control={control}
render={({ field }) => (
- <TextField
+ <MuiInput
{...field}
- label=""
- type="number"
- fullWidth
- inputProps={{ min: 0, max: 360 }}
+ size="small"
+ value={field.value}
onChange={(e) => {
- const value = parseFloat(e.target.value);
+ 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',
}}
/>
)}
@@ -252,11 +242,12 @@
</Box>
</Box>
</Grid>
+
<Grid item xs={12}>
<Divider />
</Grid>
- {/* 澶嶅埗 */}
+ {/* copy */}
<Grid item xs={12}>
<Typography variant="inherit">
{translate('page.map.settings.map.copy.title')}
@@ -264,7 +255,6 @@
</Grid>
<Grid item xs={6} sx={{
paddingTop: '8px !important',
- paddingLeft: '8px !important',
}}>
<Controller
name="copyDirection"
@@ -297,7 +287,6 @@
</Grid>
<Grid item xs={6} sx={{
paddingTop: '8px !important',
- paddingLeft: '8px !important',
}}>
<Controller
name="copyCount"
@@ -313,18 +302,40 @@
)}
/>
</Grid>
-
- {/* 鎻愪氦鎸夐挳 */}
<Grid item xs={12}>
<Stack direction="row" spacing={2}>
- <Button type="submit" variant="contained" color="primary">
- {translate('ra.action.confirm')}
+ <Button variant="contained" color="primary">
+ {translate('page.map.settings.map.copy.execute')}
</Button>
- <Button variant="outlined" color="secondary" onClick={() => reset()}>
- {translate('common.action.reset')}
+ <Button variant="text" color="primary">
+ {translate('page.map.settings.map.copy.reverse')}
</Button>
</Stack>
</Grid>
+
+ <Grid item xs={12}>
+ <Divider />
+ </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 variant="outlined" color="error" onClick={() => {
+ Tool.getMapContainer().removeChild(sprite);
+ setSpriteSettings(null);
+ Tool.removeSelectedEffect();
+ reset();
+ }}>
+ {translate('ra.action.delete')}
+ </Button>
+ {/* <ConfirmButton /> */}
+ </Stack>
+ </Grid>
</Grid>
</Box>
);
--
Gitblit v1.9.1