|
|
|
|
@ -354,18 +354,66 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async exportExcel(sheetName) {
|
|
|
|
|
let filterTableColumns = this.$refs['xyTable']?.tableFormat || []
|
|
|
|
|
const res = await index(
|
|
|
|
|
Object.assign(this.select, { page: 1, page_size: 9999 })
|
|
|
|
|
);
|
|
|
|
|
if (res.data) {
|
|
|
|
|
let headers = this.form.map((i) => {
|
|
|
|
|
let headers = this.form.filter(i => filterTableColumns.find(j => j.prop === i.field)).map((i) => {
|
|
|
|
|
return {
|
|
|
|
|
key: i.field,
|
|
|
|
|
title: i.name,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
if(filterTableColumns.find(j => j.prop === 'assets')) {
|
|
|
|
|
headers.unshift({
|
|
|
|
|
key: 'assets',
|
|
|
|
|
title: '资产'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const data = res.data.map((row) =>
|
|
|
|
|
headers.map((header) => row[header.key])
|
|
|
|
|
headers.map((header) => {
|
|
|
|
|
if(header.key === 'assets') {
|
|
|
|
|
return row.asset_handles_to_assets?.map(i => (i.land_id ? '【土地】' : '【房产】')+(i.lands?.name || i.house?.name)).toString()
|
|
|
|
|
}
|
|
|
|
|
const i = this.form.find(i => i.field === header.key)
|
|
|
|
|
//if (i.edit_input === 'file' || i.edit_input === 'files') return ''
|
|
|
|
|
// if (
|
|
|
|
|
// i.select_item &&
|
|
|
|
|
// typeof i.select_item === "object" &&
|
|
|
|
|
// !(i.select_item instanceof Array)
|
|
|
|
|
// ) {
|
|
|
|
|
// let keys = Object.keys(i.select_item);
|
|
|
|
|
// let paramMap = new Map();
|
|
|
|
|
// keys.forEach((key) => {
|
|
|
|
|
// paramMap.set(i.select_item[key], key);
|
|
|
|
|
// });
|
|
|
|
|
// return paramMap.get(row[i.field]?.toString());
|
|
|
|
|
// }
|
|
|
|
|
if (i._relations) {
|
|
|
|
|
let { link_relation, foreign_key, link_with_name } = i._relations;
|
|
|
|
|
if (link_relation === "newHasOne" || link_relation === "hasOne") {
|
|
|
|
|
return row[link_with_name]?.original_name || row[link_with_name]?.name ||
|
|
|
|
|
row[link_with_name]?.no ||
|
|
|
|
|
row[link_with_name]?.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (link_relation === "hasMany" || link_relation === "newHasMany") {
|
|
|
|
|
return row[link_with_name]?.map((o) => (
|
|
|
|
|
o?.name ||
|
|
|
|
|
o?.no ||
|
|
|
|
|
o?.value ||
|
|
|
|
|
o?.biaoti ||
|
|
|
|
|
o?.mingcheng
|
|
|
|
|
)).toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.table.find(i => i.prop === header.key)?.formatter) {
|
|
|
|
|
return this.table.find(i => i.prop === header.key).formatter(row, {}, row[header.key])
|
|
|
|
|
}
|
|
|
|
|
return row[header.key]
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
data.unshift(headers.map((header) => header.title));
|
|
|
|
|
const wb = XLSX.utils.book_new();
|
|
|
|
|
|