fix: Optimization of knowledge base workflow execution logic

This commit is contained in:
shaohuzhang1 2025-11-24 11:55:59 +08:00
parent 7e7e786bef
commit b121d95f10
6 changed files with 46 additions and 23 deletions

View File

@ -19,9 +19,9 @@
</template>
<script setup lang="ts">
import type { FormField } from '@/components/dynamics-form/type'
import { computed, ref } from 'vue'
import { computed, ref, useAttrs } from 'vue'
import _ from 'lodash'
const rowTemp = ref<any>()
const attrs = useAttrs() as any
const props = defineProps<{
modelValue?: string
@ -58,7 +58,7 @@ const option_list = computed(() => {
const label = (option: any) => {
//
if (props.modelValue && option_list.value) {
if (props.modelValue && option_list.value && !attrs['allow-create']) {
const oldItem = option_list.value.find((item) => item[valueField.value] === props.modelValue)
if (!oldItem) {
emit('update:modelValue', undefined)

View File

@ -180,9 +180,9 @@ const loadNode = (node: Node, resolve: (nodeData: Tree[]) => void) => {
request_call(request, {
url: renderTemplate(attrs.url, props.otherParams),
body: { current_node: node.level == 0 ? undefined : node.data },
then: (res) => {
then: (res: any) => {
resolve(res.data)
res.data.forEach((childNode) => {
res.data.forEach((childNode: any) => {
if (childNode.is_exist) {
treeRef.value?.setChecked(childNode.token, true, false)
}
@ -191,9 +191,12 @@ const loadNode = (node: Node, resolve: (nodeData: Tree[]) => void) => {
loading: loading,
})
}
const props = withDefaults(defineProps<{ modelValue?: any; formField: FormField; otherParams }>(), {
modelValue: () => [],
})
const props = withDefaults(
defineProps<{ modelValue?: any; formField: FormField; otherParams: any }>(),
{
modelValue: () => [],
},
)
const emit = defineEmits(['update:modelValue', 'change'])

View File

@ -173,5 +173,6 @@ interface FormField {
children?: Array<FormField>
required_asterisk?: boolean
[propName: string]: any
}
export type { FormField }

View File

@ -17,7 +17,7 @@ import ActionVue from '@/views/knowledge-workflow/component/action/index.vue'
import { ref } from 'vue'
const drawer = ref<boolean>(false)
const _workflow = ref<any>(null)
const _knowledge_id = ref<string>()
const _knowledge_id = ref<string>('')
const close = () => {
drawer.value = false
}

View File

@ -1,6 +1,5 @@
<template>
<DynamicsForm
v-loading="loading"
v-model="form_data"
:render_data="model_form_field"
:model="form_data"
@ -53,11 +52,20 @@ const model_form_field = ref<Array<FormField>>([])
const props = defineProps<{
workflow: any
knowledge_id: string
loading: boolean
}>()
const workspace_id = computed(() => {
return user.getWorkspaceId()
})
const loading = ref<boolean>(false)
const emit = defineEmits(['update:loading'])
const _loading = computed({
get: () => {
return props.loading
},
set: (v: boolean) => {
emit('update:loading', v)
},
})
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
const base_form_data = ref<{ node_id: string }>({ node_id: '' })
const dynamics_form_data = ref<Dict<any>>({})
@ -90,6 +98,7 @@ const sourceChange = (node_id: string) => {
: 'tool',
node_id,
n,
_loading,
)
.then((ok: any) => {
dynamicsFormRef.value?.render(ok.data)

View File

@ -1,26 +1,35 @@
<template>
<div style="height: 100%; width: 100%">
<div style="height: 100%; width: 100%" v-loading="loading">
<div style="height: calc(100% - 57px); overflow-y: auto; width: 100%">
<component
ref="ActionRef"
:is="ak[active]"
:workflow="workflow"
:knowledge_id="knowledge_id"
:id="action_id"
></component>
<keep-alive>
<component
ref="ActionRef"
:is="ak[active]"
v-model:loading="loading"
:workflow="workflow"
:knowledge_id="knowledge_id"
:id="action_id"
></component>
</keep-alive>
</div>
<div class="el-drawer__footer">
<el-button>Cancel</el-button>
<el-button v-if="base_form_list.length > 0 && active == 'knowledge_base'" @click="up"
<el-button
v-if="base_form_list.length > 0 && active == 'knowledge_base'"
:loading="loading"
@click="up"
>上一步</el-button
>
<el-button v-if="base_form_list.length > 0 && active == 'data_source'" @click="next"
<el-button
v-if="base_form_list.length > 0 && active == 'data_source'"
:loading="loading"
@click="next"
>下一步</el-button
>
<el-button
v-if="base_form_list.length > 0 ? active == 'knowledge_base' : true"
@click="upload"
type="primary"
:loading="loading"
>Upload
</el-button>
</div>
@ -42,6 +51,7 @@ const ak = {
knowledge_base: KnowledgeBase,
result: Result,
}
const loading = ref<boolean>(false)
const action_id = ref<string>()
const ActionRef = ref()
const form_data = ref<any>({})
@ -71,7 +81,7 @@ const up = () => {
const upload = () => {
ActionRef.value.validate().then(() => {
form_data.value[active.value] = ActionRef.value.get_data()
KnowledgeApi.workflowAction(props.knowledge_id, form_data.value).then((ok) => {
KnowledgeApi.workflowAction(props.knowledge_id, form_data.value, loading).then((ok) => {
action_id.value = ok.data.id
active.value = 'result'
})