Skip to content

Commit cdc5fae

Browse files
feat: Execution records and details function
1 parent 3eff896 commit cdc5fae

File tree

13 files changed

+128
-47
lines changed

13 files changed

+128
-47
lines changed
Lines changed: 3 additions & 0 deletions
Loading

ui/src/components/app-icon/KnowledgeIcon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</el-avatar>
1414
<el-avatar
1515
v-else-if="type == 4"
16-
class="avatar-purple"
16+
class="avatar-orange"
1717
shape="square"
1818
:size="size"
1919
>

ui/src/styles/app.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ h5 {
428428
background: #3370ff;
429429
}
430430

431+
.avatar-orange {
432+
background: #ff8800;
433+
}
434+
431435
.layout-bg {
432436
background: var(--app-layout-bg-color);
433437
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525
</template>
2626
<script setup lang="ts">
27-
import { onUnmounted, ref, computed } from 'vue'
27+
import { onUnmounted, ref, computed, watch } from 'vue'
2828
2929
import ExecutionDetailContent from '@/components/ai-chat/component/knowledge-source-component/ExecutionDetailContent.vue'
3030
import { useRoute } from 'vue-router'
@@ -83,6 +83,15 @@ const stopPolling = () => {
8383
8484
// 启动轮询
8585
pollingTimer = setTimeout(getKnowledgeWorkflowAction, 0)
86+
87+
watch(
88+
() => props.id,
89+
() => {
90+
stopPolling()
91+
pollingTimer = setTimeout(getKnowledgeWorkflowAction, 0)
92+
},
93+
)
94+
8695
onUnmounted(() => {
8796
stopPolling()
8897
})

ui/src/views/knowledge-workflow/component/execution-record/ExecutionDetailDrawer.vue

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,22 @@
2828
<el-row :gutter="16" class="lighter">
2929
<el-col :span="6">
3030
<p class="color-secondary mb-4">{{ $t('workflow.initiator') }}</p>
31-
<p>{{ detail?.meta.user_name || '-' }}</p>
31+
<p>{{ props.currentContent?.meta.user_name || '-' }}</p>
3232
</el-col>
3333
<el-col :span="6">
3434
<p class="color-secondary mb-4">{{ $t('common.status.label') }}</p>
3535
<p>
36-
<el-text class="color-text-primary" v-if="detail?.state === 'SUCCESS'">
36+
<el-text
37+
class="color-text-primary"
38+
v-if="props.currentContent?.state === 'SUCCESS'"
39+
>
3740
<el-icon class="color-success"><SuccessFilled /></el-icon>
3841
{{ $t('common.status.success') }}
3942
</el-text>
40-
<el-text class="color-text-primary" v-else-if="detail?.state === 'FAILURE'">
43+
<el-text
44+
class="color-text-primary"
45+
v-else-if="props.currentContent?.state === 'FAILURE'"
46+
>
4147
<el-icon class="color-danger"><CircleCloseFilled /></el-icon>
4248
{{ $t('common.status.fail') }}
4349
</el-text>
@@ -49,15 +55,26 @@
4955
</el-col>
5056
<el-col :span="6">
5157
<p class="color-secondary mb-4">{{ $t('chat.KnowledgeSource.consumeTime') }}</p>
52-
<p>{{ detail?.run_time != undefined ? detail?.run_time + 's' : '-' }}</p>
58+
<p>
59+
{{
60+
props.currentContent?.run_time != undefined
61+
? props.currentContent?.run_time + 's'
62+
: '-'
63+
}}
64+
</p>
5365
</el-col>
5466
<el-col :span="6">
5567
<p class="color-secondary mb-4">{{ $t('chat.executionDetails.createTime') }}</p>
56-
<p>{{ datetimeFormat(detail?.create_time) }}</p>
68+
<p>{{ datetimeFormat(props.currentContent?.create_time) }}</p>
5769
</el-col>
5870
</el-row>
5971
</el-card>
60-
<Result :knowledge_id="knowledge_id" :id="action_id" is-record />
72+
<Result
73+
:knowledge_id="props.currentContent.knowledge_id"
74+
:id="currentId"
75+
is-record
76+
v-if="props.currentContent"
77+
/>
6178
</el-scrollbar>
6279
</div>
6380
<template #footer>
@@ -82,10 +99,10 @@ import { t } from '@/locales'
8299
const props = withDefaults(
83100
defineProps<{
84101
/**
85-
* 当前的id
102+
* 当前的action_id
86103
*/
87104
currentId: string
88-
currentContent: string
105+
currentContent: any
89106
/**
90107
* 下一条
91108
*/
@@ -102,7 +119,7 @@ const props = withDefaults(
102119
{},
103120
)
104121
105-
const emit = defineEmits(['update:currentId', 'update:currentContent', 'refresh'])
122+
const emit = defineEmits(['update:currentId', 'update:currentContent'])
106123
107124
const route = useRoute()
108125
@@ -118,42 +135,22 @@ const apiType = computed(() => {
118135
119136
const loading = ref(false)
120137
const visible = ref(false)
121-
const action_id = ref<string>('')
122-
const knowledge_id = ref<string>('')
123-
const detail = ref<any>(null)
124-
125-
function closeHandle() {
126-
action_id.value = ''
127-
knowledge_id.value = ''
128-
detail.value = null
129-
}
130138
131-
function getRecord() {
132-
if (props.currentId && visible.value) {
133-
}
134-
}
139+
function closeHandle() {}
135140
136141
watch(
137142
() => props.currentId,
138-
() => {
139-
action_id.value = ''
140-
knowledge_id.value = ''
141-
detail.value = null
142-
},
143+
() => {},
143144
)
144145
145146
watch(visible, (bool) => {
146147
if (!bool) {
147148
emit('update:currentId', '')
148-
emit('update:currentContent', '')
149-
emit('refresh')
149+
emit('update:currentContent', null)
150150
}
151151
})
152152
153-
const open = (row: any) => {
154-
action_id.value = row.id
155-
knowledge_id.value = row.knowledge_id
156-
detail.value = row
153+
const open = () => {
157154
visible.value = true
158155
}
159156

ui/src/views/knowledge-workflow/component/execution-record/ExecutionRecordDrawer.vue

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
@changePage="changePage"
4848
:maxTableHeight="150"
4949
:paginationConfig="paginationConfig"
50+
:row-class-name="setRowClass"
5051
>
5152
<el-table-column prop="user_name" :label="$t('workflow.initiator')">
5253
<template #default="{ row }">
@@ -94,7 +95,15 @@
9495
</template>
9596
</el-table-column>
9697
</app-table-infinite-scroll>
97-
<ExecutionDetailDrawer ref="ExecutionDetailDrawerRef" />
98+
<ExecutionDetailDrawer
99+
ref="ExecutionDetailDrawerRef"
100+
v-model:currentId="currentId"
101+
v-model:currentContent="currentContent"
102+
:next="nextRecord"
103+
:pre="preRecord"
104+
:pre_disable="pre_disable"
105+
:next_disable="next_disable"
106+
/>
98107
</el-drawer>
99108
</template>
100109
<script setup lang="ts">
@@ -104,6 +113,7 @@ import ExecutionDetailDrawer from './ExecutionDetailDrawer.vue'
104113
import { computed, ref, reactive } from 'vue'
105114
import { useRoute, useRouter } from 'vue-router'
106115
import { datetimeFormat } from '@/utils/time'
116+
import type { Dict } from '@/api/type/common'
107117
const drawer = ref<boolean>(false)
108118
const route = useRoute()
109119
@@ -118,7 +128,7 @@ const apiType = computed(() => {
118128
})
119129
const paginationConfig = reactive({
120130
current_page: 1,
121-
page_size: 50,
131+
page_size: 10,
122132
total: 0,
123133
})
124134
const query = ref<any>({
@@ -129,10 +139,22 @@ const loading = ref(false)
129139
const filter_type = ref<string>('user_name')
130140
const active_knowledge_id = ref<string>('')
131141
const data = ref<Array<any>>([])
142+
const tableIndexMap = computed<Dict<number>>(() => {
143+
return data.value
144+
.map((row, index) => ({
145+
[row.id]: index,
146+
}))
147+
.reduce((pre, next) => ({ ...pre, ...next }), {})
148+
})
132149
const ExecutionDetailDrawerRef = ref<any>()
150+
const currentId = ref<string>('')
151+
const currentContent = ref<string>('')
133152
134153
const toDetails = (row: any) => {
135-
ExecutionDetailDrawerRef.value.open(row)
154+
currentContent.value = row
155+
currentId.value = row.id
156+
157+
ExecutionDetailDrawerRef.value?.open()
136158
}
137159
138160
const changeFilterHandle = () => {
@@ -144,13 +166,59 @@ const changePage = () => {
144166
}
145167
146168
const getList = () => {
147-
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
169+
return loadSharedApi({ type: 'knowledge', systemType: apiType.value })
148170
.getWorkflowActionPage(active_knowledge_id.value, paginationConfig, query.value, loading)
149171
.then((ok: any) => {
150172
paginationConfig.total = ok.data?.total
151173
data.value = data.value.concat(ok.data.records)
152174
})
153175
}
176+
177+
const setRowClass = ({ row }: any) => {
178+
return currentId.value === row?.id ? 'highlight' : ''
179+
}
180+
181+
/**
182+
* 下一页
183+
*/
184+
const nextRecord = () => {
185+
const index = tableIndexMap.value[currentId.value] + 1
186+
if (index >= data.value.length) {
187+
if (index >= paginationConfig.total - 1) {
188+
return
189+
}
190+
paginationConfig.current_page = paginationConfig.current_page + 1
191+
getList().then(() => {
192+
currentId.value = data.value[index].id
193+
currentContent.value = data.value[index]
194+
})
195+
} else {
196+
currentId.value = data.value[index].id
197+
currentContent.value = data.value[index]
198+
}
199+
}
200+
const pre_disable = computed(() => {
201+
const index = tableIndexMap.value[currentId.value] - 1
202+
return index < 0
203+
})
204+
205+
const next_disable = computed(() => {
206+
const index = tableIndexMap.value[currentId.value] + 1
207+
return index >= data.value.length && index >= paginationConfig.total - 1
208+
})
209+
/**
210+
* 上一页
211+
*/
212+
const preRecord = () => {
213+
const index = tableIndexMap.value[currentId.value] - 1
214+
console.log('index', index)
215+
216+
if (index >= 0) {
217+
currentId.value = data.value[index].id
218+
currentContent.value = data.value[index]
219+
}
220+
}
221+
154222
const open = (knowledge_id: string) => {
155223
active_knowledge_id.value = knowledge_id
156224
getList()

ui/src/views/knowledge/KnowledgeSetting.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
v-if="detail?.type === 4"
8787
>
8888
<div class="flex align-center">
89-
<el-avatar class="mr-8 avatar-purple" shape="square" :size="32">
89+
<el-avatar class="mr-8 avatar-orange" shape="square" :size="32">
9090
<img src="@/assets/knowledge/logo_workflow.svg" style="width: 60%" alt="" />
9191
</el-avatar>
9292
<div>

ui/src/views/knowledge/component/KnowledgeListContainer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
</el-dropdown-item>
100100
<el-dropdown-item @click="openCreateDialog(CreateWorkflowKnowledgeDialog)">
101101
<div class="flex">
102-
<el-avatar class="avatar-purple mt-4" shape="square" :size="32">
102+
<el-avatar class="avatar-orange mt-4" shape="square" :size="32">
103103
<img src="@/assets/knowledge/logo_workflow.svg" style="width: 60%" alt="" />
104104
</el-avatar>
105105
<div class="pre-wrap ml-8">

ui/src/workflow/icons/base-node-icon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<el-avatar shape="square" style="background: #FF8800;">
2+
<el-avatar shape="square avatar-orange">
33
<img src="@/assets/workflow/icon_hi.svg" style="width: 75%" alt="" />
44
</el-avatar>
55
</template>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
2-
<el-avatar shape="square" style="background: #ff8800">
3-
<img src="@/assets/workflow/icon_hi.svg" style="width: 75%" alt="" />
2+
<el-avatar shape="square avatar-orange">
3+
<img src="@/assets/workflow/icon_knowledge-base.svg" style="width: 75%" alt="" />
44
</el-avatar>
55
</template>
66
<script setup lang="ts"></script>

0 commit comments

Comments
 (0)