feat: 文档状态

This commit is contained in:
wangdan-fit2cloud 2023-12-14 10:47:51 +08:00
parent 4274504b31
commit e42892f9a5
2 changed files with 47 additions and 7 deletions

View File

@ -121,6 +121,28 @@ const getDocumentDetail: (dataset_id: string, document_id: string) => Promise<Re
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 {
postSplitDocument,
getDocument,
@ -129,5 +151,6 @@ export default {
putDocument,
delDocument,
getDocumentDetail,
listSplitPattern
listSplitPattern,
putDocumentRefresh
}

View File

@ -80,14 +80,14 @@
</el-table-column>
<el-table-column label="操作" align="center">
<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-button type="primary" text>
<el-button type="primary" text @click.stop="refreshDocument(row)">
<el-icon><RefreshRight /></el-icon>
</el-button>
</el-tooltip>
</span>
<span class="ml-4">
<span>
<el-tooltip effect="dark" content="删除" placement="top">
<el-button type="primary" text @click.stop="deleteDocument(row)">
<el-icon><Delete /></el-icon>
@ -102,7 +102,7 @@
</LayoutContainer>
</template>
<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 documentApi from '@/api/document'
import { numberFormat } from '@/utils/utils'
@ -125,6 +125,23 @@ const paginationConfig = reactive({
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) {
router.push({ path: `/dataset/${id}/${row.id}` })
}
@ -215,13 +232,13 @@ function handleSizeChange() {
getList()
}
function getList() {
function getList(bool?: boolean) {
documentApi
.getDocument(
id as string,
paginationConfig,
filterText.value && { name: filterText.value },
loading
bool ? undefined : loading
)
.then((res) => {
documentData.value = res.data.records