mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
feat: 处理层级区域分组右键,多选等
This commit is contained in:
parent
3b7f9e5dec
commit
99b344bdef
@ -59,7 +59,7 @@ export const mousedownHandleUnStop = (e: MouseEvent, item?: CreateComponentType
|
|||||||
chartEditStore.setTargetSelectChart(undefined)
|
chartEditStore.setTargetSelectChart(undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
// * 移动图表
|
// * 鼠标事件
|
||||||
export const useMouseHandle = () => {
|
export const useMouseHandle = () => {
|
||||||
// * Click 事件, 松开鼠标触发
|
// * Click 事件, 松开鼠标触发
|
||||||
const mouseClickHandle = (e: MouseEvent, item: CreateComponentType | CreateComponentGroupType) => {
|
const mouseClickHandle = (e: MouseEvent, item: CreateComponentType | CreateComponentGroupType) => {
|
||||||
@ -70,7 +70,13 @@ export const useMouseHandle = () => {
|
|||||||
window.$KeyboardActive?.has(WinKeyboard.CTRL_SOURCE_KEY) ||
|
window.$KeyboardActive?.has(WinKeyboard.CTRL_SOURCE_KEY) ||
|
||||||
window.$KeyboardActive?.has(MacKeyboard.CTRL_SOURCE_KEY)
|
window.$KeyboardActive?.has(MacKeyboard.CTRL_SOURCE_KEY)
|
||||||
) {
|
) {
|
||||||
chartEditStore.setTargetSelectChart(item.id, true)
|
// 若已选中,则去除
|
||||||
|
if(chartEditStore.targetChart.selectId.includes(item.id)) {
|
||||||
|
const exList = chartEditStore.targetChart.selectId.filter(e => e !== item.id)
|
||||||
|
chartEditStore.setTargetSelectChart(exList)
|
||||||
|
} else {
|
||||||
|
chartEditStore.setTargetSelectChart(item.id, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
class="root-item-content"
|
class="root-item-content"
|
||||||
:class="{ hover: hover, select: select }"
|
:class="{ hover: hover, select: select }"
|
||||||
@click="clickHandle($event)"
|
@click="clickHandle($event)"
|
||||||
@mousedown="groupMousedownHandle()"
|
@mousedown="groupMousedownHandle($event)"
|
||||||
@mouseenter="mouseenterHandle(componentGroupData)"
|
@mouseenter="mouseenterHandle(componentGroupData)"
|
||||||
@mouseleave="mouseleaveHandle(componentGroupData)"
|
@mouseleave="mouseleaveHandle(componentGroupData)"
|
||||||
@contextmenu="handleContextMenu($event, componentGroupData, optionsHandle)"
|
@contextmenu="handleContextMenu($event, componentGroupData, optionsHandle)"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
v-for="element in componentGroupData.groupList"
|
v-for="element in componentGroupData.groupList"
|
||||||
:key="element.id"
|
:key="element.id"
|
||||||
:componentData="element"
|
:componentData="element"
|
||||||
@mousedown="mousedownHandle(element)"
|
@mousedown="mousedownHandle($event, element, componentGroupData.id)"
|
||||||
@mouseenter="mouseenterHandle(element)"
|
@mouseenter="mouseenterHandle(element)"
|
||||||
@mouseleave="mouseleaveHandle(element)"
|
@mouseleave="mouseleaveHandle(element)"
|
||||||
@contextmenu="handleContextMenu($event, componentGroupData, undefined, undefined, pickOptionsList)"
|
@contextmenu="handleContextMenu($event, componentGroupData, undefined, undefined, pickOptionsList)"
|
||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, PropType } from 'vue'
|
import { ref, computed, PropType } from 'vue'
|
||||||
import { MouseEventButton } from '@/enums/editPageEnum'
|
import { MouseEventButton, WinKeyboard, MacKeyboard } from '@/enums/editPageEnum'
|
||||||
import { MenuEnum } from '@/enums/editPageEnum'
|
import { MenuEnum } from '@/enums/editPageEnum'
|
||||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
@ -99,9 +99,15 @@ const optionsHandle = (
|
|||||||
|
|
||||||
// 点击
|
// 点击
|
||||||
const clickHandle = (e: MouseEvent) => {
|
const clickHandle = (e: MouseEvent) => {
|
||||||
|
// 按下左键 + CTRL
|
||||||
|
if (
|
||||||
|
window.$KeyboardActive?.has(WinKeyboard.CTRL_SOURCE_KEY) ||
|
||||||
|
window.$KeyboardActive?.has(MacKeyboard.CTRL_SOURCE_KEY)
|
||||||
|
)
|
||||||
|
return
|
||||||
// 判断左右键
|
// 判断左右键
|
||||||
expend.value = !expend.value
|
expend.value = !expend.value
|
||||||
mousedownHandle(props.componentGroupData)
|
mousedownHandle(e, props.componentGroupData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算当前选中目标
|
// 计算当前选中目标
|
||||||
@ -116,15 +122,36 @@ const hover = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 组点击事件
|
// 组点击事件
|
||||||
const groupMousedownHandle = () => {
|
const groupMousedownHandle = (e: MouseEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
onClickOutSide()
|
onClickOutSide()
|
||||||
chartEditStore.setTargetSelectChart(props.componentGroupData.id)
|
// 若此时按下了 CTRL, 表示多选
|
||||||
|
const id = props.componentGroupData.id
|
||||||
|
if (
|
||||||
|
e.buttons === MouseEventButton.LEFT &&
|
||||||
|
(window.$KeyboardActive?.has(WinKeyboard.CTRL_SOURCE_KEY) ||
|
||||||
|
window.$KeyboardActive?.has(MacKeyboard.CTRL_SOURCE_KEY))
|
||||||
|
) {
|
||||||
|
// 若已选中,则去除
|
||||||
|
if (chartEditStore.targetChart.selectId.includes(id)) {
|
||||||
|
const exList = chartEditStore.targetChart.selectId.filter(e => e !== id)
|
||||||
|
chartEditStore.setTargetSelectChart(exList)
|
||||||
|
} else {
|
||||||
|
chartEditStore.setTargetSelectChart(id, true)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
chartEditStore.setTargetSelectChart(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公共点击事件
|
// 公共点击事件
|
||||||
const mousedownHandle = (item: CreateComponentType | CreateComponentGroupType) => {
|
const mousedownHandle = (e: MouseEvent, item: CreateComponentType | CreateComponentGroupType, id?: string) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
|
||||||
onClickOutSide()
|
onClickOutSide()
|
||||||
chartEditStore.setTargetSelectChart(item.id)
|
chartEditStore.setTargetSelectChart(id || item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公共进入事件
|
// 公共进入事件
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
title="图层"
|
title="图层"
|
||||||
:depth="2"
|
:depth="2"
|
||||||
@back="backHandle"
|
@back="backHandle"
|
||||||
|
@mousedown="boxMousedownHandle($event)"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon size="16" :depth="2">
|
<n-icon size="16" :depth="2">
|
||||||
@ -25,7 +26,7 @@
|
|||||||
<layers-list-item
|
<layers-list-item
|
||||||
v-else
|
v-else
|
||||||
:componentData="element"
|
:componentData="element"
|
||||||
@mousedown="mousedownHandle(element)"
|
@mousedown="mousedownHandle($event, element)"
|
||||||
@mouseenter="mouseenterHandle(element)"
|
@mouseenter="mouseenterHandle(element)"
|
||||||
@mouseleave="mouseleaveHandle(element)"
|
@mouseleave="mouseleaveHandle(element)"
|
||||||
@contextmenu="handleContextMenu($event, element, optionsHandle)"
|
@contextmenu="handleContextMenu($event, element, optionsHandle)"
|
||||||
@ -40,7 +41,6 @@
|
|||||||
import { computed, toRaw } from 'vue'
|
import { computed, toRaw } from 'vue'
|
||||||
import Draggable from 'vuedraggable'
|
import Draggable from 'vuedraggable'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
import { ContentBox } from '../ContentBox/index'
|
import { ContentBox } from '../ContentBox/index'
|
||||||
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'
|
||||||
@ -48,7 +48,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
|||||||
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 { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
|
import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
|
||||||
import { MenuEnum } from '@/enums/editPageEnum'
|
import { MenuEnum, MouseEventButton, WinKeyboard, MacKeyboard } from '@/enums/editPageEnum'
|
||||||
|
|
||||||
import { LayersListItem } from './components/LayersListItem/index'
|
import { LayersListItem } from './components/LayersListItem/index'
|
||||||
import { LayersGroupListItem } from './components/LayersGroupListItem/index'
|
import { LayersGroupListItem } from './components/LayersGroupListItem/index'
|
||||||
@ -111,10 +111,32 @@ const onMoveCallback = (val: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const boxMousedownHandle = (e: MouseEvent) => {
|
||||||
|
chartEditStore.setTargetSelectChart()
|
||||||
|
}
|
||||||
|
|
||||||
// 点击事件
|
// 点击事件
|
||||||
const mousedownHandle = (item: CreateComponentType) => {
|
const mousedownHandle = (e: MouseEvent, item: CreateComponentType) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
onClickOutSide()
|
onClickOutSide()
|
||||||
chartEditStore.setTargetSelectChart(item.id)
|
// 若此时按下了 CTRL, 表示多选
|
||||||
|
const id = item.id
|
||||||
|
if (
|
||||||
|
e.buttons === MouseEventButton.LEFT &&
|
||||||
|
(window.$KeyboardActive?.has(WinKeyboard.CTRL_SOURCE_KEY) ||
|
||||||
|
window.$KeyboardActive?.has(MacKeyboard.CTRL_SOURCE_KEY))
|
||||||
|
) {
|
||||||
|
// 若已选中,则去除
|
||||||
|
if (chartEditStore.targetChart.selectId.includes(id)) {
|
||||||
|
const exList = chartEditStore.targetChart.selectId.filter(e => e !== id)
|
||||||
|
chartEditStore.setTargetSelectChart(exList)
|
||||||
|
} else {
|
||||||
|
chartEditStore.setTargetSelectChart(id, true)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
chartEditStore.setTargetSelectChart(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进入事件
|
// 进入事件
|
||||||
|
@ -87,6 +87,9 @@ const macKeyList: Array<string> = [
|
|||||||
|
|
||||||
// 处理键盘记录
|
// 处理键盘记录
|
||||||
const keyRecordHandle = () => {
|
const keyRecordHandle = () => {
|
||||||
|
// 初始化清空
|
||||||
|
if(window.$KeyboardActive) window.$KeyboardActive = new Set([])
|
||||||
|
|
||||||
document.onkeydown = (e: KeyboardEvent) => {
|
document.onkeydown = (e: KeyboardEvent) => {
|
||||||
if(window.$KeyboardActive) window.$KeyboardActive.add(e.key.toLocaleLowerCase())
|
if(window.$KeyboardActive) window.$KeyboardActive.add(e.key.toLocaleLowerCase())
|
||||||
else window.$KeyboardActive = new Set([e.key.toLocaleLowerCase()])
|
else window.$KeyboardActive = new Set([e.key.toLocaleLowerCase()])
|
||||||
|
Loading…
Reference in New Issue
Block a user