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