fix: 解决组件移动未加入历史栈

This commit is contained in:
yangwq7
2022-08-25 20:27:57 +08:00
parent a7edef16f4
commit 0db49d055f
4 changed files with 95 additions and 11 deletions
@@ -313,6 +313,21 @@ export const useChartEditStore = defineStore({
loadingError()
}
},
// * 重置组件位置
resetComponentPostion(item: CreateComponentType | CreateComponentGroupType):void{
const index = this.fetchTargetIndex(item.id)
if(index > -1){
const componentInstance = this.getComponentList[index]
componentInstance.attr = Object.assign(componentInstance.attr, {
x: item.attr.x,
y: item.attr.y
})
}
},
// * 移动组件
moveComponentList(item: CreateComponentType | CreateComponentGroupType){
chartHistoryStore.createMoveHistory([item])
},
// * 更新组件列表某一项的值
updateComponentList(index: number, newData: CreateComponentType | CreateComponentGroupType) {
if (index < 1 && index > this.getComponentList.length) return
@@ -530,6 +545,15 @@ export const useChartEditStore = defineStore({
return
}
// 处理移动
const isMove = HistoryItem.actionType === HistoryActionTypeEnum.MOVE
if(isMove){
historyData.forEach(item => {
this.resetComponentPostion(item)
})
return
}
// 处理层级
const isTop = HistoryItem.actionType === HistoryActionTypeEnum.TOP
const isBottom = HistoryItem.actionType === HistoryActionTypeEnum.BOTTOM