2025-09-04 16:41:54 +08:00
|
|
|
<template>
|
2025-11-17 14:54:32 +08:00
|
|
|
<div class="group__container" :class="props.model.id" @mouseleave="setNodeProperties">
|
2025-09-24 08:59:23 +08:00
|
|
|
<NodeTitle
|
|
|
|
|
:icon="loop"
|
|
|
|
|
:nodeId="props.model.id"
|
|
|
|
|
:nodeProperties="props.properties"
|
|
|
|
|
:nodeName="props.properties?.name || '循环'"
|
|
|
|
|
nodeDesc="循环执行一系列任务,直至输出所有结果"
|
2025-11-17 14:54:32 +08:00
|
|
|
:showZoom="false"
|
2025-12-17 13:39:02 +08:00
|
|
|
@setNodeName="setNodeName"
|
2025-09-24 08:59:23 +08:00
|
|
|
/>
|
2026-04-14 11:35:42 +08:00
|
|
|
<div>循环体</div>
|
|
|
|
|
<div
|
|
|
|
|
class="child__container"
|
|
|
|
|
@drop="handleDrop"
|
|
|
|
|
@dragover="handleDragover"
|
|
|
|
|
>
|
|
|
|
|
<slot></slot>
|
|
|
|
|
</div>
|
2025-09-04 16:41:54 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2025-09-24 08:59:23 +08:00
|
|
|
import NodeTitle from "../../components/NodeTitle.vue";
|
|
|
|
|
import loop from "../../icon/loop.svg";
|
2026-04-14 11:35:42 +08:00
|
|
|
import { addNewEdge } from "@/utils/flow";
|
2026-04-15 15:30:29 +08:00
|
|
|
import { emitter } from "@/utils/eventBus";
|
|
|
|
|
import { onUnmounted } from "vue";
|
2025-09-04 16:41:54 +08:00
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
model: Object,
|
|
|
|
|
graphModel: Object,
|
|
|
|
|
properties: Object,
|
|
|
|
|
nowTime: Number,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2025-09-24 08:59:23 +08:00
|
|
|
const emits = defineEmits(["bindRef", "addToGroup", "contentChange"]);
|
2025-09-04 16:41:54 +08:00
|
|
|
|
|
|
|
|
const handleDragover = (e) => {
|
2025-09-24 08:59:23 +08:00
|
|
|
e.preventDefault();
|
|
|
|
|
};
|
2025-09-04 16:41:54 +08:00
|
|
|
|
|
|
|
|
const handleDrop = (e) => {
|
2025-09-24 08:59:23 +08:00
|
|
|
e.preventDefault();
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
|
|
let flowNode = e.dataTransfer.getData("flowNode");
|
|
|
|
|
flowNode = JSON.parse(flowNode);
|
|
|
|
|
const point = lf.getPointByClient(e.clientX, e.clientY);
|
|
|
|
|
const { type, ...other } = flowNode;
|
|
|
|
|
const node = lf.addNode({
|
|
|
|
|
type,
|
|
|
|
|
x: point.canvasOverlayPosition.x,
|
|
|
|
|
y: point.canvasOverlayPosition.y,
|
|
|
|
|
properties: {
|
|
|
|
|
parentId: props.model.id,
|
|
|
|
|
...other,
|
|
|
|
|
},
|
|
|
|
|
});
|
2026-04-15 15:30:29 +08:00
|
|
|
if (
|
|
|
|
|
!["selectArea", "branch", "stopLoop", "subStart", "subEnd"].includes(node.type)
|
|
|
|
|
) {
|
|
|
|
|
emitter.emit("openParamsDrawer", node);
|
|
|
|
|
}
|
2025-09-24 08:59:23 +08:00
|
|
|
|
|
|
|
|
emits("addToGroup", node.id);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
addNewEdge(props.model.id);
|
|
|
|
|
}, 50);
|
|
|
|
|
};
|
2025-09-04 16:41:54 +08:00
|
|
|
|
2025-12-17 13:39:02 +08:00
|
|
|
const setNodeName = (name) => {
|
|
|
|
|
const properties = lf.getProperties(props.model.id);
|
|
|
|
|
lf.setProperties(props.model.id, {
|
|
|
|
|
...properties,
|
|
|
|
|
name
|
|
|
|
|
});
|
|
|
|
|
emits("contentChange");
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 15:30:29 +08:00
|
|
|
onUnmounted(() => {
|
|
|
|
|
emitter.off("openParamsDrawer");
|
|
|
|
|
})
|
|
|
|
|
|
2025-09-04 16:41:54 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.group__container {
|
2025-09-24 08:59:23 +08:00
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2026-07-08 11:09:51 +08:00
|
|
|
// min-height: 420px;
|
2025-09-24 08:59:23 +08:00
|
|
|
background: #fff;
|
|
|
|
|
padding: 12px;
|
|
|
|
|
cursor: default;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
border: 2px solid white;
|
2026-07-08 11:09:51 +08:00
|
|
|
// box-shadow: 0 5px 15px 0#00000008;
|
2025-09-24 08:59:23 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
position: relative;
|
2025-09-04 16:41:54 +08:00
|
|
|
|
2025-09-24 08:59:23 +08:00
|
|
|
.title {
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
2025-09-04 16:41:54 +08:00
|
|
|
|
2025-09-24 08:59:23 +08:00
|
|
|
.child__container {
|
|
|
|
|
min-height: 100px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
background-color: #f6f8fa;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-row {
|
|
|
|
|
align-items: end;
|
|
|
|
|
}
|
2025-09-04 16:41:54 +08:00
|
|
|
}
|
2025-09-24 08:59:23 +08:00
|
|
|
</style>
|