|
@@ -17,7 +17,7 @@
|
|
|
<n-text class="not-layer-text">暂无图层~</n-text>
|
|
<n-text class="not-layer-text">暂无图层~</n-text>
|
|
|
</n-space>
|
|
</n-space>
|
|
|
<!-- https://github.com/SortableJS/vue.draggable.next -->
|
|
<!-- https://github.com/SortableJS/vue.draggable.next -->
|
|
|
- <draggable item-key="id" v-model="reverseList" ghostClass="ghost" @change="onMoveCallback">
|
|
|
|
|
|
|
+ <draggable item-key="id" v-model="layerList" ghostClass="ghost" @change="onMoveCallback">
|
|
|
<template #item="{ element }">
|
|
<template #item="{ element }">
|
|
|
<div class="go-content-layer-box">
|
|
<div class="go-content-layer-box">
|
|
|
<!-- 组合 -->
|
|
<!-- 组合 -->
|
|
@@ -27,7 +27,7 @@
|
|
|
v-else
|
|
v-else
|
|
|
:componentData="element"
|
|
:componentData="element"
|
|
|
@mousedown="mousedownHandle($event, 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)"
|
|
|
></layers-list-item>
|
|
></layers-list-item>
|
|
@@ -38,7 +38,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed, toRaw } from 'vue'
|
|
|
|
|
|
|
+import { computed, ref, watch } 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'
|
|
@@ -58,9 +58,23 @@ import { icon } from '@/plugins'
|
|
|
const { LayersIcon } = icon.ionicons5
|
|
const { LayersIcon } = icon.ionicons5
|
|
|
const chartLayoutStore = useChartLayoutStore()
|
|
const chartLayoutStore = useChartLayoutStore()
|
|
|
const chartEditStore = useChartEditStore()
|
|
const chartEditStore = useChartEditStore()
|
|
|
-
|
|
|
|
|
const { handleContextMenu, onClickOutSide } = useContextMenu()
|
|
const { handleContextMenu, onClickOutSide } = useContextMenu()
|
|
|
|
|
|
|
|
|
|
+const layerList = ref<any>([])
|
|
|
|
|
+
|
|
|
|
|
+// 逆序展示
|
|
|
|
|
+const reverseList = computed(() => {
|
|
|
|
|
+ const list: Array<CreateComponentType | CreateComponentGroupType> = cloneDeep(chartEditStore.getComponentList)
|
|
|
|
|
+ return list.reverse()
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => reverseList.value,
|
|
|
|
|
+ newValue => {
|
|
|
|
|
+ layerList.value = newValue
|
|
|
|
|
+ }
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
// 右键事件
|
|
// 右键事件
|
|
|
const optionsHandle = (
|
|
const optionsHandle = (
|
|
|
targetList: MenuOptionsItemType[],
|
|
targetList: MenuOptionsItemType[],
|
|
@@ -80,12 +94,6 @@ const optionsHandle = (
|
|
|
}
|
|
}
|
|
|
return targetList
|
|
return targetList
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// 逆序展示
|
|
|
|
|
-const reverseList = computed(() => {
|
|
|
|
|
- const list: Array<CreateComponentType | CreateComponentGroupType> = cloneDeep(chartEditStore.getComponentList)
|
|
|
|
|
- return list.reverse()
|
|
|
|
|
-})
|
|
|
|
|
|
|
|
|
|
// 缩小
|
|
// 缩小
|
|
|
const backHandle = () => {
|
|
const backHandle = () => {
|
|
@@ -95,14 +103,13 @@ const backHandle = () => {
|
|
|
// 移动结束处理
|
|
// 移动结束处理
|
|
|
const onMoveCallback = (val: any) => {
|
|
const onMoveCallback = (val: any) => {
|
|
|
const { oldIndex, newIndex } = val.moved
|
|
const { oldIndex, newIndex } = val.moved
|
|
|
- const moveTarget = toRaw(val.moved.element)
|
|
|
|
|
if (newIndex - oldIndex > 0) {
|
|
if (newIndex - oldIndex > 0) {
|
|
|
// 从上往下
|
|
// 从上往下
|
|
|
- chartEditStore.getComponentList.splice(-(oldIndex + 1), 1)
|
|
|
|
|
|
|
+ const moveTarget = chartEditStore.getComponentList.splice(-(oldIndex + 1), 1)[0]
|
|
|
chartEditStore.getComponentList.splice(-newIndex, 0, moveTarget)
|
|
chartEditStore.getComponentList.splice(-newIndex, 0, moveTarget)
|
|
|
} else {
|
|
} else {
|
|
|
// 从下往上
|
|
// 从下往上
|
|
|
- chartEditStore.getComponentList.splice(-(oldIndex + 1), 1)
|
|
|
|
|
|
|
+ const moveTarget = chartEditStore.getComponentList.splice(-(oldIndex + 1), 1)[0]
|
|
|
if (newIndex === 0) {
|
|
if (newIndex === 0) {
|
|
|
chartEditStore.getComponentList.push(moveTarget)
|
|
chartEditStore.getComponentList.push(moveTarget)
|
|
|
} else {
|
|
} else {
|