yunxing 3 years ago
parent
commit
86dbcd36bf

+ 8 - 4
src/components/editview/basePlanEditer.vue

@@ -177,6 +177,7 @@ export default {
                 // 画板是否可拖动;
                 this.scene.addItem(imgItem);
                 this.view.DragMove = true;
+                this.planLoading = false;
                 this.view.fitSceneToView();
             });
         },
@@ -251,7 +252,7 @@ export default {
             // 画板是否可拖动
             this.view.DragMove = true;
             this.view.fitSceneToView();
-
+            this.planLoading = false;
             // 设置初始化缩放比例
             this.initScale = this.view.scale;
             bus.$emit("initScale", this.view.scale);
@@ -456,6 +457,10 @@ export default {
             parser.casementList.forEach((t) => {
                 t.visible = val;
             });
+            if (this.view?.scene) this.view.fitSceneToView();
+            // 设置初始化缩放比例
+            this.initScale = this.view.scale;
+            bus.$emit("initScale", this.view.scale);
         },
         // 读取拓扑图
         readPlanMsg() {
@@ -641,6 +646,8 @@ export default {
                     zoneItem.visible = Boolean(zoneItem.legendData.outline);
                     // zoneItem.connect("finishCreated", this.scene, this.scene.finishCreated);
                     zoneItem.connect("onContextMenu", this, this.scene.getItem);
+                    // TODO: addItem 需要写在 zoneDecorator 修饰器前,保证在 SPlanZone中能使用 this.scene.view.scale
+                    this.scene.addItem(zoneItem);
                     if (this.styleMap[zone.id]) {
                         SPlanDecorator.zoneDecorator(zoneItem, this.styleMap[zone.id]);
                     } else if (this.styleMap[zone.classCode]) {
@@ -648,7 +655,6 @@ export default {
                     } else {
                         SPlanDecorator.zoneDecorator(zoneItem, this.styleMap["defaultZoneStyle"]);
                     }
-                    this.scene.addItem(zoneItem);
                     this.ADDZONE(zoneItem);
                 }
             });
@@ -740,8 +746,6 @@ export default {
             // 设置初始化缩放比例
             this.initScale = this.view.scale;
             bus.$emit("initScale", this.view.scale);
-            // 关闭顶部的loading提示
-            this.planLoading = false;
         },
         // 生成快照并保存草稿
         savePlanDraft() {

+ 31 - 2
src/components/editview/leftToolBar/addEquipmentDialog.vue

@@ -74,6 +74,7 @@
                 :disabled="!spacePartitionType.length"
                 :data="dataTree3"
                 @change="treeChange3"
+                id="treeSelect"
             />
         </div>
         <!-- 表格 -->
@@ -202,6 +203,26 @@ export default {
             deep: true,
         },
         /**
+         * 监听分区类型值,修复treeSelect禁用时,点击caption仍然能点击开的问题
+         */
+        "spacePartitionType.length"(val) {
+            // 分区类型无数据
+            if (!val) {
+                this.$nextTick(() => {
+                    const el = document.querySelector("#treeSelect .p-select-input-caption");
+                    const elClone = el.cloneNode(true);
+                    el.parentNode.replaceChild(elClone, el);
+                });
+            } else {
+                // 分区类型有数据
+                this.$nextTick(() => {
+                    const el = document.querySelector("#treeSelect .p-select-input-caption");
+                    const elClone = el.cloneNode(true);
+                    el.parentNode.replaceChild(this.el, el);
+                });
+            }
+        },
+        /**
          * 监听分区下实例变化(点击下拉框删除按钮,触发表格数据查询)
          */
         spacePartitionInstance: {
@@ -214,7 +235,7 @@ export default {
         },
     },
     // eslint-disable-next-line @typescript-eslint/no-empty-function
-    created() { },
+    created() {},
     mounted() {
         /*   setTimeout(() => {
             this.showPopover = true;
@@ -271,6 +292,8 @@ export default {
          * 显示弹窗时的处理
          */
         initModal() {
+            this.curentSelectTree1 = [];
+            this.spacePartitionType = [];
             this.tableDataBak = [];
             this.tableData = [];
             // 查询设备实例树
@@ -278,6 +301,12 @@ export default {
             // 分区类型 列表
             this.getType();
             this.getDict();
+            this.$nextTick(() => {
+                const el = document.querySelector("#treeSelect .p-select-input-caption");
+                this.el = el;
+                const elClone = el.cloneNode(true);
+                el.parentNode.replaceChild(elClone, el);
+            });
         },
         /**
          * 查询设备实例树
@@ -314,7 +343,7 @@ export default {
             };
             const res = await PartiInstancQuery(postParams);
             const data = res.content.map((v) => {
-                return { id: v.id, name: v.localName || '--' };
+                return { id: v.id, name: v.localName || "--" };
             });
             this.spacePartitionInstance = [];
             if (data.length) {

+ 32 - 3
src/components/editview/leftToolBar/addSpaceDialog.vue

@@ -48,6 +48,7 @@
                 :disabled="!spacePartitionType.length"
                 :data="dataTree3"
                 @change="treeChange3"
+                id="treeSelect"
             />
         </div>
         <!-- 表格 -->
@@ -148,6 +149,26 @@ export default {
             deep: true,
         },
         /**
+         * 监听分区类型值,修复treeSelect禁用时,点击caption仍然能点击开的问题
+         */
+        "spacePartitionType.length"(val) {
+            // 分区类型无数据
+            if (!val) {
+                this.$nextTick(() => {
+                    const el = document.querySelector("#treeSelect .p-select-input-caption");
+                    const elClone = el.cloneNode(true);
+                    el.parentNode.replaceChild(elClone, el);
+                });
+            } else {
+                // 分区类型有数据
+                this.$nextTick(() => {
+                    const el = document.querySelector("#treeSelect .p-select-input-caption");
+                    const elClone = el.cloneNode(true);
+                    el.parentNode.replaceChild(this.el, el);
+                });
+            }
+        },
+        /**
          * 监听分区下实例变化(点击下拉框删除按钮,触发表格数据查询)
          */
         spacePartitionInstance: {
@@ -160,7 +181,7 @@ export default {
         },
     },
     mounted() {
-        // 
+        //
     },
     methods: {
         ...mapMutations(["ADDRULE"]),
@@ -200,12 +221,20 @@ export default {
          * 显示弹窗时的处理
          */
         initModal() {
+            this.spacePartitionType = [];
+            this.spacePartitionInstance = [];
             this.tableDataBak = [];
             this.tableData = [];
             // 分区类型 列表
             this.getType();
             // 空间功能类型
             this.getDict();
+            this.$nextTick(() => {
+                const el = document.querySelector("#treeSelect .p-select-input-caption");
+                this.el = el;
+                const elClone = el.cloneNode(true);
+                el.parentNode.replaceChild(elClone, el);
+            });
         },
         /**
          * 空间分区类型 列表
@@ -230,10 +259,10 @@ export default {
             };
             const res = await PartiInstancQuery(postParams);
             const data = res.content.map((v) => {
-                return { id: v.id, name: v.localName || '--' };
+                return { id: v.id, name: v.localName || "--" };
             });
             this.spacePartitionInstance = [];
-             if (data.length) {
+            if (data.length) {
                 this.selectData = data;
             } else {
                 this.selectData = [{ disabled: true, name: "暂无数据", id: "" }];

+ 6 - 1
src/lib/item/SPlanZone.ts

@@ -194,7 +194,12 @@ export class SPlanZone extends SGraphEdit {
                         obj.moveTo(item.pos.x, item.pos.y);
                     } else {
                         const avgPos = this.getAverageVal();
-                        obj.moveTo(avgPos.avgX, avgPos.avgY - this.font.size * (0.5 * val.length - 0.5 - index));
+                        const scale = this.scene?.view?.scale;
+                        if (scale) {
+                            obj.moveTo(avgPos.avgX, avgPos.avgY - (this.font.size * (0.5 * val.length - 0.5 - index)) / scale);
+                        } else {
+                            obj.moveTo(avgPos.avgX, avgPos.avgY - this.font.size * (0.5 * val.length - 0.5 - index));
+                        }
                     }
 
                     obj.connect("onMove", this, this.textMove.bind(this));