mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
chore: type Report.vue
- add print button
This commit is contained in:
parent
494e25e3d6
commit
40d889ae73
@ -17,4 +17,4 @@ export const reports = {
|
|||||||
GSTR2,
|
GSTR2,
|
||||||
StockLedger,
|
StockLedger,
|
||||||
StockBalance,
|
StockBalance,
|
||||||
} as Record<string, typeof Report>;
|
} as const;
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
>
|
>
|
||||||
{{ group.group }}
|
{{ group.group }}
|
||||||
</DropdownWithActions>
|
</DropdownWithActions>
|
||||||
|
<Button ref="printButton" :icon="true" :title="t`Open Report Print View`">
|
||||||
|
<feather-icon name="printer" class="w-4 h-4"></feather-icon>
|
||||||
|
</Button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
|
||||||
<!-- Filters -->
|
<!-- Filters -->
|
||||||
@ -28,7 +31,7 @@
|
|||||||
:df="field"
|
:df="field"
|
||||||
:value="report.get(field.fieldname)"
|
:value="report.get(field.fieldname)"
|
||||||
:read-only="loading"
|
:read-only="loading"
|
||||||
@change="async (value) => await report.set(field.fieldname, value)"
|
@change="async (value) => await report?.set(field.fieldname, value)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -36,10 +39,12 @@
|
|||||||
<ListReport v-if="report" :report="report" class="" />
|
<ListReport v-if="report" :report="report" class="" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { computed } from '@vue/reactivity';
|
import { computed } from '@vue/reactivity';
|
||||||
import { t } from 'fyo';
|
import { t } from 'fyo';
|
||||||
import { reports } from 'reports';
|
import { reports } from 'reports';
|
||||||
|
import { Report } from 'reports/Report';
|
||||||
|
import Button from 'src/components/Button.vue';
|
||||||
import FormControl from 'src/components/Controls/FormControl.vue';
|
import FormControl from 'src/components/Controls/FormControl.vue';
|
||||||
import DropdownWithActions from 'src/components/DropdownWithActions.vue';
|
import DropdownWithActions from 'src/components/DropdownWithActions.vue';
|
||||||
import PageHeader from 'src/components/PageHeader.vue';
|
import PageHeader from 'src/components/PageHeader.vue';
|
||||||
@ -47,11 +52,15 @@ import ListReport from 'src/components/Report/ListReport.vue';
|
|||||||
import { fyo } from 'src/initFyo';
|
import { fyo } from 'src/initFyo';
|
||||||
import { docsPathMap } from 'src/utils/misc';
|
import { docsPathMap } from 'src/utils/misc';
|
||||||
import { docsPathRef } from 'src/utils/refs';
|
import { docsPathRef } from 'src/utils/refs';
|
||||||
import { defineComponent } from 'vue';
|
import { ActionGroup } from 'src/utils/types';
|
||||||
|
import { PropType, defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
reportClassName: String,
|
reportClassName: {
|
||||||
|
type: String as PropType<keyof typeof reports>,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
defaultFilters: {
|
defaultFilters: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '{}',
|
default: '{}',
|
||||||
@ -60,7 +69,7 @@ export default defineComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
report: null,
|
report: null as null | Report,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
@ -68,22 +77,30 @@ export default defineComponent({
|
|||||||
report: computed(() => this.report),
|
report: computed(() => this.report),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: { PageHeader, FormControl, ListReport, DropdownWithActions },
|
components: {
|
||||||
|
PageHeader,
|
||||||
|
FormControl,
|
||||||
|
ListReport,
|
||||||
|
DropdownWithActions,
|
||||||
|
Button,
|
||||||
|
},
|
||||||
async activated() {
|
async activated() {
|
||||||
docsPathRef.value = docsPathMap[this.reportClassName] ?? docsPathMap.Reports;
|
docsPathRef.value =
|
||||||
|
docsPathMap[this.reportClassName] ?? docsPathMap.Reports!;
|
||||||
await this.setReportData();
|
await this.setReportData();
|
||||||
|
|
||||||
const filters = JSON.parse(this.defaultFilters);
|
const filters = JSON.parse(this.defaultFilters);
|
||||||
const filterKeys = Object.keys(filters);
|
const filterKeys = Object.keys(filters);
|
||||||
for (const key of filterKeys) {
|
for (const key of filterKeys) {
|
||||||
await this.report.set(key, filters[key]);
|
await this.report?.set(key, filters[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterKeys.length) {
|
if (filterKeys.length) {
|
||||||
await this.report.updateData();
|
await this.report?.updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fyo.store.isDevelopment) {
|
if (fyo.store.isDevelopment) {
|
||||||
|
// @ts-ignore
|
||||||
window.rep = this;
|
window.rep = this;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -104,13 +121,13 @@ export default defineComponent({
|
|||||||
acc[ac.group] ??= {
|
acc[ac.group] ??= {
|
||||||
group: ac.group,
|
group: ac.group,
|
||||||
label: ac.label ?? '',
|
label: ac.label ?? '',
|
||||||
e: ac.type,
|
type: ac.type ?? 'secondary',
|
||||||
actions: [],
|
actions: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
acc[ac.group].actions.push(ac);
|
acc[ac.group].actions.push(ac);
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {} as Record<string, ActionGroup>);
|
||||||
|
|
||||||
return Object.values(actionsMap);
|
return Object.values(actionsMap);
|
||||||
},
|
},
|
||||||
|
@ -157,7 +157,8 @@ function getCreateList(fyo: Fyo): SearchItem[] {
|
|||||||
function getReportList(fyo: Fyo): SearchItem[] {
|
function getReportList(fyo: Fyo): SearchItem[] {
|
||||||
const hasGstin = !!fyo.singles?.AccountingSettings?.gstin;
|
const hasGstin = !!fyo.singles?.AccountingSettings?.gstin;
|
||||||
const hasInventory = !!fyo.singles?.AccountingSettings?.enableInventory;
|
const hasInventory = !!fyo.singles?.AccountingSettings?.enableInventory;
|
||||||
return Object.keys(reports)
|
const reportNames = Object.keys(reports) as (keyof typeof reports)[];
|
||||||
|
return reportNames
|
||||||
.filter((r) => {
|
.filter((r) => {
|
||||||
const report = reports[r];
|
const report = reports[r];
|
||||||
if (report.isInventory && !hasInventory) {
|
if (report.isInventory && !hasInventory) {
|
||||||
|
Loading…
Reference in New Issue
Block a user