fix: 新增图表居中拖拽

This commit is contained in:
MTrun
2022-01-27 23:16:51 +08:00
parent f57fa702d9
commit 5e07c2ca6d
9 changed files with 83 additions and 34 deletions
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia'
import debounce from 'lodash/debounce'
import { loadingStart, loadingFinish, loadingError } from '@/utils'
import {
chartEditStoreType,
EditCanvasType,
@@ -53,16 +54,23 @@ export const useChartEditStoreStore = defineStore({
},
// * 删除组件列表
removeComponentList<T extends { key: string }>(chartData: T | number): void {
if(typeof chartData === 'number') {
this.componentList.splice(chartData, 1)
return
loadingStart()
try {
if(typeof chartData === 'number') {
this.componentList.splice(chartData, 1)
loadingFinish()
return
}
const i = this.componentList.findIndex(e => e.key === chartData.key)
if (i !== -1) {
this.componentList.splice(i, 1)
loadingFinish()
return
}
window['$message'].success(`图表删除失败,无法找到此元素`)
} catch(value) {
loadingError()
}
const i = this.componentList.findIndex(e => e.key === chartData.key)
if (i !== -1) {
this.componentList.splice(i, 1)
return
}
window['$message'].success(`图表删除失败,无法找到此元素`)
},
// * 设置数据项
setEditCanvasItem<