优化前端导出参数类型,以及导出参数的赋值判断

pull/186/head
DZero 2022-10-27 16:31:00 +08:00
parent 22e656daf3
commit b55d39b755
1 changed files with 9 additions and 8 deletions

View File

@ -24,7 +24,7 @@ interface ListPageOptions {
// 导出文件名 // 导出文件名
name?: string | (() => string); name?: string | (() => string);
//导出参数 //导出参数
params?: object; params?: object | (() => string);
}; };
// 导入配置 // 导入配置
importConfig?: { importConfig?: {
@ -64,10 +64,11 @@ export function useListPage(options: ListPageOptions) {
// 导出 excel // 导出 excel
async function onExportXls() { async function onExportXls() {
//update-begin---author:wangshuai ---date:20220411 for导出新增自定义参数------------ //update-begin---author:wangshuai ---date:20220411 for导出新增自定义参数------------
let { url, name, params } = options?.exportConfig ?? {}; const { url, name, params } = options?.exportConfig ?? {};
let realUrl = typeof url === 'function' ? url() : url; const realParams = typeof params === 'function' ? params() : params;
const realUrl = typeof url === 'function' ? url() : url;
if (realUrl) { if (realUrl) {
let title = typeof name === 'function' ? name() : name; const title = typeof name === 'function' ? name() : name;
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知- //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知-
let paramsForm = {}; let paramsForm = {};
try { try {
@ -78,10 +79,10 @@ export function useListPage(options: ListPageOptions) {
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知- //update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知-
//如果参数不为空,则整合到一起 //如果参数不为空,则整合到一起
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId
if (params) { if (realParams !== undefined && realParams !== null) {
Object.keys(params).map((k) => { Object.keys(realParams).map((k) => {
let temp = (params as object)[k]; const temp = (realParams as object)[k];
if (temp) { if (temp !== undefined && temp !== null && temp !== '') {
paramsForm[k] = unref(temp); paramsForm[k] = unref(temp);
} }
}); });