135 lines
4.1 KiB
Vue
135 lines
4.1 KiB
Vue
<template>
|
|
<div
|
|
:class="animationsClass(groupData.styles.animations)"
|
|
:style="{
|
|
...getSizeStyle(groupData.attr),
|
|
...getFilterStyle(groupData.styles),
|
|
}"
|
|
@click="clickBtn"
|
|
@dblclick="dblclickBtn"
|
|
@contextmenu="rightclickBtn"
|
|
@mouseenter="mouseenterBtn"
|
|
@mouseleave="mouseleaveBtn"
|
|
>
|
|
<div
|
|
class="chart-item"
|
|
v-for="item in groupData.groupList"
|
|
:class="animationsClass(item.styles.animations)"
|
|
:key="item.id"
|
|
:style="{
|
|
...getComponentAttrStyle(item.attr, groupIndex),
|
|
...getStatusStyle(item.status),
|
|
...getPreviewConfigStyle(item.preview),
|
|
...(getBlendModeStyle(item.styles) as any),
|
|
}"
|
|
>
|
|
<component
|
|
:is="item.chartConfig.chartKey"
|
|
:id="item.id"
|
|
:chartConfig="item"
|
|
:themeSetting="themeSetting"
|
|
:themeColor="themeColor"
|
|
:style="{
|
|
...getSizeStyle(item.attr),
|
|
...getFilterStyle(item.styles),
|
|
...getTransformStyle(item.styles),
|
|
}"
|
|
v-on="useLifeHandler(item)"
|
|
></component>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { PropType, ref } from 'vue';
|
|
import { CreateComponentGroupType } from '@/packages/index.d';
|
|
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils';
|
|
import {
|
|
getSizeStyle,
|
|
getComponentAttrStyle,
|
|
getStatusStyle,
|
|
getPreviewConfigStyle,
|
|
} from '../../utils';
|
|
import { useLifeHandler } from '@/hooks';
|
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
|
|
import { eventHandlerHook } from '@/hooks/eventHandler.hook';
|
|
|
|
const chartEditStore = useChartEditStore();
|
|
const props = defineProps({
|
|
groupData: {
|
|
type: Object as PropType<CreateComponentGroupType>,
|
|
required: true,
|
|
},
|
|
themeSetting: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
themeColor: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
groupIndex: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
});
|
|
console.log(props.groupData);
|
|
// 单击交互
|
|
const clickElementItem = ref([]);
|
|
// 双击交互
|
|
const dbclickElementItem = ref([]);
|
|
// 右击交互
|
|
const rightclickElementItem = ref([]);
|
|
// 鼠标移入交互
|
|
const mouseenterElementItem = ref([]);
|
|
// 鼠标移出交互
|
|
const mouseleaveElementItem = ref([]);
|
|
|
|
const list = props.groupData.events.interactConfigEvents;
|
|
for (let i = 0; i < list.length; i++) {
|
|
if (list[i].type == 'click') {
|
|
for (let j = 0; j < list[i].movementList.length; j++) {
|
|
clickElementItem.value.push(list[i].movementList[j]);
|
|
}
|
|
} else if (list[i].type == 'dblclick') {
|
|
for (let j = 0; j < list[i].movementList.length; j++) {
|
|
dbclickElementItem.value.push(list[i].movementList[j]);
|
|
}
|
|
} else if (list[i].type == 'rightclick') {
|
|
for (let j = 0; j < list[i].movementList.length; j++) {
|
|
rightclickElementItem.value.push(list[i].movementList[j]);
|
|
}
|
|
} else if (list[i].type == 'mousein') {
|
|
for (let j = 0; j < list[i].movementList.length; j++) {
|
|
mouseenterElementItem.value.push(list[i].movementList[j]);
|
|
}
|
|
} else if (list[i].type == 'mouseout') {
|
|
for (let j = 0; j < list[i].movementList.length; j++) {
|
|
mouseleaveElementItem.value.push(list[i].movementList[j]);
|
|
}
|
|
}
|
|
}
|
|
const clickBtn = () => {
|
|
eventHandlerHook(chartEditStore.getComponentList, clickElementItem.value);
|
|
};
|
|
const dblclickBtn = () => {
|
|
eventHandlerHook(chartEditStore.getComponentList, dbclickElementItem.value);
|
|
};
|
|
const rightclickBtn = (event) => {
|
|
event.preventDefault(); // 阻止默认的右键菜单
|
|
eventHandlerHook(chartEditStore.getComponentList, rightclickElementItem.value);
|
|
};
|
|
const mouseenterBtn = () => {
|
|
eventHandlerHook(chartEditStore.getComponentList, mouseenterElementItem.value);
|
|
};
|
|
const mouseleaveBtn = () => {
|
|
eventHandlerHook(chartEditStore.getComponentList, mouseleaveElementItem.value);
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.chart-item {
|
|
position: absolute;
|
|
}
|
|
</style>
|