Browse Source

字段修改 旋转

haojianlong 4 years ago
parent
commit
6483ccffe9

+ 2 - 2
persagy-web-big-edit/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/big-edit",
-    "version": "2.2.26",
+    "version": "2.2.30",
     "description": "博锐尚格二维图形编辑器。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -40,7 +40,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@persagy-web/edit": "2.2.25",
+        "@persagy-web/edit": "2.2.27",
         "@types/uuid": "^8.0.0",
         "crypto-js": "^4.0.0",
         "axios": "^0.20.0"

+ 16 - 13
persagy-web-big-edit/src/index.ts

@@ -24,16 +24,19 @@
  * *********************************************************************************************************************
  */
 
-import { SBaseEditScene } from "./SBaseEditScene"
-import { SBaseExplainEdit } from "./items/SBaseExplainEdit"
-import { SBasePipe } from "./items/SBasePipe"
-import { SBaseArrow } from "./items/SBaseArrow"
-import { Anchor } from "./types/Anchor"
-import { ElementData } from "./types/ElementData"
-import { Legend } from "./types/Legend"
-import { Marker } from "./types/Marker"
-import { Relation } from "./types/Relation"
-import { BigEditFactory } from "./BigEditFactory"
-import { SBaseEquipment } from "./items/SBaseEquipment"
-import { SBaseArrowPolyEdit } from './items/SBaseArrowPolyEdit'
-export { SBaseArrow, SBasePipe, SBaseEquipment, BigEditFactory, Anchor, Legend, Marker, Relation, ElementData, SBaseEditScene, SBaseExplainEdit, SBaseArrowPolyEdit }
+import { SBaseEditScene } from "./SBaseEditScene";
+import { SBaseExplainEdit } from "./items/SBaseExplainEdit";
+import { SBasePipe } from "./items/SBasePipe";
+import { SBaseArrow } from "./items/SBaseArrow";
+import { BigEditFactory } from "./BigEditFactory";
+import { SBaseEquipment } from "./items/SBaseEquipment";
+import { SBaseArrowPolyEdit } from "./items/SBaseArrowPolyEdit";
+export {
+    SBaseArrow,
+    SBasePipe,
+    SBaseEquipment,
+    BigEditFactory,
+    SBaseEditScene,
+    SBaseExplainEdit,
+    SBaseArrowPolyEdit
+};

+ 6 - 7
persagy-web-big-edit/src/items/SBaseEquipment.ts

@@ -27,7 +27,7 @@
 import { SGraphItem, SAnchorItem } from "@persagy-web/graph/lib";
 import { SBaseIconTextEdit, SBaseTextEdit } from "@persagy-web/edit";
 import { SColor } from "@persagy-web/draw/lib";
-import { uuid } from "./../until";
+import { v1 as uuidv1 } from "uuid";
 import { Legend, svgTobase64 } from "@persagy-web/big/lib";
 
 /**
@@ -106,8 +106,8 @@ export class SBaseEquipment extends SBaseIconTextEdit {
                 let item = new SAnchorItem(this);
 
                 // 是否存在 anchorId
-                if (t.id) {
-                    item.id = t.id;
+                if (t.anchorId) {
+                    item.id = t.anchorId;
                 }
 
                 item.moveTo(t.pos.x, t.pos.y);
@@ -115,7 +115,7 @@ export class SBaseEquipment extends SBaseIconTextEdit {
             });
         } else {
             const anchorPoint = [
-                { x: this.img.x, y: this.img.y, anchorId: uuid() }
+                { pos: { x: this.img.x, y: this.img.y }, anchorId: uuidv1() }
             ];
 
             // 没锚点则默认中心点为锚点
@@ -126,7 +126,7 @@ export class SBaseEquipment extends SBaseIconTextEdit {
                     item.id = t.anchorId;
                 }
 
-                item.moveTo(t.x, t.y);
+                item.moveTo(t.pos.x, t.pos.y);
                 return item;
             });
         }
@@ -257,14 +257,13 @@ export class SBaseEquipment extends SBaseIconTextEdit {
             // 遍历锚点获取需要存储的数据格式
             const list = this.anchorList.map(item => {
                 return {
-                    id: item.id,
+                    anchorId: item.id, // 数据类型中定义为 id,但是后台保存要的是字段anchorId
                     pos: {
                         x: item.x,
                         y: item.y
                     }
                 };
             });
-
             this.legendData.anchorList = list;
             // 反馈大小
             if (this.legendData.size) {

+ 1 - 1
persagy-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/big",
-    "version": "2.2.54",
+    "version": "2.2.55",
     "description": "博锐尚格建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 1 - 1
persagy-web-big/src/items/icon/SIconTextItem.ts

@@ -269,7 +269,7 @@ export class SIconTextItem extends SObjectItem {
                 return {
                     x: t.pos.x,
                     y: t.pos.y,
-                    id: t.id
+                    id: t.anchorId
                 };
             });
         } else {

+ 1 - 1
persagy-web-big/src/types/topology/Anchor.ts

@@ -33,7 +33,7 @@ import { Point } from "@persagy-web/graph/lib";
  */
 export interface Anchor {
     /** ID */
-    id: string;
+    anchorId: string;
     /** 位置 */
     pos: Point;
 }

+ 2 - 2
persagy-web-edit/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/edit",
-    "version": "2.2.25",
+    "version": "2.2.27",
     "description": "博锐尚格二维图形编辑器。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -40,7 +40,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@persagy-web/big": "2.2.54",
+        "@persagy-web/big": "2.2.55",
         "@types/uuid": "^8.0.0"
     }
 }

+ 6 - 1
persagy-web-edit/src/items/SBaseImageEdit.ts

@@ -250,7 +250,11 @@ export class SBaseImageEdit extends SGraphEdit {
                 // 设置层级
                 this.zOrder = data.style.default.zorder;
             }
-
+            // 存在默认 style
+            if (data.style.default.rotate) {
+                // 设置旋转角度
+                this.rotate = data.style.default.rotate;
+            }
             // 图片url
             if (data.style.default.url) {
                 this.defaultUrl = data.style.default.url;
@@ -394,6 +398,7 @@ export class SBaseImageEdit extends SGraphEdit {
         this.data.pos.y = this.pos.y;
         this.data.style.default.zorder = this.zOrder;
         this.data.style.default.url = this.defaultUrl;
+        this.data.style.default.rotate = this.rotate;
         this.data.style.default.lineWidth = this.lineWidth;
         this.data.style.default.strokeColor = this.strokeColor.value;
         this.data.style.default.lineStyle = this.lineStyle;