2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00

[fix] Use frappe.call to get report data on ReportPage

This commit is contained in:
Faris Ansari 2018-09-06 14:04:45 +05:30
parent 4c0e85aaec
commit 06c06a81cb

View File

@ -25,17 +25,39 @@ export default {
} }
}, },
methods: { methods: {
getReportData(filters) { async getReportData(filters) {
frappe.methods[this.reportConfig.method](filters).then(data => { let data = await frappe.call({
if (this.datatable) { method: this.reportConfig.method,
this.datatable.refresh(data || []); args: filters
} else {
this.datatable = new DataTable(this.$refs.datatable, {
columns: this.reportColumns,
data: data || []
});
}
}); });
let rows, columns;
if (data.rows) {
rows = data.rows;
} else {
rows = data;
}
if (data.columns) {
columns = data.columns;
}
if (!rows) {
rows = [];
}
if (!columns) {
columns = this.reportColumns;
}
if (this.datatable) {
this.datatable.refresh(rows, columns);
} else {
this.datatable = new DataTable(this.$refs.datatable, {
columns: columns,
data: rows
});
}
} }
}, },
components: { components: {