2022-01-20 21:25:35 +08:00
|
|
|
<template>
|
2022-08-21 14:42:31 +08:00
|
|
|
<edit-rule></edit-rule>
|
2022-03-14 19:52:01 +08:00
|
|
|
<content-box
|
2022-01-20 21:25:35 +08:00
|
|
|
id="go-chart-edit-layout"
|
|
|
|
:flex="true"
|
|
|
|
:showTop="false"
|
|
|
|
:showBottom="true"
|
|
|
|
:depth="1"
|
2022-01-28 21:05:07 +08:00
|
|
|
:xScroll="true"
|
2022-04-11 18:17:09 +08:00
|
|
|
@drop="dragHandle"
|
|
|
|
@dragover="dragoverHandle"
|
|
|
|
@dragenter="dragoverHandle"
|
2022-01-20 21:25:35 +08:00
|
|
|
>
|
2022-04-09 16:40:57 +08:00
|
|
|
<!-- 画布主体 -->
|
2022-03-28 17:17:44 +08:00
|
|
|
<div id="go-chart-edit-content" @contextmenu="handleContextMenu">
|
2022-01-26 17:38:16 +08:00
|
|
|
<!-- 展示 -->
|
2022-03-15 17:49:02 +08:00
|
|
|
<edit-range>
|
2022-05-03 16:43:23 +08:00
|
|
|
<!-- 滤镜预览 -->
|
2022-08-06 18:16:48 +08:00
|
|
|
<div
|
|
|
|
:style="{
|
2022-05-04 13:21:27 +08:00
|
|
|
...getFilterStyle(chartEditStore.getEditCanvasConfig),
|
|
|
|
...rangeStyle
|
2022-08-06 18:16:48 +08:00
|
|
|
}"
|
|
|
|
>
|
2022-05-03 16:43:23 +08:00
|
|
|
<!-- 图表 -->
|
2022-08-06 18:16:48 +08:00
|
|
|
<div v-for="(item, index) in chartEditStore.getComponentList" :key="item.id">
|
2022-08-12 20:39:20 +08:00
|
|
|
<!-- 分组 -->
|
2022-08-21 14:42:31 +08:00
|
|
|
<edit-group
|
|
|
|
v-if="item.isGroup"
|
|
|
|
:groupData="(item as CreateComponentGroupType)"
|
|
|
|
:groupIndex="index"
|
|
|
|
></edit-group>
|
|
|
|
|
2022-08-06 18:16:48 +08:00
|
|
|
<!-- 单组件 -->
|
|
|
|
<edit-shape-box
|
2022-08-15 11:43:32 +08:00
|
|
|
v-else
|
2022-08-06 18:16:48 +08:00
|
|
|
:data-id="item.id"
|
|
|
|
:index="index"
|
|
|
|
:style="useComponentStyle(item.attr, index)"
|
|
|
|
:item="item"
|
|
|
|
@click="mouseClickHandle($event, item)"
|
|
|
|
@mousedown="mousedownHandle($event, item)"
|
|
|
|
@mouseenter="mouseenterHandle($event, item)"
|
|
|
|
@mouseleave="mouseleaveHandle($event, item)"
|
|
|
|
@contextmenu="handleContextMenu($event, item, optionsHandle)"
|
|
|
|
>
|
|
|
|
<component
|
|
|
|
class="edit-content-chart"
|
|
|
|
:class="animationsClass(item.styles.animations)"
|
|
|
|
:is="item.chartConfig.chartKey"
|
|
|
|
:chartConfig="item"
|
|
|
|
:themeSetting="themeSetting"
|
|
|
|
:themeColor="themeColor"
|
|
|
|
:style="{
|
|
|
|
...useSizeStyle(item.attr),
|
|
|
|
...getFilterStyle(item.styles),
|
|
|
|
...getTransformStyle(item.styles)
|
|
|
|
}"
|
|
|
|
></component>
|
|
|
|
</edit-shape-box>
|
|
|
|
</div>
|
2022-05-03 16:43:23 +08:00
|
|
|
</div>
|
2022-03-14 19:52:01 +08:00
|
|
|
</edit-range>
|
2022-01-20 21:25:35 +08:00
|
|
|
</div>
|
2022-04-09 16:40:57 +08:00
|
|
|
|
|
|
|
<!-- 工具栏 -->
|
|
|
|
<template #aside>
|
|
|
|
<edit-tools></edit-tools>
|
|
|
|
</template>
|
|
|
|
|
2022-01-20 21:25:35 +08:00
|
|
|
<!-- 底部控制 -->
|
2022-01-23 01:12:49 +08:00
|
|
|
<template #bottom>
|
2022-03-14 16:07:35 +08:00
|
|
|
<EditBottom></EditBottom>
|
2022-01-21 17:55:35 +08:00
|
|
|
</template>
|
2022-03-14 19:52:01 +08:00
|
|
|
</content-box>
|
2022-01-20 21:25:35 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2022-03-15 17:49:02 +08:00
|
|
|
import { onMounted, computed } from 'vue'
|
2022-05-03 16:43:23 +08:00
|
|
|
import { chartColors } from '@/settings/chartThemes/index'
|
2022-08-06 17:20:56 +08:00
|
|
|
import { MenuEnum } from '@/enums/editPageEnum'
|
|
|
|
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
2022-06-29 09:55:44 +08:00
|
|
|
import { animationsClass, getFilterStyle, getTransformStyle } from '@/utils'
|
2022-05-03 16:43:23 +08:00
|
|
|
import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
|
2022-08-06 17:20:56 +08:00
|
|
|
import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d'
|
2022-05-03 16:43:23 +08:00
|
|
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
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'
|
2022-05-23 23:50:35 +08:00
|
|
|
import { useSync } from '../hooks/useSync.hook'
|
2022-04-11 18:17:09 +08:00
|
|
|
import { dragHandle, dragoverHandle, useMouseHandle } from './hooks/useDrag.hook'
|
2022-01-27 20:47:22 +08:00
|
|
|
import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook'
|
2022-05-03 16:43:23 +08:00
|
|
|
|
2022-05-10 17:56:45 +08:00
|
|
|
import { ContentBox } from '../ContentBox/index'
|
2022-08-06 18:16:48 +08:00
|
|
|
import { EditGroup } from './components/EditGroup'
|
2022-05-03 16:43:23 +08:00
|
|
|
import { EditRange } from './components/EditRange'
|
2022-08-21 14:42:31 +08:00
|
|
|
import { EditRule } from './components/EditRule'
|
2022-05-03 16:43:23 +08:00
|
|
|
import { EditBottom } from './components/EditBottom'
|
|
|
|
import { EditShapeBox } from './components/EditShapeBox'
|
|
|
|
import { EditTools } from './components/EditTools'
|
2022-01-25 18:19:44 +08:00
|
|
|
|
2022-03-04 20:57:36 +08:00
|
|
|
const chartEditStore = useChartEditStore()
|
2022-01-31 23:37:43 +08:00
|
|
|
const { handleContextMenu } = useContextMenu()
|
2022-05-24 17:42:49 +08:00
|
|
|
const { dataSyncFetch, intervalDataSyncUpdate } = useSync()
|
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
|
|
|
|
|
|
|
// 点击事件
|
2022-06-28 21:57:29 +08:00
|
|
|
const { mouseenterHandle, mouseleaveHandle, mousedownHandle, mouseClickHandle } = useMouseHandle()
|
2022-02-03 22:54:31 +08:00
|
|
|
|
2022-08-06 17:20:56 +08:00
|
|
|
// 右键事件
|
2022-08-06 18:16:48 +08:00
|
|
|
const optionsHandle = (
|
|
|
|
targetList: MenuOptionsItemType[],
|
|
|
|
allList: MenuOptionsItemType[],
|
2022-08-14 01:04:03 +08:00
|
|
|
targetInstance: CreateComponentType
|
2022-08-06 18:16:48 +08:00
|
|
|
) => {
|
2022-08-15 16:50:52 +08:00
|
|
|
// 多选
|
|
|
|
const moreMenuEnums = [MenuEnum.GROUP, MenuEnum.DELETE]
|
|
|
|
// 单选
|
|
|
|
const singleMenuEnums = targetList
|
|
|
|
|
2022-08-06 17:20:56 +08:00
|
|
|
// 多选处理
|
2022-08-06 18:16:48 +08:00
|
|
|
if (chartEditStore.getTargetChart.selectId.length > 1) {
|
|
|
|
const list: MenuOptionsItemType[] = []
|
2022-08-21 14:42:31 +08:00
|
|
|
|
2022-08-15 16:50:52 +08:00
|
|
|
allList.forEach(item => {
|
2022-08-06 18:16:48 +08:00
|
|
|
// 成组
|
2022-08-15 16:50:52 +08:00
|
|
|
if (moreMenuEnums.includes(item.key as MenuEnum)) {
|
2022-08-06 18:16:48 +08:00
|
|
|
list.push(item)
|
2022-08-06 17:20:56 +08:00
|
|
|
}
|
|
|
|
})
|
2022-08-06 18:16:48 +08:00
|
|
|
return list
|
2022-08-06 17:20:56 +08:00
|
|
|
}
|
2022-08-15 16:50:52 +08:00
|
|
|
return singleMenuEnums
|
2022-08-06 17:20:56 +08:00
|
|
|
}
|
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-05-04 13:21:27 +08:00
|
|
|
// 背景
|
|
|
|
const rangeStyle = computed(() => {
|
|
|
|
// 设置背景色和图片背景
|
|
|
|
const background = chartEditStore.getEditCanvasConfig.background
|
|
|
|
const backgroundImage = chartEditStore.getEditCanvasConfig.backgroundImage
|
|
|
|
const selectColor = chartEditStore.getEditCanvasConfig.selectColor
|
|
|
|
const backgroundColor = background ? background : undefined
|
|
|
|
|
|
|
|
const computedBackground = selectColor
|
|
|
|
? { background: backgroundColor }
|
2022-07-26 15:35:23 +08:00
|
|
|
: { background: `url(${backgroundImage}) no-repeat center center / cover !important` }
|
2022-05-04 13:21:27 +08:00
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
return {
|
|
|
|
...computedBackground,
|
|
|
|
width: 'inherit',
|
|
|
|
height: 'inherit'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-02-03 22:54:31 +08:00
|
|
|
onMounted(() => {
|
2022-05-23 23:50:35 +08:00
|
|
|
// 键盘事件
|
2022-02-03 22:54:31 +08:00
|
|
|
useAddKeyboard()
|
2022-05-23 23:50:35 +08:00
|
|
|
// 获取数据
|
|
|
|
dataSyncFetch()
|
2022-05-24 17:42:49 +08:00
|
|
|
// 定时更新数据
|
|
|
|
intervalDataSyncUpdate()
|
2022-02-03 22:54:31 +08:00
|
|
|
})
|
2022-01-20 21:25:35 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-04-09 16:40:57 +08:00
|
|
|
@include goId('chart-edit-layout') {
|
2022-01-20 21:25:35 +08:00
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
2022-01-21 17:55:35 +08:00
|
|
|
overflow: hidden;
|
2022-01-20 21:25:35 +08:00
|
|
|
@extend .go-point-bg;
|
2022-04-09 16:40:57 +08:00
|
|
|
@include background-image('background-point');
|
|
|
|
@include goId('chart-edit-content') {
|
2022-04-05 20:16:59 +08:00
|
|
|
border-radius: 10px;
|
2022-08-21 14:42:31 +08:00
|
|
|
margin: 25px;
|
2022-04-07 19:33:49 +08:00
|
|
|
overflow: hidden;
|
2022-01-20 21:25:35 +08:00
|
|
|
@extend .go-transition;
|
2022-04-09 16:40:57 +08:00
|
|
|
@include fetch-theme('box-shadow');
|
2022-01-27 20:47:22 +08:00
|
|
|
.edit-content-chart {
|
2022-01-25 22:41:12 +08:00
|
|
|
position: absolute;
|
2022-04-07 09:57:00 +08:00
|
|
|
overflow: hidden;
|
2022-01-23 01:12:49 +08:00
|
|
|
}
|
2022-01-20 21:25:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|