From da6ffd9b8d9687f8fb876e194da597c02f25f588 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 18 六月 2024 16:57:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/Four-Way-Rack' into Four-Way-Rack

---
 zy-asrs-flow/src/pages/map/index.jsx |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/index.jsx b/zy-asrs-flow/src/pages/map/index.jsx
index 21351a2..6e970a7 100644
--- a/zy-asrs-flow/src/pages/map/index.jsx
+++ b/zy-asrs-flow/src/pages/map/index.jsx
@@ -1,7 +1,7 @@
 import * as React from 'react'
 import * as TWEEDLE from 'tweedle.js';
 import { FormattedMessage, useIntl, useModel } from '@umijs/max';
-import { Layout, Button, Flex, Row, Col, FloatButton, Select, notification, Segmented } from 'antd';
+import { Layout, Button, Flex, Row, Col, FloatButton, Select, notification, Segmented, message } from 'antd';
 const { Header, Content } = Layout;
 import {
     AppstoreAddOutlined,
@@ -12,6 +12,7 @@
 import './index.css'
 import { createStyles } from 'antd-style';
 import Edit from './components/device';
+import Http from '@/utils/http';
 import Settings from './components/settings'
 import * as Utils from './utils'
 import WebSocketClient from './websocket'
@@ -131,6 +132,13 @@
             }, 200)
         }
         initialize();
+
+        return () => {
+            websocket.onMessage = (data) => { }
+            if (websocket) {
+                websocket.close();
+            }
+        }
     }, []);
 
     // resize
@@ -242,6 +250,25 @@
     }, [curSprite]);
     const prevCurSprite = prevCurSpriteRef.current;
 
+    const clearLockPath = async (floor) => {
+        const hide = message.loading(intl.formatMessage({ id: 'page.clearing', defaultMessage: '姝e湪娓呯┖' }));
+        try {
+            const resp = await Http.doGet('api/map/clearLockPath', { lev: floor });
+            if (resp.code === 200) {
+                message.success(intl.formatMessage({ id: 'page.clearing.success', defaultMessage: '娓呯┖鎴愬姛' }));
+                return true;
+            } else {
+                message.error(resp.msg);
+                return false;
+            }
+        } catch (error) {
+            message.error(intl.formatMessage({ id: 'page.clearing.fail', defaultMessage: '娓呯┖澶辫触璇烽噸璇曪紒' }));
+            return false;
+        } finally {
+            hide();
+        }
+    }
+
     // fn switch floor
     const switchFloor = async (floor) => {
         await Utils.fetchMapData(floor);
@@ -322,6 +349,16 @@
                                             className='map-header-button'
                                             size={'large'}
                                             onClick={() => {
+                                                clearLockPath(curFloor)
+                                            }}
+                                        >
+                                            <FormattedMessage id='map.clearLockPath' defaultMessage='娓呯┖璺緞' />
+                                        </Button>
+
+                                        <Button
+                                            className='map-header-button'
+                                            size={'large'}
+                                            onClick={() => {
                                                 switchFloor(curFloor)
                                             }}
                                         >

--
Gitblit v1.9.1