xushiting il y a 2 ans
Parent
commit
c72ef161d5

+ 49 - 6
src/views/draw-file/board/editCAD/Controls/UIControl.js

@@ -85,8 +85,12 @@ export default class UIControl{
      * @param {*} value 属性值
      */
     setAttributes(type, name, value) {
-
-        
+        let item = stateService.getFocusItem()
+        switch (name) {
+            case 'delete':
+                this.deleteItem()
+                break;
+        }
         stateService.clearFocusItem();
     }
 
@@ -96,11 +100,23 @@ export default class UIControl{
         switch (item.type) {
             case VectorType.Tag:
                 const tag = floorplanService.getTag(item.vectorId)
-                value = item.value;
-                return;
+                value = tag.value;
+                break;
             case VectorType.Table:
-                value = item.value;
-                return;
+                const table = floorplanService.getTable(item.vectorId)
+                const cellIds = table.cells;
+                value = [];
+                for(let i=0;i<cellIds.length;++i){
+                    const cell = floorplanService.getCell(cellIds[i])
+                    value.push({
+                        width:cell.width,
+                        height:cell.height,
+                        value:cell.value,
+                        colIndex:cell.colIndex,
+                        rowIndex:cell.rowIndex
+                    })
+                }
+                break;
         }
         this.bus.emit('showAttribute',{
             type:type,
@@ -114,6 +130,33 @@ export default class UIControl{
         this.bus.emit('hideUI')
     }
 
+    deleteItem() {
+        let item = stateService.getFocusItem()
+        if (item) {
+            if (item.type == VectorType.Wall) {
+                floorplanService.deleteWall(item.vectorId)
+            } else if (item.type == VectorType.Rectangle) {
+                floorplanService.deleteRectangle(item.vectorId)
+            } else if (item.type == VectorType.Circle) {
+                floorplanService.deleteCircle(item.vectorId)
+            } else if (item.type == VectorType.Arrow) {
+                floorplanService.deleteArrow(item.vectorId)
+            } else if (item.type == VectorType.Icon) {
+                floorplanService.deleteIcon(item.vectorId)
+            }  else if (item.type == VectorType.Tag) {
+                floorplanService.deleteTag(item.vectorId)
+            } else if (item.type == VectorType.Table) {
+                floorplanService.deleteTable(item.vectorId)
+            } else if (signService.isSign(item.type)) {
+                floorplanService.deleteSign(item.vectorId)
+            } else if (item.type == VectorType.WallCorner) {
+                wallService.deleteWallCorner(item.vectorId)
+            }
+            this.layer.history.save()
+            this.layer.renderer.autoRedraw()
+        }
+    }
+
     getSignTypeForUI() {
         if (this.selectUI == UIEvents.Cigaret) {
             return VectorType.Cigaret

+ 6 - 27
src/views/draw-file/board/editCAD/Layer.js

@@ -429,9 +429,9 @@ export default class Layer {
                     }
                 } else {
                     moveTag.moveFullTag(dx,dy, draggingItem.vectorId)
-                    this.lastX = X
-                    this.lastY = Y
                 }
+                this.lastX = X
+                this.lastY = Y
                 break
             case LayerEvents.MoveTag:
                 needAutoRedraw = true
@@ -451,9 +451,10 @@ export default class Layer {
                     }
                 } else {
                     moveTable.moveFullTable(dx,dy, draggingItem.vectorId)
-                    this.lastX = X
-                    this.lastY = Y
+
                 }
+                this.lastX = X
+                this.lastY = Y
                 break
             case LayerEvents.MoveTable:
                 needAutoRedraw = true
@@ -759,7 +760,7 @@ export default class Layer {
             this.recoveryHistory()
             console.log('ctrl+y')
         } else if (e.code == 'Delete') {
-            this.deleteItem()
+            this.uiControl.deleteItem()
             this.uiControl.clearUI();
             this.history.save()
             this.renderer.autoRedraw()
@@ -892,26 +893,4 @@ export default class Layer {
         this.uiControl.clearUI()
         elementService.hideAll()
     }
-
-    deleteItem() {
-        let item = stateService.getFocusItem()
-        if (item) {
-            if (item.type == VectorType.Wall) {
-                floorplanService.deleteWall(item.vectorId)
-            } else if (componentService.isComponent(item.type)) {
-                floorplanService.deleteComponent(item.vectorId)
-            } else if (item.type == VectorType.Tag) {
-                floorplanService.deleteTag(item.vectorId)
-            } else if (item.type == VectorType.Table) {
-                floorplanService.deleteTable(item.vectorId)
-            } else if (signService.isSign(item.type)) {
-                floorplanService.deleteSign(item.vectorId)
-            } else if (item.type == VectorType.WallCorner) {
-                wallService.deleteWallCorner(item.vectorId)
-            }
-            this.history.save()
-            this.renderer.autoRedraw()
-        }
-    }
-
 }