Commit ba5724c5 authored by “yiyousong”'s avatar “yiyousong”

pref:修改样表报表导出

parent a0484dce
......@@ -357,7 +357,7 @@ export default {
let page = 1;
let size = 1000;
let execute = async () => {
let { data, total } = await fn(page, size, searchForm);
let { data, total } = await fn({ page, size, ...searchForm });
dataList = [...dataList, ...data];
this.$app.progressFile.show = true;
this.$app.progressFile.percent = parseInt(
......
......@@ -190,6 +190,8 @@ export default {
this.togetBillList();
},
async togetBillList(searchForm = {}) {
let list = [];
let listTotal = 0;
let pramse = {
page: this.tablePagination.current,
size: this.tablePagination.pageSize,
......@@ -208,8 +210,13 @@ export default {
if (code == 1) {
this.tableSourceData = data.data;
this.tablePagination.total = data.total;
return data.data;
list = data.data;
listTotal = data.total;
}
return {
data: list,
total: listTotal,
};
},
// 重置
......@@ -248,22 +255,21 @@ export default {
// 导出
async handleExportTable() {
this.btnLoading = true;
let data = [];
if (this.tableSelectedKeys.length && this.tableSelectedRows.length) {
let data = [];
// 深度克隆避免影响页面表格展示
data = this.$_.cloneDeep(this.tableSelectedRows);
} else {
data = this.$_.cloneDeep(
await this.togetBillList({ page: 1, size: -1 })
export2Excel(
this.tHeader,
this.filterVal,
data,
"样表记录报表" + this.$moment().format("YYYYMMDDHHmmss")
);
if (!data.length) return;
// for (let item of data) {
// Object.keys(obj).forEach((key) => {
// if (item.type == key) {
// item.type = obj[key];
// }
// });
// }
} else {
this.dataSection(this.togetBillList, {}, (data) => {
if (!data.length) {
this.$message.warning("暂无数据");
return;
}
export2Excel(
this.tHeader,
......@@ -271,8 +277,36 @@ export default {
data,
"样表记录报表" + this.$moment().format("YYYYMMDDHHmmss")
);
});
}
this.btnLoading = false;
},
// 数据切片
async dataSection(fn, searchForm, callback) {
let dataList = [];
let page = 1;
let size = 1000;
let execute = async () => {
let { data, total } = await fn({ page, size, ...searchForm });
dataList = [...dataList, ...data];
this.$app.progressFile.show = true;
this.$app.progressFile.percent = parseInt(
(dataList.length / total) * 100
);
if (dataList.length >= total || data.length == 0) {
if (callback) callback(dataList);
this.$app.progressFile.show = false;
this.$app.progressFile.percent = 1;
return;
}
setTimeout(() => {
page += 1;
execute();
});
};
execute();
},
},
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment