|
|
@@ -4,9 +4,12 @@
|
|
|
v-for="group in props.fenceGroups"
|
|
|
:key="group.uid"
|
|
|
:groupId="group.uid"
|
|
|
+ :fenceId="group.fenceId"
|
|
|
:draggable="props.draggable && props.isEdit"
|
|
|
:name="group.name"
|
|
|
@mouse-down="handleGroupMouseDown"
|
|
|
+ @mouse-up="handleGroupMouseUp"
|
|
|
+ @drag-move="handleGroupMove"
|
|
|
>
|
|
|
<v-line :config="group.lineConfig" />
|
|
|
<v-circle
|
|
|
@@ -20,6 +23,7 @@
|
|
|
</v-group>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
+ import { ref } from 'vue';
|
|
|
import { FenceCircleConfig, FenceGroup } from './types';
|
|
|
|
|
|
const props = defineProps<{
|
|
|
@@ -30,7 +34,13 @@
|
|
|
currentGroupId: string;
|
|
|
}>();
|
|
|
|
|
|
- const emits = defineEmits<{ (e: 'selectGroup', groupId: string): unknown }>();
|
|
|
+ const emits = defineEmits<{
|
|
|
+ (e: 'selectGroup', groupId: string): unknown;
|
|
|
+ (e: 'groupEndMove', groupId: string): unknown;
|
|
|
+ }>();
|
|
|
+
|
|
|
+ /** 当前移动的group id */
|
|
|
+ const moveGroupId = ref('');
|
|
|
|
|
|
const handleCircleDragMove = (circleConfig: FenceCircleConfig, e) => {
|
|
|
console.log('circle move', e);
|
|
|
@@ -50,8 +60,24 @@
|
|
|
|
|
|
const handleGroupMouseDown = (e) => {
|
|
|
if (!props.isEdit) return;
|
|
|
+ moveGroupId.value = '';
|
|
|
e.target.parent.moveToTop();
|
|
|
+ console.log('groupMouseDown', e);
|
|
|
emits('selectGroup', e.target.parent.attrs.groupId);
|
|
|
};
|
|
|
+
|
|
|
+ const handleGroupMouseUp = (e) => {
|
|
|
+ const currentGroupId = e.target.parent.attrs.groupId;
|
|
|
+ if (moveGroupId.value !== currentGroupId) return;
|
|
|
+ console.log('groupEndMove', currentGroupId);
|
|
|
+ moveGroupId.value = '';
|
|
|
+ // 分组停止移动
|
|
|
+ emits('groupEndMove', currentGroupId);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleGroupMove = (e) => {
|
|
|
+ // console.log('groupMove', e);
|
|
|
+ moveGroupId.value = e.target.attrs.groupId;
|
|
|
+ };
|
|
|
</script>
|
|
|
<style scoped></style>
|