Quellcode durchsuchen

Merge branch 'develop' of http://39.106.8.246:3003/web/wanda-editer into pro

yunxing vor 4 Jahren
Ursprung
Commit
ede2119ec7
1 geänderte Dateien mit 137 neuen und 18 gelöschten Zeilen
  1. 137 18
      src/components/baseEditer.vue

+ 137 - 18
src/components/baseEditer.vue

@@ -22,6 +22,9 @@ import { Loading } from "element-ui";
 import { Message } from "element-ui";
 import { SEquipParser } from "../../../sagacloud-web/saga-web-big/src";
 import { SEquipmentParser } from "../lib/parsers/SEquipmentParser";
+import { saveJSON } from "../utils/util";
+import { SEquipmentItem } from "@/lib/items/SEquipmentItem"; // 设备类
+
 let fengmap = null;
 //// 底图空间增加字段 isExtracted:boolean true 已被提取过
 export default {
@@ -71,8 +74,7 @@ export default {
             this.clearGraphy();
             this.scene = new EditScence();
             this.view.scene = this.scene;
-            this.initLoad();
-            console.log("fitSceneToView");
+            // this.initLoad();
             this.view.fitSceneToView();
             this.scene.emitChange = this.emitChange; //监听
             this.scene.scenceUpdate = this.scenceUpdate;
@@ -89,7 +91,8 @@ export default {
             const itemMap = {};
             // 使用 SEquipmentParser 解析器增加设备
             let parserData1 = new SEquipmentParser(null);
-            parserData1.parseData(Nodes);
+            let Equipmnet = Nodes.filter(node => node.GraphElementType === "Equipmnet");
+            parserData1.parseData(Equipmnet);
             parserData1.equipmentItem.map(item => {
                 item.selectable = true;
                 item.connect("equipImgLoadOver", this, () => {
@@ -117,8 +120,120 @@ export default {
                     t.endItem = endItem || null;
                 }
             });
-            // bus.$emit("elementDataChange", this.scene);
-            console.log("initLoad end");
+            // 增加管线类(需在图标类图例添加后添加)
+            parserData.relationList.forEach(t => {
+                this.scene.addItem(t);
+                this.scene.Relations.push(t);
+                // 设置锚点
+                if (t.anchor1ID) {
+                    const startAnc = itemMap[t.anchor1ID];
+                    startAnc.isConnected = true;
+                    startAnc.parent?.connect("changePos", t, t.changePos);
+                    t.startAnchor = startAnc || null;
+                }
+                if (t.anchor2ID) {
+                    const endAnc = itemMap[t.anchor2ID];
+                    endAnc.isConnected = true;
+                    endAnc.parent?.connect("changePos", t, t.changePos);
+                    t.endAnchor = endAnc || null;
+                }
+            });
+            bus.$emit("elementDataChange", this.scene);
+        },
+        /**
+         * 本地上传万抽后,读取json进行处理
+         * @param data json数据
+         */
+        loadJSON(data) {
+            const parserData = new STopologyParser(null);
+            parserData.parseData(data.Elements);
+            let Markers = data.Elements.Markers;
+            let Nodes = data.Elements.Nodes;
+            const itemMap = {};
+            // 使用 SEquipmentParser 解析器增加设备
+            let parserData1 = new SEquipmentParser(null);
+            let Equipmnet = Nodes.filter(node => node.GraphElementType === "Equipmnet");
+            parserData1.parseData(Equipmnet);
+            parserData1.equipmentItem.map(item => {
+                item.selectable = true;
+                item.connect("equipImgLoadOver", this, () => {
+                    this.view.fitSceneToView();
+                });
+                this.scene.addItem(item);
+                // this.scene.equipmentItem.push(item);
+                this.scene.Nodes.push(item);
+                console.log(item);
+                itemMap[item.id] = item;
+            });
+            // 使用STopologyParser 解析器 增加直线,管线桥线
+            // 多边形(此item需在直线item添加之前添加)
+            parserData.zoneLegendList.forEach(t => {
+                this.scene.addItem(t);
+                // 记录提取
+                if (t.data.Properties && t.data.Properties.FID) {
+                    this.scene.fidToItem[t.data.Properties.FID].isExtracted = true;
+                }
+                this.scene.Nodes.push(t);
+                itemMap[t.id] = t;
+            });
+            // 增加文字(此item需在直线item添加之前添加)
+            parserData.textMarkerList.forEach(t => {
+                this.scene.addItem(t);
+                this.scene.Markers.push(t);
+                itemMap[t.id] = t;
+            });
+            // 增加图片(此item需在直线item添加之前添加)
+            parserData.imageMarkerList.forEach(t => {
+                this.scene.addItem(t);
+                this.scene.Markers.push(t);
+                itemMap[t.id] = t;
+            });
+            // 增加图标类图例(此item需在管线item添加之前添加)
+            parserData.imageLegendList.forEach(t => {
+                this.scene.addItem(t);
+                this.scene.Nodes.push(t);
+                if (t.anchorList && t.anchorList.length) {
+                    t.anchorList.forEach(anc => {
+                        itemMap[anc.id] = anc;
+                    });
+                }
+            });
+            // 增加直线
+            parserData.lineMarkerList.forEach(t => {
+                this.scene.addItem(t);
+                this.scene.Markers.push(t);
+                // 设置关联Item
+                if (t.data.Properties && t.data.Properties.StartItemId) {
+                    const startItem = itemMap[t.data.Properties.StartItemId];
+                    startItem?.connect("onMove", t, t.changePos);
+                    t.startItem = startItem || null;
+                }
+                if (t.data.Properties && t.data.Properties.EndItemId) {
+                    const endItem = itemMap[t.data.Properties.EndItemId];
+                    endItem?.connect("onMove", t, t.changePos);
+                    t.endItem = endItem || null;
+                }
+            });
+            // 增加管线类(需在图标类图例添加后添加)
+            parserData.relationList.forEach(t => {
+                this.scene.addItem(t);
+                this.scene.Relations.push(t);
+                // 设置锚点
+                if (t.anchor1ID) {
+                    const startAnc = itemMap[t.anchor1ID];
+                    startAnc.isConnected = true;
+                    startAnc.parent?.connect("changePos", t, t.changePos);
+                    t.startAnchor = startAnc || null;
+                }
+                if (t.anchor2ID) {
+                    const endAnc = itemMap[t.anchor2ID];
+                    endAnc.isConnected = true;
+                    endAnc.parent?.connect("changePos", t, t.changePos);
+                    t.endAnchor = endAnc || null;
+                }
+            });
+            this.view.fitSceneToView();
+            bus.$emit("elementDataChange", this.scene);
         },
         // 不适用平面图逻辑(调用蜂鸟接口,加载底图)
         init1() {
@@ -298,20 +413,15 @@ export default {
         getBus() {
             // 添加设备
             bus.$on("addEquip", () => {
-                console.log(11111);
                 // console.log("addEquip");
-                console.log("get bus addEquip");
-                console.log(event);
                 const parserData = new SEquipmentParser(null);
-                //  14d978b7edd346f088d6cfb53ada4070`;  //冷冻泵
-                //  4fde075cdafe4e4ea46e876276feab9d`;  //水冷螺杆机组
-                //  4aa6051e025d4193a776a5b2d2604ed8 //冷却塔1
-                //  ece9f93ffc754035bcec2e8f27d66a59 //冷却塔2
+                //
                 let Nodes = [
                     {
                         ID: "123123", // ID
                         Name: "1#冷冻泵", // 名称
                         AttachObjectIds: ["Eq001", "Eq002"], // 返回工程信息化对象 ID 列表
+                        GraphElementType: "Equipmnet",
                         Pos: { X: 170, Y: 188 }, // 位置
                         Size: { Width: 80, Height: 80 }, // 大小
                         InfoList: [
@@ -344,11 +454,11 @@ export default {
                             StatusImage: [
                                 {
                                     Status: "Running", // 运行
-                                    ImageKey: "14d978b7edd346f088d6cfb53ada4070"
+                                    ImageKey: "8bec0771df4c459bb6e692a7eee18d22"
                                 },
                                 {
                                     Status: "Stop", // 停止
-                                    ImageKey: "4aa6051e025d4193a776a5b2d2604ed8"
+                                    ImageKey: "270abb1b84d5416fa059b68d1f51ac33"
                                 },
                                 {
                                     Status: "Selected", // 选择
@@ -365,6 +475,7 @@ export default {
                         ID: "34535345", // ID
                         Name: "2#冷冻泵", // 名称
                         AttachObjectIds: ["Eq001", "Eq002"], // 返回工程信息化对象 ID 列表
+                        GraphElementType: "Equipmnet",
                         Pos: { X: 177, Y: 288 },
                         Size: { Width: 80, Height: 80 }, // 大小
                         InfoList: [
@@ -385,7 +496,7 @@ export default {
                             StatusImage: [
                                 {
                                     Status: "Running", // 运行
-                                    ImageKey: "4fde075cdafe4e4ea46e876276feab9d"
+                                    ImageKey: "d0a5e641e789480e84c8c4f60fbe1c80"
                                 }
                             ]
                         } // 由应用自己定义
@@ -401,6 +512,11 @@ export default {
                 window.vm = this;
                 // this.scene.addEquipment(event);
             });
+            // 添加本地json文件
+            bus.$on("loadJSON", json => {
+                console.log("on loadJSON");
+                this.loadJSON(json);
+            });
             // TODO: 修改底图
             bus.$on("changeImgUrl", val => {
                 window.vm = this;
@@ -477,13 +593,16 @@ export default {
                     BuildingID: this.urlMsg.BuildingID, // 建筑ID
                     FloorID: this.urlMsg.FloorID // 楼层id
                 };
-                Message({
+                /*   Message({
                     message: "上传中,切勿关闭窗口!",
                     type: "warning"
-                });
+                }); */
                 console.log("%c========", "color:blue");
                 console.log(data);
-                console.log(JSON.stringify(data, null, 2));
+                // 保存json文件到本地
+                let jsonData = JSON.stringify(data, null, 2);
+                let name = `${new Date().getTime()}.json`;
+                saveJSON(jsonData, name);
                 return true;
                 saveGroup(data)
                     .then(res => {