Skip to content

Commit ec4f844

Browse files
committed
fix(应用): 修复对话日志添加的知识库的相关问题
1 parent 4fd6884 commit ec4f844

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

ui/src/views/log/component/EditContentDialog.vue

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,33 +216,36 @@ const onUploadImg = async (files: any, callback: any) => {
216216
callback(res.map((item) => item.data))
217217
}
218218
219-
function changeDataset(id: string) {
220-
if (user.userInfo) {
221-
localStorage.setItem(user.userInfo.id + 'chat_dataset_id', id)
222-
}
219+
function changeDataset(dataset_id: string) {
220+
localStorage.setItem(id + 'chat_dataset_id', dataset_id)
223221
form.value.document_id = ''
224-
getDocument(id)
222+
getDocument(dataset_id)
225223
}
226224
227-
function changeDocument(id: string) {
228-
if (user.userInfo) {
229-
localStorage.setItem(user.userInfo.id + 'chat_document_id', id)
230-
}
225+
function changeDocument(document_id: string) {
226+
localStorage.setItem(id + 'chat_document_id', document_id)
231227
}
232228
233-
function getDocument(id: string) {
234-
document.asyncGetAllDocument(id, loading).then((res: any) => {
229+
function getDocument(dataset_id: string) {
230+
document.asyncGetAllDocument(dataset_id, loading).then((res: any) => {
235231
documentList.value = res.data
232+
if (localStorage.getItem(id + 'chat_document_id')) {
233+
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string
234+
}
235+
if (!documentList.value.find((v) => v.id === form.value.document_id)) {
236+
form.value.document_id = ''
237+
}
236238
})
237239
}
238240
239241
function getDataset() {
240242
application.asyncGetApplicationDataset(id, loading).then((res: any) => {
241243
datasetList.value = res.data
242-
if (localStorage.getItem(user.userInfo?.id + 'chat_dataset_id')) {
243-
form.value.dataset_id = localStorage.getItem(user.userInfo?.id + 'chat_dataset_id') as string
244+
if (localStorage.getItem(id + 'chat_dataset_id')) {
245+
form.value.dataset_id = localStorage.getItem(id + 'chat_dataset_id') as string
244246
if (!datasetList.value.find((v) => v.id === form.value.dataset_id)) {
245247
form.value.dataset_id = ''
248+
form.value.document_id = ''
246249
} else {
247250
getDocument(form.value.dataset_id)
248251
}
@@ -252,9 +255,6 @@ function getDataset() {
252255
253256
const open = (data: any) => {
254257
getDataset()
255-
if (localStorage.getItem(user.userInfo?.id + 'chat_document_id')) {
256-
form.value.document_id = localStorage.getItem(user.userInfo?.id + 'chat_document_id') as string
257-
}
258258
form.value.chat_id = data.chat_id
259259
form.value.record_id = data.id
260260
form.value.problem_text = data.problem_text ? data.problem_text.substring(0, 256) : ''

ui/src/views/log/index.vue

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<el-button @click="dialogVisible = true">清除策略</el-button>
3434
<el-button @click="exportLog">导出</el-button>
3535
<el-button @click="openDocumentDialog" :disabled="multipleSelection.length === 0"
36-
>添加至知识库</el-button
37-
>
36+
>添加至知识库
37+
</el-button>
3838
</div>
3939
</div>
4040

@@ -171,9 +171,9 @@
171171
<span>天之前的对话记录</span>
172172
<template #footer>
173173
<div class="dialog-footer" style="margin-top: 16px">
174-
<el-button @click="dialogVisible = false">{{
175-
$t('layout.topbar.avatar.dialog.cancel')
176-
}}</el-button>
174+
<el-button @click="dialogVisible = false"
175+
>{{ $t('layout.topbar.avatar.dialog.cancel') }}
176+
</el-button>
177177
<el-button type="primary" @click="saveCleanTime">
178178
{{ $t('layout.topbar.avatar.dialog.save') }}
179179
</el-button>
@@ -253,7 +253,7 @@
253253
</el-form>
254254
<template #footer>
255255
<span class="dialog-footer">
256-
<el-button @click.prevent="dialogVisible = false"> 取消 </el-button>
256+
<el-button @click.prevent="documentDialogVisible = false"> 取消 </el-button>
257257
<el-button type="primary" @click="submitForm(formRef)" :loading="documentLoading">
258258
保存
259259
</el-button>
@@ -365,6 +365,7 @@ const rules = reactive<FormRules>({
365365
366366
const optionLoading = ref(false)
367367
const documentList = ref<any[]>([])
368+
368369
function filterChange(val: string) {
369370
if (val === 'clear') {
370371
filter.value = cloneDeep(defaultFilter)
@@ -487,6 +488,7 @@ function getDetail() {
487488
days.value = res.data.clean_time
488489
})
489490
}
491+
490492
const exportLog = () => {
491493
const arr: string[] = []
492494
multipleSelection.value.map((v) => {
@@ -542,28 +544,26 @@ function saveCleanTime() {
542544
})
543545
}
544546
545-
function changeDataset(id: string) {
546-
if (user.userInfo) {
547-
localStorage.setItem(user.userInfo.id + 'chat_dataset_id', id)
548-
}
547+
function changeDataset(dataset_id: string) {
548+
localStorage.setItem(id + 'chat_dataset_id', dataset_id)
549549
form.value.document_id = ''
550-
getDocument(id)
550+
getDocument(dataset_id)
551551
}
552552
553-
function changeDocument(id: string) {
554-
if (user.userInfo) {
555-
localStorage.setItem(user.userInfo.id + 'chat_document_id', id)
556-
}
553+
function changeDocument(document_id: string) {
554+
localStorage.setItem(id + 'chat_document_id', document_id)
557555
}
558556
559557
const datasetList = ref<any[]>([])
558+
560559
function getDataset() {
561560
application.asyncGetApplicationDataset(id, documentLoading).then((res: any) => {
562561
datasetList.value = res.data
563-
if (localStorage.getItem(user.userInfo?.id + 'chat_dataset_id')) {
564-
form.value.dataset_id = localStorage.getItem(user.userInfo?.id + 'chat_dataset_id') as string
562+
if (localStorage.getItem(id + 'chat_dataset_id')) {
563+
form.value.dataset_id = localStorage.getItem(id + 'chat_dataset_id') as string
565564
if (!datasetList.value.find((v) => v.id === form.value.dataset_id)) {
566565
form.value.dataset_id = ''
566+
form.value.document_id = ''
567567
} else {
568568
getDocument(form.value.dataset_id)
569569
}
@@ -594,20 +594,24 @@ const submitForm = async (formEl: FormInstance | undefined) => {
594594
})
595595
}
596596
597-
function getDocument(id: string) {
598-
document.asyncGetAllDocument(id, documentLoading).then((res: any) => {
597+
function getDocument(dataset_id: string) {
598+
document.asyncGetAllDocument(dataset_id, documentLoading).then((res: any) => {
599599
documentList.value = res.data
600+
if (localStorage.getItem(id + 'chat_document_id')) {
601+
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string
602+
}
603+
if (!documentList.value.find((v) => v.id === form.value.document_id)) {
604+
form.value.document_id = ''
605+
}
600606
})
601607
}
602608
603609
function openDocumentDialog() {
604610
getDataset()
605-
if (localStorage.getItem(user.userInfo?.id + 'chat_document_id')) {
606-
form.value.document_id = localStorage.getItem(user.userInfo?.id + 'chat_document_id') as string
607-
}
608611
formRef.value?.clearValidate()
609612
documentDialogVisible.value = true
610613
}
614+
611615
onMounted(() => {
612616
changeDayHandle(history_day.value)
613617
getDetail()

0 commit comments

Comments
 (0)