YaolongHan 4 years ago
parent
commit
6a505d3746
1 changed files with 90 additions and 57 deletions
  1. 90 57
      src/components/baseEditer.vue

+ 90 - 57
src/components/baseEditer.vue

@@ -96,9 +96,9 @@ export default {
       }
     };
     // 自动保存(时间差为一分钟)
-    // this.autoSave = setInterval(() => {
-    //   this.saveMsgNoMessage();
-    // }, 60000);
+    this.autoSave = setInterval(() => {
+      this.saveMsgNoMessage();
+    }, 60000);
   },
   methods: {
     init() {
@@ -112,10 +112,10 @@ export default {
       this.clearGraphy();
       this.scene = new EditScence();
 
-      if(this.urlMsg.fmapID.includes('null')){
-          this.loadings.close();
-          this.view.scene = this.scene;
-          this.readGraph();
+      if (this.urlMsg.fmapID.includes("null")) {
+        this.loadings.close();
+        this.view.scene = this.scene;
+        this.readGraph();
       }
       window.FENGMAP = new SFengParser(
         "fengMap",
@@ -128,18 +128,18 @@ export default {
       const floorid = this.urlMsg.FloorID;
       window.FENGMAP.loadMap(this.urlMsg.fmapID, resp => {
         this.floorList = resp;
-        window.FENGMAP
-          .loadTheme(
-            `${this.mapServerURL}/webtheme/${this.urlMsg.fmapID}/${this.urlMsg.fmapID}.theme`
-          )
+        window.FENGMAP.loadTheme(
+          `${this.mapServerURL}/webtheme/${this.urlMsg.fmapID}/${this.urlMsg.fmapID}.theme`
+        )
           .then(response => {
             console.log("获取rf成功", response);
             this.parserData(floorid);
             // this.readGraph();
             // loadings.close();
-          }).catch(()=>{
-              this.loadings.close();
           })
+          .catch(() => {
+            this.loadings.close();
+          });
         // this.view.fitSceneToView();
       });
       // 获取typeid
@@ -156,9 +156,9 @@ export default {
             `${this.mapServerURL}/webtheme/${this.urlMsg.fmapID}/${window.FENGMAP.frImg}`
           );
           imgItem.showType = SImageShowType.AutoFit;
-          imgItem.connect('imgLoadOver',this,()=> {
+          imgItem.connect("imgLoadOver", this, () => {
             this.readGraph();
-          })
+          });
           this.scene.addItem(imgItem);
           this.view.scene = this.scene;
           // this.view.fitSceneToView();
@@ -176,7 +176,7 @@ export default {
             this.fParser.parseData(res);
             this.scene.fidToItem = {};
             this.fParser.spaceList.forEach(t => {
-              t.nameColor = '#2a2a2a';
+              t.nameColor = "#2a2a2a";
               t.zOrder = t.zOrder + t.data.Height;
               t.selectable = true;
               this.scene.fidToItem[t.data.SourceId] = t;
@@ -194,7 +194,7 @@ export default {
               this.fParser.pList.push(item);
               this.scene.fidToItem[t.SourceId] = item;
               this.scene.addItem(item);
-            })
+            });
             this.view.scene = this.scene;
             // this.view.fitSceneToView();
             // this.loading = false;
@@ -292,13 +292,13 @@ export default {
           });
         }
         this.view.fitSceneToView();
-          // 设置初始化缩放比例
+        // 设置初始化缩放比例
         this.initScale = this.view.scale;
         this.view.maxScale = this.initScale * 10;
         this.view.minScale = this.initScale / 10;
         bus.$emit("initScale", this.view.scale);
         bus.$emit("elementDataChange", this.scene);
-        this.loadings.close()
+        this.loadings.close();
       });
     },
     // 监听变化
@@ -320,7 +320,7 @@ export default {
       document.getElementById("canvas").focus();
     },
     getBus() {
-      bus.$off()
+      bus.$off();
       bus.$on("changeText", val => {
         this.scene.updatedText(val);
       });
@@ -358,10 +358,11 @@ export default {
         this.scene.changeOrderItem(val);
       });
       bus.$on("extractItem", () => {
-        const map = {},type={};
+        const map = {},
+          type = {};
         this.fParser.spaceList.forEach(t => {
           if (this.hasTypeList.indexOf(t.data.Type) > -1) {
-            type[t.data.Type] = 'Zone'
+            type[t.data.Type] = "Zone";
             if (map[t.data.Type]) {
               map[t.data.Type]++;
             } else {
@@ -371,7 +372,7 @@ export default {
         });
         this.fParser.pList.forEach(t => {
           if (this.hasTypeList.indexOf(t.data.Type) > -1) {
-            type[t.data.Type] = 'Image'
+            type[t.data.Type] = "Image";
             if (map[t.data.Type]) {
               map[t.data.Type]++;
             } else {
@@ -407,47 +408,56 @@ export default {
       });
       bus.$on("exportByKey", val => {
         if (val.type == "Image") {
-          const list = this.fParser.pList.map(t => {
-            if (t.data.Type == val.key && val.age.Url) {
+          const list = this.fParser.pList
+            .map(t => {
+              if (t.data.Type == val.key && val.age.Url) {
                 if (!t.isExtracted) {
                   t.isExtracted = true;
                   const data = {
                     ID: uuid(),
-                    Name: '',
+                    Name: "",
                     // Name: val.age.Name,
                     GraphElementType: val.age.Type,
                     Num: 1,
                     GraphElementId: val.age.Id,
                     AttachObjectIds: [],
                     Pos: { X: t.data.Pos.X, Y: -t.data.Pos.Y },
-                    Scale: { X: 1, Y: 1, Z: 1 },          // 缩放
+                    Scale: { X: 1, Y: 1, Z: 1 }, // 缩放
                     Rolate: { X: 0, Y: 0, Z: 0 },
-                    Size: { Width: 0, Height: 0 },         // 大小
+                    Size: { Width: 0, Height: 0 }, // 大小
                     Type: val.age.Type,
                     Properties: {
-                        IconUrl: '/serve/topology-wanda/Picture/query/' + val.age.Url,
-                        Url: '/serve/topology-wanda/Picture/query/' + val.age.Url,
-                        Num: 1, // 此num与信息工程化得num无关
-                        sWidth: 32,  //icon 的宽
-                        sHeight: 32,   //icon 的高
-                        font: 14,    //font
-                        color: "#1F2429",  //字体颜色
-                        GraphCategoryId: val.age.GraphCategoryId,
-                        InfoSystemId: val.age.InfoSystemId?val.age.InfoSystemId:'',   //信息工程话分类ID分类
-                        FID: t.data.SourceId,
-                        InfoTypeId:val.age.InfoTypeId.length? val.age.InfoTypeId :[],
-                        InfoLocal:val.age.InfoLocal.length ?val.age.InfoLocal :[]
-                    },
+                      IconUrl:
+                        "/serve/topology-wanda/Picture/query/" + val.age.Url,
+                      Url: "/serve/topology-wanda/Picture/query/" + val.age.Url,
+                      Num: 1, // 此num与信息工程化得num无关
+                      sWidth: 32, //icon 的宽
+                      sHeight: 32, //icon 的高
+                      font: 14, //font
+                      color: "#1F2429", //字体颜色
+                      GraphCategoryId: val.age.GraphCategoryId,
+                      InfoSystemId: val.age.InfoSystemId
+                        ? val.age.InfoSystemId
+                        : "", //信息工程话分类ID分类
+                      FID: t.data.SourceId,
+                      InfoTypeId: val.age.InfoTypeId.length
+                        ? val.age.InfoTypeId
+                        : [],
+                      InfoLocal: val.age.InfoLocal.length
+                        ? val.age.InfoLocal
+                        : []
+                    }
                   };
-                  const item = new SImageLegendItem(null, data)
+                  const item = new SImageLegendItem(null, data);
                   item.selectable = true;
                   item.moveable = true;
                   this.scene.addItem(item);
                   this.scene.Nodes.push(item);
-                  return item
+                  return item;
                 }
               }
-          }).filter(item => item);
+            })
+            .filter(item => item);
           this.scene.AddListCommand(list);
           bus.$emit("elementDataChange", this.scene);
         } else if (val.type == "Zone") {
@@ -466,17 +476,24 @@ export default {
                     OutLine: t.pointArr[0],
                     SubType: "",
                     Properties: {
-                      IconUrl: '/serve/topology-wanda/Picture/query/' + val.age.Url,
-                      InfoSystemId: val.age.InfoSystemId?val.age.InfoSystemId:'',   //信息工程话分类ID分类
+                      IconUrl:
+                        "/serve/topology-wanda/Picture/query/" + val.age.Url,
+                      InfoSystemId: val.age.InfoSystemId
+                        ? val.age.InfoSystemId
+                        : "", //信息工程话分类ID分类
                       StrokeColor: val.age.Color,
                       FillColor: val.age.FillColor,
                       LineDash: val.age.LineDash,
                       font: 20,
                       color: "#646A73",
-                      TextPos: { X: 0, Y: 0},
+                      TextPos: { X: 0, Y: 0 },
                       FID: t.data.SourceId,
-                      InfoTypeId:val.age.InfoTypeId.length? val.age.InfoTypeId :[],
-                      InfoLocal:val.age.InfoLocal.length ?val.age.InfoLocal :[]
+                      InfoTypeId: val.age.InfoTypeId.length
+                        ? val.age.InfoTypeId
+                        : [],
+                      InfoLocal: val.age.InfoLocal.length
+                        ? val.age.InfoLocal
+                        : []
                     },
                     Num: 1
                   };
@@ -487,7 +504,7 @@ export default {
           const parserData = new STopologyParser(null);
           parserData.parseData({ Nodes: list });
           parserData.zoneLegendList.forEach(t => {
-            t.$emit('finishCreated')
+            t.$emit("finishCreated");
             this.scene.addItem(t);
             this.scene.Nodes.push(t);
           });
@@ -521,11 +538,11 @@ export default {
         this.scene.upadatfillColor(val);
       });
       bus.$on("CUSTOMbgColor", val => {
-        this.scene.updateCustomBgColor(val)
-      })
+        this.scene.updateCustomBgColor(val);
+      });
       bus.$on("CUSTOMbdColor", val => {
-        this.scene.updateCustomBdColor(val)
-      })
+        this.scene.updateCustomBdColor(val);
+      });
       // 修改当前得状态是否为编辑状态
       bus.$on("OpenEditStatus", () => {
         ` `; // 获取焦点item (必须选中且仅选中一个)
@@ -611,8 +628,8 @@ export default {
       bus.$on("changeUndo", () => {
         this.scene.undo();
       });
-         // 选中状态
-      bus.$on("toggleItem", (item) => {
+      // 选中状态
+      bus.$on("toggleItem", item => {
         this.scene.toggleItem(item);
       });
     },
@@ -659,7 +676,15 @@ export default {
             window.open(url, true); */
             // // 发布成功跳转草稿箱
             const token = this.$store.getters["token"];
-            this.$router.push({ path: 'drafts', query: { projectId:this.urlMsg.projectId,BuildingID:this.urlMsg.BuildingID,fmapID:this.urlMsg.fmapID,token:token}})
+            this.$router.push({
+              path: "drafts",
+              query: {
+                projectId: this.urlMsg.projectId,
+                BuildingID: this.urlMsg.BuildingID,
+                fmapID: this.urlMsg.fmapID,
+                token: token
+              }
+            });
           }, 2000);
         } else {
           Message({
@@ -736,10 +761,18 @@ export default {
             this.graphId = res.Data;
             console.log("自动保存成功");
           } else {
+            Message({
+              message: "服务器连接失败!请关掉编辑器窗口,重新打开绘制!",
+              type: "error"
+            });
             console.log("自动保存失败");
           }
         })
         .catch(err => {
+          Message({
+            message: "服务器连接失败!请关掉编辑器窗口,重新打开绘制!",
+            type: "error"
+          });
           console.log("自动保存失败");
         });
     }