完成基本上传导入前端代码
This commit is contained in:
parent
0caf428d67
commit
05aabea1a2
@ -2,7 +2,7 @@
|
|||||||
* @Author: Kane
|
* @Author: Kane
|
||||||
* @Date: 2023-10-17 11:18:19
|
* @Date: 2023-10-17 11:18:19
|
||||||
* @LastEditors: Kane
|
* @LastEditors: Kane
|
||||||
* @FilePath: /task_schedule/src/utils/api/BIReport.ts
|
* @FilePath: /task_schedule/src/utils/BIReport.ts
|
||||||
* @Description: BI报表相关的代码
|
* @Description: BI报表相关的代码
|
||||||
*
|
*
|
||||||
* Copyright (c) ${2023} by Kane, All Rights Reserved.
|
* Copyright (c) ${2023} by Kane, All Rights Reserved.
|
||||||
@ -31,6 +31,8 @@ interface ImportBIReportResponse
|
|||||||
importedCount: number,
|
importedCount: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ImportBIReportResponseHandler = ( response: ImportBIReportResponse, error?: any ) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
@ -72,5 +74,6 @@ export {
|
|||||||
type BIReportType,
|
type BIReportType,
|
||||||
type ImportBIReportRequest,
|
type ImportBIReportRequest,
|
||||||
type ImportBIReportResponse,
|
type ImportBIReportResponse,
|
||||||
|
type ImportBIReportResponseHandler,
|
||||||
importBIReport
|
importBIReport
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
name="files"
|
name="files"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
:data="ui.uploadParameters"
|
:data="ui.uploadParameters"
|
||||||
|
:on-success="onUploadSuccess"
|
||||||
>
|
>
|
||||||
<el-icon class="el-icon--upload">
|
<el-icon class="el-icon--upload">
|
||||||
<upload-filled />
|
<upload-filled />
|
||||||
@ -62,9 +63,12 @@ import {
|
|||||||
type BIReportType,
|
type BIReportType,
|
||||||
type ImportBIReportRequest,
|
type ImportBIReportRequest,
|
||||||
type ImportBIReportResponse,
|
type ImportBIReportResponse,
|
||||||
|
type ImportBIReportResponseHandler,
|
||||||
importBIReport
|
importBIReport
|
||||||
} from "@/utils/BIReport.js";
|
} from "@/utils/BIReport.js";
|
||||||
import { UploadFilled } from "@element-plus/icons-vue";
|
import { type FileUploadResponse } from "@/utils/fileUpload.js";
|
||||||
|
// import { UploadFilled } from "@element-plus/icons-vue";
|
||||||
|
import { type UploadProps, type UploadFile, type UploadFiles, ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
|
||||||
interface UI
|
interface UI
|
||||||
{
|
{
|
||||||
@ -79,6 +83,13 @@ interface UI
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "BiDataUploadView",
|
name: "BiDataUploadView",
|
||||||
|
props: {
|
||||||
|
reportType: {
|
||||||
|
type: Number,
|
||||||
|
require: true,
|
||||||
|
default: (): number => -9999,
|
||||||
|
},
|
||||||
|
},
|
||||||
setup()
|
setup()
|
||||||
{
|
{
|
||||||
const ui: UI = reactive({
|
const ui: UI = reactive({
|
||||||
@ -105,8 +116,97 @@ export default {
|
|||||||
showFileList: false,
|
showFileList: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传成功响应函数
|
||||||
|
* @param response 响应结果参数
|
||||||
|
* @param uploadFile
|
||||||
|
* @param uploadFiles
|
||||||
|
*/
|
||||||
|
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,
|
||||||
|
hasCaption: ui.hasCaption,
|
||||||
|
sheetIndex: ui.sheetIndex,
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log( "请求参数", request );
|
||||||
|
|
||||||
|
// 发出请求
|
||||||
|
importBIReport( request, importResponseHandler );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 失败了,提示一下
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
response.message,
|
||||||
|
"上传文件错误",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
type: "warning",
|
||||||
|
center: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((): void => {})
|
||||||
|
.catch((): void => {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handler函数
|
||||||
|
* @param response
|
||||||
|
* @param error
|
||||||
|
*/
|
||||||
|
const importResponseHandler: ImportBIReportResponseHandler = ( response: ImportBIReportResponse, error?: any ): void =>
|
||||||
|
{
|
||||||
|
if ( response.success )
|
||||||
|
{
|
||||||
|
ElMessage({
|
||||||
|
type: "success",
|
||||||
|
message: response.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
response.message,
|
||||||
|
"导入错误",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
type: "warning",
|
||||||
|
center: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((): void => {})
|
||||||
|
.catch((): void => {});
|
||||||
|
console.log( error );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ui,
|
ui,
|
||||||
|
onUploadSuccess,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -77,6 +77,9 @@
|
|||||||
v-model="ui.showUploadDialog"
|
v-model="ui.showUploadDialog"
|
||||||
title="上传报表"
|
title="上传报表"
|
||||||
width="600px"
|
width="600px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
:show-close="true"
|
||||||
>
|
>
|
||||||
<BiDataUploadView />
|
<BiDataUploadView />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user