From ae9f5505eb01efdfd6a7a6ac9d84b77aa741052d Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 11 十月 2024 14:05:45 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/settings/MapSettings.jsx | 45 +++++++++++++++++++++++++-------------------- 1 files changed, 25 insertions(+), 20 deletions(-) diff --git a/zy-acs-flow/src/map/settings/MapSettings.jsx b/zy-acs-flow/src/map/settings/MapSettings.jsx index 04dec03..8770a27 100644 --- a/zy-acs-flow/src/map/settings/MapSettings.jsx +++ b/zy-acs-flow/src/map/settings/MapSettings.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { useForm, Controller } from 'react-hook-form'; import { Box, @@ -15,12 +15,15 @@ Divider, } from '@mui/material'; import MuiInput from '@mui/material/Input'; -import { styled } from '@mui/material/styles'; import { useTranslate } from 'react-admin'; +import * as Tool from '../tool'; +import ConfirmButton from '../../page/components/ConfirmButton'; +import CopyDrawer from './CopyDrawer'; const MapSettings = (props) => { - const { sprite, onSubmit } = props; + const { sprite, setSpriteSettings, onSubmit, width } = props; const translate = useTranslate(); + const [copyVisible, setCopyVisible] = useState(false); const { control, handleSubmit, reset, watch } = useForm({ defaultValues: { @@ -31,27 +34,24 @@ rotation: (sprite?.rotation * 180) / Math.PI || 0, copyDirection: 'right', copyCount: 1, - // 鍏朵粬榛樿鍊�... }, }); - // 鐩戝惉鎵�鏈夊瓧娈电殑鍙樺寲 const watchAllFields = watch(); useEffect(() => { if (sprite) { + setCopyVisible(false); reset({ x: sprite.position.x, y: sprite.position.y, 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; @@ -59,26 +59,15 @@ sprite.scale.x = data.scaleX; sprite.scale.y = data.scaleY; sprite.rotation = (data.rotation * Math.PI) / 180; - // 鏇存柊鍏朵粬灞炴��... } }; - // 澶勭悊琛ㄥ崟鎻愪氦 const onFormSubmit = (data) => { updateSprite(data); if (onSubmit) { onSubmit(data); } }; - - // 鏃嬭浆婊戝潡鐨勫埢搴� - 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 }}> @@ -318,7 +307,9 @@ </Grid> <Grid item xs={12}> <Stack direction="row" spacing={2}> - <Button variant="contained" color="primary"> + <Button variant="contained" color="primary" onClick={() => { + setCopyVisible(true); + }}> {translate('page.map.settings.map.copy.execute')} </Button> <Button variant="text" color="primary"> @@ -326,6 +317,14 @@ </Button> </Stack> </Grid> + + <CopyDrawer + open={copyVisible} + onCancel={() => { + setCopyVisible(false); + }} + width={width} + /> <Grid item xs={12}> <Divider /> @@ -339,9 +338,15 @@ </Grid> <Grid item xs={12}> <Stack direction="row" spacing={2}> - <Button variant="outlined" color="error"> + <Button variant="outlined" color="error" onClick={() => { + Tool.getMapContainer().removeChild(sprite); + setSpriteSettings(null); + Tool.removeSelectedEffect(); + reset(); + }}> {translate('ra.action.delete')} </Button> + {/* <ConfirmButton /> */} </Stack> </Grid> </Grid> -- Gitblit v1.9.1