115 lines
3.2 KiB
Vue
Raw Normal View History

2022-01-20 21:25:35 +08:00
<template>
<ContentBox
id="go-chart-edit-layout"
ref="editDomRef"
:flex="true"
:showTop="false"
:showBottom="true"
:depth="1"
2022-01-28 21:05:07 +08:00
:xScroll="true"
@drop="handleDrag"
2022-01-24 21:12:18 +08:00
@dragover="handleDragOver"
2022-01-20 21:25:35 +08:00
>
<div id="go-chart-edit-content">
2022-01-26 17:38:16 +08:00
<!-- 展示 -->
2022-01-30 14:20:28 +08:00
<EditRange ref="editRangeRef">
2022-01-29 23:58:56 +08:00
<!-- 图表 -->
2022-02-10 20:01:22 +08:00
<EditShapeBox
2022-01-26 17:38:16 +08:00
v-for="(item, index) in chartEditStore.getComponentList"
2022-01-25 22:41:12 +08:00
:key="item.id"
2022-01-29 23:58:56 +08:00
:data-id="item.id"
2022-01-27 20:47:22 +08:00
:index="index"
2022-01-26 17:38:16 +08:00
:style="useComponentStyle(item.attr, index)"
2022-01-29 23:58:56 +08:00
:item="item"
@mousedown="mousedownHandle($event, item)"
@mouseenter="mouseenterHandle($event, item)"
@mouseleave="mouseleaveHandle($event, item)"
2022-02-01 01:20:00 +08:00
@contextmenu="handleContextMenu($event, item)"
2022-01-27 20:47:22 +08:00
>
<component
class="edit-content-chart"
:is="item.key"
:chartConfig="item"
2022-02-21 19:45:11 +08:00
:themeSetting="themeSetting"
:themeColor="themeColor"
2022-01-27 20:47:22 +08:00
:style="useSizeStyle(item.attr)"
/>
2022-02-10 20:01:22 +08:00
</EditShapeBox>
2022-01-25 18:19:44 +08:00
</EditRange>
2022-01-20 21:25:35 +08:00
</div>
<!-- 底部控制 -->
<template #bottom>
2022-01-21 17:55:35 +08:00
<EditBottom />
</template>
2022-01-20 21:25:35 +08:00
</ContentBox>
</template>
<script lang="ts" setup>
2022-02-06 01:04:05 +08:00
import { ref, onMounted, computed } from 'vue'
2022-01-20 21:25:35 +08:00
import { ContentBox } from '../ContentBox/index'
import { EditRange } from './components/EditRange'
2022-01-21 17:55:35 +08:00
import { EditBottom } from './components/EditBottom'
2022-02-10 20:01:22 +08:00
import { EditShapeBox } from './components/EditShapeBox/index'
2022-01-27 22:30:35 +08:00
2022-01-30 19:38:12 +08:00
import { useLayout } from './hooks/useLayout.hook'
2022-02-04 18:28:02 +08:00
import { useAddKeyboard } from '../hooks/useKeyboard.hook'
import { handleDrag, handleDragOver, useMouseHandle } from './hooks/useDrag.hook'
import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
2022-01-25 18:19:44 +08:00
import { getChartEditStore } from './hooks/useStore.hook'
2022-01-27 20:47:22 +08:00
import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook'
2022-01-30 14:20:28 +08:00
import { CreateComponentType } from '@/packages/index.d'
2022-02-06 01:04:05 +08:00
import { chartColors } from '@/settings/chartThemes/index'
2022-01-25 18:19:44 +08:00
const chartEditStore = getChartEditStore()
const { handleContextMenu } = useContextMenu()
2022-01-29 23:58:56 +08:00
2022-01-24 16:25:43 +08:00
// 布局处理
useLayout()
2022-01-30 14:20:28 +08:00
// 点击事件
const editRangeRef = ref<HTMLElement | null>(null)
const { mouseenterHandle, mouseleaveHandle, mousedownHandle } = useMouseHandle()
2022-02-03 22:54:31 +08:00
2022-02-21 19:45:11 +08:00
// 主题色
const themeSetting = computed(() => {
const chartThemeSetting = chartEditStore.getEditCanvasConfig.chartThemeSetting
return chartThemeSetting
})
// 配置项
const themeColor = computed(() => {
const chartThemeColor = chartEditStore.getEditCanvasConfig.chartThemeColor
return chartColors[chartThemeColor]
2022-02-06 01:04:05 +08:00
})
2022-02-03 22:54:31 +08:00
// 键盘事件
onMounted(() => {
useAddKeyboard()
})
2022-01-20 21:25:35 +08:00
</script>
<style lang="scss" scoped>
@include goId(chart-edit-layout) {
position: relative;
width: 100%;
2022-01-21 17:55:35 +08:00
overflow: hidden;
2022-01-27 20:47:22 +08:00
@include background-image('background-point');
2022-01-20 21:25:35 +08:00
@extend .go-point-bg;
@include goId(chart-edit-content) {
2022-01-27 20:47:22 +08:00
margin: 20px;
/* overflow: hidden; */
2022-01-20 21:25:35 +08:00
transform-origin: left top;
border: 1px solid rgba(0, 0, 0, 0);
2022-01-20 21:25:35 +08:00
@extend .go-transition;
&.content-resize {
border-radius: 15px;
2022-01-27 20:47:22 +08:00
@include hover-border-color('hover-border-color');
2022-01-25 22:41:12 +08:00
}
2022-01-27 20:47:22 +08:00
.edit-content-chart {
2022-01-25 22:41:12 +08:00
position: absolute;
}
2022-01-20 21:25:35 +08:00
}
}
</style>