fix: table export 时忽略未知的列
This commit is contained in:
parent
f1d36edec0
commit
d76f9962a8
@ -117,20 +117,24 @@ const print = function () {
|
||||
document.body.innerHTML = oldContent;
|
||||
};
|
||||
|
||||
// 导出 table 数据
|
||||
const exportData = () => {
|
||||
const head = [];
|
||||
const body = [];
|
||||
tableColumns.value.forEach((item) => {
|
||||
head.push(item.title);
|
||||
try {
|
||||
tableDataSource.value.forEach((dataItem) => {
|
||||
if (dataItem[item.key] != undefined) {
|
||||
head.push(item.title);
|
||||
throw new Error("exception");
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
});
|
||||
tableDataSource.value.forEach((item) => {
|
||||
let obj = [];
|
||||
tableColumns.value.forEach((tableColumn) => {
|
||||
// @ts-ignore
|
||||
Object.keys(item).forEach((name) => {
|
||||
if (tableColumn.key === name) {
|
||||
// @ts-ignore
|
||||
obj.push(item[name]);
|
||||
}
|
||||
});
|
||||
|
@ -260,17 +260,17 @@ export default {
|
||||
customSlot:"password",
|
||||
key:"password",
|
||||
align: "center"
|
||||
},{
|
||||
title:"操作",
|
||||
width: "180px",
|
||||
customSlot:"operator",
|
||||
key:"operator"
|
||||
},{
|
||||
title:"年龄",
|
||||
width: "180px",
|
||||
key:"age",
|
||||
sort: true,
|
||||
align: "right"
|
||||
},{
|
||||
title:"操作",
|
||||
width: "180px",
|
||||
customSlot:"operator",
|
||||
key:"operator"
|
||||
}
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user