feat: 组件ChartsItemBox支持双击添加图标

This commit is contained in:
tnt group 2022-09-16 10:30:53 +08:00
parent 05849a3d92
commit d4ba828d08

View File

@ -8,6 +8,7 @@
draggable
@dragstart="dragStartHandle($event, item)"
@dragend="dragendHandle"
@dblclick="dblclickHandle(item)"
>
<div class="list-header">
<mac-os-control-btn :mini="true" :disabled="true"></mac-os-control-btn>
@ -25,9 +26,10 @@ import { PropType } from 'vue'
import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { componentInstall } from '@/utils'
import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils'
import { DragKeyEnum } from '@/enums/editPageEnum'
import { ConfigType } from '@/packages/index.d'
import { createComponent } from '@/packages'
import { ConfigType, CreateComponentType } from '@/packages/index.d'
import { fetchConfigComponent, fetchChartComponent } from '@/packages/index'
import omit from 'lodash/omit'
const chartEditStore = useChartEditStore()
@ -54,6 +56,26 @@ const dragStartHandle = (e: DragEvent, item: ConfigType) => {
const dragendHandle = () => {
chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_CREATE, false)
}
//
const dblclickHandle = async (item: ConfigType) => {
try {
loadingStart()
//
componentInstall(item.chartKey, fetchChartComponent(item))
componentInstall(item.conKey, fetchConfigComponent(item))
//
let newComponent: CreateComponentType = await createComponent(item)
//
chartEditStore.addComponentList(newComponent, false, true)
//
chartEditStore.setTargetSelectChart(newComponent.id)
loadingFinish()
} catch (error) {
loadingError()
window['$message'].warning(`图表正在研发中, 敬请期待...`)
}
}
</script>
<style lang="scss" scoped>