fix: The data source Tree uses fetc_list_function (#4440)

This commit is contained in:
shaohuzhang1 2025-12-05 10:46:26 +08:00 committed by GitHub
parent 44326c3a7c
commit 3627d8ac4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -168,8 +168,13 @@ function renderTemplate(template: string, data: any) {
}
const loadNode = (node: Node, resolve: (nodeData: Tree[]) => void) => {
const get_extra = inject('get_extra') as any
request_call(request, {
url: renderTemplate(attrs.url, props.otherParams),
url: renderTemplate(
'/workspace/${current_workspace_id}/knowledge/${current_knowledge_id}/datasource/tool/${current_tool_id}/' +
attrs.fetch_list_function,
{ ...props.otherParams, ...(get_extra ? get_extra() : {}) },
),
body: { current_node: node.level == 0 ? undefined : node.data },
then: (res: any) => {
resolve(res.data)

View File

@ -43,7 +43,7 @@
</DynamicsForm>
</template>
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { computed, ref, watch, provide } from 'vue'
import { WorkflowKind, WorkflowType } from '@/enums/application'
import DynamicsForm from '@/components/dynamics-form/index.vue'
import type { FormField } from '@/components/dynamics-form/type'
@ -100,9 +100,18 @@ const form_data = computed({
const source_node_list = computed(() => {
return props.workflow?.nodes?.filter((n: any) => n.properties.kind === WorkflowKind.DataSource)
})
const extra = ref<any>({
current_tool_id: undefined,
})
const get_extra = () => {
return extra.value
}
provide('get_extra', get_extra)
const sourceChange = (node_id: string) => {
base_form_data.value.node_id = node_id
const n = source_node_list.value.find((n: any) => n.id == node_id)
extra.value.current_tool_id = n.properties.node_data.tool_lib_id
node_id = n
? [WorkflowType.DataSourceLocalNode, WorkflowType.DataSourceWebNode].includes(n.type)
? n.type