2025-11-17 14:54:32 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="title__container">
|
|
|
|
|
|
<div class="title">
|
|
|
|
|
|
<div class="left">
|
2025-12-17 14:29:32 +08:00
|
|
|
|
<img :src="imageUrl()" alt="" />
|
2025-11-17 14:54:32 +08:00
|
|
|
|
<div class="text__container">
|
|
|
|
|
|
<div class="text__title" v-if="showTextTitle">
|
|
|
|
|
|
<span class="text">{{ nodeName }}</span>
|
2026-04-14 16:17:52 +08:00
|
|
|
|
<el-icon class="editIcon" @click="showTextTitle = false"><EditPen/></el-icon>
|
2025-11-17 14:54:32 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="input_name_container" v-else>
|
2025-12-17 13:39:02 +08:00
|
|
|
|
<el-input v-model="nodeName" @keydown="handleInputKeydown" />
|
2025-11-17 14:54:32 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
class="input_name_select"
|
|
|
|
|
|
circle
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="confirmNodeName"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><Select /></el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
class="input_name_closeBold"
|
|
|
|
|
|
circle
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@click="cancelNodeName"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><CloseBold /></el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="right">
|
2025-11-17 17:32:33 +08:00
|
|
|
|
<el-tooltip
|
|
|
|
|
|
class="box-item"
|
|
|
|
|
|
effect="dark"
|
|
|
|
|
|
content="执行"
|
|
|
|
|
|
placement="top"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button v-if="nodeType && nodeType !=='NONE'" circle @click="execute">
|
|
|
|
|
|
<el-icon>
|
|
|
|
|
|
<VideoPlay />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</el-tooltip>
|
2025-11-17 14:54:32 +08:00
|
|
|
|
<el-tooltip
|
|
|
|
|
|
class="box-item"
|
|
|
|
|
|
effect="dark"
|
|
|
|
|
|
content="删除"
|
|
|
|
|
|
placement="top"
|
|
|
|
|
|
>
|
2025-11-17 17:32:33 +08:00
|
|
|
|
<el-button circle @click="deleteNode">
|
2025-11-17 14:54:32 +08:00
|
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="subTitle">{{ props.nodeDesc }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="js">
|
2026-04-17 15:07:36 +08:00
|
|
|
|
import { onUnmounted, ref } from 'vue'
|
|
|
|
|
|
import { EditPen, Select, CloseBold, Delete, VideoPlay } from '@element-plus/icons-vue'
|
2025-11-17 14:54:32 +08:00
|
|
|
|
import { ElMessageBox } from 'element-plus'
|
2025-12-17 14:29:32 +08:00
|
|
|
|
import { computed } from 'vue'
|
2026-04-17 15:07:36 +08:00
|
|
|
|
import { emitter } from "@/utils/eventBus";
|
2025-11-17 14:54:32 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
icon: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
nodeId: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
nodeProperties: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
default: () => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
nodeDesc: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
nodeName: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
nodeType: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-04-17 15:07:36 +08:00
|
|
|
|
const emits = defineEmits(['setNodeName'])
|
2025-11-17 14:54:32 +08:00
|
|
|
|
|
|
|
|
|
|
const showTextTitle = ref(true)
|
|
|
|
|
|
const nodeName = ref(props.nodeProperties.name || props.nodeName)
|
|
|
|
|
|
|
|
|
|
|
|
const confirmNodeName = () => {
|
2025-12-17 13:39:02 +08:00
|
|
|
|
emits('setNodeName', nodeName.value)
|
2025-11-17 14:54:32 +08:00
|
|
|
|
showTextTitle.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const cancelNodeName = () => {
|
|
|
|
|
|
nodeName.value = props.nodeProperties?.name || props.nodeName
|
|
|
|
|
|
showTextTitle.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const deleteNode = () => {
|
|
|
|
|
|
ElMessageBox.confirm(
|
|
|
|
|
|
'是否删除该节点?',
|
|
|
|
|
|
'警告',
|
|
|
|
|
|
{
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
|
type: 'warning',
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
if (props.nodeType === 'selectArea') {
|
|
|
|
|
|
const children = lf.getNodeModelById(props.nodeId).children
|
|
|
|
|
|
lf.getNodeModelById(props.nodeId).children = []
|
|
|
|
|
|
children.forEach(item => {
|
|
|
|
|
|
lf.getNodeModelById(item).draggable = true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
lf.deleteNode(props.nodeId);
|
2026-04-17 15:07:36 +08:00
|
|
|
|
emitter.emit('deleteNode', props.nodeId);
|
2025-11-17 14:54:32 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-17 17:32:33 +08:00
|
|
|
|
const execute = () => {
|
|
|
|
|
|
const myEvent = new CustomEvent('singleNodeExecution', {
|
|
|
|
|
|
bubbles: false, // 是否冒泡(默认 false)
|
|
|
|
|
|
cancelable: false, // 是否可被 preventDefault() 取消(默认 false)
|
|
|
|
|
|
detail: { ...props.nodeProperties } // 自定义数据(任意类型,通过 event.detail 读取)
|
|
|
|
|
|
});
|
|
|
|
|
|
document.dispatchEvent(myEvent);
|
|
|
|
|
|
}
|
2025-12-17 13:39:02 +08:00
|
|
|
|
|
|
|
|
|
|
const handleInputKeydown = (e) => {
|
|
|
|
|
|
// 阻止事件冒泡到 Logic Flow 节点,避免被其事件拦截
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
// 可选:明确放行 Ctrl+V(增强兼容性)
|
|
|
|
|
|
if ((e.ctrlKey || e.metaKey) && e.key === "v") {
|
|
|
|
|
|
e.returnValue = true; // 允许默认粘贴行为
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-17 14:29:32 +08:00
|
|
|
|
|
|
|
|
|
|
const imageUrl = () => {
|
|
|
|
|
|
return new URL(props.icon, import.meta.url).href;
|
|
|
|
|
|
}
|
2026-04-17 15:07:36 +08:00
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
|
emitter.off("deleteNode");
|
|
|
|
|
|
})
|
2025-11-17 14:54:32 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
2026-01-13 15:20:51 +08:00
|
|
|
|
.title__container {
|
2025-11-17 14:54:32 +08:00
|
|
|
|
.title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
.left {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
|
|
|
|
img {
|
|
|
|
|
|
width: 24px;
|
|
|
|
|
|
height: 24px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text__container {
|
|
|
|
|
|
.text__title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
margin: 0 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.editIcon {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input_name_container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.el-input {
|
|
|
|
|
|
margin-left: 12px;
|
2026-04-14 16:17:52 +08:00
|
|
|
|
width: 120px;
|
2025-11-17 14:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input_name_select {
|
|
|
|
|
|
color: #00b42a;
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.input_name_closeBold {
|
|
|
|
|
|
color: #f53f3f;
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.right {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
.el-button {
|
|
|
|
|
|
border: none;
|
2025-11-17 17:32:33 +08:00
|
|
|
|
font-size: 24px;
|
2025-11-17 14:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.subTitle {
|
|
|
|
|
|
color: #737a87;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
margin: 8px 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|