fix: table export 时忽略未知的列

This commit is contained in:
就眠儀式 2022-04-16 16:54:14 +08:00
parent f1d36edec0
commit d76f9962a8
2 changed files with 13 additions and 9 deletions

View File

@ -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]);
}
});

View File

@ -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"
}
]