feat: 完成上传文件删除前端实现

This commit is contained in:
wkc
2026-03-16 15:14:54 +08:00
parent 8f9cb19c9f
commit 37cdf5b399
4 changed files with 151 additions and 14 deletions

View File

@@ -88,6 +88,17 @@
</template>
</el-table-column>
<el-table-column prop="uploadUser" label="上传人" width="100"></el-table-column>
<el-table-column label="操作" width="160" fixed="right">
<template slot-scope="scope">
<el-button
v-if="getRowAction(scope.row)"
type="text"
@click="handleRowAction(scope.row)"
>
{{ getRowAction(scope.row).text }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@@ -361,8 +372,14 @@ import {
batchUploadFiles,
getFileUploadList,
getFileUploadStatistics,
deleteFileUploadRecord,
} from "@/api/ccdiProjectUpload";
import { parseTime } from "@/utils/ruoyi";
import {
getUploadFileAction,
getUploadFileStatusText,
getUploadFileStatusType,
} from "./uploadFileActionRules.mjs";
export default {
name: "UploadData",
@@ -1167,26 +1184,81 @@ export default {
this.loadFileList();
},
getRowAction(row) {
return getUploadFileAction(row.fileStatus);
},
handleRowAction(row) {
const action = this.getRowAction(row);
if (!action) {
return;
}
if (action.key === "viewError") {
this.handleViewError(row);
return;
}
if (action.key === "delete") {
this.handleDeleteFile(row);
}
},
handleViewError(row) {
this.$alert(row.errorMessage || "未知错误", "错误信息", {
confirmButtonText: "确定",
type: "error",
});
},
async handleDeleteFile(row) {
try {
await this.$confirm(
"删除后将同步删除流水分析平台中的文件,并清除本系统中该文件对应的所有银行流水数据,是否继续?",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
);
await deleteFileUploadRecord(row.id);
this.$message.success("删除成功");
await Promise.all([this.loadStatistics(), this.loadFileList()]);
if (this.hasActivePollingRecords()) {
this.startPolling();
} else {
this.stopPolling();
}
} catch (error) {
if (error === "cancel" || error === "close") {
return;
}
this.$message.error("删除失败:" + ((error && error.message) || "未知错误"));
}
},
hasActivePollingRecords() {
return (
this.statistics.uploading > 0 ||
this.statistics.parsing > 0 ||
this.fileUploadList.some((item) =>
["uploading", "parsing"].includes(item.fileStatus)
)
);
},
/** 状态文本映射 */
getStatusText(status) {
const map = {
uploading: "上传中",
parsing: "解析中",
parsed_success: "解析成功",
parsed_failed: "解析失败",
};
return map[status] || status;
return getUploadFileStatusText(status);
},
/** 状态标签类型映射 */
getStatusType(status) {
const map = {
uploading: "primary",
parsing: "warning",
parsed_success: "success",
parsed_failed: "danger",
};
return map[status] || "info";
return getUploadFileStatusType(status);
},
/** 格式化文件大小 */

View File

@@ -0,0 +1,32 @@
export function getUploadFileAction(status) {
const actionMap = {
parsed_failed: { key: "viewError", text: "查看错误原因" },
parsed_success: { key: "delete", text: "删除" }
};
return actionMap[status] || null;
}
export function getUploadFileStatusText(status) {
const map = {
uploading: "上传中",
parsing: "解析中",
parsed_success: "解析成功",
parsed_failed: "解析失败",
deleted: "已删除"
};
return map[status] || status;
}
export function getUploadFileStatusType(status) {
const map = {
uploading: "primary",
parsing: "warning",
parsed_success: "success",
parsed_failed: "danger",
deleted: "info"
};
return map[status] || "info";
}