baocun
This commit is contained in:
@@ -2,18 +2,22 @@
|
|||||||
* @Author: Kane Wang <wangkane@qq.com>
|
* @Author: Kane Wang <wangkane@qq.com>
|
||||||
* @Date: 2025-10-31 17:33:13
|
* @Date: 2025-10-31 17:33:13
|
||||||
* @LastEditors: Kane Wang
|
* @LastEditors: Kane Wang
|
||||||
* @LastModified: 2025-10-31 17:36:03
|
* @LastModified: 2025-11-19 21:16:07
|
||||||
* @FilePath: src/main/java/com/cpic/xim/web/controllers/fileupload/UploadedFile.java
|
* @FilePath: src/main/java/com/cpic/xim/utils/files/UploadedFile.java
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
* Copyright (c) 2025 by Kane All rights reserved
|
* Copyright (c) 2025 by Kane All rights reserved
|
||||||
*/
|
*/
|
||||||
package com.cpic.xim.utils.files;
|
package com.cpic.xim.utils.files;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
public class UploadedFile
|
public class UploadedFile
|
||||||
{
|
{
|
||||||
|
@JsonProperty( "fileName" )
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
|
@JsonProperty( "localFilePath" )
|
||||||
private String localFilePath;
|
private String localFilePath;
|
||||||
|
|
||||||
public String getFileName()
|
public String getFileName()
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* @author Kane Wang <wangkane@qq.com>
|
||||||
|
* @date 2025-11-19 21:08:58
|
||||||
|
* Copyright © CPIC All rights reserved
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface UploadFileResponse
|
||||||
|
{
|
||||||
|
success: boolean;
|
||||||
|
message: string;
|
||||||
|
fileList: UploadedFile[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UploadedFile
|
||||||
|
{
|
||||||
|
fileName: string;
|
||||||
|
localFilePath: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { type UploadFileResponse, type UploadedFile };
|
||||||
63
开发日志.md
63
开发日志.md
@@ -66,3 +66,66 @@ tomcat 默认是不支持跨域的,不做配置使用vue下载文件会有Acce
|
|||||||
### pdf预览组件
|
### pdf预览组件
|
||||||
|
|
||||||
使用
|
使用
|
||||||
|
|
||||||
|
## 技术
|
||||||
|
|
||||||
|
### element-plus 文件上传
|
||||||
|
|
||||||
|
element-plus 文件上传组件的响应函数,作为:on-success属性值。要传递的参数作为:data属性值。
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { type FileUploadResponse } from "@/utils/fileUpload.js";
|
||||||
|
import { type UploadProps, type UploadFile, type UploadFiles, ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
|
||||||
|
const onUploadSuccess: UploadProps["onSuccess"] = ( response: FileUploadResponse, uploadFile: UploadFile, uploadFiles: UploadFiles ): void =>
|
||||||
|
{
|
||||||
|
// 先判断成功标志位
|
||||||
|
if ( response.success )
|
||||||
|
{
|
||||||
|
// 成功,发出导入报表请求
|
||||||
|
if ( response.fileList.length === 0 )
|
||||||
|
{
|
||||||
|
// 上传文件路径有问题,提示一下
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
"上传文件的保存路径有误,请联系开发人员。",
|
||||||
|
"上传文件错误",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
type: "warning",
|
||||||
|
center: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((): void => {})
|
||||||
|
.catch((): void => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
const request: ImportBIReportRequest = {
|
||||||
|
filePath: response.fileList[0],
|
||||||
|
reportType: ui.selectedReportType,
|
||||||
|
firstRow: ui.firstRow,
|
||||||
|
sheetIndex: ui.sheetIndex,
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log( "请求参数", request );
|
||||||
|
|
||||||
|
// 发出请求
|
||||||
|
importBIReport( request, importResponseHandler );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 失败了,提示一下
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
response.message,
|
||||||
|
"上传文件错误",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
type: "warning",
|
||||||
|
center: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((): void => {})
|
||||||
|
.catch((): void => {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user