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: {
getReportData(filters) {
frappe.methods[this.reportConfig.method](filters).then(data => {
if (this.datatable) {
this.datatable.refresh(data || []);
} else {
this.datatable = new DataTable(this.$refs.datatable, {
columns: this.reportColumns,
data: data || []
});
}
async getReportData(filters) {
let data = await frappe.call({
method: this.reportConfig.method,
args: filters
});
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: {