mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
fix: 处理多个组件选中移动无法撤回的 bug
This commit is contained in:
parent
085c393767
commit
fe22e1d330
@ -332,8 +332,8 @@ export const useChartEditStore = defineStore({
|
||||
}
|
||||
},
|
||||
// * 移动组件
|
||||
moveComponentList(item: CreateComponentType | CreateComponentGroupType) {
|
||||
chartHistoryStore.createMoveHistory([item])
|
||||
moveComponentList(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||
chartHistoryStore.createMoveHistory(item)
|
||||
},
|
||||
// * 更新组件列表某一项的值
|
||||
updateComponentList(index: number, newData: CreateComponentType | CreateComponentGroupType) {
|
||||
|
@ -223,13 +223,13 @@ export const useMouseHandle = () => {
|
||||
const startY = e.screenY
|
||||
|
||||
// 记录历史位置
|
||||
let prevComponentInstance: CreateComponentType | CreateComponentGroupType
|
||||
let prevComponentInstance: Array<CreateComponentType | CreateComponentGroupType> = []
|
||||
chartEditStore.getTargetChart.selectId.forEach(id => {
|
||||
if (!targetMap.has(id)) return
|
||||
|
||||
const index = chartEditStore.fetchTargetIndex(id)
|
||||
// 拿到初始位置数据
|
||||
prevComponentInstance = cloneDeep(chartEditStore.getComponentList[index])
|
||||
prevComponentInstance.push(cloneDeep(chartEditStore.getComponentList[index]))
|
||||
})
|
||||
|
||||
// 记录初始位置
|
||||
@ -278,14 +278,19 @@ export const useMouseHandle = () => {
|
||||
chartEditStore.setMousePosition(0, 0, 0, 0)
|
||||
chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_DRAG, false)
|
||||
// 加入历史栈
|
||||
if (prevComponentInstance) {
|
||||
if (prevComponentInstance.length) {
|
||||
chartEditStore.getTargetChart.selectId.forEach(id => {
|
||||
if (!targetMap.has(id)) return
|
||||
const index = chartEditStore.fetchTargetIndex(id)
|
||||
const curComponentInstance = chartEditStore.getComponentList[index]
|
||||
prevComponentInstance.attr = Object.assign(prevComponentInstance.attr, {
|
||||
offsetX: curComponentInstance.attr.x - prevComponentInstance.attr.x,
|
||||
offsetY: curComponentInstance.attr.y - prevComponentInstance.attr.y
|
||||
// 找到记录的所选组件
|
||||
prevComponentInstance.forEach(preItem => {
|
||||
if (preItem.id === id) {
|
||||
preItem.attr = Object.assign(preItem.attr, {
|
||||
offsetX: curComponentInstance.attr.x - preItem.attr.x,
|
||||
offsetY: curComponentInstance.attr.y - preItem.attr.y
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
chartEditStore.moveComponentList(prevComponentInstance)
|
||||
|
Loading…
Reference in New Issue
Block a user