From 0e8b41f6f2ffa21ca6394e20053b262d2dc1e1be Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 20 三月 2024 14:00:38 +0800
Subject: [PATCH] #
---
 zy-asrs-flow/src/pages/map/utils.js |   47 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index dfeee52..b089a48 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/zy-asrs-flow/src/pages/map/utils.js
@@ -5,6 +5,7 @@
 import { API_TIMEOUT } from '@/config/setting'
 import agv from '/public/img/map/agv.svg'
 import shelf from '/public/img/map/shelf.png'
+import point from '/public/img/map/point.svg'
 
 let app = null;
 let mapContainer = null;
@@ -28,6 +29,7 @@
 
 export const SENSOR_TYPE = Object.freeze({
     SHELF: "SHELF",
+    POINT: "POINT",
     AGV: "AGV",
 })
 
@@ -307,6 +309,12 @@
                     label: intl.formatMessage({ id: 'map.sensor.type.agv', defaultMessage: '鏃犱汉灏忚溅' })
                 })
                 break;
+            case SENSOR_TYPE.POINT:
+                options.push({
+                    value: value,
+                    label: intl.formatMessage({ id: 'map.sensor.type.point', defaultMessage: '瀹氫綅鐐�' })
+                })
+                break;
             default:
                 break;
         }
@@ -328,6 +336,9 @@
                 case SENSOR_TYPE.AGV:
                     sprite = PIXI.Sprite.from(agv);
                     break;
+                case SENSOR_TYPE.POINT:
+                    sprite = PIXI.Sprite.from(point);
+                    break;
                 default:
                     break;
             }
@@ -337,6 +348,9 @@
                 sprite.data.uuid = item.uuid;
                 sprite.data.no = item.no;
 
+                // dynamical data
+                Object.assign(sprite.data, item.property);
+
                 // graph
                 sprite.position.set(item.positionX, item.positionY);
                 sprite.scale.set(item.scaleX, item.scaleY);
@@ -344,7 +358,7 @@
                 mapContainer.addChild(sprite);
             }
         })
-        
+
     }).catch((error) => {
         console.error(error);
     })
@@ -359,11 +373,13 @@
     let mapItemList = [];
     mapContainer?.children.forEach(child => {
         if (child.data?.uuid) {
+            const { type, uuid, no, ...property } = child.data;
             mapItemList.push({
                 // data
-                type: child.data.type,
-                uuid: child.data.uuid,
-                no: child.data.no,
+                type: type,
+                uuid: uuid,
+                no: no,
+                property: property,
 
                 // graph
                 positionX: child.position.x,
@@ -404,4 +420,27 @@
         });
         childList = [];
     }
+}
+
+export const beCenter = (sprite) => {
+    if (!sprite || !app || !mapContainer) {
+        return;
+    }
+
+    mapContainer.scale.set(1);
+    mapContainer.position.set(0, 0);
+
+    let bounds = sprite.getBounds();
+    let centerPoint = {
+        x: bounds.x + bounds.width / 2,
+        y: bounds.y + bounds.height / 2
+    };
+
+    let targetPos = {
+        x: app.renderer.width / 3 - centerPoint.x * mapContainer.scale.x,
+        y: app.renderer.height / 3 - centerPoint.y * mapContainer.scale.y
+    };
+
+    new TWEEDLE.Tween(mapContainer.position).easing(TWEEDLE.Easing.Quadratic.Out)
+        .to(targetPos, 500).start();
 }
\ No newline at end of file
--
Gitblit v1.9.1