|
33 | 33 | <el-button @click="dialogVisible = true">清除策略</el-button> |
34 | 34 | <el-button @click="exportLog">导出</el-button> |
35 | 35 | <el-button @click="openDocumentDialog" :disabled="multipleSelection.length === 0" |
36 | | - >添加至知识库</el-button |
37 | | - > |
| 36 | + >添加至知识库 |
| 37 | + </el-button> |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 |
|
|
171 | 171 | <span>天之前的对话记录</span> |
172 | 172 | <template #footer> |
173 | 173 | <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> |
177 | 177 | <el-button type="primary" @click="saveCleanTime"> |
178 | 178 | {{ $t('layout.topbar.avatar.dialog.save') }} |
179 | 179 | </el-button> |
|
253 | 253 | </el-form> |
254 | 254 | <template #footer> |
255 | 255 | <span class="dialog-footer"> |
256 | | - <el-button @click.prevent="dialogVisible = false"> 取消 </el-button> |
| 256 | + <el-button @click.prevent="documentDialogVisible = false"> 取消 </el-button> |
257 | 257 | <el-button type="primary" @click="submitForm(formRef)" :loading="documentLoading"> |
258 | 258 | 保存 |
259 | 259 | </el-button> |
@@ -365,6 +365,7 @@ const rules = reactive<FormRules>({ |
365 | 365 |
|
366 | 366 | const optionLoading = ref(false) |
367 | 367 | const documentList = ref<any[]>([]) |
| 368 | +
|
368 | 369 | function filterChange(val: string) { |
369 | 370 | if (val === 'clear') { |
370 | 371 | filter.value = cloneDeep(defaultFilter) |
@@ -487,6 +488,7 @@ function getDetail() { |
487 | 488 | days.value = res.data.clean_time |
488 | 489 | }) |
489 | 490 | } |
| 491 | +
|
490 | 492 | const exportLog = () => { |
491 | 493 | const arr: string[] = [] |
492 | 494 | multipleSelection.value.map((v) => { |
@@ -542,28 +544,26 @@ function saveCleanTime() { |
542 | 544 | }) |
543 | 545 | } |
544 | 546 |
|
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) |
549 | 549 | form.value.document_id = '' |
550 | | - getDocument(id) |
| 550 | + getDocument(dataset_id) |
551 | 551 | } |
552 | 552 |
|
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) |
557 | 555 | } |
558 | 556 |
|
559 | 557 | const datasetList = ref<any[]>([]) |
| 558 | +
|
560 | 559 | function getDataset() { |
561 | 560 | application.asyncGetApplicationDataset(id, documentLoading).then((res: any) => { |
562 | 561 | 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 |
565 | 564 | if (!datasetList.value.find((v) => v.id === form.value.dataset_id)) { |
566 | 565 | form.value.dataset_id = '' |
| 566 | + form.value.document_id = '' |
567 | 567 | } else { |
568 | 568 | getDocument(form.value.dataset_id) |
569 | 569 | } |
@@ -594,20 +594,24 @@ const submitForm = async (formEl: FormInstance | undefined) => { |
594 | 594 | }) |
595 | 595 | } |
596 | 596 |
|
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) => { |
599 | 599 | 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 | + } |
600 | 606 | }) |
601 | 607 | } |
602 | 608 |
|
603 | 609 | function openDocumentDialog() { |
604 | 610 | 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 | | - } |
608 | 611 | formRef.value?.clearValidate() |
609 | 612 | documentDialogVisible.value = true |
610 | 613 | } |
| 614 | +
|
611 | 615 | onMounted(() => { |
612 | 616 | changeDayHandle(history_day.value) |
613 | 617 | getDetail() |
|
0 commit comments