2026-04-13 10:31:55 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-drawer
|
2026-07-29 16:17:39 +08:00
|
|
|
|
:model-value="props.drawer"
|
|
|
|
|
|
custom-class="flow-params-drawer"
|
2026-07-06 11:11:59 +08:00
|
|
|
|
:title="props.data.properties?.name || '参数配置'"
|
2026-07-29 16:17:39 +08:00
|
|
|
|
class="flow-params-drawer"
|
|
|
|
|
|
size="min(560px, 92vw)"
|
|
|
|
|
|
append-to-body
|
|
|
|
|
|
destroy-on-close
|
|
|
|
|
|
:close-on-click-modal="false"
|
2026-07-06 11:11:59 +08:00
|
|
|
|
:before-close="confirmSave"
|
2026-04-13 10:31:55 +08:00
|
|
|
|
>
|
2026-07-06 11:11:59 +08:00
|
|
|
|
<component
|
|
|
|
|
|
:is="currentComponent"
|
|
|
|
|
|
ref="paramsComponentRef"
|
|
|
|
|
|
:data="props.data"
|
|
|
|
|
|
@save-success="handleSaveSuccess"
|
|
|
|
|
|
@save-error="handleSaveError"
|
|
|
|
|
|
/>
|
2026-04-13 10:31:55 +08:00
|
|
|
|
</el-drawer>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-07-29 16:17:39 +08:00
|
|
|
|
import { ref, computed } from 'vue'
|
2026-07-06 11:11:59 +08:00
|
|
|
|
import { emitter } from '@/utils/eventBus'
|
|
|
|
|
|
|
|
|
|
|
|
// 导入各子组件
|
|
|
|
|
|
import StartParams from './params/StartParams.vue'
|
|
|
|
|
|
import BasicNodeParams from './params/BasicNodeParams.vue'
|
|
|
|
|
|
import CodeNodeParams from './params/CodeNodeParams.vue'
|
|
|
|
|
|
import HttpNodeParams from './params/HttpNodeParams.vue'
|
|
|
|
|
|
import SdAgentNodeParams from './params/SdAgentNodeParams.vue'
|
2026-07-28 09:22:22 +08:00
|
|
|
|
import RecognizeNodeParams from './params/RecognizeNodeParams.vue'
|
2026-04-13 10:31:55 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
2026-07-06 11:11:59 +08:00
|
|
|
|
drawer: Boolean,
|
|
|
|
|
|
data: Object
|
2026-04-13 10:31:55 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['close'])
|
2026-07-06 11:11:59 +08:00
|
|
|
|
const paramsComponentRef = ref(null)
|
|
|
|
|
|
|
|
|
|
|
|
// 根据节点类型决定渲染哪个子组件
|
|
|
|
|
|
const currentComponent = computed(() => {
|
|
|
|
|
|
const type = props.data?.type
|
|
|
|
|
|
if (type === 'start') return StartParams
|
|
|
|
|
|
if (['currentLoop', 'serviceNode', 'sleep', 'loop'].includes(type)) return BasicNodeParams
|
|
|
|
|
|
if (type === 'code') return CodeNodeParams
|
|
|
|
|
|
if (type === 'http') return HttpNodeParams
|
|
|
|
|
|
if (type === 'sdAgent') return SdAgentNodeParams
|
2026-07-28 09:22:22 +08:00
|
|
|
|
if (type === 'recognize') return RecognizeNodeParams
|
2026-07-06 11:11:59 +08:00
|
|
|
|
return null
|
|
|
|
|
|
})
|
2026-04-13 10:31:55 +08:00
|
|
|
|
|
2026-07-06 11:11:59 +08:00
|
|
|
|
// 这里提供一个公开方法供父组件调用
|
|
|
|
|
|
const confirmSave = async () => {
|
|
|
|
|
|
if (paramsComponentRef.value && typeof paramsComponentRef.value.validateAndSave === 'function') {
|
|
|
|
|
|
await paramsComponentRef.value.validateAndSave()
|
2026-07-29 16:17:39 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
emits('close')
|
2026-04-14 16:17:52 +08:00
|
|
|
|
}
|
2026-04-16 14:37:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-06 11:11:59 +08:00
|
|
|
|
// 暴露给父组件使用
|
|
|
|
|
|
defineExpose({ confirmSave })
|
2026-04-16 14:37:27 +08:00
|
|
|
|
|
2026-07-06 11:11:59 +08:00
|
|
|
|
// 保存成功 / 失败处理
|
|
|
|
|
|
const handleSaveSuccess = () => {
|
|
|
|
|
|
emitter.emit('setProperties', { id: props.data.id })
|
2026-07-08 11:09:51 +08:00
|
|
|
|
emitter.emit("throwAnError", { id: props.data.id, hasError: false, type: props.data.type });
|
2026-07-06 11:11:59 +08:00
|
|
|
|
// 无错误,关闭抽屉
|
|
|
|
|
|
emits('close')
|
2026-04-16 09:32:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-06 11:11:59 +08:00
|
|
|
|
const handleSaveError = () => {
|
|
|
|
|
|
emitter.emit('setProperties', { id: props.data.id })
|
2026-07-08 11:09:51 +08:00
|
|
|
|
emitter.emit("throwAnError", { id: props.data.id, hasError: true, type: props.data.type });
|
2026-07-06 11:11:59 +08:00
|
|
|
|
emits('close')
|
2026-04-16 09:32:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-06 11:11:59 +08:00
|
|
|
|
// 组件卸载时清理事件监听
|
|
|
|
|
|
// 注意:emitter.off 应在各子组件中自行清理,父组件不再重复
|
2026-04-13 10:31:55 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2026-04-13 15:17:11 +08:00
|
|
|
|
<style lang="scss">
|
2026-07-29 16:17:39 +08:00
|
|
|
|
.flow-params-drawer {
|
|
|
|
|
|
.el-drawer__header {
|
|
|
|
|
|
min-height: 62px;
|
|
|
|
|
|
margin-bottom: 0 !important;
|
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
|
border-bottom: 1px solid #e4e8ef;
|
|
|
|
|
|
color: #1f2937;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 650;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-drawer__body {
|
|
|
|
|
|
padding: 0 20px 24px;
|
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-collapse {
|
|
|
|
|
|
border-top: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-collapse-item__header {
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
color: #344054;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
font-weight: 650;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form__container {
|
|
|
|
|
|
padding: 4px 0 10px;
|
|
|
|
|
|
}
|
2026-04-13 15:17:11 +08:00
|
|
|
|
}
|
2026-07-29 16:17:39 +08:00
|
|
|
|
</style>
|