diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 01d6d4b5..36ad45d7 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -1,3 +1,4 @@ +import { toRaw } from 'vue' import { defineStore } from 'pinia' import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { PublicGroupConfigClass } from '@/packages/public/publicConfig' @@ -294,10 +295,12 @@ export const useChartEditStore = defineStore({ // * 删除组件 removeComponentList(id?:string | string[], isHistory = true): void { try { - loadingStart() const idArr = this.idPreFormat(id) const history: Array = [] // 遍历所有对象 + if (!idArr.length) return + + loadingStart() idArr.forEach(ids => { const index = this.fetchTargetIndex(ids) if (index !== -1) { @@ -639,6 +642,7 @@ export const useChartEditStore = defineStore({ b: 0 } const targetList: CreateComponentType[] = [] + const historyList: CreateComponentType[] = [] // 若目标中有数组则先解组 const newSelectIds: string[] = [] @@ -670,10 +674,12 @@ export const useChartEditStore = defineStore({ groupAttr.b = b < y + h ? y + h : b targetList.push(item) + historyList.push(toRaw(item)) }) // 修改原数据之前,先记录 - if(isHistory) chartHistoryStore.createGroupHistory(targetList) + console.log(historyList) + if(isHistory) chartHistoryStore.createGroupHistory(historyList) // 设置子组件的位置 targetList.forEach((item: CreateComponentType) => { @@ -709,6 +715,9 @@ export const useChartEditStore = defineStore({ const unGroup = (targetIndex: number) => { const targetGroup = this.getComponentList[targetIndex] as CreateComponentGroupType if (!targetGroup.isGroup) return + + // 记录数据 + if(isHistory) chartHistoryStore.createUnGroupHistory([targetGroup]) // 分离组件并还原位置属性 targetGroup.groupList.forEach(item => { diff --git a/src/views/chart/ContentEdit/components/EditHistory/index.vue b/src/views/chart/ContentEdit/components/EditHistory/index.vue index 45757828..de4cf48c 100644 --- a/src/views/chart/ContentEdit/components/EditHistory/index.vue +++ b/src/views/chart/ContentEdit/components/EditHistory/index.vue @@ -95,7 +95,7 @@ const labelHandle = (e: HistoryItemType) => { return historyActionTypeName[HistoryTargetTypeEnum.CANVAS] } else if (e.actionType === HistoryActionTypeEnum.GROUP) { return `${historyActionTypeName[e.actionType]}` - } else { + } else if (e.historyData.length) { return `${historyActionTypeName[e.actionType]} - ${(e.historyData[0] as CreateComponentType).chartConfig.title}` } } @@ -108,7 +108,10 @@ const options = computed(() => { icon: iconHandle(e) } }) - return reverse(options) + + return reverse(options.filter(item => { + return item.label + })) })