Skip to content

Commit 842b4dd

Browse files
authored
fix: Workflow knowledge base execution supports document removal and continued import (#4420)
1 parent fb2c1b0 commit 842b4dd

File tree

5 files changed

+72
-46
lines changed

5 files changed

+72
-46
lines changed

ui/src/views/document/ImportWorkflowDocument.vue

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="upload-document__component main-calc-height">
1010
<el-scrollbar>
1111
<div class="upload-component p-24" style="min-width: 850px">
12-
<keep-alive>
12+
<keep-alive :key="key" :include="['data_source', 'knowledge_base']">
1313
<component
1414
ref="ActionRef"
1515
:is="ak[active]"
@@ -25,7 +25,9 @@
2525
</div>
2626
</el-card>
2727
<div class="upload-document__footer text-right border-t">
28-
<el-button :disabled="loading" @click="router.go(-1)">{{ $t('common.cancel') }}</el-button>
28+
<el-button v-if="active == 'result'" @click="continueImporting">
29+
{{ $t('views.document.buttons.continueImporting') }}
30+
</el-button>
2931
<el-button
3032
v-if="base_form_list.length > 0 && active == 'knowledge_base'"
3133
:loading="loading"
@@ -48,23 +50,27 @@
4850
>
4951
{{ $t('views.document.buttons.import') }}
5052
</el-button>
53+
<el-button v-if="active == 'result'" type="primary" @click="goDocument">{{
54+
$t('views.knowledge.ResultSuccess.buttons.toDocument')
55+
}}</el-button>
5156
</div>
5257
</div>
5358
</template>
5459
<script setup lang="ts">
55-
import { computed, ref, provide, type Ref, onMounted } from 'vue'
60+
import { computed, ref, provide, type Ref, onMounted, nextTick } from 'vue'
5661
import { useRouter, useRoute } from 'vue-router'
5762
import DataSource from '@/views/knowledge-workflow/component/action/DataSource.vue'
5863
import Result from '@/views/knowledge-workflow/component/action/Result.vue'
5964
import applicationApi from '@/api/application/application'
6065
import KnowledgeBase from '@/views/knowledge-workflow/component/action/KnowledgeBase.vue'
61-
import { loadSharedApi } from '@/utils/dynamics-api/shared-api.ts'
66+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
6267
import { WorkflowType } from '@/enums/application'
6368
provide('upload', (file: any, loading?: Ref<boolean>) => {
6469
return applicationApi.postUploadFile(file, id as string, 'KNOWLEDGE', loading)
6570
})
6671
const router = useRouter()
6772
const route = useRoute()
73+
const key = ref<number>(0)
6874
const {
6975
params: { folderId },
7076
query: { id },
@@ -132,7 +138,23 @@ function getDetail() {
132138
_workflow.value = res.data.work_flow
133139
})
134140
}
135-
141+
const continueImporting = () => {
142+
active.value = 'data_source'
143+
key.value++
144+
action_id.value = undefined
145+
const c_workflow = _workflow.value
146+
_workflow.value = null
147+
form_data.value = {}
148+
nextTick(() => {
149+
_workflow.value = c_workflow
150+
})
151+
}
152+
const goDocument = () => {
153+
const newUrl = router.resolve({
154+
path: `/knowledge/${id}/${folderId}/4/document`,
155+
}).href
156+
window.open(newUrl)
157+
}
136158
onMounted(() => {
137159
getDetail()
138160
})

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

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:before-close="close"
99
>
1010
<div style="height: calc(100% - 57px)" v-loading="loading">
11-
<keep-alive>
11+
<keep-alive :key="key" :include="['data_source', 'knowledge_base']">
1212
<component
1313
ref="ActionRef"
1414
:is="ak[active]"
@@ -20,10 +20,9 @@
2020
</keep-alive>
2121
</div>
2222
<template #footer>
23-
<el-button :loading="loading" @click="close">{{ $t('common.cancel') }}</el-button>
24-
<!-- <el-button v-if="active == 'result'" @click="continueImporting" :loading="loading">
23+
<el-button v-if="active == 'result'" @click="continueImporting">
2524
{{ $t('views.document.buttons.continueImporting') }}
26-
</el-button> -->
25+
</el-button>
2726
<el-button
2827
v-if="base_form_list.length > 0 && active == 'knowledge_base'"
2928
:loading="loading"
@@ -46,35 +45,29 @@
4645
>
4746
{{ $t('views.document.buttons.import') }}
4847
</el-button>
49-
<!-- <el-button
50-
v-if="active == 'result'"
51-
type="primary"
52-
@click="
53-
router.push({
54-
path: `/knowledge/${id}/${folderId}/4/document`,
55-
})
56-
"
57-
>{{ $t('views.knowledge.ResultSuccess.buttons.toDocument') }}</el-button
58-
> -->
48+
<el-button v-if="active == 'result'" type="primary" @click="goDocument">{{
49+
$t('views.knowledge.ResultSuccess.buttons.toDocument')
50+
}}</el-button>
5951
</template>
6052
</el-drawer>
6153
</template>
6254
<script setup lang="ts">
63-
import { computed, ref, provide, type Ref } from 'vue'
55+
import { computed, ref, provide, type Ref, nextTick } from 'vue'
6456
import DataSource from '@/views/knowledge-workflow/component/action/DataSource.vue'
6557
import Result from '@/views/knowledge-workflow/component/action/Result.vue'
6658
import applicationApi from '@/api/application/application'
6759
import KnowledgeBase from '@/views/knowledge-workflow/component/action/KnowledgeBase.vue'
6860
import { WorkflowType } from '@/enums/application'
69-
import { loadSharedApi } from '@/utils/dynamics-api/shared-api.ts'
61+
62+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
7063
import permissionMap from '@/permission'
7164
import { MsgError } from '@/utils/message'
7265
import { t } from '@/locales'
73-
7466
import { useRoute, useRouter } from 'vue-router'
7567
provide('upload', (file: any, loading?: Ref<boolean>) => {
7668
return applicationApi.postUploadFile(file, id, 'KNOWLEDGE', loading)
7769
})
70+
const key = ref<number>(0)
7871
const router = useRouter()
7972
const route = useRoute()
8073
const {
@@ -153,8 +146,21 @@ const upload = () => {
153146
}
154147
}
155148
const continueImporting = () => {
156-
action_id.value = undefined
157149
active.value = 'data_source'
150+
key.value++
151+
action_id.value = undefined
152+
const c_workflow = _workflow.value
153+
_workflow.value = null
154+
form_data.value = {}
155+
nextTick(() => {
156+
_workflow.value = c_workflow
157+
})
158+
}
159+
const goDocument = () => {
160+
const newUrl = router.resolve({
161+
path: `/knowledge/${id}/${folderId}/4/document`,
162+
}).href
163+
window.open(newUrl)
158164
}
159165
defineExpose({ close, open })
160166
</script>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
prop="node_id"
1818
:rules="base_form_data_rule.node_id"
1919
>
20-
<el-row class="w-full" gutter="8">
20+
<el-row class="w-full" :gutter="8">
2121
<el-col :span="8" v-for="node in source_node_list" :key="node.id">
2222
<el-card
2323
shadow="never"

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
</h4>
66
<div class="mb-16">
77
<!-- 执行结果 -->
8-
<!-- <el-alert
9-
v-if="isSuccess"
10-
:title="$t('views.workflow.debug.executionSuccess')"
11-
type="success"
12-
show-icon
13-
:closable="false"
14-
/>
15-
<el-alert
16-
v-else
17-
:title="$t('views.workflow.debug.executionFailed')"
18-
type="error"
19-
show-icon
20-
:closable="false"
21-
/> -->
8+
<el-alert
9+
v-if="state == 'SUCCESS'"
10+
:title="$t('views.workflow.debug.executionSuccess')"
11+
type="success"
12+
show-icon
13+
:closable="false"
14+
/>
15+
<el-alert
16+
v-if="state == 'FAILURE'"
17+
:title="$t('views.workflow.debug.executionFailed')"
18+
type="error"
19+
show-icon
20+
:closable="false"
21+
/>
2222
</div>
2323
<p class="lighter mb-8">{{ $t('chat.executionDetails.title') }}</p>
2424
<ExecutionDetailContent :detail="detail" app-type="WORK_FLOW"></ExecutionDetailContent>
@@ -45,21 +45,22 @@ const knowledge_action = ref<any>()
4545
let pollingTimer: any = null
4646
4747
const getKnowledgeWorkflowAction = () => {
48+
if (pollingTimer == null) {
49+
return
50+
}
4851
knowledgeApi
4952
.getWorkflowAction(props.knowledge_id, props.id)
5053
.then((ok) => {
5154
knowledge_action.value = ok.data
55+
})
56+
.finally(() => {
5257
if (['SUCCESS', 'FAILURE', 'REVOKED'].includes(state.value)) {
5358
stopPolling()
5459
} else {
5560
// 请求完成后再设置下次轮询
5661
pollingTimer = setTimeout(getKnowledgeWorkflowAction, 2000)
5762
}
5863
})
59-
.catch(() => {
60-
// 错误时也继续轮询
61-
pollingTimer = setTimeout(getKnowledgeWorkflowAction, 2000)
62-
})
6364
}
6465
6566
const stopPolling = () => {
@@ -70,8 +71,7 @@ const stopPolling = () => {
7071
}
7172
7273
// 启动轮询
73-
getKnowledgeWorkflowAction()
74-
74+
pollingTimer = setTimeout(getKnowledgeWorkflowAction, 0)
7575
onUnmounted(() => {
7676
stopPolling()
7777
})

ui/src/workflow/common/NodeContainer.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ import type { FormInstance } from 'element-plus'
180180
import { t } from '@/locales'
181181
import { useRoute } from 'vue-router'
182182
import DropdownMenu from '@/components/workflow-dropdown-menu/index.vue'
183-
const w = inject('workflowMode')
184-
console.log(w)
185183
const route = useRoute()
186184
const {
187185
params: { id },

0 commit comments

Comments
 (0)