2
0
mirror of https://github.com/frappe/books.git synced 2025-01-25 08:08:37 +00:00
books/src/pages/Report.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
2.3 KiB
Vue
Raw Normal View History

2019-10-14 03:26:20 +05:30
<template>
<div class="flex flex-col w-full h-full">
<PageHeader :title="title">
<!--
<DropdownWithActions
v-for="group of actionGroups"
:key="group.label"
:type="group.type"
:actions="group.actions"
class="text-xs"
>
{{ group.label }}
</DropdownWithActions>
<DropdownWithActions :actions="actions" />
-->
2019-10-14 03:26:20 +05:30
</PageHeader>
<!-- Filters -->
<div v-if="report" class="mx-4 grid grid-cols-5 gap-2">
<FormControl
v-for="field in report.filters"
size="small"
:show-label="field.fieldtype === 'Check'"
:key="field.fieldname + '-filter'"
class="bg-gray-100 rounded"
:class="field.fieldtype === 'Check' ? 'flex pl-2 py-1' : ''"
input-class="bg-transparent text-sm"
:df="field"
:value="report.get(field.fieldname)"
:read-only="loading"
@change="async (value) => await report.set(field.fieldname, value)"
/>
</div>
<!-- Report Body -->
<ListReport v-if="report" :report="report" class="mx-4 mt-4" />
2019-10-14 03:26:20 +05:30
</div>
</template>
<script>
import { computed } from '@vue/reactivity';
import { t } from 'fyo';
import { reports } from 'reports';
2022-04-22 16:32:03 +05:30
import FormControl from 'src/components/Controls/FormControl.vue';
import PageHeader from 'src/components/PageHeader.vue';
import ListReport from 'src/components/Report/ListReport.vue';
import { fyo } from 'src/initFyo';
import { defineComponent } from 'vue';
2019-10-14 03:26:20 +05:30
export default defineComponent({
props: {
reportName: String,
2019-10-14 03:26:20 +05:30
},
data() {
return {
loading: false,
report: null,
2019-10-14 03:26:20 +05:30
};
},
provide() {
return {
report: computed(() => this.report),
};
},
components: { PageHeader, FormControl, ListReport },
async activated() {
await this.setReportData();
if (fyo.store.isDevelopment) {
window.rep = this;
}
2019-10-14 03:26:20 +05:30
},
computed: {
title() {
return reports[this.reportName]?.title ?? t`Report`;
},
},
methods: {
async setReportData() {
const Report = reports[this.reportName];
if (this.report === null) {
this.report = new Report(fyo);
await this.report.initialize();
2022-03-18 13:29:48 +05:30
}
2022-04-27 17:32:43 +05:30
if (!this.report.reportData.length) {
await this.report.setReportData();
}
},
},
});
2019-10-14 03:26:20 +05:30
</script>