Compare commits

...

2 Commits

Author SHA1 Message Date
刘妍 3b3c6ac8c2 Merge branch 'main' of http://123.132.248.154:10000/gitY/LinYeFangHuo 2025-02-19 09:34:57 +08:00
刘妍 b9a36b51c2 分组事件 2025-02-19 09:34:53 +08:00
5 changed files with 367 additions and 289 deletions

View File

@ -67,24 +67,19 @@
} }
} }
const clickBtn = () => { const clickBtn = () => {
console.log('单击');
eventHandlerHook(chartEditStore.getComponentList, clickElementItem.value); eventHandlerHook(chartEditStore.getComponentList, clickElementItem.value);
}; };
const dblclickBtn = () => { const dblclickBtn = () => {
console.log('双击');
eventHandlerHook(chartEditStore.getComponentList, dbclickElementItem.value); eventHandlerHook(chartEditStore.getComponentList, dbclickElementItem.value);
}; };
const rightclickBtn = (event) => { const rightclickBtn = (event) => {
console.log('右击');
event.preventDefault(); // event.preventDefault(); //
eventHandlerHook(chartEditStore.getComponentList, rightclickElementItem.value); eventHandlerHook(chartEditStore.getComponentList, rightclickElementItem.value);
}; };
const mouseenterBtn = () => { const mouseenterBtn = () => {
console.log('鼠标移入');
eventHandlerHook(chartEditStore.getComponentList, mouseenterElementItem.value); eventHandlerHook(chartEditStore.getComponentList, mouseenterElementItem.value);
}; };
const mouseleaveBtn = () => { const mouseleaveBtn = () => {
console.log('鼠标移出');
eventHandlerHook(chartEditStore.getComponentList, mouseleaveElementItem.value); eventHandlerHook(chartEditStore.getComponentList, mouseleaveElementItem.value);
}; };
</script> </script>

View File

@ -37,7 +37,13 @@
</n-tabs> </n-tabs>
<!-- 编辑 --> <!-- 编辑 -->
<n-tabs v-if="selectTarget" v-model:value="tabsSelect" class="tabs-box" size="small" type="segment"> <n-tabs
v-if="selectTarget"
v-model:value="tabsSelect"
class="tabs-box"
size="small"
type="segment"
>
<n-tab-pane <n-tab-pane
v-for="item in selectTarget.isGroup ? chartsDefaultTabList : chartsTabList" v-for="item in selectTarget.isGroup ? chartsDefaultTabList : chartsTabList"
:key="item.key" :key="item.key"
@ -62,105 +68,113 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, toRefs, watch, computed } from 'vue' import { ref, toRefs, watch, computed } from 'vue';
import { icon } from '@/plugins' import { icon } from '@/plugins';
import { loadAsyncComponent ,acquiesceAsyncComponent} from '@/utils' import { loadAsyncComponent, acquiesceAsyncComponent } from '@/utils';
import { ContentBox } from '../ContentBox/index' import { ContentBox } from '../ContentBox/index';
import { TabsEnum } from './index.d' import { TabsEnum } from './index.d';
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore';
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d';
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
const { getDetails } = toRefs(useChartLayoutStore()) const { getDetails } = toRefs(useChartLayoutStore());
const { setItem } = useChartLayoutStore() const { setItem } = useChartLayoutStore();
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore();
const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, RocketIcon } = icon.ionicons5 const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, RocketIcon } = icon.ionicons5;
const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue')) const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'));
const CanvasPage = acquiesceAsyncComponent(() => import('./components/CanvasPage/index.vue')) const CanvasPage = acquiesceAsyncComponent(() => import('./components/CanvasPage/index.vue'));
const ChartSetting = loadAsyncComponent(() => import('./components/ChartSetting/index.vue')) const ChartSetting = loadAsyncComponent(() => import('./components/ChartSetting/index.vue'));
const ChartData = loadAsyncComponent(() => import('./components/ChartData/index.vue')) const ChartData = loadAsyncComponent(() => import('./components/ChartData/index.vue'));
const ChartEvent = loadAsyncComponent(() => import('./components/ChartEvent/index.vue')) const ChartEvent = loadAsyncComponent(() => import('./components/ChartEvent/index.vue'));
const ChartAnimation = loadAsyncComponent(() => import('./components/ChartAnimation/index.vue')) const ChartAnimation = loadAsyncComponent(() => import('./components/ChartAnimation/index.vue'));
const collapsed = ref<boolean>(getDetails.value) const collapsed = ref<boolean>(getDetails.value);
const tabsSelect = ref<TabsEnum>(TabsEnum.CHART_SETTING) const tabsSelect = ref<TabsEnum>(TabsEnum.CHART_SETTING);
const collapsedHandle = () => { const collapsedHandle = () => {
collapsed.value = true collapsed.value = true;
setItem(ChartLayoutStoreEnum.DETAILS, true) setItem(ChartLayoutStoreEnum.DETAILS, true);
} };
const expandHandle = () => { const expandHandle = () => {
collapsed.value = false collapsed.value = false;
setItem(ChartLayoutStoreEnum.DETAILS, false) setItem(ChartLayoutStoreEnum.DETAILS, false);
} };
const selectTarget = computed(() => { const selectTarget = computed(() => {
const selectId = chartEditStore.getTargetChart.selectId const selectId = chartEditStore.getTargetChart.selectId;
// //
if (selectId.length !== 1) return undefined if (selectId.length !== 1) return undefined;
const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()] const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()];
if (target?.isGroup) { if (target?.isGroup) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties // eslint-disable-next-line vue/no-side-effects-in-computed-properties
tabsSelect.value = TabsEnum.CHART_SETTING tabsSelect.value = TabsEnum.CHART_SETTING;
} }
return target return target;
}) });
watch(getDetails, newData => { watch(getDetails, (newData) => {
if (newData) { if (newData) {
collapsedHandle() collapsedHandle();
} else { } else {
expandHandle() expandHandle();
} }
}) });
// //
const globalTabList = [ const globalTabList = [
{ {
key: TabsEnum.PAGE_SETTING, key: TabsEnum.PAGE_SETTING,
title: '页面配置', title: '页面配置',
icon: DesktopOutlineIcon, icon: DesktopOutlineIcon,
render: CanvasPage render: CanvasPage,
} },
] ];
const defaultTabList = [
const chartsDefaultTabList = [
{ {
key: TabsEnum.CHART_SETTING, key: TabsEnum.CHART_SETTING,
title: '定制', title: '定制',
icon: ConstructIcon, icon: ConstructIcon,
render: ChartSetting render: ChartSetting,
}, },
{ {
key: TabsEnum.CHART_ANIMATION, key: TabsEnum.CHART_ANIMATION,
title: '动画', title: '动画',
icon: LeafIcon, icon: LeafIcon,
render: ChartAnimation render: ChartAnimation,
} },
] ];
const chartsDefaultTabList = [
...defaultTabList,
{
key: TabsEnum.CHART_EVENT,
title: '事件',
icon: RocketIcon,
render: ChartEvent,
},
];
const chartsTabList = [ const chartsTabList = [
...chartsDefaultTabList, ...defaultTabList,
{ {
key: TabsEnum.CHART_DATA, key: TabsEnum.CHART_DATA,
title: '数据', title: '数据',
icon: FlashIcon, icon: FlashIcon,
render: ChartData render: ChartData,
}, },
{ {
key: TabsEnum.CHART_EVENT, key: TabsEnum.CHART_EVENT,
title: '事件', title: '事件',
icon: RocketIcon, icon: RocketIcon,
render: ChartEvent render: ChartEvent,
} },
] ];
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@include go(content-configurations) { @include go(content-configurations) {
overflow: hidden; overflow: hidden;
.tabs-box { .tabs-box {
padding: 10px; padding: 10px;
@ -168,5 +182,5 @@ const chartsTabList = [
padding-top: 2px; padding-top: 2px;
} }
} }
} }
</style> </style>

View File

@ -12,7 +12,7 @@
...useSizeStyle(groupData.attr), ...useSizeStyle(groupData.attr),
...getFilterStyle(groupData.styles), ...getFilterStyle(groupData.styles),
...getTransformStyle(groupData.styles), ...getTransformStyle(groupData.styles),
...getBlendModeStyle(groupData.styles) as any ...(getBlendModeStyle(groupData.styles) as any),
}" }"
@click="mouseClickHandle($event, groupData)" @click="mouseClickHandle($event, groupData)"
@mousedown="mousedownHandle($event, groupData)" @mousedown="mousedownHandle($event, groupData)"
@ -29,7 +29,7 @@
:item="item" :item="item"
:hiddenPoint="true" :hiddenPoint="true"
:style="{ :style="{
...useComponentStyle(item.attr, groupIndex) ...useComponentStyle(item.attr, groupIndex),
}" }"
> >
<component <component
@ -42,7 +42,7 @@
:style="{ :style="{
...useSizeStyle(item.attr), ...useSizeStyle(item.attr),
...getFilterStyle(item.styles), ...getFilterStyle(item.styles),
...getTransformStyle(item.styles) ...getTransformStyle(item.styles),
}" }"
></component> ></component>
</edit-shape-box> </edit-shape-box>
@ -51,79 +51,88 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, PropType } from 'vue' import { computed, PropType } from 'vue';
import { MenuEnum } from '@/enums/editPageEnum' import { MenuEnum } from '@/enums/editPageEnum';
import { chartColors } from '@/settings/chartThemes/index' import { chartColors } from '@/settings/chartThemes/index';
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d';
import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d' import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d';
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle, colorCustomMerge } from '@/utils' import {
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' animationsClass,
import { useContextMenu, divider } from '@/views/chart/hooks/useContextMenu.hook' getFilterStyle,
import { useMouseHandle } from '../../hooks/useDrag.hook' getTransformStyle,
import { useComponentStyle, useSizeStyle } from '../../hooks/useStyle.hook' getBlendModeStyle,
import { EditShapeBox } from '../../components/EditShapeBox' colorCustomMerge,
} from '@/utils';
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
import { useContextMenu, divider } from '@/views/chart/hooks/useContextMenu.hook';
import { useMouseHandle } from '../../hooks/useDrag.hook';
import { useComponentStyle, useSizeStyle } from '../../hooks/useStyle.hook';
import { EditShapeBox } from '../../components/EditShapeBox';
const props = defineProps({ const props = defineProps({
groupData: { groupData: {
type: Object as PropType<CreateComponentGroupType>, type: Object as PropType<CreateComponentGroupType>,
required: true required: true,
}, },
groupIndex: { groupIndex: {
type: Number, type: Number,
required: true required: true,
} },
}) });
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore();
const { handleContextMenu } = useContextMenu() const { handleContextMenu } = useContextMenu();
// //
const { mouseenterHandle, mouseleaveHandle, mousedownHandle, mouseClickHandle } = useMouseHandle() const { mouseenterHandle, mouseleaveHandle, mousedownHandle, mouseClickHandle } =
useMouseHandle();
// //
const optionsHandle = ( const optionsHandle = (
targetList: MenuOptionsItemType[], targetList: MenuOptionsItemType[],
allList: MenuOptionsItemType[], allList: MenuOptionsItemType[],
targetInstance: CreateComponentType targetInstance: CreateComponentType,
) => { ) => {
const filter = (menulist: MenuEnum[]) => { const filter = (menulist: MenuEnum[]) => {
return allList.filter(i => menulist.includes(i.key as MenuEnum)) return allList.filter((i) => menulist.includes(i.key as MenuEnum));
} };
// //
if (chartEditStore.getTargetChart.selectId.length > 1) { if (chartEditStore.getTargetChart.selectId.length > 1) {
return filter([MenuEnum.GROUP, MenuEnum.DELETE]) return filter([MenuEnum.GROUP, MenuEnum.DELETE]);
} else { } else {
const statusMenuEnums: MenuEnum[] = [] const statusMenuEnums: MenuEnum[] = [];
if (targetInstance.status.lock) { if (targetInstance.status.lock) {
statusMenuEnums.push(MenuEnum.LOCK) statusMenuEnums.push(MenuEnum.LOCK);
} else { } else {
statusMenuEnums.push(MenuEnum.UNLOCK) statusMenuEnums.push(MenuEnum.UNLOCK);
} }
if (targetInstance.status.hide) { if (targetInstance.status.hide) {
statusMenuEnums.push(MenuEnum.HIDE) statusMenuEnums.push(MenuEnum.HIDE);
} else { } else {
statusMenuEnums.push(MenuEnum.SHOW) statusMenuEnums.push(MenuEnum.SHOW);
} }
// //
const singleMenuEnums = [MenuEnum.UN_GROUP] const singleMenuEnums = [MenuEnum.UN_GROUP];
return [ return [
...filter(singleMenuEnums), ...filter(singleMenuEnums),
divider(), divider(),
...targetList.filter(i => !statusMenuEnums.includes(i.key as MenuEnum)) ...targetList.filter((i) => !statusMenuEnums.includes(i.key as MenuEnum)),
] ];
} }
} };
// //
const themeColor = computed(() => { const themeColor = computed(() => {
const colorCustomMergeData = colorCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo) const colorCustomMergeData = colorCustomMerge(
return colorCustomMergeData[chartEditStore.getEditCanvasConfig.chartThemeColor] chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo,
}) );
return colorCustomMergeData[chartEditStore.getEditCanvasConfig.chartThemeColor];
});
// //
const themeSetting = computed(() => { const themeSetting = computed(() => {
const chartThemeSetting = chartEditStore.getEditCanvasConfig.chartThemeSetting const chartThemeSetting = chartEditStore.getEditCanvasConfig.chartThemeSetting;
return chartThemeSetting return chartThemeSetting;
}) });
</script> </script>

View File

@ -21,69 +21,69 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, PropType } from 'vue' import { computed, PropType } from 'vue';
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d';
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore';
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d';
import { useSizeStyle, usePointStyle } from '../../hooks/useStyle.hook' import { useSizeStyle, usePointStyle } from '../../hooks/useStyle.hook';
import { useMousePointHandle } from '../../hooks/useDrag.hook' import { useMousePointHandle } from '../../hooks/useDrag.hook';
const props = defineProps({ const props = defineProps({
item: { item: {
type: Object as PropType<CreateComponentType | CreateComponentGroupType>, type: Object as PropType<CreateComponentType | CreateComponentGroupType>,
required: true required: true,
}, },
hiddenPoint: { hiddenPoint: {
type: Boolean, type: Boolean,
required: false required: false,
} },
}) });
const designStore = useDesignStore() const designStore = useDesignStore();
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore();
// //
const pointList = ['t', 'r', 'b', 'l', 'lt', 'rt', 'lb', 'rb'] const pointList = ['t', 'r', 'b', 'l', 'lt', 'rt', 'lb', 'rb'];
// //
const cursorResize = ['n', 'e', 's', 'w', 'nw', 'ne', 'sw', 'se'] const cursorResize = ['n', 'e', 's', 'w', 'nw', 'ne', 'sw', 'se'];
// //
const themeColor = computed(() => { const themeColor = computed(() => {
return designStore.getAppTheme return designStore.getAppTheme;
}) });
// //
const hover = computed(() => { const hover = computed(() => {
const isDrag = chartEditStore.getEditCanvas[EditCanvasTypeEnum.IS_DRAG] const isDrag = chartEditStore.getEditCanvas[EditCanvasTypeEnum.IS_DRAG];
if (isDrag) return false if (isDrag) return false;
if (props.item.status.lock) return false if (props.item.status.lock) return false;
return props.item.id === chartEditStore.getTargetChart.hoverId return props.item.id === chartEditStore.getTargetChart.hoverId;
}) });
// //
const select = computed(() => { const select = computed(() => {
const id = props.item.id const id = props.item.id;
if (props.item.status.lock) return false if (props.item.status.lock) return false;
return chartEditStore.getTargetChart.selectId.find((e: string) => e === id) return chartEditStore.getTargetChart.selectId.find((e: string) => e === id);
}) });
// //
const lock = computed(() => { const lock = computed(() => {
return props.item.status.lock return props.item.status.lock;
}) });
// //
const hide = computed(() => { const hide = computed(() => {
return props.item.status.hide return props.item.status.hide;
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@include go(shape-box) { @include go(shape-box) {
position: absolute; position: absolute;
cursor: move; cursor: move;
@ -165,5 +165,5 @@ const hide = computed(() => {
} }
} }
} }
} }
</style> </style>

View File

@ -5,6 +5,11 @@
...getSizeStyle(groupData.attr), ...getSizeStyle(groupData.attr),
...getFilterStyle(groupData.styles), ...getFilterStyle(groupData.styles),
}" }"
@click="clickBtn"
@dblclick="dblclickBtn"
@contextmenu="rightclickBtn"
@mouseenter="mouseenterBtn"
@mouseleave="mouseleaveBtn"
> >
<div <div
class="chart-item" class="chart-item"
@ -36,7 +41,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PropType } from 'vue'; import { PropType, ref } from 'vue';
import { CreateComponentGroupType } from '@/packages/index.d'; import { CreateComponentGroupType } from '@/packages/index.d';
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'; import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils';
import { import {
@ -46,7 +51,10 @@
getPreviewConfigStyle, getPreviewConfigStyle,
} from '../../utils'; } from '../../utils';
import { useLifeHandler } from '@/hooks'; import { useLifeHandler } from '@/hooks';
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
import { eventHandlerHook } from '@/hooks/eventHandler.hook';
const chartEditStore = useChartEditStore();
const props = defineProps({ const props = defineProps({
groupData: { groupData: {
type: Object as PropType<CreateComponentGroupType>, type: Object as PropType<CreateComponentGroupType>,
@ -65,6 +73,58 @@
required: true, 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>