refactor(PageContent): ♻️ 导入模板参数改名
This commit is contained in:
@@ -452,7 +452,7 @@
|
|||||||
<div class="el-upload__tip">
|
<div class="el-upload__tip">
|
||||||
*.xlsx / *.xls
|
*.xlsx / *.xls
|
||||||
<el-link
|
<el-link
|
||||||
v-if="contentConfig.importsTemplate"
|
v-if="contentConfig.importTemplate"
|
||||||
type="primary"
|
type="primary"
|
||||||
icon="download"
|
icon="download"
|
||||||
:underline="false"
|
:underline="false"
|
||||||
@@ -730,11 +730,11 @@ function handleFileExceed(files: File[]) {
|
|||||||
}
|
}
|
||||||
// 下载导入模板
|
// 下载导入模板
|
||||||
function handleDownloadTemplate() {
|
function handleDownloadTemplate() {
|
||||||
const importsTemplate = props.contentConfig.importsTemplate;
|
const importTemplate = props.contentConfig.importTemplate;
|
||||||
if (typeof importsTemplate === "string") {
|
if (typeof importTemplate === "string") {
|
||||||
window.open(importsTemplate);
|
window.open(importTemplate);
|
||||||
} else if (typeof importsTemplate === "function") {
|
} else if (typeof importTemplate === "function") {
|
||||||
importsTemplate().then((response) => {
|
importTemplate().then((response) => {
|
||||||
const fileData = response.data;
|
const fileData = response.data;
|
||||||
const fileName = decodeURI(
|
const fileName = decodeURI(
|
||||||
response.headers["content-disposition"].split(";")[1].split("=")[1]
|
response.headers["content-disposition"].split(";")[1].split("=")[1]
|
||||||
@@ -742,7 +742,7 @@ function handleDownloadTemplate() {
|
|||||||
saveXlsx(fileData, fileName);
|
saveXlsx(fileData, fileName);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error("未配置importsTemplate");
|
ElMessage.error("未配置importTemplate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 导入确认
|
// 导入确认
|
||||||
|
|||||||
@@ -92,10 +92,10 @@ export interface IContentConfig<T = any> {
|
|||||||
exportAction?: (queryParams: T) => Promise<any>;
|
exportAction?: (queryParams: T) => Promise<any>;
|
||||||
// 前端全量导出的网络请求函数(需返回promise)
|
// 前端全量导出的网络请求函数(需返回promise)
|
||||||
exportsAction?: (queryParams: T) => Promise<IObject[]>;
|
exportsAction?: (queryParams: T) => Promise<IObject[]>;
|
||||||
|
// 导入模板
|
||||||
|
importTemplate?: string | (() => Promise<any>);
|
||||||
// 后端导入的网络请求函数(需返回promise)
|
// 后端导入的网络请求函数(需返回promise)
|
||||||
importAction?: (file: File) => Promise<any>;
|
importAction?: (file: File) => Promise<any>;
|
||||||
// 前端导入模板
|
|
||||||
importsTemplate?: string | (() => Promise<any>);
|
|
||||||
// 前端导入的网络请求函数(需返回promise)
|
// 前端导入的网络请求函数(需返回promise)
|
||||||
importsAction?: (data: IObject[]) => Promise<any>;
|
importsAction?: (data: IObject[]) => Promise<any>;
|
||||||
// 主键名(默认为id)
|
// 主键名(默认为id)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const contentConfig: IContentConfig<UserQuery> = {
|
|||||||
return UserAPI.import(1, file);
|
return UserAPI.import(1, file);
|
||||||
},
|
},
|
||||||
exportAction: UserAPI.export,
|
exportAction: UserAPI.export,
|
||||||
importsTemplate: UserAPI.downloadTemplate,
|
importTemplate: UserAPI.downloadTemplate,
|
||||||
importsAction(data) {
|
importsAction(data) {
|
||||||
// 模拟导入数据
|
// 模拟导入数据
|
||||||
console.log("importsAction", data);
|
console.log("importsAction", data);
|
||||||
|
|||||||
Reference in New Issue
Block a user