|
|
@ -633,6 +633,17 @@ const resetDefaultValues = () => { |
|
|
|
console.error(error); |
|
|
|
}); |
|
|
|
}; |
|
|
|
const showLoading = (msg: string = '正在处理,请稍等...') => { |
|
|
|
$q.loading.show({ |
|
|
|
message: msg, |
|
|
|
boxClass: 'bg-grey-2 text-grey-9', |
|
|
|
spinnerColor: 'primary', |
|
|
|
}); |
|
|
|
}; |
|
|
|
const hideLoading = () => { |
|
|
|
$q.loading.hide(); |
|
|
|
}; |
|
|
|
|
|
|
|
const buttonObj = reactive({ |
|
|
|
separator: 'separator', |
|
|
|
query: { |
|
|
@ -791,10 +802,19 @@ const buttonObj = reactive({ |
|
|
|
icon: 'file_download', |
|
|
|
labelI18nKey: 'action.export', |
|
|
|
label: t('action.export'), |
|
|
|
click: () => { |
|
|
|
click: async () => { |
|
|
|
showLoading(); |
|
|
|
let exportData = table.rows; |
|
|
|
// 判断是否配置了 url, 配置了以不分页形式请求后端获取全部数据一把导出。 |
|
|
|
if (!Tools.isEmpty(props.fetchDataUrl) || !Tools.isEmpty(props.dataUrl)) { |
|
|
|
const fetchResult = await getExportData(); |
|
|
|
if (fetchResult && fetchResult.length > 0) { |
|
|
|
exportData = fetchResult; |
|
|
|
} |
|
|
|
} |
|
|
|
const content = [tableColumns.value.map((col) => wrapCsvValue(col.label))] |
|
|
|
.concat( |
|
|
|
table.rows.map((row) => |
|
|
|
exportData.map((row) => |
|
|
|
tableColumns.value |
|
|
|
.map((col) => wrapCsvValue(typeof col.field === 'function' ? col.field(row) : row[col.field === void 0 ? col.name : col.field], col.format, row)) |
|
|
|
.join(','), |
|
|
@ -811,6 +831,7 @@ const buttonObj = reactive({ |
|
|
|
if (status !== true) { |
|
|
|
NotifyManager.error(t('action.export.failed')); |
|
|
|
} |
|
|
|
hideLoading(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
addTop: { |
|
|
@ -890,6 +911,21 @@ const expandFun = (arr, treeExpand) => { |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
const getExportData = async () => { |
|
|
|
let resultData = <any>[]; |
|
|
|
const reqParams: any = { pageable: false }; |
|
|
|
let urlSearchParams = buildQueryCriterias(reqParams); |
|
|
|
const resp = await axios.get(url.fetchDataUrl || url.dataUrl, { params: urlSearchParams }); |
|
|
|
if (resp && resp.data) { |
|
|
|
const responseData = resp.data; |
|
|
|
if (Array.isArray(responseData)) { |
|
|
|
resultData = responseData; |
|
|
|
} else if (typeof responseData === 'object' && responseData.content) { |
|
|
|
resultData = responseData.content; |
|
|
|
} |
|
|
|
} |
|
|
|
return resultData; |
|
|
|
}; |
|
|
|
|
|
|
|
const screenCols = { xs: 1, sm: 2, md: 3, lg: 4, xl: 6 }; |
|
|
|
const queryFormColsNumComputed = computed(() => { |
|
|
|