Procházet zdrojové kódy

提起功能完善

haojianlong před 4 roky
rodič
revize
f5dfc3cc38

+ 4 - 0
src/api/editer.js

@@ -96,4 +96,8 @@ export function queryInfoSystem(params){
 // 图例搜索
 export function graphElementGroup(params){
     return httputils.postJson(`${testApi}/infoSystem/graphElementGroup`, params)
+}
+// 图例搜索(提取用)
+export function graphElementSearch(params){
+    return httputils.postJson(`${testApi}/graphElement/search`, params)
 }

+ 105 - 37
src/components/baseEditer.vue

@@ -8,7 +8,7 @@
 </template>
 <script>
 import { SFengParser } from "@saga-web/feng-map";
-import { SFloorParser } from "@saga-web/big";
+import { SFloorParser,SItemStatus } from "@saga-web/big";
 import { FloorView } from "./../lib/FloorView";
 import { EditScence } from "./mapClass/EditScence";
 import bus from "@/bus";
@@ -22,9 +22,11 @@ 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 { SImageLegendItem } from "@/lib/items/SImageLegendItem";
 import store from "../store";
 import { Loading } from "element-ui";
 import { Message } from "element-ui";
+import { SCircleItem } from "@/lib/items/SCircleItem"
 let fengmap = null;
 //// 底图空间增加字段 isExtracted:boolean true 已被提取过
 export default {
@@ -160,6 +162,13 @@ export default {
             this.fParser.doorList.forEach(t => this.scene.addItem(t));
             this.fParser.columnList.forEach(t => this.scene.addItem(t));
             this.fParser.casementList.forEach(t => this.scene.addItem(t));
+            this.fParser.pList = [];
+            res.PList.forEach(t => {
+              const item = new SCircleItem(null, t);
+              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;
@@ -307,9 +316,20 @@ export default {
         this.scene.changeAlignItem(val);
       });
       bus.$on("extractItem", () => {
-        const map = {};
+        const map = {},type={};
         this.fParser.spaceList.forEach(t => {
           if (this.hasTypeList.indexOf(t.data.Type) > -1) {
+            type[t.data.Type] = 'Zone'
+            if (map[t.data.Type]) {
+              map[t.data.Type]++;
+            } else {
+              map[t.data.Type] = 1;
+            }
+          }
+        });
+        this.fParser.pList.forEach(t => {
+          if (this.hasTypeList.indexOf(t.data.Type) > -1) {
+            type[t.data.Type] = 'Image'
             if (map[t.data.Type]) {
               map[t.data.Type]++;
             } else {
@@ -324,6 +344,7 @@ export default {
             name: key,
             age: "",
             number: map[key],
+            type: type[key],
             address: "提取"
           });
         }
@@ -333,41 +354,89 @@ export default {
         this.saveMsg();
       });
       bus.$on("exportByKey", val => {
-        const list = this.fParser.spaceList
-          .map(t => {
-            if (t.data.Type == val.key) {
-              if (!t.isExtracted) {
-                t.isExtracted = true;
-                return {
-                  ID: uuid(),
-                  Name: val.name,
-                  GraphElementType: val.properties.Type,
-                  GraphElementId: "273d633cc5c54a4882794b34843d1a00",
-                  AttachObjectIds: [],
-                  Pos: { x: t.x, y: t.y },
-                  OutLine: t.pointArr[0],
-                  SubType: "",
-                  Properties: {
-                    StrokeColor: "#3d73c0",
-                    FillColor: "#72f5f980",
-                    font: 0,
-                    color: "",
-                    TextPos: { X: 0, Y: 0 }
-                  },
-                  Num: 1
-                };
+        if (val.type == "Image") {
+          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: 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 },          // 缩放
+                    Rolate: { X: 0, Y: 0, Z: 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: 24,  //icon 的宽
+                        sHeight: 24,   //icon 的高
+                        font: 12,    //font
+                        color: '',  //字体颜色
+                        GraphCategoryId: val.age.GraphCategoryId,
+                        InfoSystemId: val.age.InfoSystemId?val.age.InfoSystemId:'',   //信息工程话分类ID分类
+                        FID: t.data.SourceId
+                    },
+                  };
+                  const item = new SImageLegendItem(null, data)
+                  item.selectable = true;
+                  item.moveable = true;
+                  this.scene.addItem(item);
+                  this.scene.Nodes.push(item);
+                  return item
+                }
               }
-            }
-          })
-          .filter(item => item);
-        const parserData = new STopologyParser(null);
-        parserData.parseData({ Nodes: list });
-        parserData.zoneLegendList.forEach(t => {
-          this.scene.addItem(t);
-          this.scene.Nodes.push(t);
-        });
-        // undo/redo事件
-        this.scene.AddListCommand(parserData.zoneLegendList);
+          }).filter(item => item);
+          this.scene.AddListCommand(list);
+          bus.$emit("elementDataChange", this.scene);
+        } else if (val.type == "Zone") {
+          const list = this.fParser.spaceList
+            .map(t => {
+              if (t.data.Type == val.key && val.age.Url) {
+                if (!t.isExtracted) {
+                  t.isExtracted = true;
+                  return {
+                    ID: uuid(),
+                    Name: val.age.Name,
+                    GraphElementType: val.age.Type,
+                    GraphElementId: val.age.Id,
+                    AttachObjectIds: [],
+                    Pos: { x: t.x, y: t.y },
+                    OutLine: t.pointArr[0],
+                    SubType: "",
+                    Properties: {
+                      IconUrl: '/serve/topology-wanda/Picture/query/' + val.age.Url,
+                      StrokeColor: val.age.Color,
+                      FillColor: val.age.FillColor,
+                      LineDash: val.age.LineDash,
+                      font: 12,
+                      color: "",
+                      TextPos: { X: 0, Y: 0},
+                      FID: t.data.SourceId
+                    },
+                    Num: 1
+                  };
+                }
+              }
+            })
+            .filter(item => item);
+          const parserData = new STopologyParser(null);
+          parserData.parseData({ Nodes: list });
+          parserData.zoneLegendList.forEach(t => {
+            t.$emit('finishCreated')
+            this.scene.addItem(t);
+            this.scene.Nodes.push(t);
+          });
+          // undo/redo事件
+          this.scene.AddListCommand(parserData.zoneLegendList);
+          bus.$emit("elementDataChange", this.scene);
+        } 
       });
       // 设备图例样式对象
       bus.$on("setLenged", obj => {
@@ -451,7 +520,6 @@ export default {
           this.canvasHeight / 2
         );
         this.changeScaleByClick = false;
-        setTimeout(() => {}, 100);
       });
       // 更改图例数据工程化数据
       bus.$on("changeAttachObjectIds", arr => {

+ 36 - 23
src/components/edit/left_toolbar.vue

@@ -121,6 +121,17 @@
             </div>
             <div v-else class="drawer-model-body drawer-model-body-extract">
               <a-table :columns="columns" :data-source="data" size="small" :pagination="false">
+                <template slot="age" slot-scope="text, record, index">
+                  <div>
+                    <img
+                      :class="['item',`item-${text.Type}`]"
+                      :src="'/serve/topology-wanda/Picture/query/'+ text.Url"
+                      alt
+                      v-if="text.Url"
+                    />
+                    <span v-else>无对应图例</span>
+                  </div>
+                </template>
                 <a-tag
                   slot="address"
                   slot-scope="text, record, index"
@@ -137,7 +148,7 @@
 </template>
 <script>
 import itemTree from "./leftbar_components/itemTree";
-import { graphElementGroup } from "@/api/editer.js";
+import { graphElementGroup, graphElementSearch} from "@/api/editer.js";
 import bus from "@/bus";
 import { queryGroup } from "@/api/editer.js";
 import { mapState, mapActions } from "vuex";
@@ -148,7 +159,8 @@ const columns = [
   },
   {
     title: "图例",
-    dataIndex: "age"
+    dataIndex: "age",
+    scopedSlots: { customRender: "age" }
   },
   {
     title: "数量",
@@ -160,22 +172,7 @@ const columns = [
     scopedSlots: { customRender: "address" }
   }
 ];
-const data = [
-  {
-    key: "1",
-    name: "电梯",
-    age: 32,
-    number: 123,
-    address: "提取"
-  },
-  {
-    key: "2",
-    name: "防火风区",
-    age: 42,
-    number: 123,
-    address: "提取"
-  }
-];
+const data = [];
 
 export default {
   components: { itemTree },
@@ -384,11 +381,27 @@ export default {
     },
     getBus() {
       bus.$on("exportItem", data => {
-        this.data = data.map(t => {
-          (t.name = this.TypeIdToGraphElement[t.key].Name),
-            (t.properties = this.TypeIdToGraphElement[t.key]);
-          return t;
-        });
+        this.data = [];
+        if (data.length) {
+          data.forEach(t => {
+            const pa = {
+              Deleted: false,
+              InfoTypeIds: [t.key],
+              PageSize: 1000,
+              Type: t.type
+            }
+            this.spinning = true
+            graphElementSearch(pa).then(res => {
+              this.spinning = false
+              if (res.Content && res.Content.length) {
+                t.age = res.Content[0];
+                t.name = this.TypeIdToGraphElement[t.key].Name
+                t.properties = this.TypeIdToGraphElement[t.key]
+                this.data.push(t)
+              }
+            })
+          })
+        }
       });
     },
     pickUp(text, record, index) {

+ 27 - 0
src/lib/items/SCircleItem.ts

@@ -0,0 +1,27 @@
+import { SGraphItem } from '@saga-web/graph/lib';
+import { SPainter, SColor } from '@saga-web/draw/lib';
+
+
+export class SCircleItem extends SGraphItem {
+  private r: number = 3;
+  data: any | null = null
+  isExtracted: boolean = false;
+
+  constructor(parent: SGraphItem | null, data: any) {
+    super(parent)
+    this.visible = false;
+    this.enabled = false;
+    this.data = data;
+    this.name = data.Name;
+    this.isTransform = false;
+    this.moveTo(data.Pos.X, -data.Pos.Y);
+  }
+
+  onDraw(painter: SPainter): void {
+    painter.brush.color = SColor.Black
+    if (this.isExtracted) {
+      painter.brush.color = SColor.Red;
+    }
+    painter.drawCircle(0, 0, this.r);
+  }
+}