Skip to content

Commit f0bbe1c

Browse files
feat: document
1 parent 56dc0c8 commit f0bbe1c

File tree

11 files changed

+367
-269
lines changed

11 files changed

+367
-269
lines changed

ui/src/api/knowledge/document.ts

Lines changed: 308 additions & 228 deletions
Large diffs are not rendered by default.

ui/src/assets/upload-icon.svg

Lines changed: 6 additions & 0 deletions
Loading

ui/src/components/generate-related-dialog/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const submitHandle = async (formEl: FormInstance) => {
166166
document_id_list: idList.value,
167167
state_list: stateMap[state.value]
168168
}
169-
documentApi.batchGenerateRelated(id, data, loading).then(() => {
169+
documentApi.putBatchGenerateRelated(id, data, loading).then(() => {
170170
MsgSuccess(t('views.document.generateQuestion.successMessage'))
171171
emit('refresh')
172172
dialogVisible.value = false

ui/src/router/modules/2knowledge.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ const ModelRouter = {
1111
meta: { title: '知识库主页', activeMenu: '/knowledge' },
1212
component: () => import('@/views/knowledge/index.vue'),
1313
},
14+
15+
// 上传文档
16+
{
17+
path: '/knowledge/document/upload',
18+
name: 'UploadDocument',
19+
meta: { activeMenu: '/knowledge' },
20+
component: () => import('@/views/document/UploadDocument.vue'),
21+
hidden: true,
22+
},
1423
],
1524
}
1625

ui/src/stores/modules/document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const useDocumentStore = defineStore('document', {
2020
async asyncPostDocument(knowledgeId: string, data: any, loading?: Ref<boolean>) {
2121
return new Promise((resolve, reject) => {
2222
documentApi
23-
.postDocument(knowledgeId, data, loading)
23+
.postMulDocument(knowledgeId, data, loading)
2424
.then((data) => {
2525
resolve(data)
2626
})

ui/src/views/knowledge/UploadDocumentKnowledge.vue renamed to ui/src/views/document/UploadDocument.vue

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
<template>
2-
<LayoutContainer :header="$t('views.document.uploadDocument')" class="create-dataset">
3-
<template #backButton>
4-
<back-button @click="back"></back-button>
5-
</template>
6-
<div class="create-dataset__main flex" v-loading="loading">
7-
<div class="create-dataset__component main-calc-height">
8-
<el-scrollbar>
9-
<template v-if="active === 0">
10-
<div class="upload-document p-24">
11-
<!-- 上传文档 -->
12-
<UploadComponent ref="UploadComponentRef" />
13-
</div>
14-
</template>
15-
<template v-else-if="active === 1">
16-
<SetRules ref="SetRulesRef" />
17-
</template>
18-
<template v-else-if="active === 2">
19-
<ResultSuccess :data="successInfo" />
20-
</template>
21-
</el-scrollbar>
22-
</div>
2+
<div class="upload-document p-12-24">
3+
<div class="flex align-center mb-16">
4+
<back-button to="-1" style="margin-left: -4px"></back-button>
5+
<h3 style="display: inline-block">{{ $t('views.document.uploadDocument') }}</h3>
236
</div>
24-
<div class="create-dataset__footer text-right border-t" v-if="active !== 2">
7+
<el-card style="--el-card-padding: 0">
8+
<div class="upload-document__main flex" v-loading="loading">
9+
<div class="upload-document__component main-calc-height">
10+
<el-scrollbar>
11+
<template v-if="active === 0">
12+
<div class="upload-component p-24">
13+
<!-- 上传文档 -->
14+
<UploadComponent ref="UploadComponentRef" />
15+
</div>
16+
</template>
17+
<template v-else-if="active === 1">
18+
<SetRules ref="SetRulesRef" />
19+
</template>
20+
<template v-else-if="active === 2">
21+
<ResultSuccess :data="successInfo" />
22+
</template>
23+
</el-scrollbar>
24+
</div>
25+
</div>
26+
</el-card>
27+
<div class="upload-document__footer text-right border-t" v-if="active !== 2">
2528
<el-button @click="router.go(-1)" :disabled="SetRulesRef?.loading || loading">{{
2629
$t('common.cancel')
2730
}}</el-button>
@@ -49,15 +52,15 @@
4952
{{ $t('views.document.buttons.import') }}
5053
</el-button>
5154
</div>
52-
</LayoutContainer>
55+
</div>
5356
</template>
5457
<script setup lang="ts">
5558
import { ref, computed, onUnmounted } from 'vue'
5659
import { useRouter, useRoute } from 'vue-router'
57-
import SetRules from './component/SetRules.vue'
58-
import ResultSuccess from './component/ResultSuccess.vue'
59-
import UploadComponent from './component/UploadComponent.vue'
60-
import documentApi from '@/api/document'
60+
import SetRules from './upload/SetRules.vue'
61+
import ResultSuccess from './upload/ResultSuccess.vue'
62+
import UploadComponent from './upload/UploadComponent.vue'
63+
import documentApi from '@/api/knowledge/document'
6164
import { MsgConfirm, MsgSuccess } from '@/utils/message'
6265
import { t } from '@/locales'
6366
import useStore from '@/stores'
@@ -68,7 +71,7 @@ const documentsType = computed(() => knowledge.documentsType)
6871
const router = useRouter()
6972
const route = useRoute()
7073
const {
71-
query: { id } // id为knowledgeID,有id的是上传文档
74+
query: { id }, // id为knowledgeID,有id的是上传文档
7275
} = route
7376
7477
const SetRulesRef = ref()
@@ -137,7 +140,7 @@ function submit() {
137140
}
138141
documents.push({
139142
name: item.name,
140-
paragraphs: item.content
143+
paragraphs: item.content,
141144
})
142145
})
143146
@@ -159,7 +162,7 @@ function back() {
159162
if (documentsFiles.value?.length > 0) {
160163
MsgConfirm(t('common.tip'), t('views.document.tip.saveMessage'), {
161164
confirmButtonText: t('common.confirm'),
162-
type: 'warning'
165+
type: 'warning',
163166
})
164167
.then(() => {
165168
router.go(-1)
@@ -175,7 +178,7 @@ onUnmounted(() => {
175178
})
176179
</script>
177180
<style lang="scss" scoped>
178-
.create-dataset {
181+
.upload-document {
179182
&__steps {
180183
min-width: 450px;
181184
max-width: 800px;
@@ -203,7 +206,7 @@ onUnmounted(() => {
203206
width: 100%;
204207
box-sizing: border-box;
205208
}
206-
.upload-document {
209+
.upload-component {
207210
width: 70%;
208211
margin: 0 auto;
209212
margin-bottom: 20px;

ui/src/views/document/component/ImportDocumentDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const submit = async (formEl: FormInstance | undefined) => {
217217
directly_return_similarity: form.value.directly_return_similarity,
218218
id_list: documentList.value
219219
}
220-
documentApi.batchEditHitHandling(id, obj, loading).then(() => {
220+
documentApi.putBatchEditHitHandling(id, obj, loading).then(() => {
221221
MsgSuccess(t('common.settingSuccess'))
222222
emit('refresh')
223223
dialogVisible.value = false

ui/src/views/document/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<el-button
1010
v-if="datasetDetail.type === 0"
1111
type="primary"
12-
@click="router.push({ path: '/knowledge/upload', query: { id: id } })"
12+
@click="router.push({ path: '/knowledge/document/upload', query: { id: id } })"
1313
>{{ $t('views.document.uploadDocument') }}
1414
</el-button>
1515
<el-button v-if="datasetDetail.type === 1" type="primary" @click="importDoc"
@@ -625,7 +625,7 @@ function cancelTaskHandle(val: any) {
625625
id_list: arr,
626626
type: val,
627627
}
628-
documentApi.batchCancelTask(id, obj, loading).then(() => {
628+
documentApi.putBatchCancelTask(id, obj, loading).then(() => {
629629
MsgSuccess(t('views.document.tip.cancelSuccess'))
630630
multipleTableRef.value?.clearSelection()
631631
})
@@ -668,7 +668,7 @@ function beforeCommand(attr: string, val: any, task_type?: number) {
668668
}
669669
670670
const cancelTask = (row: any, task_type: number) => {
671-
documentApi.cancelTask(row.dataset_id, row.id, { type: task_type }).then(() => {
671+
documentApi.putCancelTask(row.dataset_id, row.id, { type: task_type }).then(() => {
672672
MsgSuccess(t('views.document.tip.sendMessage'))
673673
})
674674
}
@@ -796,7 +796,7 @@ function syncMulDocument() {
796796
arr.push(v.id)
797797
}
798798
})
799-
documentApi.delMulSyncDocument(id, arr, loading).then(() => {
799+
documentApi.putMulSyncDocument(id, arr, loading).then(() => {
800800
MsgSuccess(t('views.document.sync.successMessage'))
801801
getList()
802802
})
File renamed without changes.

ui/src/views/knowledge/component/SetRules.vue renamed to ui/src/views/document/upload/SetRules.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
import { ref, computed, onMounted, reactive, watch } from 'vue'
123123
import ParagraphPreview from '@/views/knowledge/component/ParagraphPreview.vue'
124124
import { cutFilename } from '@/utils/utils'
125-
import documentApi from '@/api/document'
125+
import documentApi from '@/api/knowledge/document'
126126
import useStore from '@/stores'
127127
import type { KeyValue } from '@/api/type/common'
128128
const { knowledge } = useStore()

0 commit comments

Comments
 (0)