feat: 完成上传文件删除前端实现
This commit is contained in:
@@ -154,3 +154,14 @@ export function getFileUploadDetail(id) {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按记录ID删除上传记录
|
||||||
|
* @param {Number} id 记录ID
|
||||||
|
*/
|
||||||
|
export function deleteFileUploadRecord(id) {
|
||||||
|
return request({
|
||||||
|
url: `/ccdi/file-upload/${id}`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -88,6 +88,17 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="uploadUser" label="上传人" width="100"></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-table>
|
||||||
|
|
||||||
<el-pagination
|
<el-pagination
|
||||||
@@ -361,8 +372,14 @@ import {
|
|||||||
batchUploadFiles,
|
batchUploadFiles,
|
||||||
getFileUploadList,
|
getFileUploadList,
|
||||||
getFileUploadStatistics,
|
getFileUploadStatistics,
|
||||||
|
deleteFileUploadRecord,
|
||||||
} from "@/api/ccdiProjectUpload";
|
} from "@/api/ccdiProjectUpload";
|
||||||
import { parseTime } from "@/utils/ruoyi";
|
import { parseTime } from "@/utils/ruoyi";
|
||||||
|
import {
|
||||||
|
getUploadFileAction,
|
||||||
|
getUploadFileStatusText,
|
||||||
|
getUploadFileStatusType,
|
||||||
|
} from "./uploadFileActionRules.mjs";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "UploadData",
|
name: "UploadData",
|
||||||
@@ -1167,26 +1184,81 @@ export default {
|
|||||||
this.loadFileList();
|
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) {
|
getStatusText(status) {
|
||||||
const map = {
|
return getUploadFileStatusText(status);
|
||||||
uploading: "上传中",
|
|
||||||
parsing: "解析中",
|
|
||||||
parsed_success: "解析成功",
|
|
||||||
parsed_failed: "解析失败",
|
|
||||||
};
|
|
||||||
return map[status] || status;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 状态标签类型映射 */
|
/** 状态标签类型映射 */
|
||||||
getStatusType(status) {
|
getStatusType(status) {
|
||||||
const map = {
|
return getUploadFileStatusType(status);
|
||||||
uploading: "primary",
|
|
||||||
parsing: "warning",
|
|
||||||
parsed_success: "success",
|
|
||||||
parsed_failed: "danger",
|
|
||||||
};
|
|
||||||
return map[status] || "info";
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 格式化文件大小 */
|
/** 格式化文件大小 */
|
||||||
|
|||||||
@@ -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";
|
||||||
|
}
|
||||||
22
tests/frontend/upload-file-action-rules.test.mjs
Normal file
22
tests/frontend/upload-file-action-rules.test.mjs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import {
|
||||||
|
getUploadFileAction,
|
||||||
|
getUploadFileStatusText,
|
||||||
|
getUploadFileStatusType
|
||||||
|
} from "../../ruoyi-ui/src/views/ccdiProject/components/detail/uploadFileActionRules.mjs";
|
||||||
|
|
||||||
|
assert.deepEqual(getUploadFileAction("parsed_failed"), {
|
||||||
|
key: "viewError",
|
||||||
|
text: "查看错误原因"
|
||||||
|
});
|
||||||
|
assert.deepEqual(getUploadFileAction("parsed_success"), {
|
||||||
|
key: "delete",
|
||||||
|
text: "删除"
|
||||||
|
});
|
||||||
|
assert.equal(getUploadFileAction("uploading"), null);
|
||||||
|
assert.equal(getUploadFileAction("parsing"), null);
|
||||||
|
assert.equal(getUploadFileAction("deleted"), null);
|
||||||
|
assert.equal(getUploadFileStatusText("deleted"), "已删除");
|
||||||
|
assert.equal(getUploadFileStatusType("deleted"), "info");
|
||||||
|
|
||||||
|
console.log("PASS");
|
||||||
Reference in New Issue
Block a user