fix: 解决 分组复制 id 会重复的问题
This commit is contained in:
parent
df0728ea12
commit
796bfd2c98
@ -493,34 +493,31 @@ export const useChartEditStore = defineStore({
|
|||||||
}
|
}
|
||||||
const parseHandle = (e: CreateComponentType | CreateComponentGroupType) => {
|
const parseHandle = (e: CreateComponentType | CreateComponentGroupType) => {
|
||||||
e = cloneDeep(e)
|
e = cloneDeep(e)
|
||||||
// 生成新 id
|
|
||||||
e.id = getUUID()
|
|
||||||
e.attr.x = this.getMousePosition.x + 30
|
e.attr.x = this.getMousePosition.x + 30
|
||||||
e.attr.y = this.getMousePosition.y + 30
|
e.attr.y = this.getMousePosition.y + 30
|
||||||
|
// 外层生成新 id
|
||||||
|
e.id = getUUID()
|
||||||
|
// 分组列表生成新 id
|
||||||
|
if (e.isGroup) {
|
||||||
|
(e as CreateComponentGroupType).groupList.forEach((item: CreateComponentType) => {
|
||||||
|
item.id = getUUID()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
const isCut = recordCharts.type === HistoryActionTypeEnum.CUT
|
const isCut = recordCharts.type === HistoryActionTypeEnum.CUT
|
||||||
|
const targetList = Array.isArray(recordCharts.charts) ? recordCharts.charts : [ recordCharts.charts ]
|
||||||
// 多项
|
// 多项
|
||||||
if (Array.isArray(recordCharts.charts)) {
|
targetList.forEach((e: CreateComponentType | CreateComponentGroupType) => {
|
||||||
recordCharts.charts.forEach((e: CreateComponentType) => {
|
this.addComponentList(parseHandle(e), undefined, true)
|
||||||
this.addComponentList(parseHandle(e), undefined, true)
|
// 剪切需删除原数据
|
||||||
// 剪切需删除原数据
|
if (isCut) {
|
||||||
if (isCut) {
|
this.setTargetSelectChart(e.id)
|
||||||
this.setTargetSelectChart(e.id)
|
this.removeComponentList(undefined, true)
|
||||||
this.removeComponentList(undefined, true)
|
}
|
||||||
}
|
})
|
||||||
})
|
if (isCut) this.setRecordChart(undefined)
|
||||||
if (isCut) this.setRecordChart(undefined)
|
|
||||||
loadingFinish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 单项
|
|
||||||
this.addComponentList(parseHandle(recordCharts.charts), undefined, true)
|
|
||||||
if (isCut) {
|
|
||||||
this.setTargetSelectChart(recordCharts.charts.id)
|
|
||||||
this.removeComponentList()
|
|
||||||
this.setRecordChart(undefined)
|
|
||||||
}
|
|
||||||
loadingFinish()
|
loadingFinish()
|
||||||
} catch (value) {
|
} catch (value) {
|
||||||
loadingError()
|
loadingError()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user