mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
feat: 新增多选的历史记录处理
This commit is contained in:
parent
4c353136d5
commit
01c2a20a0f
@ -117,7 +117,7 @@ export type TargetChartType = {
|
|||||||
|
|
||||||
// 数据记录
|
// 数据记录
|
||||||
export type RecordChartType = {
|
export type RecordChartType = {
|
||||||
charts: CreateComponentType | CreateComponentType[] | CreateComponentGroupType
|
charts: CreateComponentType | CreateComponentGroupType | Array<CreateComponentType | CreateComponentGroupType>
|
||||||
type: HistoryActionTypeEnum.CUT | HistoryActionTypeEnum.COPY
|
type: HistoryActionTypeEnum.CUT | HistoryActionTypeEnum.COPY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,41 +252,60 @@ export const useChartEditStore = defineStore({
|
|||||||
// * 统一格式化处理入参 id
|
// * 统一格式化处理入参 id
|
||||||
idPreFormat(id?: string | string[]) {
|
idPreFormat(id?: string | string[]) {
|
||||||
const idArr = []
|
const idArr = []
|
||||||
if (!id) idArr.push(...this.getTargetChart.selectId)
|
if (!id) {
|
||||||
|
idArr.push(...this.getTargetChart.selectId)
|
||||||
|
return idArr
|
||||||
|
}
|
||||||
if (isString(id)) idArr.push(id)
|
if (isString(id)) idArr.push(id)
|
||||||
if (isArray(id)) idArr.push(...id)
|
if (isArray(id)) idArr.push(...id)
|
||||||
return idArr
|
return idArr
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* * 新增组件列表
|
* * 新增组件列表
|
||||||
* @param chartConfig 新图表实例
|
* @param componentInstance 新图表实例
|
||||||
* @param isHead 是否头部插入
|
* @param isHead 是否头部插入
|
||||||
* @param isHistory 是否进行记录
|
* @param isHistory 是否进行记录
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
addComponentList(chartConfig: CreateComponentType | CreateComponentGroupType, isHead = false, isHistory = false): void {
|
addComponentList(
|
||||||
if (isHistory) {
|
componentInstance:
|
||||||
chartHistoryStore.createAddHistory(chartConfig)
|
| CreateComponentType
|
||||||
}
|
| CreateComponentGroupType
|
||||||
if (isHead) {
|
| CreateComponentType[]
|
||||||
this.componentList.unshift(chartConfig)
|
| CreateComponentGroupType[],
|
||||||
|
isHead = false,
|
||||||
|
isHistory = false
|
||||||
|
): void {
|
||||||
|
if(componentInstance instanceof Array) {
|
||||||
|
componentInstance.forEach(item => {
|
||||||
|
this.addComponentList(item, isHead, isHistory)
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.componentList.push(chartConfig)
|
if (isHistory) {
|
||||||
|
chartHistoryStore.createAddHistory([componentInstance])
|
||||||
|
}
|
||||||
|
if (isHead) {
|
||||||
|
this.componentList.unshift(componentInstance)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.componentList.push(componentInstance)
|
||||||
},
|
},
|
||||||
// * 删除组件
|
// * 删除组件
|
||||||
removeComponentList(id?:string | string[], isHistory = true): void {
|
removeComponentList(id?:string | string[], isHistory = true): void {
|
||||||
try {
|
try {
|
||||||
loadingStart()
|
loadingStart()
|
||||||
const idArr = this.idPreFormat(id)
|
const idArr = this.idPreFormat(id)
|
||||||
|
const history: Array<CreateComponentType | CreateComponentGroupType> = []
|
||||||
// 遍历所有对象
|
// 遍历所有对象
|
||||||
idArr.forEach(ids => {
|
idArr.forEach(ids => {
|
||||||
const index = this.fetchTargetIndex(ids)
|
const index = this.fetchTargetIndex(ids)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
isHistory ? chartHistoryStore.createDeleteHistory(this.getComponentList[index]) : undefined
|
history.push(this.getComponentList[index])
|
||||||
this.componentList.splice(index, 1)
|
this.componentList.splice(index, 1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
isHistory && chartHistoryStore.createDeleteHistory(history)
|
||||||
loadingFinish()
|
loadingFinish()
|
||||||
return
|
return
|
||||||
} catch(value) {
|
} catch(value) {
|
||||||
@ -331,8 +350,8 @@ export const useChartEditStore = defineStore({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 记录原有位置
|
// 记录原有位置
|
||||||
const setIndex = (t:CreateComponentType | CreateComponentGroupType, i:number) => {
|
const setIndex = (componentInstance:CreateComponentType | CreateComponentGroupType, i:number) => {
|
||||||
const temp = cloneDeep(t)
|
const temp = cloneDeep(componentInstance)
|
||||||
temp.attr.zIndex = i
|
temp.attr.zIndex = i
|
||||||
return temp
|
return temp
|
||||||
}
|
}
|
||||||
@ -340,7 +359,7 @@ export const useChartEditStore = defineStore({
|
|||||||
// 历史记录
|
// 历史记录
|
||||||
if (isHistory) {
|
if (isHistory) {
|
||||||
chartHistoryStore.createLayerHistory(
|
chartHistoryStore.createLayerHistory(
|
||||||
setIndex(targetData, index),
|
[setIndex(targetData, index)],
|
||||||
isEnd ? HistoryActionTypeEnum.BOTTOM : HistoryActionTypeEnum.TOP
|
isEnd ? HistoryActionTypeEnum.BOTTOM : HistoryActionTypeEnum.TOP
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -391,7 +410,7 @@ export const useChartEditStore = defineStore({
|
|||||||
// 历史记录
|
// 历史记录
|
||||||
if (isHistory) {
|
if (isHistory) {
|
||||||
chartHistoryStore.createLayerHistory(
|
chartHistoryStore.createLayerHistory(
|
||||||
targetItem,
|
[targetItem],
|
||||||
isDown ? HistoryActionTypeEnum.DOWN : HistoryActionTypeEnum.UP
|
isDown ? HistoryActionTypeEnum.DOWN : HistoryActionTypeEnum.UP
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -482,45 +501,54 @@ export const useChartEditStore = defineStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// * 撤回/前进 目标处理
|
// * 撤回/前进 目标处理
|
||||||
setBackAndSetForwardHandle(item: HistoryItemType, isForward = false) {
|
setBackAndSetForwardHandle(HistoryItem: HistoryItemType, isForward = false) {
|
||||||
// 处理画布
|
// 处理画布
|
||||||
if (item.targetType === HistoryTargetTypeEnum.CANVAS) {
|
if (HistoryItem.targetType === HistoryTargetTypeEnum.CANVAS) {
|
||||||
this.editCanvas = item.historyData as EditCanvasType
|
this.editCanvas = HistoryItem.historyData[0] as EditCanvasType
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const historyData = item.historyData as CreateComponentType
|
let historyData = HistoryItem.historyData as Array<CreateComponentType | CreateComponentGroupType>
|
||||||
|
if(isArray(historyData)) {
|
||||||
|
// 选中目标元素,支持多个
|
||||||
|
historyData.forEach((item: CreateComponentType | CreateComponentGroupType) => {
|
||||||
|
this.setTargetSelectChart(item.id, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 处理新增类型
|
// 处理新增类型
|
||||||
const isAdd = item.actionType === HistoryActionTypeEnum.ADD
|
const isAdd = HistoryItem.actionType === HistoryActionTypeEnum.ADD
|
||||||
const isDel = item.actionType === HistoryActionTypeEnum.DELETE
|
const isDel = HistoryItem.actionType === HistoryActionTypeEnum.DELETE
|
||||||
this.setTargetSelectChart(historyData.id)
|
|
||||||
if (isAdd || isDel) {
|
if (isAdd || isDel) {
|
||||||
if ((isAdd && isForward) || (isDel && !isForward)) {
|
if ((isAdd && isForward) || (isDel && !isForward)) {
|
||||||
this.addComponentList(historyData)
|
historyData.forEach(item => {
|
||||||
return
|
this.addComponentList(item)
|
||||||
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
this.removeComponentList(undefined, false)
|
historyData.forEach(item => {
|
||||||
|
this.removeComponentList(item.id, false)
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理层级
|
// 处理层级
|
||||||
const isTop = item.actionType === HistoryActionTypeEnum.TOP
|
const isTop = HistoryItem.actionType === HistoryActionTypeEnum.TOP
|
||||||
const isBottom = item.actionType === HistoryActionTypeEnum.BOTTOM
|
const isBottom = HistoryItem.actionType === HistoryActionTypeEnum.BOTTOM
|
||||||
if (isTop || isBottom) {
|
if (isTop || isBottom) {
|
||||||
if (!isForward) {
|
if (!isForward) {
|
||||||
// 插入到原有位置
|
// 插入到原有位置
|
||||||
if (isTop) this.getComponentList.pop()
|
if (isTop) this.getComponentList.pop()
|
||||||
if (isBottom) this.getComponentList.shift()
|
if (isBottom) this.getComponentList.shift()
|
||||||
this.getComponentList.splice(historyData.attr.zIndex, 0, historyData)
|
this.getComponentList.splice(historyData[0].attr.zIndex, 0, historyData[0])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (isTop) this.setTop(false)
|
if (isTop) this.setTop(false)
|
||||||
if (isBottom) this.setBottom(false)
|
if (isBottom) this.setBottom(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isUp = item.actionType === HistoryActionTypeEnum.UP
|
const isUp = HistoryItem.actionType === HistoryActionTypeEnum.UP
|
||||||
const isDown = item.actionType === HistoryActionTypeEnum.DOWN
|
const isDown = HistoryItem.actionType === HistoryActionTypeEnum.DOWN
|
||||||
if (isUp || isDown) {
|
if (isUp || isDown) {
|
||||||
if ((isUp && isForward) || (isDown && !isForward)) {
|
if ((isUp && isForward) || (isDown && !isForward)) {
|
||||||
this.setUp(false)
|
this.setUp(false)
|
||||||
@ -530,8 +558,17 @@ export const useChartEditStore = defineStore({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理内容修改
|
// 处理分组
|
||||||
this.getComponentList[this.fetchTargetIndex()] = item.historyData as CreateComponentType
|
const isGroup = HistoryItem.actionType === HistoryActionTypeEnum.GROUP
|
||||||
|
const isUnGroup = HistoryItem.actionType === HistoryActionTypeEnum.UN_GROUP
|
||||||
|
if (isGroup || isUnGroup) {
|
||||||
|
if ((isGroup && isForward) || (isUnGroup && !isForward)) {
|
||||||
|
this.setGroup(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.setUnGroup([historyData[0].id], undefined, false)
|
||||||
|
return
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// * 撤回
|
// * 撤回
|
||||||
setBack() {
|
setBack() {
|
||||||
@ -542,13 +579,6 @@ export const useChartEditStore = defineStore({
|
|||||||
loadingFinish()
|
loadingFinish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (Array.isArray(targetData)) {
|
|
||||||
targetData.forEach((e: HistoryItemType) => {
|
|
||||||
this.setBackAndSetForwardHandle(e)
|
|
||||||
})
|
|
||||||
loadingFinish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setBackAndSetForwardHandle(targetData)
|
this.setBackAndSetForwardHandle(targetData)
|
||||||
loadingFinish()
|
loadingFinish()
|
||||||
|
|
||||||
@ -565,13 +595,6 @@ export const useChartEditStore = defineStore({
|
|||||||
loadingFinish()
|
loadingFinish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (Array.isArray(targetData)) {
|
|
||||||
targetData.forEach((e: HistoryItemType) => {
|
|
||||||
this.setBackAndSetForwardHandle(e, true)
|
|
||||||
})
|
|
||||||
loadingFinish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setBackAndSetForwardHandle(targetData, true)
|
this.setBackAndSetForwardHandle(targetData, true)
|
||||||
loadingFinish()
|
loadingFinish()
|
||||||
|
|
||||||
@ -599,9 +622,9 @@ export const useChartEditStore = defineStore({
|
|||||||
attr.x -= distance
|
attr.x -= distance
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// * 创建分组
|
// * 创建分组
|
||||||
setGroup() {
|
setGroup(isHistory = true) {
|
||||||
try {
|
try {
|
||||||
const selectIds = this.getTargetChart.selectId
|
const selectIds = this.getTargetChart.selectId
|
||||||
if (selectIds.length < 2) return
|
if (selectIds.length < 2) return
|
||||||
@ -628,7 +651,7 @@ export const useChartEditStore = defineStore({
|
|||||||
newSelectIds.push(e.id)
|
newSelectIds.push(e.id)
|
||||||
})
|
})
|
||||||
}, false)
|
}, false)
|
||||||
} else {
|
} else if (targetIndex !== -1) {
|
||||||
newSelectIds.push(id)
|
newSelectIds.push(id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -649,6 +672,9 @@ export const useChartEditStore = defineStore({
|
|||||||
targetList.push(item)
|
targetList.push(item)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 修改原数据之前,先记录
|
||||||
|
if(isHistory) chartHistoryStore.createGroupHistory(targetList)
|
||||||
|
|
||||||
// 设置子组件的位置
|
// 设置子组件的位置
|
||||||
targetList.forEach((item: CreateComponentType) => {
|
targetList.forEach((item: CreateComponentType) => {
|
||||||
item.attr.x = item.attr.x - groupAttr.l
|
item.attr.x = item.attr.x - groupAttr.l
|
||||||
|
@ -15,6 +15,8 @@ export const historyActionTypeName = {
|
|||||||
[HistoryActionTypeEnum.BOTTOM]: '层级置底',
|
[HistoryActionTypeEnum.BOTTOM]: '层级置底',
|
||||||
[HistoryActionTypeEnum.UP]: '层级上移',
|
[HistoryActionTypeEnum.UP]: '层级上移',
|
||||||
[HistoryActionTypeEnum.DOWN]: '层级下移',
|
[HistoryActionTypeEnum.DOWN]: '层级下移',
|
||||||
|
[HistoryActionTypeEnum.GROUP]: '创建分组',
|
||||||
|
[HistoryActionTypeEnum.UN_GROUP]: '解除分组',
|
||||||
[HistoryActionTypeEnum.SELECT_HISTORY]: '选择记录',
|
[HistoryActionTypeEnum.SELECT_HISTORY]: '选择记录',
|
||||||
|
|
||||||
[HistoryTargetTypeEnum.CANVAS]: '画布初始化'
|
[HistoryTargetTypeEnum.CANVAS]: '画布初始化'
|
||||||
|
@ -56,10 +56,10 @@ export enum HistoryStackItemEnum {
|
|||||||
// 历史记录项类型
|
// 历史记录项类型
|
||||||
export interface HistoryItemType {
|
export interface HistoryItemType {
|
||||||
// 会有同时操作多个组件场景
|
// 会有同时操作多个组件场景
|
||||||
[HistoryStackItemEnum.ID]: string | string[]
|
[HistoryStackItemEnum.ID]: string
|
||||||
[HistoryStackItemEnum.TARGET_TYPE]: HistoryTargetTypeEnum
|
[HistoryStackItemEnum.TARGET_TYPE]: HistoryTargetTypeEnum
|
||||||
[HistoryStackItemEnum.ACTION_TYPE]: HistoryActionTypeEnum
|
[HistoryStackItemEnum.ACTION_TYPE]: HistoryActionTypeEnum
|
||||||
[HistoryStackItemEnum.HISTORY_DATA]: CreateComponentType | CreateComponentGroupType | EditCanvasType
|
[HistoryStackItemEnum.HISTORY_DATA]: CreateComponentType[] | CreateComponentGroupType[] | EditCanvasType[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 历史 Store 类型
|
// 历史 Store 类型
|
||||||
|
@ -35,31 +35,26 @@ export const useChartHistoryStore = defineStore({
|
|||||||
* @param targetType 对象类型(默认图表)
|
* @param targetType 对象类型(默认图表)
|
||||||
*/
|
*/
|
||||||
createStackItem(
|
createStackItem(
|
||||||
item: CreateComponentType | CreateComponentGroupType | EditCanvasType,
|
item: CreateComponentType[] | CreateComponentGroupType[] | EditCanvasType[],
|
||||||
actionType: HistoryActionTypeEnum,
|
actionType: HistoryActionTypeEnum,
|
||||||
targetType: HistoryTargetTypeEnum = HistoryTargetTypeEnum.CHART
|
targetType: HistoryTargetTypeEnum = HistoryTargetTypeEnum.CHART
|
||||||
) {
|
) {
|
||||||
// 优化性能转为freeze
|
// 优化性能转为 freeze
|
||||||
this.pushBackStackItem(Object.freeze({
|
this.pushBackStackItem(
|
||||||
[HistoryStackItemEnum.ID]: new Date().getTime().toString(),
|
Object.freeze({
|
||||||
[HistoryStackItemEnum.HISTORY_DATA]: item,
|
[HistoryStackItemEnum.ID]: new Date().getTime().toString(),
|
||||||
[HistoryStackItemEnum.ACTION_TYPE]: actionType,
|
[HistoryStackItemEnum.HISTORY_DATA]: item,
|
||||||
[HistoryStackItemEnum.TARGET_TYPE]: targetType
|
[HistoryStackItemEnum.ACTION_TYPE]: actionType,
|
||||||
} as const))
|
[HistoryStackItemEnum.TARGET_TYPE]: targetType
|
||||||
|
} as const)
|
||||||
|
)
|
||||||
},
|
},
|
||||||
// * 画布初始化
|
// * 画布初始化
|
||||||
canvasInit(canvas: EditCanvasType) {
|
canvasInit(canvas: EditCanvasType) {
|
||||||
this.createStackItem(
|
this.createStackItem([canvas], HistoryActionTypeEnum.ADD, HistoryTargetTypeEnum.CANVAS)
|
||||||
canvas,
|
|
||||||
HistoryActionTypeEnum.ADD,
|
|
||||||
HistoryTargetTypeEnum.CANVAS
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
// * 推入后退栈
|
// * 推入后退栈
|
||||||
pushBackStackItem(
|
pushBackStackItem(item: HistoryItemType | Array<HistoryItemType>, notClear = false): void {
|
||||||
item: HistoryItemType | Array<HistoryItemType>,
|
|
||||||
notClear = false
|
|
||||||
): void {
|
|
||||||
if (item instanceof Array) this.backStack = [...this.backStack, ...item]
|
if (item instanceof Array) this.backStack = [...this.backStack, ...item]
|
||||||
else this.backStack.push(item)
|
else this.backStack.push(item)
|
||||||
this.backStack.splice(0, this.backStack.length - editHistoryMax)
|
this.backStack.splice(0, this.backStack.length - editHistoryMax)
|
||||||
@ -69,30 +64,17 @@ export const useChartHistoryStore = defineStore({
|
|||||||
},
|
},
|
||||||
// * 推入前进栈
|
// * 推入前进栈
|
||||||
pushForwardStack(item: HistoryItemType | Array<HistoryItemType>): void {
|
pushForwardStack(item: HistoryItemType | Array<HistoryItemType>): void {
|
||||||
if (item instanceof Array)
|
if (item instanceof Array) this.forwardStack = [...this.forwardStack, ...item]
|
||||||
this.forwardStack = [...this.forwardStack, ...item]
|
|
||||||
else this.forwardStack.push(item)
|
else this.forwardStack.push(item)
|
||||||
},
|
},
|
||||||
// * 移出后退栈
|
// * 移出后退栈
|
||||||
popBackStackItem(
|
popBackStackItem(): HistoryItemType | undefined {
|
||||||
index?: number
|
|
||||||
): HistoryItemType[] | HistoryItemType | undefined {
|
|
||||||
const length = this.backStack.length
|
|
||||||
if (index && length >= index) {
|
|
||||||
return this.backStack.splice(-index)
|
|
||||||
}
|
|
||||||
if (this.backStack.length > 0) {
|
if (this.backStack.length > 0) {
|
||||||
return this.backStack.pop()
|
return this.backStack.pop()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// * 移出前进栈
|
// * 移出前进栈
|
||||||
popForwardStack(
|
popForwardStack(): HistoryItemType | undefined {
|
||||||
index?: number
|
|
||||||
): HistoryItemType[] | HistoryItemType | undefined {
|
|
||||||
const length = this.forwardStack.length
|
|
||||||
if (index && length >= index) {
|
|
||||||
return this.forwardStack.splice(-index)
|
|
||||||
}
|
|
||||||
if (this.forwardStack.length > 0) {
|
if (this.forwardStack.length > 0) {
|
||||||
return this.forwardStack.pop()
|
return this.forwardStack.pop()
|
||||||
}
|
}
|
||||||
@ -104,7 +86,7 @@ export const useChartHistoryStore = defineStore({
|
|||||||
// * 清空后退栈(保留初始化)
|
// * 清空后退栈(保留初始化)
|
||||||
clearBackStack() {
|
clearBackStack() {
|
||||||
const canvasHistory = this.getBackStack[0]
|
const canvasHistory = this.getBackStack[0]
|
||||||
this.backStack = [canvasHistory]
|
this.backStack = [canvasHistory]
|
||||||
},
|
},
|
||||||
// * 撤回
|
// * 撤回
|
||||||
backAction() {
|
backAction() {
|
||||||
@ -148,59 +130,43 @@ export const useChartHistoryStore = defineStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// * 新增组件记录
|
// * 新增组件记录
|
||||||
createAddHistory(item: CreateComponentType | CreateComponentGroupType) {
|
createAddHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
this.createStackItem(
|
this.createStackItem(item, HistoryActionTypeEnum.ADD, HistoryTargetTypeEnum.CHART)
|
||||||
item,
|
|
||||||
HistoryActionTypeEnum.ADD,
|
|
||||||
HistoryTargetTypeEnum.CHART
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
// * 更新属性记录(大小、图表属性)
|
// * 更新属性记录(大小、图表属性)
|
||||||
createUpdateHistory(item: CreateComponentType | CreateComponentGroupType) {
|
createUpdateHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
this.createStackItem(
|
this.createStackItem(item, HistoryActionTypeEnum.UPDATE, HistoryTargetTypeEnum.CHART)
|
||||||
item,
|
|
||||||
HistoryActionTypeEnum.UPDATE,
|
|
||||||
HistoryTargetTypeEnum.CHART
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
// * 删除组件记录
|
// * 删除组件记录
|
||||||
createDeleteHistory(item: CreateComponentType | CreateComponentGroupType) {
|
createDeleteHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
this.createStackItem(
|
this.createStackItem(item, HistoryActionTypeEnum.DELETE, HistoryTargetTypeEnum.CHART)
|
||||||
item,
|
|
||||||
HistoryActionTypeEnum.DELETE,
|
|
||||||
HistoryTargetTypeEnum.CHART
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
// * 移动组件记录
|
// * 移动组件记录
|
||||||
createMoveHistory(item: CreateComponentType | CreateComponentGroupType) {
|
createMoveHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
this.createStackItem(
|
this.createStackItem(item, HistoryActionTypeEnum.MOVE, HistoryTargetTypeEnum.CHART)
|
||||||
item,
|
|
||||||
HistoryActionTypeEnum.MOVE,
|
|
||||||
HistoryTargetTypeEnum.CHART
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
// * 改变层级组件记录
|
// * 改变层级组件记录
|
||||||
createLayerHistory(
|
createLayerHistory(
|
||||||
item: CreateComponentType | CreateComponentGroupType,
|
item: Array<CreateComponentType | CreateComponentGroupType>,
|
||||||
type:
|
type:
|
||||||
| HistoryActionTypeEnum.TOP
|
| HistoryActionTypeEnum.TOP
|
||||||
| HistoryActionTypeEnum.DOWN
|
| HistoryActionTypeEnum.DOWN
|
||||||
| HistoryActionTypeEnum.UP
|
| HistoryActionTypeEnum.UP
|
||||||
| HistoryActionTypeEnum.BOTTOM
|
| HistoryActionTypeEnum.BOTTOM
|
||||||
) {
|
) {
|
||||||
this.createStackItem(
|
this.createStackItem(item, type, HistoryTargetTypeEnum.CHART)
|
||||||
item,
|
|
||||||
type,
|
|
||||||
HistoryTargetTypeEnum.CHART
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
// * 剪切组件记录
|
// * 剪切组件记录
|
||||||
createPasteHistory(item: CreateComponentType | CreateComponentGroupType) {
|
createPasteHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
this.createStackItem(
|
this.createStackItem(item, HistoryActionTypeEnum.CUT, HistoryTargetTypeEnum.CHART)
|
||||||
item,
|
},
|
||||||
HistoryActionTypeEnum.CUT,
|
// * 创建分组
|
||||||
HistoryTargetTypeEnum.CHART
|
createGroupHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
)
|
this.createStackItem(item, HistoryActionTypeEnum.GROUP, HistoryTargetTypeEnum.CHART)
|
||||||
|
},
|
||||||
|
// * 解除分组
|
||||||
|
createUnGroupHistory(item: Array<CreateComponentType | CreateComponentGroupType>) {
|
||||||
|
this.createStackItem(item, HistoryActionTypeEnum.GROUP, HistoryTargetTypeEnum.CHART)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -96,7 +96,7 @@ const labelHandle = (e: HistoryItemType) => {
|
|||||||
} else if (e.actionType === HistoryActionTypeEnum.GROUP) {
|
} else if (e.actionType === HistoryActionTypeEnum.GROUP) {
|
||||||
return `${historyActionTypeName[e.actionType]}`
|
return `${historyActionTypeName[e.actionType]}`
|
||||||
} else {
|
} else {
|
||||||
return `${historyActionTypeName[e.actionType]} - ${(e.historyData as CreateComponentType).chartConfig.title}`
|
return `${historyActionTypeName[e.actionType]} - ${(e.historyData[0] as CreateComponentType).chartConfig.title}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +136,8 @@ export const useMouseHandle = () => {
|
|||||||
let offsetY = (moveEvent.screenY - startY) / scale
|
let offsetY = (moveEvent.screenY - startY) / scale
|
||||||
|
|
||||||
chartEditStore.getTargetChart.selectId.forEach(id => {
|
chartEditStore.getTargetChart.selectId.forEach(id => {
|
||||||
|
if(!targetMap.has(id)) return
|
||||||
|
|
||||||
const index = chartEditStore.fetchTargetIndex(id)
|
const index = chartEditStore.fetchTargetIndex(id)
|
||||||
// 拿到初始位置数据
|
// 拿到初始位置数据
|
||||||
const { x, y, w, h } = targetMap.get(id)
|
const { x, y, w, h } = targetMap.get(id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user