feat: implement date range selection for quotation stats and payment report
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 10s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 10s
This commit is contained in:
parent
4659965f62
commit
d2cf4a8733
1 changed files with 81 additions and 35 deletions
|
|
@ -1,14 +1,15 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// NOTE: Library
|
// NOTE: Library
|
||||||
import { onMounted, reactive } from 'vue';
|
import { onMounted, reactive, watch } from 'vue';
|
||||||
|
|
||||||
// NOTE: Components
|
// NOTE: Components
|
||||||
import SelectInput from 'src/components/shared/SelectInput.vue';
|
import SelectInput from 'src/components/shared/SelectInput.vue';
|
||||||
import StatCardComponent from 'src/components/StatCardComponent.vue';
|
import StatCardComponent from 'src/components/StatCardComponent.vue';
|
||||||
import ChartReceipt from './chart/ChartReceipt.vue';
|
import ChartReceipt from './chart/ChartReceipt.vue';
|
||||||
import ChartOpportunity from './chart/ChartOpportunity.vue';
|
|
||||||
import ChartQuotationStatus from './chart/ChartQuotationStatus.vue';
|
import ChartQuotationStatus from './chart/ChartQuotationStatus.vue';
|
||||||
import ChartSales from './chart/ChartSales.vue';
|
import VueDatePicker from '@vuepic/vue-datepicker';
|
||||||
|
// import ChartOpportunity from './chart/ChartOpportunity.vue';
|
||||||
|
// import ChartSales from './chart/ChartSales.vue';
|
||||||
|
|
||||||
// NOTE: Stores & Type
|
// NOTE: Stores & Type
|
||||||
import { useNavigator } from 'src/stores/navigator';
|
import { useNavigator } from 'src/stores/navigator';
|
||||||
|
|
@ -16,6 +17,7 @@ import { useQuotationStore } from 'src/stores/quotations';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useReportStore } from 'src/stores/report';
|
import { useReportStore } from 'src/stores/report';
|
||||||
import { PaymentDataStatus } from 'src/stores/payment/types';
|
import { PaymentDataStatus } from 'src/stores/payment/types';
|
||||||
|
import { dateFormatJS } from 'src/utils/datetime';
|
||||||
|
|
||||||
// NOTE: Variable
|
// NOTE: Variable
|
||||||
const navigatorStore = useNavigator();
|
const navigatorStore = useNavigator();
|
||||||
|
|
@ -24,57 +26,101 @@ const reportStore = useReportStore();
|
||||||
const { stats: quotationStats } = storeToRefs(quotationStore);
|
const { stats: quotationStats } = storeToRefs(quotationStore);
|
||||||
const { dataReportPayment } = storeToRefs(reportStore);
|
const { dataReportPayment } = storeToRefs(reportStore);
|
||||||
|
|
||||||
|
const endDate = new Date();
|
||||||
|
const startDate = new Date(new Date().setFullYear(endDate.getFullYear() - 1));
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
year: 'now',
|
date: [startDate, endDate],
|
||||||
});
|
});
|
||||||
|
|
||||||
// NOTE: mock
|
// const option = reactive({
|
||||||
const option = reactive({
|
// role: [
|
||||||
role: [
|
// { label: 'ผู้ดูแล', value: 'admin' },
|
||||||
{ label: 'ผู้ดูแล', value: 'admin' },
|
// { label: 'ผู้ใช้', value: 'user' },
|
||||||
{ label: 'ผู้ใช้', value: 'user' },
|
// ],
|
||||||
],
|
// });
|
||||||
year: [
|
|
||||||
{ label: 'ปีนี้', value: 'now' },
|
async function fetchData() {
|
||||||
{ label: '2024', value: '2024' },
|
const ret = await quotationStore.getQuotationStats({
|
||||||
],
|
startDate: state.date[0],
|
||||||
});
|
endDate: state.date[1],
|
||||||
|
});
|
||||||
|
if (ret) {
|
||||||
|
quotationStats.value = {
|
||||||
|
issued: 0,
|
||||||
|
accepted: 0,
|
||||||
|
expired: 0,
|
||||||
|
paymentInProcess: 0,
|
||||||
|
paymentSuccess: 0,
|
||||||
|
processComplete: 0,
|
||||||
|
canceled: 0,
|
||||||
|
};
|
||||||
|
quotationStats.value = Object.assign(quotationStats.value, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
const retPayment = await reportStore.getReportPayment({
|
||||||
|
startDate: state.date[0],
|
||||||
|
endDate: state.date[1],
|
||||||
|
});
|
||||||
|
if (retPayment) {
|
||||||
|
dataReportPayment.value = retPayment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navigatorStore.current.title = 'dashboard.title';
|
navigatorStore.current.title = 'dashboard.title';
|
||||||
navigatorStore.current.path = [{ text: '' }];
|
navigatorStore.current.path = [{ text: '' }];
|
||||||
|
|
||||||
const ret = await quotationStore.getQuotationStats();
|
await fetchData();
|
||||||
if (ret) {
|
|
||||||
quotationStats.value = Object.assign(quotationStats.value, ret);
|
|
||||||
console.log(quotationStats.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
const retPayment = await reportStore.getReportPayment();
|
|
||||||
|
|
||||||
if (retPayment) {
|
|
||||||
dataReportPayment.value = retPayment;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => state.date,
|
||||||
|
async () => {
|
||||||
|
await fetchData();
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="column full-height no-wrap">
|
<div class="column full-height no-wrap">
|
||||||
<header class="row q-gutter-sm">
|
<header class="row q-gutter-sm">
|
||||||
<SelectInput
|
<!-- <SelectInput
|
||||||
class="col-md-3 col"
|
class="col-md-3 col"
|
||||||
:option="option.role"
|
:option="option.role"
|
||||||
v-model="state.role"
|
v-model="state.role"
|
||||||
></SelectInput>
|
for="selecte-role"
|
||||||
<SelectInput
|
></SelectInput> -->
|
||||||
class="col-md-2 col"
|
<VueDatePicker
|
||||||
:option="option.year"
|
utc
|
||||||
v-model="state.year"
|
range
|
||||||
|
teleport
|
||||||
|
auto-apply
|
||||||
|
for="select-date-range"
|
||||||
|
class="col-md-4 col"
|
||||||
|
v-model="state.date"
|
||||||
|
:dark="$q.dark.isActive"
|
||||||
|
:locale="$i18n.locale === 'tha' ? 'th' : 'en'"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #trigger>
|
||||||
<q-icon name="mdi-calendar-outline app-text-muted" />
|
<q-input
|
||||||
|
placeholder="DD/MM/YYYY"
|
||||||
|
hide-bottom-space
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
for="select-date-range"
|
||||||
|
:model-value="
|
||||||
|
dateFormatJS({ date: state.date[0] }) +
|
||||||
|
' - ' +
|
||||||
|
dateFormatJS({ date: state.date[1] })
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<q-icon name="mdi-calendar-outline" class="app-text-muted" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
</template>
|
</template>
|
||||||
</SelectInput>
|
</VueDatePicker>
|
||||||
|
|
||||||
<div class="col-12 scroll">
|
<div class="col-12 scroll">
|
||||||
<div style="display: inline-block">
|
<div style="display: inline-block">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue