Forráskód Böngészése

修改业务空间创建逻辑

haojianlong 3 éve
szülő
commit
eecc2303eb

+ 1 - 0
src/utils/graph/DivideFloorScene.ts

@@ -16,6 +16,7 @@ export class DivideFloorScene extends FloorScene {
     /** 绘制的分区item */
     drawItem: DrawZoneItem | null = null;
     /** 当前绘制命令 cut-交集区域绘制 zoneDraw-绘制业务空间 */
+    // 2021.3.4需求不算交集,直接绘制业务空间
     drawCmd: string = '';
 
     /** 是否开启吸附  */

+ 1 - 1
src/utils/graph/DrawZoneItem.ts

@@ -14,7 +14,7 @@ export class DrawZoneItem extends SGraphStyleItem {
     /** Y 坐标最大值 */
     private maxY = Number.MIN_SAFE_INTEGER;
     /** 轮廓线坐标 */
-    private pointList: SPoint[] = [];
+    pointList: SPoint[] = [];
 
     /** 当前状态 */
     protected _status: number = SItemStatus.Normal;

+ 33 - 30
src/views/maintain/space/components/createBSP.vue

@@ -1,38 +1,41 @@
 <template>
-  <el-dialog :title="title" :visible.sync="dialogVisible" width="400px" id="createBSP">
-    <div>请输入创建的业务空间名:</div>
-    <el-input :placeholder="`请输入业务空间名称`" v-model="roomName"></el-input>
-    <span slot="footer" class="dialog-footer">
-      <el-button size="small" @click="dialogVisible=false">取 消</el-button>
-      <el-button size="small" type="primary" @click="confirm">确 定</el-button>
-    </span>
-  </el-dialog>
+    <el-dialog :title="title" :visible.sync="dialogVisible" width="400px" id="createBSP">
+        <div>请输入创建的业务空间名:</div>
+        <el-input :placeholder="`请输入业务空间名称`" v-model="roomName"></el-input>
+        <span slot="footer" class="dialog-footer">
+            <el-button size="small" @click="dialogVisible=false">取 消</el-button>
+            <el-button size="small" type="primary" @click="confirm" :disabled="confirmDisable">确 定</el-button>
+        </span>
+    </el-dialog>
 </template>
 
 <script>
 export default {
-  data() {
-    return {
-      title: '提示',
-      dialogVisible: false,
-      roomName: '',
-    };
-  },
-  methods: {
-    // 显示弹窗
-    showDialog(val) {
-      this.roomName = val;
-      this.dialogVisible = true;
+    data() {
+        return {
+            title: '提示',
+            dialogVisible: false,
+            roomName: '',
+            confirmDisable: true
+        };
+    },
+    methods: {
+        // 显示弹窗
+        showDialog(val) {
+            this.roomName = val;
+            this.dialogVisible = true;
+            this.confirmDisable = false;
+        },
+        // 确认
+        confirm() {
+            if (this.roomName == '') {
+                this.$message.warning("请填写空间名称");
+                return
+            }
+            this.confirmDisable = true
+            this.$emit('createRoom', this.roomName);
+            this.dialogVisible = false;
+        }
     },
-    // 确认
-    confirm() {
-      if (this.roomName == '') {
-        this.$message.warning("请填写空间名称");
-        return
-      }
-      this.$emit('createRoom', this.roomName);
-      this.dialogVisible = false;
-    }
-  },
 };
 </script>

+ 62 - 25
src/views/maintain/space/components/spaceGraph.vue

@@ -18,7 +18,7 @@
                 </div>
                 <div class="button-group">
                     <!-- 默认操作模式 -->
-                    <div v-show="type==1">
+                    <div v-if="type==1">
                         <el-dropdown split-button type="primary" @click="editGraphy" @command="handleCommand">
                             创建业务空间
                             <el-dropdown-menu slot="dropdown">
@@ -32,17 +32,17 @@
                         <el-button plain @click="cancelGraphy" v-show="!zoneDisable">取 消</el-button>
                     </div>
                     <!-- 点击未关联的业务空间 -->
-                    <div v-show="type==3">
+                    <div v-if="type==3">
                         <el-button plain @click="createNewZone">创建单个全新的业务空间</el-button>
                         <el-button plain @click="cancelGraphy">取 消</el-button>
                     </div>
                     <!-- 重新划分业务空间 -->
-                    <div v-show="type==4">
+                    <div v-if="type==4">
                         <el-button plain @click="cancelGraphy">取 消</el-button>
                         <el-button type="primary" @click="saveRefactorBSP">保存</el-button>
                     </div>
                     <!-- 批量创建所选业务空间 -->
-                    <div v-show="type==5">
+                    <div v-if="type==5">
                         <el-button type="primary" @click="groupCreateZone">批量创建所选业务空间</el-button>
                         <el-button plain @click="cancelGraphy">取 消</el-button>
                     </div>
@@ -220,7 +220,6 @@ export default class spaceGraph extends Vue {
             this.scene.isSpaceSelectable = false;
         }
         this.getBussiness();
-        this.canvasLoading = false;
     }
     // 清除canvas
     clearGraphy() {
@@ -269,24 +268,27 @@ export default class spaceGraph extends Vue {
     }
     // 创建新的业务空间
     createNewZone() {
-        let arr = this.scene?.selectContainer.itemList;
-        if (arr.length) {
-            let tempArr = [];
-            this.localFun = [];
-            arr.map((t) => {
-                tempArr.push(this.BIMIDToSIName[t.data.SourceId]);
-                if (
-                    this.sourceIdToISP[t.data.SourceId] &&
-                    this.sourceIdToISP[t.data.SourceId].infos
-                ) {
-                    this.localFun.push(
+        if (this.scene) {
+            let arr = this.scene.selectContainer.itemList;
+            if (arr.length || this.scene.drawItem) {
+                // 手绘的空间只有轮廓线可用
+                let tempArr = [];
+                this.localFun = [];
+                arr.map((t) => {
+                    tempArr.push(this.BIMIDToSIName[t.data.SourceId]);
+                    if (
+                        this.sourceIdToISP[t.data.SourceId] &&
                         this.sourceIdToISP[t.data.SourceId].infos
-                    );
-                }
-            });
-            this.$refs.createBSP.showDialog(tempArr.toString());
-        } else {
-            this.$message.warning("请至少选择一个空间");
+                    ) {
+                        this.localFun.push(
+                            this.sourceIdToISP[t.data.SourceId].infos
+                        );
+                    }
+                });
+                this.$refs.createBSP.showDialog(tempArr.toString());
+            } else {
+                this.$message.warning("请至少选择一个空间");
+            }
         }
     }
     handleCommand() {}
@@ -385,7 +387,7 @@ export default class spaceGraph extends Vue {
             zoneObj.infos = temp[0];
         }
         if (this.scene) {
-            zoneObj = this.calIntersect(zoneObj);
+            zoneObj = this.setZoneOutline(zoneObj);
             this.handleUpdateZone(zoneObj);
         }
     }
@@ -436,7 +438,11 @@ export default class spaceGraph extends Vue {
             zoneObj.infos = this.localFun[0];
         }
         if (this.scene) {
-            zoneObj = this.calIntersect(zoneObj);
+            // 旧逻辑--计算区域交集--
+            // zoneObj = this.calIntersect(zoneObj);
+
+            // 设置业务空间轮廓线
+            zoneObj = this.setZoneOutline(zoneObj);
             this.handleCreateZone(zoneObj);
         }
     }
@@ -499,6 +505,37 @@ export default class spaceGraph extends Vue {
     }
 
     /**
+     * 新逻辑添加业务空间轮廓线
+     */
+    setZoneOutline(zoneObj: any) {
+        if (this.scene) {
+            if (this.scene.drawItem) {
+                if (
+                    this.scene.drawItem.pointList.length &&
+                    this.scene.drawItem.pointList.length > 2
+                ) {
+                    const temp = this.scene.drawItem.pointList.map((t) => {
+                        return {
+                            X: t.x,
+                            Y: -t.y,
+                            Z: 0,
+                        };
+                    });
+                    zoneObj.outline.push([temp]);
+                }
+            }
+            let arr = this.scene.selectContainer.itemList;
+            if (arr.length) {
+                arr.forEach((t) => {
+                    if (t instanceof SSpaceItem)
+                        zoneObj.outline.push(t.data.OutLine);
+                });
+            }
+        }
+        return zoneObj;
+    }
+
+    /**
      * 创建业务空间接口
      */
     handleCreateZone(zoneObj: any) {
@@ -551,7 +588,7 @@ export default class spaceGraph extends Vue {
     // 切割划分
     divide() {
         if (this.scene) {
-            this.scene.drawCmd = "cut";
+            this.scene.drawCmd = "zoneDraw";
         }
     }
     // 清除切割划分