- {{ report.title }}
+ {{ report.title }}
+
+
+ onFilterChange(df, value)"
+ :target="
+ df.fieldtype === 'DynamicLink' ? filters[df.references] : null
+ "
+ />
+
+
-
-
+
+
{{ column.label }}
+ >
+ {{ column.label }}
+
+ >
+
+
+ {{ frappe.format(row[column.fieldname], column) }}
+
+
@@ -41,7 +68,9 @@ import PageHeader from '@/components/PageHeader';
import Button from '@/components/Button';
import SearchBar from '@/components/SearchBar';
import Row from '@/components/Row';
+import FormControl from '@/components/Controls/FormControl';
import reportViewConfig from '@/../reports/view';
+import throttle from 'lodash/throttle';
export default {
name: 'Report',
@@ -50,26 +79,36 @@ export default {
PageHeader,
Button,
SearchBar,
- Row
+ Row,
+ FormControl
+ },
+ provide() {
+ return {
+ doc: this.filters
+ }
},
data() {
+ let filters = {};
+ for (let df of reportViewConfig[this.reportName].filterFields) {
+ filters[df.fieldname] = null;
+ }
+
return {
+ filters,
rows: [],
columns: []
};
},
- mounted() {
+ async mounted() {
this.columns = this.report.getColumns();
- this.fetchReportData();
+ await this.setDefaultFilters();
+ await this.fetchReportData();
},
methods: {
async fetchReportData() {
let data = await frappe.call({
method: this.report.method,
- args: {
- fromDate: '2019-09-01',
- toDate: '2019-10-31'
- }
+ args: this.filters
});
let rows, columns;
@@ -88,6 +127,25 @@ export default {
}
this.rows = rows;
+ },
+
+ onFilterChange(df, value) {
+ this.filters[df.fieldname] = value;
+ this.fetchReportData();
+ },
+
+ async setDefaultFilters() {
+ for (let df of this.report.filterFields) {
+ let defaultValue = null;
+ if (df.default) {
+ if (typeof df.default === 'function') {
+ defaultValue = await df.default();
+ } else {
+ defaultValue = df.default;
+ }
+ }
+ this.filters[df.fieldname] = defaultValue;
+ }
}
},
computed: {