Skip to content

Commit b121d95

Browse files
committed
fix: Optimization of knowledge base workflow execution logic
1 parent 7e7e786 commit b121d95

File tree

6 files changed

+46
-23
lines changed

6 files changed

+46
-23
lines changed

ui/src/components/dynamics-form/items/select/SingleSelect.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
</template>
2020
<script setup lang="ts">
2121
import type { FormField } from '@/components/dynamics-form/type'
22-
import { computed, ref } from 'vue'
22+
import { computed, ref, useAttrs } from 'vue'
2323
import _ from 'lodash'
24-
const rowTemp = ref<any>()
24+
const attrs = useAttrs() as any
2525
2626
const props = defineProps<{
2727
modelValue?: string
@@ -58,7 +58,7 @@ const option_list = computed(() => {
5858
5959
const label = (option: any) => {
6060
//置空
61-
if (props.modelValue && option_list.value) {
61+
if (props.modelValue && option_list.value && !attrs['allow-create']) {
6262
const oldItem = option_list.value.find((item) => item[valueField.value] === props.modelValue)
6363
if (!oldItem) {
6464
emit('update:modelValue', undefined)

ui/src/components/dynamics-form/items/tree/Tree.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ const loadNode = (node: Node, resolve: (nodeData: Tree[]) => void) => {
180180
request_call(request, {
181181
url: renderTemplate(attrs.url, props.otherParams),
182182
body: { current_node: node.level == 0 ? undefined : node.data },
183-
then: (res) => {
183+
then: (res: any) => {
184184
resolve(res.data)
185-
res.data.forEach((childNode) => {
185+
res.data.forEach((childNode: any) => {
186186
if (childNode.is_exist) {
187187
treeRef.value?.setChecked(childNode.token, true, false)
188188
}
@@ -191,9 +191,12 @@ const loadNode = (node: Node, resolve: (nodeData: Tree[]) => void) => {
191191
loading: loading,
192192
})
193193
}
194-
const props = withDefaults(defineProps<{ modelValue?: any; formField: FormField; otherParams }>(), {
195-
modelValue: () => [],
196-
})
194+
const props = withDefaults(
195+
defineProps<{ modelValue?: any; formField: FormField; otherParams: any }>(),
196+
{
197+
modelValue: () => [],
198+
},
199+
)
197200
198201
const emit = defineEmits(['update:modelValue', 'change'])
199202

ui/src/components/dynamics-form/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,6 @@ interface FormField {
173173

174174
children?: Array<FormField>
175175
required_asterisk?: boolean
176+
[propName: string]: any
176177
}
177178
export type { FormField }

ui/src/views/knowledge-workflow/component/Debug.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import ActionVue from '@/views/knowledge-workflow/component/action/index.vue'
1717
import { ref } from 'vue'
1818
const drawer = ref<boolean>(false)
1919
const _workflow = ref<any>(null)
20-
const _knowledge_id = ref<string>()
20+
const _knowledge_id = ref<string>('')
2121
const close = () => {
2222
drawer.value = false
2323
}

ui/src/views/knowledge-workflow/component/action/DataSource.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<DynamicsForm
3-
v-loading="loading"
43
v-model="form_data"
54
:render_data="model_form_field"
65
:model="form_data"
@@ -53,11 +52,20 @@ const model_form_field = ref<Array<FormField>>([])
5352
const props = defineProps<{
5453
workflow: any
5554
knowledge_id: string
55+
loading: boolean
5656
}>()
5757
const workspace_id = computed(() => {
5858
return user.getWorkspaceId()
5959
})
60-
const loading = ref<boolean>(false)
60+
const emit = defineEmits(['update:loading'])
61+
const _loading = computed({
62+
get: () => {
63+
return props.loading
64+
},
65+
set: (v: boolean) => {
66+
emit('update:loading', v)
67+
},
68+
})
6169
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
6270
const base_form_data = ref<{ node_id: string }>({ node_id: '' })
6371
const dynamics_form_data = ref<Dict<any>>({})
@@ -90,6 +98,7 @@ const sourceChange = (node_id: string) => {
9098
: 'tool',
9199
node_id,
92100
n,
101+
_loading,
93102
)
94103
.then((ok: any) => {
95104
dynamicsFormRef.value?.render(ok.data)

ui/src/views/knowledge-workflow/component/action/index.vue

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
<template>
2-
<div style="height: 100%; width: 100%">
2+
<div style="height: 100%; width: 100%" v-loading="loading">
33
<div style="height: calc(100% - 57px); overflow-y: auto; width: 100%">
4-
<component
5-
ref="ActionRef"
6-
:is="ak[active]"
7-
:workflow="workflow"
8-
:knowledge_id="knowledge_id"
9-
:id="action_id"
10-
></component>
4+
<keep-alive>
5+
<component
6+
ref="ActionRef"
7+
:is="ak[active]"
8+
v-model:loading="loading"
9+
:workflow="workflow"
10+
:knowledge_id="knowledge_id"
11+
:id="action_id"
12+
></component>
13+
</keep-alive>
1114
</div>
1215
<div class="el-drawer__footer">
13-
<el-button>Cancel</el-button>
14-
<el-button v-if="base_form_list.length > 0 && active == 'knowledge_base'" @click="up"
16+
<el-button
17+
v-if="base_form_list.length > 0 && active == 'knowledge_base'"
18+
:loading="loading"
19+
@click="up"
1520
>上一步</el-button
1621
>
17-
<el-button v-if="base_form_list.length > 0 && active == 'data_source'" @click="next"
22+
<el-button
23+
v-if="base_form_list.length > 0 && active == 'data_source'"
24+
:loading="loading"
25+
@click="next"
1826
>下一步</el-button
1927
>
2028
<el-button
2129
v-if="base_form_list.length > 0 ? active == 'knowledge_base' : true"
2230
@click="upload"
2331
type="primary"
32+
:loading="loading"
2433
>Upload
2534
</el-button>
2635
</div>
@@ -42,6 +51,7 @@ const ak = {
4251
knowledge_base: KnowledgeBase,
4352
result: Result,
4453
}
54+
const loading = ref<boolean>(false)
4555
const action_id = ref<string>()
4656
const ActionRef = ref()
4757
const form_data = ref<any>({})
@@ -71,7 +81,7 @@ const up = () => {
7181
const upload = () => {
7282
ActionRef.value.validate().then(() => {
7383
form_data.value[active.value] = ActionRef.value.get_data()
74-
KnowledgeApi.workflowAction(props.knowledge_id, form_data.value).then((ok) => {
84+
KnowledgeApi.workflowAction(props.knowledge_id, form_data.value, loading).then((ok) => {
7585
action_id.value = ok.data.id
7686
active.value = 'result'
7787
})

0 commit comments

Comments
 (0)