xushiting 2 anos atrás
pai
commit
51ec2b790b

+ 10 - 8
src/views/draw-file/board/editCAD/Controls/UIControl.js

@@ -108,14 +108,16 @@ export default class UIControl{
                 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
-                    })
+                    for(let j=0;j<cellIds[i].length;++j){
+                        const cell = floorplanService.getCell(cellIds[i][j])
+                        value.push({
+                            width:cell.width,
+                            height:cell.height,
+                            value:cell.value,
+                            colIndex:cell.colIndex,
+                            rowIndex:cell.rowIndex
+                        })
+                    }
                 }
                 break;
         }

+ 34 - 11
src/views/draw-file/board/editCAD/History/History.js

@@ -17,8 +17,7 @@ import { iconService } from '../Service/IconService'
 import mitt from 'mitt'
 
 export default class History {
-    constructor(layer) {
-        this.layer = layer
+    constructor() {
         this.bus = mitt()
         this.init();
     }
@@ -99,11 +98,35 @@ export default class History {
     // 撤销
     handleUndo() {
         this.goPreState()
+        this.layer.renderer.autoRedraw()
+        const historyState = historyService.getHistoryState()
+        if (historyState.pre) {
+            //可以继续撤销
+            history.bus.emit('undoAvailable', true)
+        }
+        else{
+            //不能继续撤销
+            history.bus.emit('undoAvailable', false)
+        }
+        history.bus.emit('redoAvailable', true)
+        this.layer.uiControl.clearUI();
     }
 
     // 恢复
     handleRedo() {
         this.goNextState()
+        this.layer.renderer.autoRedraw()
+        const historyState = historyService.getHistoryState()
+        if (historyState.next) {
+            //可以继续恢复
+            history.bus.emit('redoAvailable', true)
+        }
+        else{
+            //不能继续恢复
+            history.bus.emit('redoAvailable', false)
+        }
+        history.bus.emit('undoAvailable', true)
+        this.layer.uiControl.clearUI();
     }
 
     // 撤销
@@ -120,9 +143,9 @@ export default class History {
             this.goPreForTags(item.tags)
             this.goPreForTables(item.tables)
             this.goPreForRectangles(item.rectangles)
-            this.goPreForCircles(item.Circles)
-            this.goPreForArrows(item.Arrows)
-            this.goPreForIcons(item.Icons)
+            this.goPreForCircles(item.circles)
+            this.goPreForArrows(item.arrows)
+            this.goPreForIcons(item.icons)
             this.goPreForSigns(item.signs)
 
             historyService.undoHistoryRecord()
@@ -277,7 +300,7 @@ export default class History {
             if (item.handle == HistoryEvents.AddIcon) {  
                 iconService.deleteIcon(item.icon.id)
             } else if (item.handle == HistoryEvents.DeleteIcon) {
-                let newIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.value,item.icon.id)
+                let newIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.icon.value,item.icon.id)
                 historyUtil.assignIconFromIcon(newIcon, item.icon)
             } else if (item.handle == HistoryEvents.ModifyIcon) {
                 const preIcon = item.preIcon
@@ -423,8 +446,8 @@ export default class History {
         for (let i = 0; i < itemForIcons.length; ++i) {
             const item = itemForIcons[i]
             if (item.handle == HistoryEvents.AddIcon) {
-                let vIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.value,item.icon.id)
-                historyUtil.assignIconFromIcon(vSign, item.icon)
+                let vIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.icon.value,item.icon.id)
+                historyUtil.assignIconFromIcon(vIcon, item.icon)
             } else if (item.handle == HistoryEvents.DeleteIcon) {
                 floorplanService.deleteIcon(item.icon.id)
             } else if (item.handle == HistoryEvents.ModifyIcon) {
@@ -490,9 +513,9 @@ export default class History {
                 this.goNextForTags(item.tags)
                 this.goNextForTables(item.tables)
                 this.goNextForRectangles(item.rectangles)
-                this.goNextForCircles(item.Circles)
-                this.goNextForArrows(item.Arrows)
-                this.goNextForIcons(item.Icons)
+                this.goNextForCircles(item.circles)
+                this.goNextForArrows(item.arrows)
+                this.goNextForIcons(item.icons)
                 this.goNextForSigns(item.signs)
             }
             change.saveCurrentInfo()

+ 2 - 0
src/views/draw-file/board/editCAD/Layer.js

@@ -46,6 +46,8 @@ export default class Layer {
         this.canvas = null;
         this.startX = null
         this.startY = null
+
+        history.layer = this
     }
 
     //开始

+ 9 - 1
src/views/draw-file/board/editCAD/Service/IconService.js

@@ -30,9 +30,14 @@ export default class IconService {
             x:(leftTopPosition.x+rightDownPosition.x)/2,
             y:(leftTopPosition.y+rightDownPosition.y)/2
         }
-        if(!value){
+        if(value == null){
             value = this.getNewValue();
         }
+        else{
+            if(!this.values.includes(value)){
+                this.values.push(value);
+            }
+        }
         const icon = new Icon(center, radius,value,vectorId)
         floorplanService.addIcon(icon)
         return icon
@@ -54,6 +59,9 @@ export default class IconService {
     }
 
     deleteIcon(iconId, floorNum) {
+        const icon = floorplanService.getIcon(iconId)
+        const index = this.values.indexOf(icon.value);
+        this.values.splice(index,1)
         floorplanService.deleteIcon(iconId, floorNum)
     }
 }