feat: 文档状态
This commit is contained in:
parent
4274504b31
commit
e42892f9a5
@ -121,6 +121,28 @@ const getDocumentDetail: (dataset_id: string, document_id: string) => Promise<Re
|
|||||||
return get(`${prefix}/${dataset_id}/document/${document_id}`)
|
return get(`${prefix}/${dataset_id}/document/${document_id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新文档向量库
|
||||||
|
* @param 参数
|
||||||
|
* dataset_id, document_id,
|
||||||
|
* {
|
||||||
|
"name": "string",
|
||||||
|
"is_active": true
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const putDocumentRefresh: (
|
||||||
|
dataset_id: string,
|
||||||
|
document_id: string,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<Result<any>> = (dataset_id, document_id, loading) => {
|
||||||
|
return put(
|
||||||
|
`${prefix}/${dataset_id}/document/${document_id}/refresh`,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
loading
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
postSplitDocument,
|
postSplitDocument,
|
||||||
getDocument,
|
getDocument,
|
||||||
@ -129,5 +151,6 @@ export default {
|
|||||||
putDocument,
|
putDocument,
|
||||||
delDocument,
|
delDocument,
|
||||||
getDocumentDetail,
|
getDocumentDetail,
|
||||||
listSplitPattern
|
listSplitPattern,
|
||||||
|
putDocumentRefresh
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,14 +80,14 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span v-if="row.status === 2">
|
<span v-if="row.status === '2'" class="mr-4">
|
||||||
<el-tooltip effect="dark" content="刷新" placement="top">
|
<el-tooltip effect="dark" content="刷新" placement="top">
|
||||||
<el-button type="primary" text>
|
<el-button type="primary" text @click.stop="refreshDocument(row)">
|
||||||
<el-icon><RefreshRight /></el-icon>
|
<el-icon><RefreshRight /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
<span class="ml-4">
|
<span>
|
||||||
<el-tooltip effect="dark" content="删除" placement="top">
|
<el-tooltip effect="dark" content="删除" placement="top">
|
||||||
<el-button type="primary" text @click.stop="deleteDocument(row)">
|
<el-button type="primary" text @click.stop="deleteDocument(row)">
|
||||||
<el-icon><Delete /></el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
@ -102,7 +102,7 @@
|
|||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, reactive, computed } from 'vue'
|
import { ref, onMounted, reactive, watch } from 'vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import documentApi from '@/api/document'
|
import documentApi from '@/api/document'
|
||||||
import { numberFormat } from '@/utils/utils'
|
import { numberFormat } from '@/utils/utils'
|
||||||
@ -125,6 +125,23 @@ const paginationConfig = reactive({
|
|||||||
total: 0
|
total: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(documentData, (list) => {
|
||||||
|
let interval
|
||||||
|
if (list.every((item) => item.status === '0')) {
|
||||||
|
interval = setInterval(() => {
|
||||||
|
getList(true)
|
||||||
|
}, 6000)
|
||||||
|
} else {
|
||||||
|
clearInterval(interval)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function refreshDocument(row: any) {
|
||||||
|
documentApi.putDocumentRefresh(row.dataset_id, row.id).then((res) => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function rowClickHandle(row: any) {
|
function rowClickHandle(row: any) {
|
||||||
router.push({ path: `/dataset/${id}/${row.id}` })
|
router.push({ path: `/dataset/${id}/${row.id}` })
|
||||||
}
|
}
|
||||||
@ -215,13 +232,13 @@ function handleSizeChange() {
|
|||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getList() {
|
function getList(bool?: boolean) {
|
||||||
documentApi
|
documentApi
|
||||||
.getDocument(
|
.getDocument(
|
||||||
id as string,
|
id as string,
|
||||||
paginationConfig,
|
paginationConfig,
|
||||||
filterText.value && { name: filterText.value },
|
filterText.value && { name: filterText.value },
|
||||||
loading
|
bool ? undefined : loading
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
documentData.value = res.data.records
|
documentData.value = res.data.records
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user