refactor: stats missing and new tab
This commit is contained in:
parent
453252c4be
commit
448d9156f9
6 changed files with 55 additions and 54 deletions
|
|
@ -1306,11 +1306,11 @@ export default {
|
|||
},
|
||||
|
||||
stats: {
|
||||
Pending: 'Debit Note',
|
||||
Expire: 'Expired',
|
||||
Payment: 'Payment',
|
||||
Receipt: 'Receipt',
|
||||
Succeed: 'Completed',
|
||||
Issued: 'Debit Note',
|
||||
Expired: 'Expired',
|
||||
PaymentPending: 'Payment',
|
||||
PaymentSuccess: 'Receipt',
|
||||
ProcessComplete: 'Completed',
|
||||
},
|
||||
|
||||
viewMode: {
|
||||
|
|
|
|||
|
|
@ -1288,11 +1288,11 @@ export default {
|
|||
},
|
||||
|
||||
stats: {
|
||||
Pending: 'ใบเพิ่มหนี้',
|
||||
Expire: 'พ้นกำหนด',
|
||||
Payment: 'ชำระเงิน',
|
||||
Receipt: 'ใบเสร็จรับเงิน',
|
||||
Succeed: 'เสร็จสิ้น',
|
||||
Issued: 'ใบเพิ่มหนี้',
|
||||
Expired: 'พ้นกำหนด',
|
||||
PaymentPending: 'ชำระเงิน',
|
||||
PaymentSuccess: 'ใบเสร็จรับเงิน',
|
||||
ProcessComplete: 'เสร็จสิ้น',
|
||||
},
|
||||
|
||||
viewMode: {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const { stats, pageMax, page, data, pageSize } = storeToRefs(debitNote);
|
|||
// NOTE: Variable
|
||||
const pageState = reactive({
|
||||
quotationId: '',
|
||||
currentTab: DebitNoteStatus.Pending,
|
||||
currentTab: DebitNoteStatus.Issued,
|
||||
hideStat: false,
|
||||
statusFilter: 'None',
|
||||
inputSearch: '',
|
||||
|
|
@ -64,7 +64,9 @@ async function getList(opts?: { page?: number; pageSize?: number }) {
|
|||
page: opts?.page || page.value,
|
||||
pageSize: opts?.pageSize || pageSize.value,
|
||||
query: pageState.inputSearch === '' ? undefined : pageState.inputSearch,
|
||||
deebitNoteStatus: pageState.currentTab as DebitNoteStatus | undefined,
|
||||
status: (pageState.currentTab === DebitNoteStatus.Issued
|
||||
? undefined
|
||||
: pageState.currentTab) as DebitNoteStatus,
|
||||
includeRegisteredBranch: true,
|
||||
});
|
||||
|
||||
|
|
@ -126,7 +128,17 @@ onMounted(async () => {
|
|||
navigator.current.title = 'debitNote.title';
|
||||
navigator.current.path = [{ text: 'debitNote.caption', i18n: true }];
|
||||
|
||||
debitNote.getDebitNoteStats().then((res) => res && (stats.value = res));
|
||||
await debitNote.getDebitNoteStats().then((res) => {
|
||||
if (res) {
|
||||
stats.value = res;
|
||||
|
||||
stats.value['issued'] = Object.values(res).reduce(
|
||||
(sum, value) => sum + value,
|
||||
0,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
getList();
|
||||
});
|
||||
|
||||
|
|
@ -184,33 +196,28 @@ watch(
|
|||
:branch="[
|
||||
{
|
||||
icon: 'material-symbols-light:receipt-long',
|
||||
count: stats[DebitNoteStatus.Pending] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.Pending}`,
|
||||
count: stats['issued'] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.Issued}`,
|
||||
color: 'orange',
|
||||
},
|
||||
{
|
||||
icon: 'mdi-clock-alert-outline',
|
||||
count: stats[DebitNoteStatus.Expire] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.Expire}`,
|
||||
color: 'cyan',
|
||||
},
|
||||
|
||||
{
|
||||
icon: 'tabler:cash-register',
|
||||
count: stats[DebitNoteStatus.Payment] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.Payment}`,
|
||||
count: stats['paymentPending'] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.PaymentPending}`,
|
||||
color: 'dark-orange',
|
||||
},
|
||||
{
|
||||
icon: 'fluent:receipt-money-16-regular',
|
||||
count: stats[DebitNoteStatus.Receipt] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.Receipt}`,
|
||||
count: stats['paymentSuccess'] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.PaymentSuccess}`,
|
||||
color: 'green',
|
||||
},
|
||||
|
||||
{
|
||||
icon: 'mdi-check-decagram-outline',
|
||||
count: stats[DebitNoteStatus.Succeed] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.Succeed}`,
|
||||
count: stats['processComplete'] || 0,
|
||||
label: `debitNote.stats.${DebitNoteStatus.ProcessComplete}`,
|
||||
color: 'blue',
|
||||
},
|
||||
]"
|
||||
|
|
|
|||
|
|
@ -4,29 +4,24 @@ import { formatNumberDecimal } from 'src/stores/utils';
|
|||
|
||||
export const taskStatusOpts = [
|
||||
{
|
||||
status: DebitNoteStatus.Expire,
|
||||
name: `debitNote.status.${DebitNoteStatus.Expire}`,
|
||||
status: DebitNoteStatus.PaymentPending,
|
||||
name: `debitNote.status.${DebitNoteStatus.PaymentPending}`,
|
||||
},
|
||||
{
|
||||
status: DebitNoteStatus.Payment,
|
||||
name: `debitNote.status.${DebitNoteStatus.Payment}`,
|
||||
status: DebitNoteStatus.PaymentSuccess,
|
||||
name: `debitNote.status.${DebitNoteStatus.PaymentSuccess}`,
|
||||
},
|
||||
{
|
||||
status: DebitNoteStatus.Receipt,
|
||||
name: `debitNote.status.${DebitNoteStatus.Receipt}`,
|
||||
},
|
||||
{
|
||||
status: DebitNoteStatus.Succeed,
|
||||
name: `debitNote.status.${DebitNoteStatus.Succeed}`,
|
||||
status: DebitNoteStatus.PaymentSuccess,
|
||||
name: `debitNote.status.${DebitNoteStatus.ProcessComplete}`,
|
||||
},
|
||||
];
|
||||
|
||||
export const pageTabs = [
|
||||
{ label: 'Pending', value: DebitNoteStatus.Pending },
|
||||
{ label: 'Expire', value: DebitNoteStatus.Expire },
|
||||
{ label: 'Payment', value: DebitNoteStatus.Payment },
|
||||
{ label: 'Receipt', value: DebitNoteStatus.Receipt },
|
||||
{ label: 'Succeed', value: DebitNoteStatus.Succeed },
|
||||
{ label: 'Pending', value: DebitNoteStatus.Issued },
|
||||
{ label: 'Payment', value: DebitNoteStatus.PaymentPending },
|
||||
{ label: 'Receipt', value: DebitNoteStatus.PaymentSuccess },
|
||||
{ label: 'Succeed', value: DebitNoteStatus.ProcessComplete },
|
||||
];
|
||||
|
||||
export enum Status {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export async function getDebitNoteList(params?: {
|
|||
page?: number;
|
||||
pageSize?: number;
|
||||
query?: string;
|
||||
deebitNoteStatus?: Status;
|
||||
status?: Status;
|
||||
includeRegisteredBranch?: boolean;
|
||||
}) {
|
||||
const res = await api.get<PaginationResult<Data>>(`/${ENDPOINT}`, {
|
||||
|
|
@ -66,12 +66,11 @@ export const useDebitNote = defineStore('debit-note-store', () => {
|
|||
const page = ref<number>(1);
|
||||
const pageMax = ref<number>(1);
|
||||
const pageSize = ref<number>(30);
|
||||
const stats = ref<Record<Status, number>>({
|
||||
[Status.Pending]: 0,
|
||||
[Status.Expire]: 0,
|
||||
[Status.Payment]: 0,
|
||||
[Status.Receipt]: 0,
|
||||
[Status.Succeed]: 0,
|
||||
const stats = ref<Record<string, number>>({
|
||||
['issued']: 0,
|
||||
['paymentPending']: 0,
|
||||
['paymentSuccess']: 0,
|
||||
['processComplete']: 0,
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ export type DebitNote = {
|
|||
};
|
||||
|
||||
export enum DebitNoteStatus {
|
||||
Pending = 'Pending',
|
||||
Expire = 'Expire',
|
||||
Payment = 'Payment',
|
||||
Receipt = 'Receipt',
|
||||
Succeed = 'Succeed',
|
||||
Issued = 'Issued',
|
||||
Expired = 'Expired',
|
||||
PaymentPending = 'PaymentPending',
|
||||
PaymentSuccess = 'PaymentSuccess',
|
||||
ProcessComplete = 'ProcessComplete',
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue