mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
feat: 新增移动撤回
This commit is contained in:
@@ -337,6 +337,28 @@ export const useChartEditStore = defineStore({
|
||||
loadingError()
|
||||
}
|
||||
},
|
||||
// * 重置组件位置
|
||||
resetComponentPosition(item: CreateComponentType | CreateComponentGroupType, isForward: boolean): void {
|
||||
const index = this.fetchTargetIndex(item.id)
|
||||
if (index > -1) {
|
||||
const componentInstance = this.getComponentList[index]
|
||||
if (isForward) {
|
||||
componentInstance.attr = Object.assign(componentInstance.attr, {
|
||||
x: item.attr.x + item.attr.offsetX,
|
||||
y: item.attr.y + item.attr.offsetY
|
||||
})
|
||||
} else {
|
||||
componentInstance.attr = Object.assign(componentInstance.attr, {
|
||||
x: item.attr.x,
|
||||
y: item.attr.y
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
// * 移动组件
|
||||
moveComponentList(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||
chartHistoryStore.createMoveHistory(item)
|
||||
},
|
||||
// * 更新组件列表某一项的值
|
||||
updateComponentList(index: number, newData: CreateComponentType | CreateComponentGroupType) {
|
||||
if (index < 1 && index > this.getComponentList.length) return
|
||||
@@ -554,6 +576,15 @@ export const useChartEditStore = defineStore({
|
||||
return
|
||||
}
|
||||
|
||||
// 处理移动
|
||||
const isMove = HistoryItem.actionType === HistoryActionTypeEnum.MOVE
|
||||
if (isMove) {
|
||||
historyData.forEach(item => {
|
||||
this.resetComponentPosition(item, isForward)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 处理层级
|
||||
const isTop = HistoryItem.actionType === HistoryActionTypeEnum.TOP
|
||||
const isBottom = HistoryItem.actionType === HistoryActionTypeEnum.BOTTOM
|
||||
@@ -586,12 +617,12 @@ export const useChartEditStore = defineStore({
|
||||
if (isGroup || isUnGroup) {
|
||||
if ((isGroup && isForward) || (isUnGroup && !isForward)) {
|
||||
const ids: string[] = []
|
||||
if(historyData.length > 1) {
|
||||
if (historyData.length > 1) {
|
||||
historyData.forEach(item => {
|
||||
ids.push(item.id)
|
||||
})
|
||||
} else {
|
||||
(historyData[0] as CreateComponentGroupType).groupList.forEach(item => {
|
||||
;(historyData[0] as CreateComponentGroupType).groupList.forEach(item => {
|
||||
ids.push(item.id)
|
||||
})
|
||||
}
|
||||
@@ -599,7 +630,7 @@ export const useChartEditStore = defineStore({
|
||||
return
|
||||
}
|
||||
// 都需使用子组件的id去解组
|
||||
if(historyData.length > 1) {
|
||||
if (historyData.length > 1) {
|
||||
this.setUnGroup([(historyData[0] as CreateComponentType).id], undefined, false)
|
||||
} else {
|
||||
this.setUnGroup([(historyData[0] as CreateComponentGroupType).groupList[0].id], undefined, false)
|
||||
|
||||
Reference in New Issue
Block a user