Skip to content

Commit 7acdd88

Browse files
feat: document
1 parent 73df001 commit 7acdd88

File tree

10 files changed

+82
-105
lines changed

10 files changed

+82
-105
lines changed

ui/src/api/knowledge/document.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ const getDocumentPage: (
5454
* 文档详情
5555
* @param 参数 knowledge_id
5656
*/
57-
const getDocumentDetail: (knowledge_id: string, document_id: string) => Promise<Result<any>> = (
58-
knowledge_id,
59-
document_id,
60-
) => {
61-
return get(`${prefix.value}/${knowledge_id}/document/${document_id}`)
57+
const getDocumentDetail: (
58+
knowledge_id: string,
59+
document_id: string,
60+
loading?: Ref<boolean>,
61+
) => Promise<Result<any>> = (knowledge_id, document_id, loading) => {
62+
return get(`${prefix.value}/${knowledge_id}/document/${document_id}`,
63+
{},
64+
loading,)
6265
}
6366

6467
/**
@@ -108,12 +111,7 @@ const putBatchCancelTask: (
108111
data: any,
109112
loading?: Ref<boolean>,
110113
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
111-
return put(
112-
`${prefix.value}/${knowledge_id}/document/batch_cancel_task`,
113-
data,
114-
undefined,
115-
loading,
116-
)
114+
return put(`${prefix.value}/${knowledge_id}/document/batch_cancel_task`, data, undefined, loading)
117115
}
118116

119117
/**
@@ -560,12 +558,11 @@ const putMulLarkSyncDocument: (
560558
const importLarkDocument: (
561559
knowledge_id: string,
562560
data: any,
563-
loading?: Ref<boolean>
561+
loading?: Ref<boolean>,
564562
) => Promise<Result<Array<any>>> = (knowledge_id, data, loading) => {
565563
return post(`${prefix.value}/lark/${knowledge_id}/import`, data, null, loading)
566564
}
567565

568-
569566
export default {
570567
getDocumentList,
571568
getDocumentPage,
@@ -596,5 +593,5 @@ export default {
596593
getLarkDocumentList,
597594
putLarkDocumentSync,
598595
putMulLarkSyncDocument,
599-
importLarkDocument
596+
importLarkDocument,
600597
}

ui/src/api/knowledge/paragraph.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,5 +300,6 @@ export default {
300300
putMulParagraph,
301301
putBatchGenerateRelated,
302302
putMigrateMulParagraph,
303-
putDisassociationProblem
303+
putDisassociationProblem,
304+
putAdjustPosition
304305
}

ui/src/api/resource-management/document.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ const getDocument: (
2727
)
2828
}
2929

30+
3031
/**
3132
* 文档详情
3233
* @param 参数 knowledge_id
3334
*/
34-
const getDocumentDetail: (knowledge_id: string, document_id: string) => Promise<Result<any>> = (
35-
knowledge_id,
36-
document_id,
37-
) => {
38-
return get(`${prefix}/${knowledge_id}/document/${document_id}`)
35+
const getDocumentDetail: (
36+
knowledge_id: string,
37+
document_id: string,
38+
loading?: Ref<boolean>,
39+
) => Promise<Result<any>> = (knowledge_id, document_id, loading) => {
40+
return get(`${prefix}/${knowledge_id}/document/${document_id}`,
41+
{},
42+
loading,)
3943
}
4044

4145
/**

ui/src/api/shared/document.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ const getDocumentPage: (
2626
loading,
2727
)
2828
}
29-
3029
/**
3130
* 文档详情
3231
* @param 参数 knowledge_id
3332
*/
34-
const getDocumentDetail: (knowledge_id: string, document_id: string) => Promise<Result<any>> = (
35-
knowledge_id,
36-
document_id,
37-
) => {
38-
return get(`${prefix}/${knowledge_id}/document/${document_id}`)
33+
const getDocumentDetail: (
34+
knowledge_id: string,
35+
document_id: string,
36+
loading?: Ref<boolean>,
37+
) => Promise<Result<any>> = (knowledge_id, document_id, loading) => {
38+
return get(`${prefix}/${knowledge_id}/document/${document_id}`, {}, loading)
3939
}
4040

4141
/**
@@ -85,12 +85,7 @@ const putBatchCancelTask: (
8585
data: any,
8686
loading?: Ref<boolean>,
8787
) => Promise<Result<boolean>> = (knowledge_id, data, loading) => {
88-
return put(
89-
`${prefix}/${knowledge_id}/document/batch_cancel_task`,
90-
data,
91-
undefined,
92-
loading,
93-
)
88+
return put(`${prefix}/${knowledge_id}/document/batch_cancel_task`, data, undefined, loading)
9489
}
9590

9691
/**
@@ -470,12 +465,7 @@ const getLarkDocumentList: (
470465
data: any,
471466
loading?: Ref<boolean>,
472467
) => Promise<Result<any>> = (knowledge_id, folder_token, data, loading) => {
473-
return post(
474-
`${prefix}/lark/${knowledge_id}/${folder_token}/doc_list`,
475-
data,
476-
undefined,
477-
loading,
478-
)
468+
return post(`${prefix}/lark/${knowledge_id}/${folder_token}/doc_list`, data, undefined, loading)
479469
}
480470

481471
/**

ui/src/views/paragraph/component/ParagraphCard.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@mouseenter="cardEnter()"
66
@mouseleave="cardLeave()"
77
@click.stop="editParagraph(data)"
8+
v-loading="loading"
89
>
910
<h2 class="mb-16">{{ data.title || '-' }}</h2>
1011
<div v-show="show" class="mk-sticky" v-if="!disabled">
@@ -30,7 +31,7 @@
3031
</el-button>
3132
</span>
3233
<span class="mr-8">
33-
<el-button link>
34+
<el-button link @click.stop="addParagraph(data)">
3435
<el-icon :size="16" :title="$t('views.applicationWorkflow.control.zoomOut')">
3536
<el-icon><CirclePlus /></el-icon>
3637
</el-icon>
@@ -154,6 +155,11 @@ function editParagraph(row: any) {
154155
}
155156
}
156157
158+
function addParagraph(row: any) {
159+
title.value = t('views.paragraph.addParagraph')
160+
ParagraphDialogRef.value.open(row, 'add')
161+
}
162+
157163
const SelectDocumentDialogRef = ref()
158164
function openSelectDocumentDialog(row?: any) {
159165
SelectDocumentDialogRef.value.open([row.id])

ui/src/views/paragraph/component/ParagraphDialog.vue

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
destroy-on-close
88
:close-on-click-modal="false"
99
:close-on-press-escape="false"
10+
@click.stop
1011
>
1112
<el-row v-loading="loading">
1213
<el-col :span="18">
1314
<el-scrollbar height="500" wrap-class="paragraph-scrollbar">
1415
<div class="p-24" style="padding-bottom: 8px">
1516
<div style="position: absolute; right: 20px; top: 20px">
16-
<el-button text @click="isEdit = true" v-if="problemId && !isEdit">
17+
<el-button text @click="isEdit = true" v-if="paragraphId && !isEdit">
1718
<el-icon><EditPen /></el-icon>
1819
</el-button>
1920
</div>
2021

2122
<ParagraphForm ref="paragraphFormRef" :data="detail" :isEdit="isEdit" />
2223
</div>
2324
</el-scrollbar>
24-
<div class="text-right p-24 pt-0" v-if="problemId && isEdit">
25+
<div class="text-right p-24 pt-0" v-if="paragraphId && isEdit">
2526
<el-button @click.prevent="cancelEdit"> {{ $t('common.cancel') }} </el-button>
2627
<el-button type="primary" :disabled="loading" @click="handleDebounceClick">
2728
{{ $t('common.save') }}
@@ -31,14 +32,14 @@
3132
<el-col :span="6" class="border-l" style="width: 300px">
3233
<!-- 关联问题 -->
3334
<ProblemComponent
34-
:problemId="problemId"
35+
:paragraphId="paragraphId"
3536
:docId="document_id"
3637
:knowledgeId="dataset_id"
3738
ref="ProblemRef"
3839
/>
3940
</el-col>
4041
</el-row>
41-
<template #footer v-if="!problemId">
42+
<template #footer v-if="!paragraphId">
4243
<span class="dialog-footer">
4344
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
4445
<el-button :disabled="loading" type="primary" @click="handleDebounceClick">
@@ -76,16 +77,17 @@ const paragraphFormRef = ref<any>()
7677
const dialogVisible = ref<boolean>(false)
7778
7879
const loading = ref(false)
79-
const problemId = ref('')
80+
const paragraphId = ref('')
8081
const detail = ref<any>({})
8182
const isEdit = ref(false)
8283
const document_id = ref('')
8384
const dataset_id = ref('')
8485
const cloneData = ref(null)
86+
const position = ref(null)
8587
8688
watch(dialogVisible, (bool) => {
8789
if (!bool) {
88-
problemId.value = ''
90+
paragraphId.value = ''
8991
detail.value = {}
9092
isEdit.value = false
9193
document_id.value = ''
@@ -99,28 +101,31 @@ const cancelEdit = () => {
99101
detail.value = cloneDeep(cloneData.value)
100102
}
101103
102-
const open = (data: any) => {
103-
if (data) {
104+
const open = (data: any, str: any) => {
105+
if (data && !str) {
104106
detail.value.title = data.title
105107
detail.value.content = data.content
106108
cloneData.value = cloneDeep(detail.value)
107-
problemId.value = data.id
109+
paragraphId.value = data.id
108110
document_id.value = data.document_id
109111
dataset_id.value = data.dataset_id || id
110112
} else {
111113
isEdit.value = true
114+
if (str === 'add') {
115+
position.value = data.position
116+
}
112117
}
113118
dialogVisible.value = true
114119
}
115120
const submitHandle = async () => {
116121
if (await paragraphFormRef.value?.validate()) {
117122
loading.value = true
118-
if (problemId.value) {
123+
if (paragraphId.value) {
119124
paragraph
120125
.asyncPutParagraph(
121126
dataset_id.value,
122127
documentId || document_id.value,
123-
problemId.value,
128+
paragraphId.value,
124129
paragraphFormRef.value?.form,
125130
loading,
126131
)
@@ -132,10 +137,14 @@ const submitHandle = async () => {
132137
const obj =
133138
ProblemRef.value.problemList.length > 0
134139
? {
140+
position: String(position.value) ? position.value : null,
135141
problem_list: ProblemRef.value.problemList,
136142
...paragraphFormRef.value?.form,
137143
}
138-
: paragraphFormRef.value?.form
144+
: {
145+
position: String(position.value) ? position.value : null,
146+
...paragraphFormRef.value?.form,
147+
}
139148
paragraphApi.postParagraph(id, documentId, obj, loading).then((res) => {
140149
dialogVisible.value = false
141150
emit('refresh')

ui/src/views/paragraph/component/ProblemComponent.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import paragraphApi from '@/api/knowledge/paragraph'
6161
import useStore from '@/stores'
6262
6363
const props = defineProps({
64-
problemId: String,
64+
paragraphId: String,
6565
docId: String,
6666
knowledgeId: String,
6767
})
@@ -83,7 +83,7 @@ const problemOptions = ref<any[]>([])
8383
const optionLoading = ref(false)
8484
8585
watch(
86-
() => props.problemId,
86+
() => props.paragraphId,
8787
(value) => {
8888
if (value) {
8989
getProblemList()
@@ -100,7 +100,7 @@ function delProblemHandle(item: any, index: number) {
100100
.asyncDisassociationProblem(
101101
props.knowledgeId || id,
102102
documentId || props.docId,
103-
props.problemId || '',
103+
props.paragraphId || '',
104104
item.id,
105105
loading,
106106
)
@@ -115,7 +115,7 @@ function delProblemHandle(item: any, index: number) {
115115
function getProblemList() {
116116
loading.value = true
117117
paragraphApi
118-
.getParagraphProblem(props.knowledgeId || id, documentId || props.docId, props.problemId || '')
118+
.getParagraphProblem(props.knowledgeId || id, documentId || props.docId, props.paragraphId || '')
119119
.then((res) => {
120120
problemList.value = res.data
121121
loading.value = false
@@ -132,19 +132,19 @@ function addProblem() {
132132
})
133133
}
134134
function addProblemHandle(val: string) {
135-
if (props.problemId) {
135+
if (props.paragraphId) {
136136
const api = problemOptions.value.some((option) => option.id === val)
137137
? paragraph.asyncAssociationProblem(
138138
props.knowledgeId || id,
139139
documentId || props.docId,
140-
props.problemId,
140+
props.paragraphId,
141141
val,
142142
loading,
143143
)
144144
: paragraphApi.postParagraphProblem(
145145
props.knowledgeId || id,
146146
documentId || props.docId,
147-
props.problemId,
147+
props.paragraphId,
148148
{
149149
content: val,
150150
},

0 commit comments

Comments
 (0)