|
@@ -26,7 +26,7 @@
|
|
|
<el-icon><CircleCheck /></el-icon> 批量入库
|
|
<el-icon><CircleCheck /></el-icon> 批量入库
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-button type="primary" :disabled="selectedIds.length === 0" @click="handleBatchAddToTask">
|
|
<el-button type="primary" :disabled="selectedIds.length === 0" @click="handleBatchAddToTask">
|
|
|
- <el-icon><Tickets /></el-icon> 批量加入任务
|
|
|
|
|
|
|
+ <el-icon><Tickets /></el-icon> 批量加入标注任务
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-button type="success" class="upload-btn" @click="handleUpload">
|
|
<el-button type="success" class="upload-btn" @click="handleUpload">
|
|
|
<el-icon><Upload /></el-icon> 上传文档
|
|
<el-icon><Upload /></el-icon> 上传文档
|
|
@@ -85,6 +85,7 @@
|
|
|
<el-table
|
|
<el-table
|
|
|
v-else
|
|
v-else
|
|
|
:data="documents"
|
|
:data="documents"
|
|
|
|
|
+ row-key="id"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
border
|
|
border
|
|
|
stripe
|
|
stripe
|
|
@@ -92,7 +93,7 @@
|
|
|
@selection-change="handleSelectionChange"
|
|
@selection-change="handleSelectionChange"
|
|
|
:row-class-name="tableRowClassName"
|
|
:row-class-name="tableRowClassName"
|
|
|
>
|
|
>
|
|
|
- <el-table-column type="selection" width="40" :selectable="canSelect" />
|
|
|
|
|
|
|
+ <el-table-column type="selection" width="40" :selectable="canSelect" :reserve-selection="true" />
|
|
|
|
|
|
|
|
<el-table-column prop="title" label="文档名称" min-width="280" show-overflow-tooltip>
|
|
<el-table-column prop="title" label="文档名称" min-width="280" show-overflow-tooltip>
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
@@ -347,6 +348,23 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
+ <!-- 加入任务设置弹窗 -->
|
|
|
|
|
+ <el-dialog v-model="taskDialogVisible" title="加入标注任务" width="400px">
|
|
|
|
|
+ <el-form :model="taskForm" :rules="taskRules" ref="taskFormRef" label-width="100px">
|
|
|
|
|
+ <el-form-item label="项目名称" prop="project_name">
|
|
|
|
|
+ <el-input v-model="taskForm.project_name" placeholder="请输入项目名称" clearable />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <span class="dialog-footer">
|
|
|
|
|
+ <el-button @click="taskDialogVisible = false">取消</el-button>
|
|
|
|
|
+ <el-button type="primary" @click="confirmAddTask" :loading="taskAdding">
|
|
|
|
|
+ 确认加入
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+
|
|
|
<div class="pagination-container" v-if="total > 0">
|
|
<div class="pagination-container" v-if="total > 0">
|
|
|
<el-pagination
|
|
<el-pagination
|
|
|
v-model:current-page="searchQuery.page"
|
|
v-model:current-page="searchQuery.page"
|
|
@@ -780,12 +798,21 @@ const ingestForm = reactive({
|
|
|
separator: '。'
|
|
separator: '。'
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const ingestRules = {
|
|
|
|
|
- kb_method: [
|
|
|
|
|
- { required: true, message: '请选择切分方式', trigger: 'change' }
|
|
|
|
|
|
|
+// 任务相关状态
|
|
|
|
|
+const taskAdding = ref(false)
|
|
|
|
|
+const taskDialogVisible = ref(false)
|
|
|
|
|
+const taskForm = reactive({
|
|
|
|
|
+ project_name: ''
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const taskRules = {
|
|
|
|
|
+ project_name: [
|
|
|
|
|
+ { required: true, message: '请输入项目名称', trigger: 'blur' },
|
|
|
|
|
+ { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const taskFormRef = ref()
|
|
|
const ingestFormRef = ref()
|
|
const ingestFormRef = ref()
|
|
|
const uploadFormRef = ref()
|
|
const uploadFormRef = ref()
|
|
|
const editFormRef = ref()
|
|
const editFormRef = ref()
|
|
@@ -1096,31 +1123,39 @@ const handleBatchAddToTask = async () => {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ taskForm.project_name = '' // 重置项目名称
|
|
|
|
|
+ if (taskFormRef.value) {
|
|
|
|
|
+ taskFormRef.value.clearValidate()
|
|
|
|
|
+ }
|
|
|
|
|
+ taskDialogVisible.value = true
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const confirmAddTask = async () => {
|
|
|
|
|
+ if (!taskFormRef.value) return
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
- await ElMessageBox.confirm(
|
|
|
|
|
- `确定要将选中的 ${selectedIds.value.length} 份文档加入任务中心吗?`,
|
|
|
|
|
- '批量加入任务',
|
|
|
|
|
- {
|
|
|
|
|
- confirmButtonText: '确定',
|
|
|
|
|
- cancelButtonText: '取消',
|
|
|
|
|
- type: 'info',
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ await taskFormRef.value.validate()
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const res = await documentApi.batchAddToTask(selectedIds.value)
|
|
|
|
|
|
|
+ taskAdding.value = true
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await documentApi.batchAddToTask(selectedIds.value, taskForm.project_name)
|
|
|
|
|
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
ElMessage.success(res.message || '操作成功')
|
|
ElMessage.success(res.message || '操作成功')
|
|
|
selectedIds.value = []
|
|
selectedIds.value = []
|
|
|
|
|
+ taskDialogVisible.value = false
|
|
|
fetchDocuments()
|
|
fetchDocuments()
|
|
|
} else {
|
|
} else {
|
|
|
ElMessage.error(res.message || '操作失败')
|
|
ElMessage.error(res.message || '操作失败')
|
|
|
}
|
|
}
|
|
|
} catch (error: any) {
|
|
} catch (error: any) {
|
|
|
- if (error !== 'cancel') {
|
|
|
|
|
- console.error('批量加入任务失败:', error)
|
|
|
|
|
- ElMessage.error('操作失败')
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ console.error('批量加入任务失败:', error)
|
|
|
|
|
+ ElMessage.error('操作失败')
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ taskAdding.value = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1271,6 +1306,19 @@ const refreshDocumentsSilently = async () => {
|
|
|
total.value = res.data.total
|
|
total.value = res.data.total
|
|
|
statistics.value.allTotal = res.data.all_total || 0
|
|
statistics.value.allTotal = res.data.all_total || 0
|
|
|
statistics.value.totalEntered = res.data.total_entered || 0
|
|
statistics.value.totalEntered = res.data.total_entered || 0
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否还需要继续轮询
|
|
|
|
|
+ const hasConverting = documents.value.some(doc => doc.conversion_status === 1)
|
|
|
|
|
+ if (!hasConverting) {
|
|
|
|
|
+ // 如果当前没有转换中的文档,不要立即停止,延迟一个周期再检查
|
|
|
|
|
+ // 这样可以避免转换任务刚提交但状态还没更新到 1 的情况
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ const stillNoConverting = documents.value.some(doc => doc.conversion_status === 1)
|
|
|
|
|
+ if (!stillNoConverting) {
|
|
|
|
|
+ stopPolling()
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 5000)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('静默刷新失败:', error)
|
|
console.error('静默刷新失败:', error)
|
|
@@ -1375,6 +1423,8 @@ const submitUpload = async () => {
|
|
|
ElMessage.success('上传成功')
|
|
ElMessage.success('上传成功')
|
|
|
uploadDialogVisible.value = false
|
|
uploadDialogVisible.value = false
|
|
|
fetchDocuments()
|
|
fetchDocuments()
|
|
|
|
|
+ // 上传后可能立即开始转换,启动轮询监控状态
|
|
|
|
|
+ startPolling()
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('上传失败:', error)
|
|
console.error('上传失败:', error)
|
|
@@ -1595,6 +1645,8 @@ const handleConvert = async (row: DocumentItem) => {
|
|
|
const res = await documentApi.convert(row.id)
|
|
const res = await documentApi.convert(row.id)
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
ElMessage.success(res.message || '转换任务已启动')
|
|
ElMessage.success(res.message || '转换任务已启动')
|
|
|
|
|
+ // 启动轮询以监控转换进度
|
|
|
|
|
+ startPolling()
|
|
|
// 触发一次静默刷新以更新状态
|
|
// 触发一次静默刷新以更新状态
|
|
|
refreshDocumentsSilently()
|
|
refreshDocumentsSilently()
|
|
|
} else {
|
|
} else {
|
|
@@ -1618,8 +1670,6 @@ const openInNewWindow = () => {
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
fetchDocuments()
|
|
fetchDocuments()
|
|
|
loadKbOptions()
|
|
loadKbOptions()
|
|
|
- // 5秒后开始第一次静默刷新,之后递归调用
|
|
|
|
|
- refreshTimer.value = window.setTimeout(refreshDocumentsSilently, 5000)
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|