baocun
This commit is contained in:
65
开发日志.md
65
开发日志.md
@@ -65,4 +65,67 @@ tomcat 默认是不支持跨域的,不做配置使用vue下载文件会有Acce
|
||||
|
||||
### 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