|
@@ -44,6 +44,7 @@
|
|
|
<div v-if="scope.row.run == 3">成功</div>
|
|
|
<div v-if="scope.row.run == 4">失败</div>
|
|
|
<div v-if="scope.row.run == 5">待处理</div>
|
|
|
+ <div v-if="scope.row.run == 6">文件异常</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" align="center" width="330">
|
|
@@ -68,21 +69,26 @@
|
|
|
<el-tooltip
|
|
|
class="item"
|
|
|
effect="dark"
|
|
|
- :content="scope.row.run === 1 ? '解析中' : '解析'"
|
|
|
+ :content="
|
|
|
+ scope.row.run === 1 || scope.row.run === 5 ? '解析中' : '解析'
|
|
|
+ "
|
|
|
placement="top"
|
|
|
>
|
|
|
<el-button
|
|
|
+ v-if="scope.row.run !== 1 && scope.row.run !== 5"
|
|
|
type="text"
|
|
|
- :icon="
|
|
|
- scope.row.run === 1
|
|
|
- ? 'el-icon-loading'
|
|
|
- : 'el-icon-caret-right'
|
|
|
- "
|
|
|
+ icon="el-icon-caret-right"
|
|
|
circle
|
|
|
- v-if="allowEdit"
|
|
|
@click="analysis(scope.row)"
|
|
|
- :loading="scope.row.analyzing"
|
|
|
- :disabled="scope.row.run === 1"
|
|
|
+ style="font-size: 20px"
|
|
|
+ >
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-loading"
|
|
|
+ circle
|
|
|
+ :disabled="true"
|
|
|
style="font-size: 20px"
|
|
|
>
|
|
|
</el-button>
|
|
@@ -238,6 +244,7 @@ import {
|
|
|
renameFile,
|
|
|
analysis,
|
|
|
batchAnalysis,
|
|
|
+ getRunStatus,
|
|
|
} from "@/api/knowledge";
|
|
|
export default {
|
|
|
props: {
|
|
@@ -400,14 +407,22 @@ export default {
|
|
|
|
|
|
/* 跳转页面 */
|
|
|
getName(e) {
|
|
|
- this.$router.push({
|
|
|
+ /* this.$router.push({
|
|
|
path: "/knowledge/category/infoList",
|
|
|
- query: { id: e.id,type:e.type },
|
|
|
- });
|
|
|
+ query: { id: e.id, type: e.type },
|
|
|
+ }); */
|
|
|
+ let _this = this;
|
|
|
+ let a = document.createElement("a");
|
|
|
+ a.href = `#/infoList?id=${e.id}&type=${e.type}`; // 使用 hash
|
|
|
+ a.target = "_blank";
|
|
|
+ a.click();
|
|
|
},
|
|
|
/* 解析 */
|
|
|
analysis(row) {
|
|
|
- this.$set(row, "analyzing", true);
|
|
|
+ if (row.run === 1 || row.run === 5) return; // 如果已经在解析中或待处理,直接返回
|
|
|
+
|
|
|
+ this.$set(row, "run", 1); // 使用 $set 确保视图更新
|
|
|
+
|
|
|
analysis({
|
|
|
document_id: row.id,
|
|
|
start_page: row.start_page || 0,
|
|
@@ -416,38 +431,45 @@ export default {
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.status === 200) {
|
|
|
- row.run = 1; // Set status to "解析中"
|
|
|
this.checkAnalysisStatus(row);
|
|
|
} else {
|
|
|
this.$message.error("解析请求失败");
|
|
|
+ this.$set(row, "run", 0); // 如果请求失败,重置状态
|
|
|
}
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
console.error("解析错误:", error);
|
|
|
this.$message.error("解析过程中出现错误");
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- this.$set(row, "analyzing", false);
|
|
|
+ this.$set(row, "run", 0); // 如果出现错误,重置状态
|
|
|
});
|
|
|
},
|
|
|
checkAnalysisStatus(row) {
|
|
|
const checkStatus = () => {
|
|
|
- // Replace this with an actual API call to check the status
|
|
|
- // For demonstration, we're using a simulated API call
|
|
|
- setTimeout(() => {
|
|
|
- // Simulating a status check
|
|
|
- const status = Math.random() > 0.7 ? 3 : 1;
|
|
|
-
|
|
|
- if (status === 3) {
|
|
|
- row.run = 3; // Analysis complete
|
|
|
- this.$message.success("解析完成");
|
|
|
- } else if (status === 1) {
|
|
|
- this.checkAnalysisStatus(row); // Check again
|
|
|
- } else {
|
|
|
- row.run = 4; // Analysis failed
|
|
|
- this.$message.error("解析失败");
|
|
|
- }
|
|
|
- }, 2000); // Check every 2 seconds
|
|
|
+ getRunStatus({ document_id: row.id })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.status === 200) {
|
|
|
+ /* */
|
|
|
+ if (res.data.run === '3') {
|
|
|
+ this.$set(row, "run",Number(res.data.run));
|
|
|
+ } else if (res.data.run === '4') {
|
|
|
+ this.$set(row, "run", Number(res.data.run));
|
|
|
+ this.$message.error("解析失败");
|
|
|
+ } else if (res.data.run === '1') {
|
|
|
+ // 如果仍在解析中,5-10秒后再次检查
|
|
|
+ setTimeout(() => {
|
|
|
+ this.checkAnalysisStatus(row);
|
|
|
+ }, 5000 + Math.random() * 5000);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error("获取解析状态失败");
|
|
|
+ this.$set(row, "run", 0); // 如果获取状态失败,重置状态
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error("获取解析状态错误:", error);
|
|
|
+ this.$message.error("获取解析状态时出现错误");
|
|
|
+ this.$set(row, "run", 0); // 如果出现错误,重置状态
|
|
|
+ });
|
|
|
};
|
|
|
checkStatus();
|
|
|
},
|