mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-25 00:33:00 +08:00
fix: 处理无数据删除会报错的bug
This commit is contained in:
parent
57be88e8aa
commit
5dd6f88a42
@ -1,3 +1,4 @@
|
|||||||
|
import { toRaw } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||||
import { PublicGroupConfigClass } from '@/packages/public/publicConfig'
|
import { PublicGroupConfigClass } from '@/packages/public/publicConfig'
|
||||||
@ -294,10 +295,12 @@ export const useChartEditStore = defineStore({
|
|||||||
// * 删除组件
|
// * 删除组件
|
||||||
removeComponentList(id?:string | string[], isHistory = true): void {
|
removeComponentList(id?:string | string[], isHistory = true): void {
|
||||||
try {
|
try {
|
||||||
loadingStart()
|
|
||||||
const idArr = this.idPreFormat(id)
|
const idArr = this.idPreFormat(id)
|
||||||
const history: Array<CreateComponentType | CreateComponentGroupType> = []
|
const history: Array<CreateComponentType | CreateComponentGroupType> = []
|
||||||
// 遍历所有对象
|
// 遍历所有对象
|
||||||
|
if (!idArr.length) return
|
||||||
|
|
||||||
|
loadingStart()
|
||||||
idArr.forEach(ids => {
|
idArr.forEach(ids => {
|
||||||
const index = this.fetchTargetIndex(ids)
|
const index = this.fetchTargetIndex(ids)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@ -639,6 +642,7 @@ export const useChartEditStore = defineStore({
|
|||||||
b: 0
|
b: 0
|
||||||
}
|
}
|
||||||
const targetList: CreateComponentType[] = []
|
const targetList: CreateComponentType[] = []
|
||||||
|
const historyList: CreateComponentType[] = []
|
||||||
|
|
||||||
// 若目标中有数组则先解组
|
// 若目标中有数组则先解组
|
||||||
const newSelectIds: string[] = []
|
const newSelectIds: string[] = []
|
||||||
@ -670,10 +674,12 @@ export const useChartEditStore = defineStore({
|
|||||||
groupAttr.b = b < y + h ? y + h : b
|
groupAttr.b = b < y + h ? y + h : b
|
||||||
|
|
||||||
targetList.push(item)
|
targetList.push(item)
|
||||||
|
historyList.push(toRaw(item))
|
||||||
})
|
})
|
||||||
|
|
||||||
// 修改原数据之前,先记录
|
// 修改原数据之前,先记录
|
||||||
if(isHistory) chartHistoryStore.createGroupHistory(targetList)
|
console.log(historyList)
|
||||||
|
if(isHistory) chartHistoryStore.createGroupHistory(historyList)
|
||||||
|
|
||||||
// 设置子组件的位置
|
// 设置子组件的位置
|
||||||
targetList.forEach((item: CreateComponentType) => {
|
targetList.forEach((item: CreateComponentType) => {
|
||||||
@ -710,6 +716,9 @@ export const useChartEditStore = defineStore({
|
|||||||
const targetGroup = this.getComponentList[targetIndex] as CreateComponentGroupType
|
const targetGroup = this.getComponentList[targetIndex] as CreateComponentGroupType
|
||||||
if (!targetGroup.isGroup) return
|
if (!targetGroup.isGroup) return
|
||||||
|
|
||||||
|
// 记录数据
|
||||||
|
if(isHistory) chartHistoryStore.createUnGroupHistory([targetGroup])
|
||||||
|
|
||||||
// 分离组件并还原位置属性
|
// 分离组件并还原位置属性
|
||||||
targetGroup.groupList.forEach(item => {
|
targetGroup.groupList.forEach(item => {
|
||||||
item.attr.x = item.attr.x + targetGroup.attr.x
|
item.attr.x = item.attr.x + targetGroup.attr.x
|
||||||
|
@ -95,7 +95,7 @@ const labelHandle = (e: HistoryItemType) => {
|
|||||||
return historyActionTypeName[HistoryTargetTypeEnum.CANVAS]
|
return historyActionTypeName[HistoryTargetTypeEnum.CANVAS]
|
||||||
} else if (e.actionType === HistoryActionTypeEnum.GROUP) {
|
} else if (e.actionType === HistoryActionTypeEnum.GROUP) {
|
||||||
return `${historyActionTypeName[e.actionType]}`
|
return `${historyActionTypeName[e.actionType]}`
|
||||||
} else {
|
} else if (e.historyData.length) {
|
||||||
return `${historyActionTypeName[e.actionType]} - ${(e.historyData[0] as CreateComponentType).chartConfig.title}`
|
return `${historyActionTypeName[e.actionType]} - ${(e.historyData[0] as CreateComponentType).chartConfig.title}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +108,10 @@ const options = computed(() => {
|
|||||||
icon: iconHandle(e)
|
icon: iconHandle(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return reverse(options)
|
|
||||||
|
return reverse(options.filter(item => {
|
||||||
|
return item.label
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user