fix:add function calculateFiscalYear
This commit is contained in:
parent
4cc8fb0c1c
commit
c966e1d961
3 changed files with 14 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import { ref, watch } from 'vue'
|
|||
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { useChekIn } from '@/stores/chekin'
|
||||
import { calculateFiscalYear } from '@/utils/function'
|
||||
|
||||
import type { DataDateMonthObject } from '@/interface/index/Main'
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ const props = defineProps({
|
|||
const emit = defineEmits(['update:year'])
|
||||
|
||||
const filterYear = ref<number>(
|
||||
stores.year ? stores.year : new Date().getFullYear()
|
||||
stores.year ? stores.year : calculateFiscalYear(new Date())
|
||||
) //ปีงบประมาณ
|
||||
const titleName = ref<string>('เพิ่มรายการลงเวลากรณีพิเศษ') //หัว popup
|
||||
const dateMonth = ref<DataDateMonthObject>({
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ import { defineStore } from 'pinia'
|
|||
import { ref } from 'vue'
|
||||
import type { FormData, Datalist } from '@/interface/response/checkin'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { calculateFiscalYear } from '@/utils/function'
|
||||
|
||||
const mixin = useCounterMixin()
|
||||
const { date2Thai } = mixin
|
||||
|
||||
/** store for checkin history*/
|
||||
export const useChekIn = defineStore('checkin', () => {
|
||||
const year = ref<number>(new Date().getFullYear())
|
||||
const year = ref<number>(calculateFiscalYear(new Date())) //ปีงบประมาณ
|
||||
const rows = ref<Datalist[]>([])
|
||||
const tab = ref<string>('history')
|
||||
|
||||
|
|
|
|||
10
src/utils/function.ts
Normal file
10
src/utils/function.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* คำนวณปีงบประมาณ
|
||||
*
|
||||
* @param date วันที่ปัจจุบัน
|
||||
* @returns ปีงบประมาณ
|
||||
*/
|
||||
export function calculateFiscalYear(date: Date) {
|
||||
const month = date.getMonth() + 1
|
||||
return month >= 10 ? date.getFullYear() + 1 : date.getFullYear()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue