Skip to content

Commit 3f7b4d4

Browse files
committed
feat: Loop body supports zooming in and out
1 parent df68117 commit 3f7b4d4

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

ui/src/workflow/nodes/loop-body-node/LoopBodyContainer.vue

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:class="{ isSelected: props.nodeModel.isSelected, error: node_status !== 200 }"
66
style="overflow: visible; background: #fff"
77
>
8-
<div v-resize="resizeStepContainer">
8+
<div>
99
<div class="flex-between">
1010
<div class="flex align-center">
1111
<component
@@ -17,14 +17,14 @@
1717
<h4 class="ellipsis-1 break-all">{{ nodeModel.properties.stepName }}</h4>
1818
</div>
1919
<!-- 放大缩小按钮 -->
20-
<!-- <el-button link @click="enlargeHandle">
20+
<el-button link @click="enlargeHandle">
2121
<AppIcon
2222
:iconName="enlarge ? 'app-minify' : 'app-magnify'"
2323
class="color-secondary"
2424
style="font-size: 20px"
2525
>
2626
</AppIcon>
27-
</el-button> -->
27+
</el-button>
2828
</div>
2929
<el-collapse-transition>
3030
<div @mousedown.stop @keydown.stop @click.stop v-show="showNode" class="mt-16">
@@ -40,7 +40,10 @@
4040
show-icon
4141
:closable="false"
4242
/>
43-
<slot></slot>
43+
<div :style="`height:${height}px`">
44+
<slot></slot>
45+
</div>
46+
4447
<template v-if="nodeFields.length > 0">
4548
<h5 class="title-decoration-1 mb-8 mt-8">
4649
{{ $t('common.param.outputParam') }}
@@ -115,16 +118,8 @@ import { ElMessage } from 'element-plus'
115118
import type { FormInstance } from 'element-plus'
116119
import { t } from '@/locales'
117120
import { WorkflowMode } from '@/enums/application'
121+
118122
provide('workflowMode', WorkflowMode.ApplicationLoop)
119-
const height = ref<{
120-
stepContainerHeight: number
121-
inputContainerHeight: number
122-
outputContainerHeight: number
123-
}>({
124-
stepContainerHeight: 0,
125-
inputContainerHeight: 0,
126-
outputContainerHeight: 0,
127-
})
128123
129124
const titleFormRef = ref()
130125
const nodeNameDialogVisible = ref<boolean>(false)
@@ -179,14 +174,7 @@ const mousedown = () => {
179174
}
180175
const showicon = ref<number | null>(null)
181176
182-
const resizeStepContainer = (wh: any) => {
183-
if (wh.height) {
184-
if (!props.nodeModel.virtual) {
185-
height.value.stepContainerHeight = wh.height
186-
props.nodeModel.setHeight(height.value.stepContainerHeight)
187-
}
188-
}
189-
}
177+
const height = ref<number>(600)
190178
191179
const props = defineProps<{
192180
nodeModel: any
@@ -211,9 +199,22 @@ const enlarge = ref(false)
211199
function enlargeHandle() {
212200
enlarge.value = !enlarge.value
213201
if (enlarge.value) {
214-
// ...
202+
props.nodeModel.graphModel.transformModel.focusOn(
203+
props.nodeModel.x,
204+
props.nodeModel.y,
205+
props.nodeModel.width + 470,
206+
props.nodeModel.height - 30,
207+
)
208+
height.value =
209+
(props.nodeModel.graphModel.height - 100) / props.nodeModel.graphModel.transformModel.SCALE_Y
210+
const width = window.innerWidth / props.nodeModel.graphModel.transformModel.SCALE_X
211+
props.nodeModel.width = width
212+
props.nodeModel.setHeight(height.value)
215213
} else {
216-
// ...
214+
height.value = 600
215+
const width = 1920
216+
props.nodeModel.width = width
217+
props.nodeModel.setHeight(height.value)
217218
}
218219
}
219220
</script>

ui/src/workflow/nodes/loop-body-node/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ class LoopBodyModel extends AppNodeModel {
3636

3737
return anchors
3838
}
39+
setHeight(height: number) {
40+
this.properties['height'] = height
41+
this.outgoing.edges.forEach((edge: any) => {
42+
// 调用自定义的更新方案
43+
edge.updatePathByAnchor()
44+
})
45+
this.incoming.edges.forEach((edge: any) => {
46+
// 调用自定义的更新方案
47+
edge.updatePathByAnchor()
48+
})
49+
}
3950
}
4051
export default {
4152
type: 'loop-body-node',

ui/src/workflow/nodes/loop-body-node/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<LoopBodyContainer :nodeModel="nodeModel">
3-
<div ref="containerRef" @wheel.stop style="height: 600px"></div>
3+
<div ref="containerRef" @wheel.stop style="height: 100%; width: 100%"></div>
44
</LoopBodyContainer>
55
</template>
66
<script setup lang="ts">

0 commit comments

Comments
 (0)