| | |
| | | MenuItem, |
| | | InputLabel, |
| | | FormControl, |
| | | FormHelperText, |
| | | Checkbox, |
| | | FormControlLabel, |
| | | Stack, |
| | | } from '@mui/material'; |
| | | import { useTranslate } from 'react-admin'; |
| | |
| | | }, |
| | | }); |
| | | |
| | | // 监听表单值的变化 |
| | | // 监听所有字段的变化 |
| | | const watchAllFields = watch(); |
| | | |
| | | useEffect(() => { |
| | |
| | | } |
| | | }; |
| | | |
| | | // 旋转滑块的刻度 |
| | | 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: 2 }}> |
| | | <Grid container spacing={2}> |
| | | <Box component="form" onSubmit={handleSubmit(onFormSubmit)} noValidate sx={{ mt: 0 }}> |
| | | <Grid container spacing={1}> |
| | | {/* 位置 */} |
| | | <Grid item xs={2}> |
| | | <Typography variant="h6">{translate('page.map.settings.map.base.position')}</Typography> |
| | | <Grid item xs={12}> |
| | | <Typography variant="button"> |
| | | {translate('page.map.settings.map.base.position')} |
| | | </Typography> |
| | | </Grid> |
| | | <Grid item xs={5}> |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="x" |
| | | control={control} |
| | |
| | | )} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={5}> |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="y" |
| | | control={control} |
| | |
| | | </Grid> |
| | | |
| | | {/* 缩放 */} |
| | | <Grid item xs={2}> |
| | | <Typography variant="h6">{translate('page.map.settings.map.base.scale')}</Typography> |
| | | <Grid item xs={12}> |
| | | <Typography variant="button"> |
| | | {translate('page.map.settings.map.base.scale')} |
| | | </Typography> |
| | | </Grid> |
| | | <Grid item xs={5}> |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="scaleX" |
| | | control={control} |
| | |
| | | )} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={5}> |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="scaleY" |
| | | control={control} |
| | |
| | | </Grid> |
| | | |
| | | {/* 旋转 */} |
| | | <Grid item xs={2}> |
| | | <Typography variant="h6">{translate('page.map.settings.map.base.rotation')}</Typography> |
| | | <Grid item xs={12}> |
| | | <Typography variant="button"> |
| | | {translate('page.map.settings.map.base.rotation')} |
| | | </Typography> |
| | | </Grid> |
| | | <Grid item xs={10}> |
| | | <Grid item xs={8}> |
| | | <Controller |
| | | name="rotation" |
| | | control={control} |
| | |
| | | min={0} |
| | | max={360} |
| | | step={1} |
| | | marks={rotationMarks} |
| | | valueLabelDisplay="auto" |
| | | valueLabelFormat={(value) => `${value}°`} |
| | | onChange={(e, value) => { |
| | | field.onChange(value); |
| | | updateSprite({ ...watchAllFields, rotation: value }); |
| | |
| | | )} |
| | | /> |
| | | </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> |
| | | |
| | | {/* 复制 */} |
| | | <Grid item xs={2}> |
| | | <Typography variant="h6">{translate('page.map.settings.map.copy.title')}</Typography> |
| | | <Grid item xs={12}> |
| | | <Typography variant="button"> |
| | | {translate('page.map.settings.map.copy.title')} |
| | | </Typography> |
| | | </Grid> |
| | | <Grid item xs={5}> |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="copyDirection" |
| | | control={control} |
| | | render={({ field }) => ( |
| | | <FormControl fullWidth> |
| | | <InputLabel>{translate('page.map.settings.map.copy.direction')}</InputLabel> |
| | | <Select {...field} label={translate('page.map.settings.map.copy.direction')}> |
| | | <MenuItem value="left">{translate('page.map.settings.map.copy.left')}</MenuItem> |
| | | <MenuItem value="right">{translate('page.map.settings.map.copy.right')}</MenuItem> |
| | | <MenuItem value="up">{translate('page.map.settings.map.copy.up')}</MenuItem> |
| | | <MenuItem value="down">{translate('page.map.settings.map.copy.down')}</MenuItem> |
| | | <InputLabel> |
| | | {translate('page.map.settings.map.copy.direction')} |
| | | </InputLabel> |
| | | <Select |
| | | {...field} |
| | | label={translate('page.map.settings.map.copy.direction')} |
| | | > |
| | | <MenuItem value="left"> |
| | | {translate('page.map.settings.map.copy.left')} |
| | | </MenuItem> |
| | | <MenuItem value="right"> |
| | | {translate('page.map.settings.map.copy.right')} |
| | | </MenuItem> |
| | | <MenuItem value="up"> |
| | | {translate('page.map.settings.map.copy.up')} |
| | | </MenuItem> |
| | | <MenuItem value="down"> |
| | | {translate('page.map.settings.map.copy.down')} |
| | | </MenuItem> |
| | | </Select> |
| | | </FormControl> |
| | | )} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={5}> |
| | | <Grid item xs={6}> |
| | | <Controller |
| | | name="copyCount" |
| | | control={control} |