From a97a7a41646937d098317f7d53ec643b45de0f14 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 09 十月 2024 16:25:46 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/MapPage.jsx |   42 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx
index b205b29..c67fcf4 100644
--- a/zy-acs-flow/src/map/MapPage.jsx
+++ b/zy-acs-flow/src/map/MapPage.jsx
@@ -1,4 +1,5 @@
 import React, { useState, useRef, useEffect, useMemo } from "react";
+import { useTranslate } from "react-admin";
 import {
     TextField,
     Select,
@@ -29,6 +30,7 @@
     const theme = useTheme();
     const themeMode = theme.palette.mode;
     const notify = useNotification();
+    const translate = useTranslate();
 
     const mapRef = useRef();
     const contentRef = useRef();
@@ -73,13 +75,30 @@
     const switchMode = (mode) => {
         switch (mode) {
             case MapMode.OBSERVER_MODE:
-                console.log('a');
+                setDeviceVisible(false);
+                player.hideGridLines();
+
+                player.activateMapMultiSelect((selectedSprites, restartFn) => {
+                    console.log(selectedSprites);
+                });
+
                 break
             case MapMode.MOVABLE_MODE:
-                console.log('b');
+                player.showGridLines();
+
+                player.activateMapMultiSelect((selectedSprites, restartFn) => {
+                    Tool.spriteListBeMovable(selectedSprites, () => {
+                        restartFn();
+                    });
+                });
                 break
             case MapMode.SETTINGS_MODE:
-                console.log('c');
+                player.hideGridLines();
+                setDeviceVisible(false);
+
+                player.activateMapMultiSelect((selectedSprites, restartFn) => {
+                    console.log(selectedSprites);
+                });
                 break
             default:
                 break
@@ -94,13 +113,15 @@
     }, [mode]);
 
     const onDrop = (sprite, type, x, y) => {
+        console.log(sprite, type, x, y);
+
         const { mapX, mapY } = Tool.getRealPosition(x, y);
         sprite.x = mapX;
         sprite.y = mapY;
 
-        // Utils.initSprite(sprite, type);
-        // mapContainer.addChild(sprite);
-        // Utils.beMovable(sprite);
+        Tool.initSprite(sprite, type);
+        mapContainer.addChild(sprite);
+        Tool.beMovable(sprite);
     };
 
     const actions = [
@@ -119,6 +140,7 @@
                 flexDirection: 'column',
             }}
         >
+            {/* header */}
             <Box
                 sx={{
                     display: 'flex',
@@ -128,6 +150,7 @@
                     padding: '0 16px',
                     height: '64px',
                     flexShrink: 0, // keep height
+                    zIndex: 200
                 }}
             >
                 <TextField
@@ -163,8 +186,9 @@
                             variant="contained"
                             color="primary"
                             sx={{ mr: 1 }}
+                            onClick={() => setDeviceVisible(!deviceVisible)}
                         >
-                            娣诲姞妯″瀷
+                            {translate('page.map.devices.title')}
                         </Button>
                     </>
                 )}
@@ -192,6 +216,7 @@
                     <MenuItem value={MapMode.SETTINGS_MODE}>閰嶇疆妯″紡</MenuItem>
                 </Select>
             </Box>
+            {/* content */}
             <Box
                 sx={{
                     flexGrow: 1,    // fill remaining of map space 
@@ -232,13 +257,16 @@
                     ))}
                 </SpeedDial>
             </Box>
+
             <Device
                 open={deviceVisible}
                 onCancel={() => {
                     setDeviceVisible(false);
                 }}
                 onDrop={onDrop}
+                width={378}
             />
+
         </Box>
     );
 }

--
Gitblit v1.9.1