|
@@ -27,6 +27,7 @@
|
|
<div v-if="scope.row.run == 1">解析中</div>
|
|
<div v-if="scope.row.run == 1">解析中</div>
|
|
<div v-if="scope.row.run == 3">成功</div>
|
|
<div v-if="scope.row.run == 3">成功</div>
|
|
<div v-if="scope.row.run == 4">失败</div>
|
|
<div v-if="scope.row.run == 4">失败</div>
|
|
|
|
+ <div v-if="scope.row.run == 5">待处理</div>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column label="操作" align="center" width="500"
|
|
<el-table-column label="操作" align="center" width="500"
|
|
@@ -38,7 +39,10 @@
|
|
size="small"
|
|
size="small"
|
|
v-if="allowEdit"
|
|
v-if="allowEdit"
|
|
@click="analysis(scope.row)"
|
|
@click="analysis(scope.row)"
|
|
- >解析</el-button
|
|
|
|
|
|
+ :loading="scope.row.analyzing"
|
|
|
|
+ :disabled="scope.row.run === 1"
|
|
|
|
+ >
|
|
|
|
+ {{ scope.row.run === 1 ? "解析中" : "解析" }}</el-button
|
|
>
|
|
>
|
|
<el-button
|
|
<el-button
|
|
type="primary"
|
|
type="primary"
|
|
@@ -58,7 +62,8 @@
|
|
type="primary"
|
|
type="primary"
|
|
size="small"
|
|
size="small"
|
|
v-if="allowEdit"
|
|
v-if="allowEdit"
|
|
- @click="btnDown(scope.row.name)"
|
|
|
|
|
|
+ @click="btnDown(scope.row)"
|
|
|
|
+ :loading="scope.row.downloading"
|
|
><svg-icon icon-class="edit" />下载</el-button
|
|
><svg-icon icon-class="edit" />下载</el-button
|
|
>
|
|
>
|
|
<el-button
|
|
<el-button
|
|
@@ -238,13 +243,50 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
/* 解析 */
|
|
/* 解析 */
|
|
- analysis(e) {
|
|
|
|
|
|
+ analysis(row) {
|
|
|
|
+ this.$set(row, "analyzing", true);
|
|
analysis({
|
|
analysis({
|
|
- document_id: e.id,
|
|
|
|
- start_page: 0,
|
|
|
|
- end_page: 1000,
|
|
|
|
- max_tokens: e.token_num,
|
|
|
|
- }).then((res) => {});
|
|
|
|
|
|
+ document_id: row.id,
|
|
|
|
+ start_page: row.start_page || 0,
|
|
|
|
+ end_page: row.end_page || 1000,
|
|
|
|
+ max_tokens: row.token_num,
|
|
|
|
+ })
|
|
|
|
+ .then((res) => {
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
+ row.run = 1; // Set status to "解析中"
|
|
|
|
+ this.checkAnalysisStatus(row);
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error("解析请求失败");
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ console.error("解析错误:", error);
|
|
|
|
+ this.$message.error("解析过程中出现错误");
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ this.$set(row, "analyzing", false);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ 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
|
|
|
|
+ };
|
|
|
|
+ checkStatus();
|
|
},
|
|
},
|
|
handleAnalClose() {
|
|
handleAnalClose() {
|
|
this.anaDialogVisible = false;
|
|
this.anaDialogVisible = false;
|
|
@@ -255,7 +297,7 @@ export default {
|
|
if (this.analForm.id == el.id) {
|
|
if (this.analForm.id == el.id) {
|
|
el.start_page = this.analForm.start_page;
|
|
el.start_page = this.analForm.start_page;
|
|
el.end_page = this.analForm.end_page;
|
|
el.end_page = this.analForm.end_page;
|
|
- el.token_num=this.analForm.token_num
|
|
|
|
|
|
+ el.token_num = this.analForm.token_num;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.anaDialogVisible = false;
|
|
this.anaDialogVisible = false;
|
|
@@ -344,10 +386,13 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- //编辑
|
|
|
|
|
|
+ //下载
|
|
btnDown(e) {
|
|
btnDown(e) {
|
|
|
|
+ // Set downloading flag for this specific row
|
|
|
|
+ this.$set(e, "downloading", true);
|
|
|
|
+
|
|
nameGetUrl({
|
|
nameGetUrl({
|
|
- name: e,
|
|
|
|
|
|
+ document_id: e.id,
|
|
})
|
|
})
|
|
.then((res) => {
|
|
.then((res) => {
|
|
if (res.status !== 200) {
|
|
if (res.status !== 200) {
|
|
@@ -355,36 +400,28 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- // 使用 fetch 来获取文件内容
|
|
|
|
- fetch(res.data.url)
|
|
|
|
- .then((response) => response.blob())
|
|
|
|
- .then((blob) => {
|
|
|
|
- // 创建一个 Blob URL
|
|
|
|
- const url = window.URL.createObjectURL(blob);
|
|
|
|
-
|
|
|
|
- // 创建一个隐藏的a标签
|
|
|
|
- const link = document.createElement("a");
|
|
|
|
- link.href = url;
|
|
|
|
- link.download = e;
|
|
|
|
-
|
|
|
|
- // 添加到body并触发点击
|
|
|
|
- document.body.appendChild(link);
|
|
|
|
- link.click();
|
|
|
|
-
|
|
|
|
- // 清理
|
|
|
|
- setTimeout(() => {
|
|
|
|
- document.body.removeChild(link);
|
|
|
|
- window.URL.revokeObjectURL(url);
|
|
|
|
- }, 100);
|
|
|
|
- })
|
|
|
|
- .catch((error) => {
|
|
|
|
- console.error("下载出错:", error);
|
|
|
|
- this.$message.error("下载失败,请稍后重试");
|
|
|
|
- });
|
|
|
|
|
|
+ return fetch(res.data.url);
|
|
|
|
+ })
|
|
|
|
+ .then((response) => response.blob())
|
|
|
|
+ .then((blob) => {
|
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
|
+ const link = document.createElement("a");
|
|
|
|
+ link.href = url;
|
|
|
|
+ link.download = e.name;
|
|
|
|
+ document.body.appendChild(link);
|
|
|
|
+ link.click();
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ document.body.removeChild(link);
|
|
|
|
+ window.URL.revokeObjectURL(url);
|
|
|
|
+ }, 100);
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
- console.error("获取下载链接出错:", error);
|
|
|
|
- this.$message.error("获取下载链接失败,请稍后重试");
|
|
|
|
|
|
+ console.error("下载出错:", error);
|
|
|
|
+ this.$message.error("下载失败,请稍后重试");
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ // Reset downloading flag when done
|
|
|
|
+ this.$set(e, "downloading", false);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
@@ -397,20 +434,27 @@ export default {
|
|
//搜索
|
|
//搜索
|
|
search() {
|
|
search() {
|
|
let _this = this;
|
|
let _this = this;
|
|
- _this.loading = true; // Set loading to true before API call
|
|
|
|
|
|
+ _this.loading = true;
|
|
getBucketContents(_this.queryForm)
|
|
getBucketContents(_this.queryForm)
|
|
.then((res) => {
|
|
.then((res) => {
|
|
if (res.status !== 200) return;
|
|
if (res.status !== 200) return;
|
|
- res.data.documents.map((el) => {
|
|
|
|
- el.start_page = this.analForm.start_page;
|
|
|
|
- el.end_page = this.analForm.end_page;
|
|
|
|
- });
|
|
|
|
- _this.dataList = res.data.documents;
|
|
|
|
|
|
+ _this.dataList = res.data.documents.map((el) => ({
|
|
|
|
+ ...el,
|
|
|
|
+ start_page: _this.analForm.start_page,
|
|
|
|
+ end_page: _this.analForm.end_page,
|
|
|
|
+ }));
|
|
_this.pageTotal = res.data.pagination.total_count;
|
|
_this.pageTotal = res.data.pagination.total_count;
|
|
- _this.loading = false; // Set loading to false after data is processed
|
|
|
|
|
|
+ _this.loading = false;
|
|
|
|
+
|
|
|
|
+ // Initialize the analysis status for each row
|
|
|
|
+ _this.dataList.forEach((row) => {
|
|
|
|
+ if (row.run === 1) {
|
|
|
|
+ _this.checkAnalysisStatus(row);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
})
|
|
})
|
|
.catch(() => {
|
|
.catch(() => {
|
|
- _this.loading = false; // Set loading to false if there's an error
|
|
|
|
|
|
+ _this.loading = false;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
//修改分页
|
|
//修改分页
|