From 3c190ac12e00e0f3435984c5d57351d136530c09 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 15 三月 2024 15:51:26 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapItem.java | 13 ++++++
zy-asrs-flow/src/locales/en-US/map.ts | 1
zy-asrs-flow/src/pages/map/index.jsx | 16 ++++++-
zy-asrs-flow/src/pages/map/utils.js | 51 +++++++++++++++++++++++++
4 files changed, 77 insertions(+), 4 deletions(-)
diff --git a/zy-asrs-flow/src/locales/en-US/map.ts b/zy-asrs-flow/src/locales/en-US/map.ts
index 00d8837..b4ea4c7 100644
--- a/zy-asrs-flow/src/locales/en-US/map.ts
+++ b/zy-asrs-flow/src/locales/en-US/map.ts
@@ -5,6 +5,7 @@
'map.device.oper': 'Device Settings',
'map.model.observer': 'Observer Pattern',
'map.model.editor': 'Editor Pattern',
+ 'map.save': 'Save Map',
'': '',
'': '',
'': '',
diff --git a/zy-asrs-flow/src/pages/map/index.jsx b/zy-asrs-flow/src/pages/map/index.jsx
index 5d5af78..5995c7c 100644
--- a/zy-asrs-flow/src/pages/map/index.jsx
+++ b/zy-asrs-flow/src/pages/map/index.jsx
@@ -237,9 +237,19 @@
{/* 3C40C6 */}
<Col span={12} style={{ backgroundColor: '#4a69bd' }}>
<Flex className={styles.flex} gap={'large'} justify={'flex-end'} align={'center'}>
- <span>
- {curSprite?.data?.uuid}
- </span>
+
+ {model !== MapModel.OBSERVER_MODEL && (
+ <>
+ <Button
+ onClick={() => {
+ Utils.saveMapData();
+ }}
+ >
+ <FormattedMessage id='map.save' defaultMessage='淇濆瓨鍦板浘' />
+ </Button>
+ </>
+ )}
+
<Select
className='map-header-select'
size={'large'}
diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index c56b8b9..ae5567b 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/zy-asrs-flow/src/pages/map/utils.js
@@ -1,5 +1,6 @@
import * as PIXI from 'pixi.js';
import * as TWEEDLE from 'tweedle.js';
+import Http from '@/utils/http';
let app = null;
let mapContainer = null;
@@ -76,7 +77,7 @@
dragTarget = event.currentTarget;
mapContainer.parent.off('pointermove');
mapContainer.parent.on('pointermove', onDragMove, dragTarget);
-
+
mapContainer.parent.off('pointerup');
mapContainer.parent.on('pointerup', onDragEnd.bind(mapContainer));
}
@@ -269,6 +270,20 @@
}
}
+export const rotationToNum = (rotation) => {
+ let res = rotation * 180 / Math.PI;
+ if (res < 0) {
+ res += 360;
+ } else if (res > 360) {
+ res -= 360;
+ }
+ return res;
+}
+
+export const rotationParseNum = (num) => {
+
+}
+
export const findSpriteByUuid = (uuid) => {
return mapContainer?.children?.find(child => child?.data?.uuid === uuid);
}
@@ -295,4 +310,38 @@
})
return options;
+}
+
+export const fetchMapData = () => {
+
+
+}
+
+export const saveMapData = async () => {
+ if (!mapContainer) {
+ return;
+ }
+
+ let mapItemList = [];
+ mapContainer?.children.forEach(child => {
+ if (child.data?.uuid) {
+ console.log(child.scale, child.rotation);
+ mapItemList.push({
+ // data
+ type: child.data.type,
+ uuid: child.data.uuid,
+ no: child.data.no,
+
+ // graph
+ positionX: child.position.x,
+ positionY: child.position.y,
+ scaleX: child.scale.x,
+ scaleY: child.scale.y,
+ rotation: rotationToNum(child.rotation)
+ })
+ }
+ })
+
+ const resp = await Http.doPost('api/map/save', { itemList: mapItemList })
+ console.log(resp);
}
\ No newline at end of file
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapItem.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapItem.java
index 42c6397..009a761 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapItem.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapItem.java
@@ -8,8 +8,21 @@
@Data
public class MapItem {
+ private String type;
+
private String uuid;
private String no;
+
+ private Double positionX;
+
+ private Double positionY;
+
+ private Double scaleX;
+
+ private Double scaleY;
+
+ private Double rotation;
+
}
--
Gitblit v1.9.1