|
@@ -962,11 +962,23 @@ export class EditScence extends SGraphScene {
|
|
|
} else {
|
|
|
this.undoStack.redo();
|
|
|
this.scenceUpdate(this);
|
|
|
- // console.log(this.undoStack.command(this.undoStack.index))
|
|
|
+ const command = this.undoStack.command(this.undoStack.index);
|
|
|
+ // 如果为删除命令,重做需要讲数据数组中的item重新删去
|
|
|
+ if (command && command.command == "DeleteCommand") {
|
|
|
+ this.clearDataItem(command.item)
|
|
|
+ } else if (command && command.command == "DeleteCommandList") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.clearDataItem(element)
|
|
|
+ });
|
|
|
+ } else if (command && command.command == "SGraphAddCommand") {
|
|
|
+ this.addDataItem(command.item)
|
|
|
+ } else if (command && command.command == "AddListCommand") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.addDataItem(element)
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 执行重做操作执行
|
|
|
*/
|
|
@@ -974,12 +986,75 @@ export class EditScence extends SGraphScene {
|
|
|
if (this.grabItem && this.grabItem.undo) {
|
|
|
this.grabItem.undo()
|
|
|
} else {
|
|
|
- // console.log(this.undoStack.command(this.undoStack.index))
|
|
|
+ const command = this.undoStack.command(this.undoStack.index);
|
|
|
+ // 如果为删除命令,重做需要讲数据数组中的item重新放回data中
|
|
|
+ if (command && command.command == "DeleteCommand") {
|
|
|
+ this.addDataItem(command.item)
|
|
|
+ } else if (command && command.command == "DeleteCommandList") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.addDataItem(element)
|
|
|
+ });
|
|
|
+ } else if (command && command.command == "SGraphAddCommand") {
|
|
|
+ this.clearDataItem(command.item)
|
|
|
+ } else if (command && command.command == "AddListCommand") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.clearDataItem(element)
|
|
|
+ });
|
|
|
+ }
|
|
|
this.undoStack.undo();
|
|
|
this.scenceUpdate(this);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
+ * 清除data数据中指定的item
|
|
|
+ */
|
|
|
+ clearDataItem(commanditem: any) {
|
|
|
+ let a = -1
|
|
|
+ this.Nodes.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == commanditem.id) {
|
|
|
+ a = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (a > -1) {
|
|
|
+ this.Nodes.splice(a, 1);
|
|
|
+ }
|
|
|
+ let b = -1;
|
|
|
+ this.Markers.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == commanditem.id) {
|
|
|
+ b = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (b > -1) {
|
|
|
+ this.Markers.splice(b, 1);
|
|
|
+ }
|
|
|
+ let c = -1;
|
|
|
+ this.Relations.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == commanditem.id) {
|
|
|
+ c = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (c > -1) {
|
|
|
+ this.Relations.splice(c, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增加指定Item到data数据中
|
|
|
+ */
|
|
|
+
|
|
|
+ addDataItem(item: any) {
|
|
|
+ //清空指定的item
|
|
|
+ this.clearDataItem(item);
|
|
|
+ // 重新填入
|
|
|
+ if (item instanceof STextMarkerItem || item instanceof SImageMarkerItem || item instanceof SLineMarkerItem || item instanceof SCustomLegendItem) {
|
|
|
+ this.Markers.push(item)
|
|
|
+ } else if (item instanceof SFHFQZoneLegendItem || item instanceof SSCPZZoneLegendItem || item instanceof SImageLegendItem || item instanceof SZoneLegendItem) {
|
|
|
+ this.Nodes.push(item)
|
|
|
+ } else if (item instanceof TipelineItem) {
|
|
|
+ this.Relations.push(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 完成事件创建的回调函数
|
|
|
*/
|
|
|
finishCreated(item: any) {
|