YaolongHan 4 anni fa
parent
commit
5418b0cdd3

+ 81 - 56
src/components/baseEditer.vue

@@ -12,14 +12,19 @@ import { SFloorParser } from "@saga-web/big";
 import { FloorView } from "./../lib/FloorView";
 import { EditScence } from "./mapClass/EditScence";
 import bus from "@/bus";
-import { saveGroup, readGroup, queryTypeGraph, publishGraph } from "@/api/editer.js";
+import {
+  saveGroup,
+  readGroup,
+  queryTypeGraph,
+  publishGraph
+} from "@/api/editer.js";
 import { STopologyParser } from "./../lib/parsers/STopologyParser";
 import { uuid } from "@/components/mapClass/until";
 import { SImageItem } from "@saga-web/graph/lib";
 import { SPainter, SColor, SFont, SPoint } from "@saga-web/draw";
 import store from "../store";
 import { Loading } from "element-ui";
-import { Message } from 'element-ui';
+import { Message } from "element-ui";
 let fengmap = null;
 //// 底图空间增加字段 isExtracted:boolean true 已被提取过
 export default {
@@ -49,9 +54,9 @@ export default {
       urlMsg: {},
       chiceItemList: [], //选中itemlist
       hasTypeList: [], // 当前类型下包含的typeid(提取)
-      graphId: '',
-      initScale: 1,  //加载好底图之后的,初始缩放比例
-      changeScaleByClick: false,  //区分 滚轮,点击 事件改变的缩放比例
+      graphId: "",
+      initScale: 1, //加载好底图之后的,初始缩放比例
+      changeScaleByClick: false //区分 滚轮,点击 事件改变的缩放比例
     };
   },
   mounted() {
@@ -61,7 +66,23 @@ export default {
     // 挂在bus
     this.getBus();
     store.dispatch("getElementType", { PageSize: 1000 });
-    window.vm = this
+    window.vm = this;
+    const that = this;
+    document.onkeydown = function(event) {
+      const e = event || window.event || arguments.callee.caller.arguments[0];
+      if (e && e.key == "Control") {
+        // 按 ctrl
+        that.scene.isDownCtrl = true;
+      }
+    };
+    document.onkeyup = function(event) {
+      const e = event || window.event || arguments.callee.caller.arguments[0];
+      if (e && e.key == "Control") {
+        // 按 ctrl
+        that.scene.isDownCtrl = false;
+        this.scene.setCmd = 'choice'
+      }
+    };
   },
   methods: {
     init() {
@@ -91,7 +112,7 @@ export default {
           .then(response => {
             console.log("获取rf成功", response);
             this.parserData(floorid);
-            this.readGraph()
+            this.readGraph();
             loadings.close();
           });
         this.view.fitSceneToView();
@@ -124,7 +145,7 @@ export default {
             }
             this.fParser = new SFloorParser(null);
             this.fParser.parseData(res);
-            this.scene.fidToItem = {}
+            this.scene.fidToItem = {};
             this.fParser.spaceList.forEach(t => {
               t.zOrder = t.zOrder + t.data.Height;
               t.selectable = true;
@@ -143,8 +164,8 @@ export default {
             this.isQuerying = false;
             console.log("success");
             // 设置初始化缩放比例
-            this.initScale = this.view.scale
-            bus.$emit('initScale', this.view.scale);
+            this.initScale = this.view.scale;
+            bus.$emit("initScale", this.view.scale);
           });
         } else {
           console.log("楼层不正确");
@@ -155,7 +176,7 @@ export default {
     readGraph() {
       this.readGroup().then(data => {
         this.graphId = data.Data[0].ID;
-        bus.$emit('setGraphId', this.graphId)
+        bus.$emit("setGraphId", this.graphId);
         if (data.Data) {
           const parserData = new STopologyParser(null);
           parserData.parseData(data.Data[0].Elements);
@@ -164,7 +185,7 @@ export default {
             this.scene.addItem(t);
             // 记录提取
             if (t.data.Properties && t.data.Properties.FID) {
-              this.scene.fidToItem[t.data.Properties.FID].isExtracted = true
+              this.scene.fidToItem[t.data.Properties.FID].isExtracted = true;
             }
             this.scene.Nodes.push(t);
           });
@@ -184,14 +205,14 @@ export default {
             this.scene.Markers.push(t);
           });
           // 增加图标类图例(此item需在管线item添加之前添加)
-          const ancToAnchor = {}
+          const ancToAnchor = {};
           parserData.imageLegendList.forEach(t => {
             this.scene.addItem(t);
             this.scene.Nodes.push(t);
             if (t.anchorList && t.anchorList.length) {
               t.anchorList.forEach(anc => {
-                ancToAnchor[anc.id] = anc
-              })
+                ancToAnchor[anc.id] = anc;
+              });
             }
           });
           // 增加管线类(需在图标类图例添加后添加)
@@ -200,16 +221,16 @@ export default {
             this.scene.Relations.push(t);
             // 设置锚点
             if (t.anchor1ID) {
-              const startAnc = ancToAnchor[t.anchor1ID]
-              startAnc.isConnected = true
-              startAnc.parent?.connect('changePos', t, t.changePos)
-              t.startAnchor = startAnc || null
+              const startAnc = ancToAnchor[t.anchor1ID];
+              startAnc.isConnected = true;
+              startAnc.parent?.connect("changePos", t, t.changePos);
+              t.startAnchor = startAnc || null;
             }
             if (t.anchor2ID) {
-              const endAnc = ancToAnchor[t.anchor2ID]
-              endAnc.isConnected = true
-              endAnc.parent?.connect('changePos', t, t.changePos)
-              t.endAnchor = endAnc || null
+              const endAnc = ancToAnchor[t.anchor2ID];
+              endAnc.isConnected = true;
+              endAnc.parent?.connect("changePos", t, t.changePos);
+              t.endAnchor = endAnc || null;
             }
           });
           this.view.fitSceneToView();
@@ -304,25 +325,27 @@ export default {
           FloorID: this.urlMsg.FloorID // 楼层id
         };
         Message({
-          message: '上传中,切勿关闭窗口!',
-          type: 'warning'
+          message: "保存中,切勿关闭窗口!",
+          type: "warning"
         });
-        saveGroup(data).then(res => {
-          Message.close()
-          this.graphId = res.Data;
-        }).catch((err)=>{
-         Message({
-          message: '上传失败!',
-          type: 'error'
-        });
-        })
+        saveGroup(data)
+          .then(res => {
+            Message.close();
+            this.graphId = res.Data;
+          })
+          .catch(err => {
+            Message({
+              message: "保存失败!",
+              type: "error"
+            });
+          });
       });
       bus.$on("exportByKey", val => {
         const list = this.fParser.spaceList
           .map(t => {
             if (t.data.Type == val.key) {
               if (!t.isExtracted) {
-                t.isExtracted = true
+                t.isExtracted = true;
                 return {
                   ID: uuid(),
                   Name: val.name,
@@ -412,31 +435,34 @@ export default {
       }),
         //发布图
         bus.$on("publishMap", () => {
-          if (this.graphId == '') {
-            this.$message.error('请先保存');
+          if (this.graphId == "") {
+            this.$message.error("请先保存");
             return false;
           }
-          this.publishBtn()
-        })
+          this.publishBtn();
+        });
       /**
        * @name changeScale缩放底图
        * @param { Number } zoom 缩放比例
        *
        */
       // TODO: changeScale缩放底图
-      bus.$on('changeScale', zoom => {
+      bus.$on("changeScale", zoom => {
         const { scale } = this.view;
-        this.changeScaleByClick = true
-        this.view.scaleByPoint(zoom, this.canvasWidth / 2, this.canvasHeight / 2)
-        this.changeScaleByClick = false
-        setTimeout(() => {
-        }, 100);
-      })
+        this.changeScaleByClick = true;
+        this.view.scaleByPoint(
+          zoom,
+          this.canvasWidth / 2,
+          this.canvasHeight / 2
+        );
+        this.changeScaleByClick = false;
+        setTimeout(() => {}, 100);
+      });
       // 更改图例数据工程化数据
-       bus.$on('changeAttachObjectIds', arr => {
-         console.log(arr);
-         this.scene.upadatAttachObjectIds(arr);
-      })
+      bus.$on("changeAttachObjectIds", arr => {
+        console.log(arr);
+        this.scene.upadatAttachObjectIds(arr);
+      });
     },
     // 读取数据
     readGroup() {
@@ -444,7 +470,7 @@ export default {
         categoryId: this.urlMsg.categoryId,
         projectId: this.urlMsg.projectId,
         BuildingID: this.urlMsg.BuildingID, // 建筑ID
-        FloorID: this.urlMsg.FloorID, // 楼层id
+        FloorID: this.urlMsg.FloorID // 楼层id
       };
       return readGroup(data);
     },
@@ -468,7 +494,7 @@ export default {
       publishGraph(data).then(res => {
         loadings.close();
         if (res.Result == "success") {
-          this.$message.success('发布成功');
+          this.$message.success("发布成功");
           setTimeout(() => {
             const data = `categoryId=${this.urlMsg.categoryId}&projectId=${this.urlMsg.projectId}&BuildingID=${this.urlMsg.BuildingID}&FloorID=${this.urlMsg.FloorID}&fmapID=${this.urlMsg.fmapID}`;
             const url =
@@ -509,15 +535,14 @@ export default {
       deep: true
     },
     // 监听scale的变化
-    'view.scale': {
+    "view.scale": {
       handler(scale) {
-
         // 滚轮触发的缩放
         if (!this.changeScaleByClick) {
-          bus.$emit('mouseScale', scale / this.initScale)
+          bus.$emit("mouseScale", scale / this.initScale);
         }
       }
-    },
+    }
   },
   created() {
     const href = window.location.href;

+ 3 - 2
src/components/edit/attr_select.vue

@@ -476,6 +476,7 @@ export default {
   },
   watch: {
     focusItemList: function(newval) {
+      console.log('xxxxxxxxxxxxxxx',newval)
       const Item = newval.itemList[0];
       this.getmajorId = Item.data.Properties.GraphCategoryId;
       if (Item.data && Item.data.SubType) {
@@ -483,7 +484,7 @@ export default {
       }else{
          this.SubType = '';
       }
-       console.log('this.SubType',this.SubType);
+
       if (newval.itemList.length == 1) {
         if (newval.itemType == "baseText") {
           this.textMsg = Item.text;
@@ -516,7 +517,7 @@ export default {
           }
         }
       }
-      let  location =[];
+      const  location =[];
       let  params ={};
       Item.data.AttachObjectIds.map(item=>{
         location.push(item.id)

+ 26 - 16
src/components/mapClass/EditScence.ts

@@ -61,13 +61,15 @@ export class EditScence extends SGraphScene {
     /** 当前选中焦点Item */
     focusItem: SGraphItem | null = null;
     /** 当前选中焦点ItemList */
-    focusItemList:SGraphItem[] | null = null;
+    focusItemList: SGraphItem[] | null = null;
     /**图例节点 */
     Nodes: any = [];  // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
     /**图例节点 */  // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
     Markers: any = [];
     /**  管线对象 */
     Relations: any = [];
+    /** 是否按下ctrl键 */
+    isDownCtrl: Boolean = false
     _isEditStatus: Boolean = true; // 是否可编辑
     set isEditStatus(bol: Boolean): void {
         this._isEditStatus = bol;
@@ -93,7 +95,6 @@ export class EditScence extends SGraphScene {
     };
     set setlegend(obj: any) {
         this._legend = obj;
-        console.log('aaaaaa', obj)
     }
     /** fid=>item映射,由解析器存入   */
     fidToItem = {}
@@ -130,7 +131,7 @@ export class EditScence extends SGraphScene {
         if (obj.itemList.length == 1) {
             // 获取聚焦item
             this.focusItem = obj.itemList[0]
-        }else{
+        } else {
             this.focusItem = null
         }
         let msg = {
@@ -147,6 +148,8 @@ export class EditScence extends SGraphScene {
      * 增加线段item
      */
     addLine(event: SMouseEvent): boolean {
+        // 创建时要清空所有选中状态
+        this.selectContainer
         const clickItem = this.clickIsItem(event);
         if (clickItem) {
             let centerPoint = clickItem.boundingRect().center();
@@ -382,6 +385,8 @@ export class EditScence extends SGraphScene {
         this.focusItem = item;
         this.cmd = 'choice';
         this.scenceUpdate(this);
+        // 创建图片块后实现回调
+        this.finishCreated(item)
     }
 
     /**
@@ -417,6 +422,7 @@ export class EditScence extends SGraphScene {
         this.focusItem = item;
         this.cmd = 'choice';
         this.scenceUpdate(this);
+        this.finishCreated(item)
     }
 
     /**
@@ -447,7 +453,6 @@ export class EditScence extends SGraphScene {
             },
         }
         const item = new SImageLegendItem(null, LegendData);
-        this.cmd = 'choice';
         item.selectable = true;
         item.moveable = true;
         item.zOrder = ItemOrder.markOrder;
@@ -456,6 +461,10 @@ export class EditScence extends SGraphScene {
         this.grabItem = item;
         this.focusItem = item;
         this.scenceUpdate(this);
+        this.finishCreated(item)
+        if(!this.isDownCtrl){
+             this.cmd = 'choice';
+        }
     }
 
     /**
@@ -524,6 +533,7 @@ export class EditScence extends SGraphScene {
      * @param color string 颜色
      */
     updatedBorderColor(color: string): void {
+        console.log('this.focusItem',this.focusItem)
         if (this.focusItem) {
             if (this.focusItem instanceof SZoneLegendItem || this.focusItem instanceof SSCPZZoneLegendItem || this.focusItem instanceof SFHFQZoneLegendItem) {
                 this.focusItem.strokeColor = new SColor(color);
@@ -668,7 +678,6 @@ export class EditScence extends SGraphScene {
      * @param AttachObjectIds Array
      */
     upadatAttachObjectIds(AttachObjectIds: []): void {
-        console.log('AttachObjectIds',AttachObjectIds)
         if (this.focusItem) {
             this.focusItem.data.AttachObjectIds = AttachObjectIds;
         }
@@ -721,12 +730,12 @@ export class EditScence extends SGraphScene {
                 }
                 this.scenceUpdate(this);
             }
-        }else{
+        } else {
             //批量删除
-            if(!this.focusItemList){
+            if (!this.focusItemList) {
                 return
             }
-            this.focusItemList.forEach((focusItem)=>{
+            this.focusItemList.forEach((focusItem) => {
                 this.removeItem(focusItem);
                 let a = -1
                 this.Nodes.forEach((item: any, index: number) => {
@@ -824,9 +833,12 @@ export class EditScence extends SGraphScene {
      * 完成事件创建的回调函数
      */
     finishCreated(item: any) {
-        this.setCmd = 'choice';
-        this.focusItem = item;
+        this.cmd = 'choice';
+        this.selectContainer.clear()
         this.selectContainer.toggleItem(item)
+        setTimeout(()=>{
+            this.focusItem = item;
+        })
     }
     ////////////////////////
     //  以下为鼠标键盘操作事件
@@ -918,14 +930,12 @@ export class EditScence extends SGraphScene {
             }
         }
         //delete键删除item
-        if(event.code == "Delete"){
-          this.deleiteItem()
+        if (event.code == "Delete") {
+            this.deleiteItem()
         }
-
         return false
     }
 
-
     /**
      * 鼠标双击事件
      *
@@ -935,8 +945,8 @@ export class EditScence extends SGraphScene {
     onDoubleClick(event: SMouseEvent): boolean {
         if (!this.isEditStatus) {
             return true
-        }else{
-           return super.onDoubleClick(event);
+        } else {
+            return super.onDoubleClick(event);
         }
 
     } // Function onDoubleClick()

+ 2 - 1
src/views/drafts.vue

@@ -293,7 +293,8 @@ export default {
         categoryId: this.categoryId,
         projectId: this.projectId,
         BuildingID: this.BuildingID, // 建筑ID
-        FloorID: floorid // 楼层id
+        FloorID: floorid, // 楼层id
+        Pub:false
       };
       return readGroup(data);
     },

+ 4 - 2
vue.config.js

@@ -15,8 +15,9 @@ module.exports = {
                 },
             },
             '/serve': {
-                target: 'http://192.168.200.87:8088/',
+                // target: 'http://192.168.200.87:8088/',
                 // target: 'http://192.168.200.83:8085/',
+                target: 'http://60.205.177.43:8080', //阿里云
                 changeOrigin: true,
                 secure: false,
                 pathRewrite: {
@@ -24,7 +25,8 @@ module.exports = {
                 },
             },
             '/data': {
-                target: 'http://192.168.200.87:9003',
+                // target: 'http://192.168.200.87:9003',
+                target: 'http://60.205.177.43:9903', //阿里云
                 changeOrigin: true,
                 secure: false,
                 pathRewrite: {