YaolongHan 4 years ago
parent
commit
950864bef7
2 changed files with 105 additions and 68 deletions
  1. 94 64
      src/components/baseEditer.vue
  2. 11 4
      src/components/edit/top_toolbar.vue

+ 94 - 64
src/components/baseEditer.vue

@@ -73,7 +73,7 @@ export default {
         left: 0
       },
       count: 0, // 顶楼为多张图时计数器
-      isCopy:''//是否为不可编辑得复制状态
+      isCopy: "" //是否为不可编辑得复制状态
     };
   },
   mounted() {
@@ -83,7 +83,11 @@ export default {
     // 挂在bus
     this.getBus();
     if (this.urlMsg.categoryId) {
-      store.dispatch("getGraphElement", { PageSize: 1000, Deleted: false, GraphCategoryIds:[this.urlMsg.categoryId] });
+      store.dispatch("getGraphElement", {
+        PageSize: 1000,
+        Deleted: false,
+        GraphCategoryIds: [this.urlMsg.categoryId]
+      });
     }
     // window.vm = this;
     const that = this;
@@ -93,8 +97,8 @@ export default {
         // 按 ctrl
         that.scene.isDownCtrl = true;
       }
-      if(e && e.key == "Meta" && isMac){
-           console.log('meta',event,isMac)
+      if (e && e.key == "Meta" && isMac) {
+        console.log("meta", event, isMac);
         // 如果为苹果键
         that.scene.isDownCtrl = true;
       }
@@ -106,24 +110,27 @@ export default {
         that.scene.isDownCtrl = false;
         that.scene.setCmd = "choice";
       }
-      if(e && e.key == "Meta" && isMac){
+      if (e && e.key == "Meta" && isMac) {
         // 如果为苹果键
         that.scene.isDownCtrl = false;
         that.scene.setCmd = "choice";
       }
     };
     // 监听粘贴事件
-    document.onpaste = e =>{
-      const text = e.clipboardData.getData('Text')
-      this.scene.crossPagePaste(text)
-    }
+    document.onpaste = e => {
+      if (this.isCopy == "true") {
+        return;
+      }
+      const text = e.clipboardData.getData("Text");
+      this.scene.crossPagePaste(text);
+    };
     // 自动保存(时间差为一分钟)
     // 如果为复制状态则不需要自动保存
-    if(this.isCopy=='true'){
-      return
-    }
+
     this.autoSave = setInterval(() => {
-      this.saveMsgNoMessage();
+      if (this.isCopy != "true") {
+        this.saveMsgNoMessage();
+      }
     }, 300000);
   },
   methods: {
@@ -186,7 +193,7 @@ export default {
       if (floor == "g80") {
         // 屋顶
         if (window.FENGMAP.frImg) {
-          const pj = this.urlMsg.fmapID.split('_')[0]
+          const pj = this.urlMsg.fmapID.split("_")[0];
           // 单张图片
           if (!ProjectRf[pj]) {
             const imgItem = new SImageItem(
@@ -209,16 +216,16 @@ export default {
                   null,
                   `${this.mapServerURL}/webtheme/${this.urlMsg.fmapID}/${t.name}`
                 );
-                item.width = t.width
-                item.height = t.height
-                item.moveTo(t.x, t.y)
+                item.width = t.width;
+                item.height = t.height;
+                item.moveTo(t.x, t.y);
                 item.connect("imgLoadOver", this, () => {
                   this.countRf(ProjectRf[pj].length);
                 });
                 this.scene.addItem(item);
-              })
+              });
               this.view.scene = this.scene;
-            } catch(e) {
+            } catch (e) {
               console.log(e);
             }
           }
@@ -235,14 +242,14 @@ export default {
       }
     },
     // 解析楼地板
-    loadBoard(floor){
+    loadBoard(floor) {
       window.FENGMAP.loadFloor(floor, res => {
-        const zone = new SBoardItem(null, res)
+        const zone = new SBoardItem(null, res);
         this.scene.addItem(zone);
-      })
+      });
     },
     // 解析底图
-    readBaseMap(floor){
+    readBaseMap(floor) {
       this.loadBoard(this.floorList[floor]);
       window.FENGMAP.parseData(this.floorList[floor], res => {
         if (res.err) {
@@ -262,7 +269,7 @@ export default {
         this.scene.spaceList = this.fParser.spaceList;
         this.fParser.wallList.forEach(t => {
           // if (!t.data.HasHole) {
-            this.scene.addItem(t)
+          this.scene.addItem(t);
           // }
         });
         this.fParser.virtualWallList.forEach(t => this.scene.addItem(t));
@@ -296,7 +303,11 @@ export default {
           parserData.zoneLegendList.forEach(t => {
             this.scene.addItem(t);
             // 记录提取
-            if (t.data.Properties && t.data.Properties.FID && this.scene.fidToItem[t.data.Properties.FID]) {
+            if (
+              t.data.Properties &&
+              t.data.Properties.FID &&
+              this.scene.fidToItem[t.data.Properties.FID]
+            ) {
               this.scene.fidToItem[t.data.Properties.FID].isExtracted = true;
             }
             this.scene.Nodes.push(t);
@@ -318,7 +329,11 @@ export default {
           parserData.imageLegendList.forEach(t => {
             this.scene.addItem(t);
             // 记录提取
-            if (t.data.Properties && t.data.Properties.FID && this.scene.fidToItem[t.data.Properties.FID]) {
+            if (
+              t.data.Properties &&
+              t.data.Properties.FID &&
+              this.scene.fidToItem[t.data.Properties.FID]
+            ) {
               this.scene.fidToItem[t.data.Properties.FID].isExtracted = true;
             }
             this.scene.Nodes.push(t);
@@ -379,17 +394,17 @@ export default {
         this.view.minScale = this.initScale / 10;
         bus2.$emit("initScale", this.view.scale);
         bus2.$emit("elementDataChange", this.scene);
-        this.loadings.close()
+        this.loadings.close();
       });
     },
     // 顶楼为多张图时计数器
     countRf(len) {
-      this.count++
+      this.count++;
       console.log(len == this.count);
       if (len == this.count) {
         this.readGraph();
       } else {
-        console.log('所有图片未加载完成');
+        console.log("所有图片未加载完成");
       }
     },
     // 监听变化
@@ -501,7 +516,7 @@ export default {
         if (val.type == "Image") {
           const list = this.fParser.pList
             .map(t => {
-              if (val.key.indexOf(t.data.Type)>-1 && val.age.Url) {
+              if (val.key.indexOf(t.data.Type) > -1 && val.age.Url) {
                 if (!t.isExtracted) {
                   t.isExtracted = true;
                   const data = {
@@ -518,22 +533,37 @@ export default {
                     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无关
-                        Size: {
-                          Width: val.age.Size?val.age.Size.Width?val.age.Size.Width:32:32,  //icon 的宽
-                          Height: val.age.Size?val.age.Size.Height?val.age.Size.Height:32:32,   //icon 的高
-                        },
-                        font: 16,    //font
-                        color: "#1F2429",  //字体颜色
-                        FrameColor: val.age.FrameColor,
-                        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无关
+                      Size: {
+                        Width: val.age.Size
+                          ? val.age.Size.Width
+                            ? val.age.Size.Width
+                            : 32
+                          : 32, //icon 的宽
+                        Height: val.age.Size
+                          ? val.age.Size.Height
+                            ? val.age.Size.Height
+                            : 32
+                          : 32 //icon 的高
+                      },
+                      font: 16, //font
+                      color: "#1F2429", //字体颜色
+                      FrameColor: val.age.FrameColor,
+                      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);
                   item.selectable = true;
@@ -550,7 +580,7 @@ export default {
         } else if (val.type == "Zone") {
           const list = this.fParser.spaceList
             .map(t => {
-              if (val.key.indexOf(t.data.Type)>-1 && val.age.Url) {
+              if (val.key.indexOf(t.data.Type) > -1 && val.age.Url) {
                 if (!t.isExtracted) {
                   t.isExtracted = true;
                   return {
@@ -582,7 +612,7 @@ export default {
                       InfoLocal: val.age.InfoLocal.length
                         ? val.age.InfoLocal
                         : [],
-                      lengendName: this._legend.Name, //图例名称
+                      lengendName: this._legend.Name //图例名称
                     },
                     Num: 1
                   };
@@ -667,7 +697,7 @@ export default {
         this.scene.isSelecting = val == "select";
       }),
         //发布图
-      bus.$on("publishMap", () => {
+        bus.$on("publishMap", () => {
           const loading = Message({
             message: "保存中,切勿关闭窗口!",
             type: "warning"
@@ -722,26 +752,26 @@ export default {
         this.scene.toggleItem(item);
       });
       //
-      bus.$on('itemAngle', ang => {
+      bus.$on("itemAngle", ang => {
         this.scene.updateItemAng(ang);
       }),
-      // 更改item样式
-      bus.$on('changeLengendItem',item=>{
-        this.scene.changeLengendItem(item)
-      }),
-      //复制操作
-      bus.$on('copymsg',()=>{
-        this.scene.copy()
-      })
+        // 更改item样式
+        bus.$on("changeLengendItem", item => {
+          this.scene.changeLengendItem(item);
+        }),
+        //复制操作
+        bus.$on("copymsg", () => {
+          this.scene.copy();
+        });
       //粘贴操作
-      bus.$on('stickmsg',()=>{
-          this.scene.paste()
-      })
+      bus.$on("stickmsg", () => {
+        this.scene.paste();
+      });
     },
     // 获取图最大最小值
-    getGraphDetail(){
+    getGraphDetail() {
       const data = {
-        Filters:`categoryId='${this.urlMsg.categoryId}';projectId='${this.urlMsg.projectId}';BuildingID='${this.urlMsg.BuildingID}';FloorID='${this.urlMsg.FloorID}'`
+        Filters: `categoryId='${this.urlMsg.categoryId}';projectId='${this.urlMsg.projectId}';BuildingID='${this.urlMsg.BuildingID}';FloorID='${this.urlMsg.FloorID}'`
       };
       return graphQuery(data);
     },
@@ -950,7 +980,7 @@ export default {
       obj[arr[0]] = arr[1];
     });
     this.urlMsg = obj;
-    this.isCopy = obj.isCopy ? obj.isCopy :'false'
+    this.isCopy = obj.isCopy ? obj.isCopy : "false";
   },
   beforeDestroy() {
     // 销毁自动保存

+ 11 - 4
src/components/edit/top_toolbar.vue

@@ -20,7 +20,7 @@
       <div class="OpenEdit">
         <i class="el-icon-back el-icon-back-two"></i>
         <p>此处可以快速切换图纸</p>
-        <el-button size="medium" round class="edit-btn" @click="opEditStatus">启动编辑</el-button>
+        <el-button size="medium" round class="edit-btn" v-show="isCopy=='true'" @click="opEditStatus">启动编辑</el-button>
       </div>
     </div>
     <div class="top-right">
@@ -159,7 +159,7 @@
           <span>发布</span>
         </div>
       </div>
-      <div class="top-right-mark">
+      <div class="top-right-mark" v-show="isCopy=='true'">
         <div class="copy" @click="copymsg">
           <img class="lock" :src="require(`./../../assets/images/copy.png`)" alt />
           <span>复制</span>
@@ -175,7 +175,7 @@ import { SGraphLayoutType, SOrderSetType } from "@saga-web/graph/lib";
 import { queryFullFloor } from "@/api/editer";
 import systym from "./codeMapSystem.js";
 import { MessageBox } from "element-ui";
-
+import { mapState, mapActions } from "vuex";
 export default {
   data() {
     return {
@@ -493,6 +493,10 @@ export default {
     // 重做
     redo() {
       bus.$emit("changeRedo");
+    },
+    //打开编辑状态
+    opEditStatus(){
+
     }
   },
   created() {
@@ -527,7 +531,10 @@ export default {
           ? 500
           : (this.scale * 100).toFixed(0);
       return scalePercent + "%";
-    }
+    },
+     ...mapState({
+      isCopy:'isCopy'
+    })
   },
   async mounted() {
     bus2.$off("FocusItemChanged");