Files
pqs-9100_client/frontend/src/views/home/components/RemoveableEdge.vue

89 lines
2.0 KiB
Vue
Raw Normal View History

2025-08-05 10:37:40 +08:00
<script setup>
import { BaseEdge, EdgeLabelRenderer, getBezierPath, useVueFlow } from '@vue-flow/core'
import { computed } from 'vue'
2025-08-27 11:17:13 +08:00
import { useCheckStore } from '@/stores/modules/check'
2025-08-05 10:37:40 +08:00
2025-08-27 11:17:13 +08:00
const checkStore = useCheckStore()
2025-08-05 10:37:40 +08:00
const props = defineProps({
2025-08-27 11:17:13 +08:00
id: {
type: String,
required: true
},
sourceX: {
type: Number,
required: true
},
sourceY: {
type: Number,
required: true
},
targetX: {
type: Number,
required: true
},
targetY: {
type: Number,
required: true
},
sourcePosition: {
type: String,
required: true
},
targetPosition: {
type: String,
required: true
},
markerEnd: {
type: String,
required: false
},
style: {
type: Object,
required: false
}
2025-08-05 10:37:40 +08:00
})
const { removeEdges } = useVueFlow()
const path = computed(() => getBezierPath(props))
2025-08-27 11:17:13 +08:00
const edgeStyle = computed(() => ({
...props.style,
strokeWidth: 3
}))
2025-08-05 10:37:40 +08:00
</script>
<script>
export default {
2025-08-27 11:17:13 +08:00
inheritAttrs: false
2025-08-05 10:37:40 +08:00
}
</script>
<template>
2025-08-27 11:17:13 +08:00
<BaseEdge :id="id" :style="edgeStyle" :path="path[0]" :marker-end="markerEnd" />
<EdgeLabelRenderer>
<div
:style="{
pointerEvents: 'all',
position: 'absolute',
transform: `translate(-50%, -50%) translate(${path[1]}px,${path[2]}px)`
}"
class="nodrag nopan"
>
<el-popconfirm v-if="checkStore.nodesConnectable" title="确定要删除这条连线吗?" @confirm="removeEdges(id)">
<template #reference>
<el-icon class="edge-icon"><Delete /></el-icon>
</template>
</el-popconfirm>
</div>
</EdgeLabelRenderer>
2025-08-05 10:37:40 +08:00
</template>
<style scoped>
.edge-icon {
2025-08-27 11:17:13 +08:00
background: white;
border-radius: 50%;
padding: 2px;
cursor: pointer;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
2025-08-05 10:37:40 +08:00
}
</style>