feat: dashboard data bind api
This commit is contained in:
parent
9a196b7077
commit
58b5613d2c
6 changed files with 100 additions and 59 deletions
|
|
@ -2,7 +2,13 @@ import { ref } from 'vue';
|
|||
import { defineStore } from 'pinia';
|
||||
import { Pagination, Status } from '../types';
|
||||
import { api } from 'src/boot/axios';
|
||||
import { Report, ReportProduct, ReportQuotation, ReportSale } from './types';
|
||||
import {
|
||||
Report,
|
||||
ReportPayment,
|
||||
ReportProduct,
|
||||
ReportQuotation,
|
||||
ReportSale,
|
||||
} from './types';
|
||||
|
||||
const ENDPOINT = 'report';
|
||||
|
||||
|
|
@ -48,12 +54,21 @@ export async function getReportProduct() {
|
|||
return null;
|
||||
}
|
||||
|
||||
export async function getReportPayment() {
|
||||
const res = await api.get<ReportPayment[]>(`/${ENDPOINT}/payment`);
|
||||
if (res.status < 400) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const useReportStore = defineStore('report-store', () => {
|
||||
const dataReportQuotation = ref<ReportQuotation[]>([]);
|
||||
const dataReportInvoice = ref<Report[]>([]);
|
||||
const dataReportReceipt = ref<Report[]>([]);
|
||||
const dataReportSale = ref<ReportSale>();
|
||||
const dataReportProduct = ref<ReportProduct[]>([]);
|
||||
const dataReportPayment = ref<ReportPayment[]>([]);
|
||||
|
||||
return {
|
||||
dataReportQuotation,
|
||||
|
|
@ -61,11 +76,13 @@ export const useReportStore = defineStore('report-store', () => {
|
|||
dataReportReceipt,
|
||||
dataReportSale,
|
||||
dataReportProduct,
|
||||
dataReportPayment,
|
||||
|
||||
getReportQuotation,
|
||||
getReportInvoice,
|
||||
getReportReceipt,
|
||||
getReportSale,
|
||||
getReportProduct,
|
||||
getReportPayment,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { QuotationStatus } from 'src/stores/quotations/types';
|
|||
import { ProductGroup } from '../product-service/types';
|
||||
import { User } from '../user';
|
||||
import { CustomerBranch } from '../customer';
|
||||
import { PaymentDataStatus } from '../payment/types';
|
||||
|
||||
export type ReportQuotation = {
|
||||
updatedAt: Date | null;
|
||||
|
|
@ -34,6 +35,12 @@ export type ReportProduct = {
|
|||
code: string;
|
||||
};
|
||||
|
||||
export type ReportPayment = {
|
||||
year: string;
|
||||
month: string;
|
||||
data: Partial<Record<PaymentDataStatus, number>>;
|
||||
};
|
||||
|
||||
export type ReportSale = {
|
||||
byCustomer: (Omit<CustomerBranch, '_count'> & { _count: number })[];
|
||||
bySale: (User & { _count: number })[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue