|
@@ -103,6 +103,15 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
<div class="batch-operations">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleBatchProcess"
|
|
|
+ :loading="isProcessing"
|
|
|
+ :disabled="selectedRows.length === 0"
|
|
|
+ class="ml-15"
|
|
|
+ >
|
|
|
+ {{ isProcessing ? "处理中..." : "批量处理文献" }}
|
|
|
+ </el-button>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
@click="handleBatchTag"
|
|
@@ -140,8 +149,8 @@
|
|
|
<el-table-column prop="create_time" label="创建时间" width="200" />
|
|
|
<el-table-column prop="status" label="处理状态" width="100">
|
|
|
<template #default="{ row }">
|
|
|
- <el-tag :type="getStatusType(row.status)">
|
|
|
- {{ getStatusText(row.status) }}
|
|
|
+ <el-tag :type="getStatusType(row.processing_status)">
|
|
|
+ {{ getStatusText(row.processing_status) }}
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -161,16 +170,17 @@
|
|
|
<el-dropdown-item @click.native="handleNameClick(row)">
|
|
|
<i class="el-icon-view"></i> 查看
|
|
|
</el-dropdown-item>
|
|
|
- <el-dropdown-item
|
|
|
- @click.native="handlePreview(row)"
|
|
|
- >
|
|
|
+ <el-dropdown-item @click.native="handlePreview(row)">
|
|
|
<i class="el-icon-tickets"></i> 预览
|
|
|
</el-dropdown-item>
|
|
|
- <el-dropdown-item
|
|
|
+ <el-dropdown-item @click.native="handleSingleProcess(row)">
|
|
|
+ <i class="el-icon-refresh"></i> 处理文献
|
|
|
+ </el-dropdown-item>
|
|
|
+ <!-- <el-dropdown-item
|
|
|
@click.native="firstHandleUpload(scope.$index, scope.row)"
|
|
|
>
|
|
|
<i class="el-icon-refresh"></i> 批量处理
|
|
|
- </el-dropdown-item>
|
|
|
+ </el-dropdown-item> -->
|
|
|
<!-- <el-dropdown-item
|
|
|
@click.native="firstHandleDelete(scope.$index, scope.row)"
|
|
|
>
|
|
@@ -268,15 +278,15 @@ import {
|
|
|
search_tags,
|
|
|
edit_tags,
|
|
|
search,
|
|
|
+ process_model_generation,
|
|
|
} from "@/api/knowledge";
|
|
|
import axios from "axios";
|
|
|
// 状态映射表
|
|
|
const STATUS_MAP = {
|
|
|
- 1: { text: "未处理", type: "info" },
|
|
|
- 2: { text: "已审核", type: "warning" },
|
|
|
- 3: { text: "已处理", type: "success" },
|
|
|
- 4: { text: "已作废", type: "danger" },
|
|
|
- 5: { text: "使用中", type: "primary" },
|
|
|
+ 0: { text: "未处理", type: "info" },
|
|
|
+ 1: { text: "处理中", type: "warning" },
|
|
|
+ 2: { text: "处理完成", type: "success" },
|
|
|
+ 3: { text: "处理失败", type: "danger" },
|
|
|
};
|
|
|
|
|
|
export default {
|
|
@@ -313,6 +323,8 @@ export default {
|
|
|
|
|
|
searchTagOptions: [], // 搜索表单的标签选项
|
|
|
searchTagsLoading: false, // 搜索表单的标签加载状态
|
|
|
+ isProcessing: false, // 批量处理的加载状态
|
|
|
+ pollingTimers: {}, // 新增:存储每个文献的轮询定时器
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -326,6 +338,31 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ // 在中添加单个处理方法
|
|
|
+ async handleSingleProcess(row) {
|
|
|
+ try {
|
|
|
+ await this.$confirm("确认要处理该文献吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+
|
|
|
+ const res = await process_model_generation([row.id]);
|
|
|
+
|
|
|
+ if (res.status === 200) {
|
|
|
+ this.$message.success("处理任务已提交");
|
|
|
+ await this.fetchGpuList(); // 刷新列表
|
|
|
+ } else {
|
|
|
+ throw new Error(res.message || "处理失败");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error === "cancel") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$message.error(error.message || "处理提交失败");
|
|
|
+ console.error("处理错误:", error);
|
|
|
+ }
|
|
|
+ },
|
|
|
/* 搜索栏模糊查找 */
|
|
|
/* 搜索表单的标签搜索 */
|
|
|
async searchFormTags(query) {
|
|
@@ -353,6 +390,43 @@ export default {
|
|
|
handleBatchTag() {
|
|
|
this.tagDialogVisible = true;
|
|
|
},
|
|
|
+ /* 批量处理文献 */
|
|
|
+ async handleBatchProcess() {
|
|
|
+ if (this.selectedRows.length === 0) {
|
|
|
+ this.$message.warning("请选择需要处理的文献");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.isProcessing = true;
|
|
|
+ const ids = this.selectedRows.map((row) => row.id);
|
|
|
+
|
|
|
+ // 添加确认对话框
|
|
|
+ await this.$confirm("确认要批量处理选中的文献吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+
|
|
|
+ const res = await process_model_generation(ids);
|
|
|
+
|
|
|
+ if (res.status === 200) {
|
|
|
+ this.$message.success("批量处理已提交");
|
|
|
+ this.selectedRows = []; // 清空选中
|
|
|
+ await this.fetchGpuList(); // 刷新列表
|
|
|
+ } else {
|
|
|
+ throw new Error(res.message || "处理失败");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error === "cancel") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$message.error(error.message || "批量处理提交失败");
|
|
|
+ console.error("批量处理错误:", error);
|
|
|
+ } finally {
|
|
|
+ this.isProcessing = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
/* 模糊搜索 */
|
|
|
async searchTags(query) {
|
|
@@ -486,11 +560,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 获取GPU列表数据
|
|
|
+ // 修改 fetchGpuList 方法中的分页处理部分
|
|
|
async fetchGpuList() {
|
|
|
this.isLoading = true;
|
|
|
try {
|
|
|
- // 构建基础参数
|
|
|
const params = {
|
|
|
page: this.currentPage,
|
|
|
page_size: this.pageSize,
|
|
@@ -499,15 +572,6 @@ export default {
|
|
|
tag_names: this.searchForm.id,
|
|
|
};
|
|
|
|
|
|
- // 只有当日期范围存在且有效时才添加日期参数
|
|
|
- if (
|
|
|
- this.searchForm.createTimeRange &&
|
|
|
- this.searchForm.createTimeRange.length === 2
|
|
|
- ) {
|
|
|
- params.create_time_start = this.searchForm.createTimeRange[0];
|
|
|
- params.create_time_end = this.searchForm.createTimeRange[1];
|
|
|
- }
|
|
|
-
|
|
|
const response = await axios.post(
|
|
|
`${process.env.VUE_APP_BASE_API}/literature-data/search/`,
|
|
|
params,
|
|
@@ -520,36 +584,95 @@ export default {
|
|
|
|
|
|
if (response.status !== 200) return;
|
|
|
|
|
|
- this.gpuList = response.data.data.list.map((item) => {
|
|
|
+ // 更新数据和分页信息
|
|
|
+ const { list, total, current_page, page_size } = response.data.data;
|
|
|
+ this.gpuList = list.map((item) => {
|
|
|
const nameParts = item.name.split(".");
|
|
|
- return {
|
|
|
+ const processedItem = {
|
|
|
...item,
|
|
|
name: nameParts[0],
|
|
|
type: nameParts.length > 1 ? nameParts.pop() : "未知",
|
|
|
};
|
|
|
+
|
|
|
+ // 检查处理状态,如果是处理中且没有设置轮询,则开始轮询
|
|
|
+ if (
|
|
|
+ processedItem.processing_status === 1 &&
|
|
|
+ !this.pollingTimers[processedItem.id]
|
|
|
+ ) {
|
|
|
+ this.startPolling(processedItem.id);
|
|
|
+ }
|
|
|
+ // 如果状态不是处理中,但存在轮询,则停止轮询
|
|
|
+ else if (
|
|
|
+ processedItem.processing_status !== 1 &&
|
|
|
+ this.pollingTimers[processedItem.id]
|
|
|
+ ) {
|
|
|
+ this.stopPolling(processedItem.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ return processedItem;
|
|
|
});
|
|
|
|
|
|
- this.total = response.data.data.total;
|
|
|
- this.currentPage = response.data.data.current_page;
|
|
|
- this.pageSize = response.data.data.page_size;
|
|
|
+ // 确保这些值都是数字类型
|
|
|
+ this.total = parseInt(total);
|
|
|
+ this.currentPage = parseInt(current_page);
|
|
|
+ this.pageSize = parseInt(page_size);
|
|
|
} catch (error) {
|
|
|
- console.error("获取列表数据失败:", error); // 添加错误日志输出
|
|
|
+ console.error("获取列表数据失败:", error);
|
|
|
this.$message.error("获取列表数据失败");
|
|
|
} finally {
|
|
|
this.isLoading = false;
|
|
|
}
|
|
|
},
|
|
|
+ // 新增:开始轮询
|
|
|
+ startPolling(id) {
|
|
|
+ if (this.pollingTimers[id]) return; // 如果已经在轮询,则不重复设置
|
|
|
|
|
|
- // 处理每页数量变化
|
|
|
+ this.pollingTimers[id] = setInterval(async () => {
|
|
|
+ try {
|
|
|
+ const response = await axios.post(
|
|
|
+ `${process.env.VUE_APP_BASE_API}/literature-data/search/`,
|
|
|
+ {
|
|
|
+ page: this.currentPage,
|
|
|
+ page_size: this.pageSize,
|
|
|
+ doc_type_id: this.selectedType || 36,
|
|
|
+ keyword: this.searchForm.name,
|
|
|
+ tag_names: this.searchForm.id,
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const item = response.data.data.list.find((item) => item.id === id);
|
|
|
+ if (item && item.processing_status !== 1) {
|
|
|
+ // 如果状态不再是"处理中",停止轮询
|
|
|
+ this.stopPolling(id);
|
|
|
+ await this.fetchGpuList(); // 刷新列表
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("轮询检查状态失败:", error);
|
|
|
+ this.stopPolling(id); // 发生错误时停止轮询
|
|
|
+ }
|
|
|
+ }, 60000); // 每分钟检查一次
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增:停止轮询
|
|
|
+ stopPolling(id) {
|
|
|
+ if (this.pollingTimers[id]) {
|
|
|
+ clearInterval(this.pollingTimers[id]);
|
|
|
+ delete this.pollingTimers[id];
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 修改分页处理方法
|
|
|
handleSizeChange(val) {
|
|
|
this.pageSize = val;
|
|
|
- this.debouncedFetchGpuList();
|
|
|
+ this.currentPage = 1; // 切换每页数量时重置为第一页
|
|
|
+ this.fetchGpuList(); // 移除防抖,直接调用
|
|
|
},
|
|
|
|
|
|
- // 处理页码变化
|
|
|
handleCurrentChange(val) {
|
|
|
this.currentPage = val;
|
|
|
- this.debouncedFetchGpuList();
|
|
|
+ this.fetchGpuList(); // 移除防抖,直接调用
|
|
|
},
|
|
|
/* 预览 */
|
|
|
handlePreview(row) {
|
|
@@ -567,7 +690,12 @@ export default {
|
|
|
console.log('详情数据:', res) */
|
|
|
this.$router.push({
|
|
|
path: "/knowledge/middPage/index",
|
|
|
- query: { id: row.id, name: row.name, tag: JSON.stringify(row.tags) },
|
|
|
+ query: {
|
|
|
+ id: row.id,
|
|
|
+ name: row.name,
|
|
|
+ tag: JSON.stringify(row.tags),
|
|
|
+ identifier: row.doc_identifier,
|
|
|
+ },
|
|
|
});
|
|
|
// 这里可以添加详情处理逻辑
|
|
|
} catch (error) {
|
|
@@ -594,8 +722,8 @@ export default {
|
|
|
const response = await getSotaDetails();
|
|
|
this.sotaDetailsList = response.data;
|
|
|
} catch (error) {
|
|
|
- this.$message.error("获取SOTA详情失败");
|
|
|
- console.error(error);
|
|
|
+ /* this.$message.error("获取SOTA详情失败");
|
|
|
+ console.error(error); */
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -606,11 +734,17 @@ export default {
|
|
|
const response = await getSotaSummary();
|
|
|
this.sotaSummaryList = response.data;
|
|
|
} catch (error) {
|
|
|
- this.$message.error("获取SOTA汇总数据失败");
|
|
|
- console.error(error);
|
|
|
+ /* this.$message.error("获取SOTA汇总数据失败");
|
|
|
+ console.error(error); */
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
+ // 在组件销毁时清理所有轮询
|
|
|
+ beforeDestroy() {
|
|
|
+ Object.keys(this.pollingTimers).forEach((id) => {
|
|
|
+ this.stopPolling(id);
|
|
|
+ });
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|