แก้ไขการแสดงผล และการดึงข้อมูลในส่วนของประวัติและการลงเวลาพิเศษ
This commit is contained in:
parent
062588d0bd
commit
61ce6f966c
4 changed files with 39 additions and 31 deletions
|
|
@ -28,11 +28,14 @@ const props = defineProps({
|
||||||
fetchData: {
|
fetchData: {
|
||||||
type: Function,
|
type: Function,
|
||||||
require: true,
|
require: true,
|
||||||
|
default: () => {
|
||||||
|
console.log('fetchData func')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const dataByIdVal = ref<any>([])
|
const dataByIdVal = ref<any>([])
|
||||||
const date = ref<Date | null>(null)
|
const date = ref<Date | null | string>(null)
|
||||||
const checkboxIn = ref<boolean>(false)
|
const checkboxIn = ref<boolean>(false)
|
||||||
const checkboxOut = ref<boolean>(false)
|
const checkboxOut = ref<boolean>(false)
|
||||||
const reason = ref<string>('')
|
const reason = ref<string>('')
|
||||||
|
|
@ -78,7 +81,7 @@ function onCkickSave() {
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
dialogConfirm($q, async () => {
|
dialogConfirm($q, async () => {
|
||||||
const data: FormTimeStemp = {
|
const data: FormTimeStemp = await {
|
||||||
checkDate: date.value,
|
checkDate: date.value,
|
||||||
checkInEdit: checkboxIn.value,
|
checkInEdit: checkboxIn.value,
|
||||||
checkOutEdit: checkboxOut.value,
|
checkOutEdit: checkboxOut.value,
|
||||||
|
|
@ -86,8 +89,6 @@ function onCkickSave() {
|
||||||
}
|
}
|
||||||
createListTime(data)
|
createListTime(data)
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
console.log('ไม่ผ่าน ')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +107,7 @@ async function createListTime(data: FormTimeStemp) {
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
props.closePopup?.()
|
props.closePopup?.()
|
||||||
props.fetchData?.()
|
props.fetchData()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +119,9 @@ onMounted(() => {
|
||||||
if (dataByIdVal.value == null) {
|
if (dataByIdVal.value == null) {
|
||||||
statusAction.value = true
|
statusAction.value = true
|
||||||
} else {
|
} else {
|
||||||
date.value = new Date(dataByIdVal.value.checkInDateTime)
|
date.value = moment(new Date(dataByIdVal.value.checkInDateTime)).format(
|
||||||
|
'YYYY-MM-DD'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -153,14 +156,15 @@ watch(
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<q-card flat bordered class="col-12 q-mt-sm" v-if="statusAction">
|
<q-card flat bordered class="col-12 q-mt-sm">
|
||||||
<div class="q-pa-sm">
|
<div class="q-pa-sm">
|
||||||
<datepicker
|
<datepicker
|
||||||
|
:readonly="!statusAction"
|
||||||
v-model="date"
|
v-model="date"
|
||||||
:locale="'th'"
|
:locale="'th'"
|
||||||
autoApply
|
|
||||||
:enableTimePicker="false"
|
:enableTimePicker="false"
|
||||||
week-start="0"
|
week-start="0"
|
||||||
|
autoApply
|
||||||
outlined
|
outlined
|
||||||
>
|
>
|
||||||
<template #year="{ year }">
|
<template #year="{ year }">
|
||||||
|
|
@ -171,12 +175,14 @@ watch(
|
||||||
</template>
|
</template>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<q-input
|
<q-input
|
||||||
|
:readonly="!statusAction"
|
||||||
ref="dateRef"
|
ref="dateRef"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
:model-value="date !== null ? date2Thai(date) : null"
|
:model-value="date !== null ? date2Thai(new Date(date)) : null"
|
||||||
:label="`${'วันที่ขอแก้ไข'}`"
|
:label="`${'วันที่ขอแก้ไข'}`"
|
||||||
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
|
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
|
||||||
|
format-header="YYYY-MM-DD"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
>
|
>
|
||||||
|
|
@ -193,14 +199,14 @@ watch(
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<q-card flat bordered class="q-pa-sm col-12 bg-grey-1 q-mt-sm" v-else>
|
<!-- <q-card flat bordered class="q-pa-sm col-12 bg-grey-1 q-mt-sm" v-else>
|
||||||
<div class="row q-gutter-md text-grey-5">
|
<div class="row q-gutter-md text-grey-5">
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<q-icon color="grey-5" name="calendar_today" />
|
<q-icon color="grey-5" name="calendar_today" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col">{{ dataByIdVal.checkInDate }}</div>
|
<div class="col">{{ dataByIdVal.checkInDate }}</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card> -->
|
||||||
|
|
||||||
<q-card
|
<q-card
|
||||||
flat
|
flat
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ interface Datalist {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FormTimeStemp {
|
interface FormTimeStemp {
|
||||||
checkDate: Date | null
|
checkDate: Date | null | string
|
||||||
checkInEdit: boolean
|
checkInEdit: boolean
|
||||||
checkOutEdit: boolean
|
checkOutEdit: boolean
|
||||||
description: string
|
description: string
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ const { date2Thai } = mixin
|
||||||
export const useChekIn = defineStore('checkin', () => {
|
export const useChekIn = defineStore('checkin', () => {
|
||||||
const year = ref<number>(new Date().getFullYear())
|
const year = ref<number>(new Date().getFullYear())
|
||||||
const rows = ref<Datalist[]>()
|
const rows = ref<Datalist[]>()
|
||||||
|
const tab = ref<string>('history')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชั่นสำหรับ map ข้อมูล เพื่อแสดงรายการในตารางประวัติการลงเวลา
|
* ฟังก์ชั่นสำหรับ map ข้อมูล เพื่อแสดงรายการในตารางประวัติการลงเวลา
|
||||||
|
|
@ -94,5 +95,6 @@ export const useChekIn = defineStore('checkin', () => {
|
||||||
year,
|
year,
|
||||||
fetchHistoryList,
|
fetchHistoryList,
|
||||||
classColorStatus,
|
classColorStatus,
|
||||||
|
tab
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,13 @@ async function changePage(pageVal: number, pageSizeVal: number, key: string) {
|
||||||
page.value = await pageVal
|
page.value = await pageVal
|
||||||
pageSize.value = await pageSizeVal
|
pageSize.value = await pageSizeVal
|
||||||
filter.value = await key
|
filter.value = await key
|
||||||
functionFetch.value
|
functionFetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
const functionFetch = computed(() => {
|
function functionFetch() {
|
||||||
const result = tab.value === 'history' ? fetchlistHistory() : fetchlistTime()
|
console.log(stores.tab)
|
||||||
return result
|
stores.tab === 'history' ? fetchlistHistory() : fetchlistTime()
|
||||||
})
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลาจาก api มาแสดง
|
* ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลาจาก api มาแสดง
|
||||||
|
|
@ -108,20 +108,20 @@ async function updateYear(y: number, m: number) {
|
||||||
year.value = y
|
year.value = y
|
||||||
month.value = m
|
month.value = m
|
||||||
stores.year = y
|
stores.year = y
|
||||||
functionFetch.value
|
functionFetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hook*/
|
/** Hook*/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await functionFetch.value
|
await functionFetch()
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => tab.value,
|
() => stores.tab,
|
||||||
() => {
|
() => {
|
||||||
page.value = 1
|
page.value = 1
|
||||||
filter.value = ''
|
filter.value = ''
|
||||||
functionFetch.value
|
functionFetch()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -144,19 +144,19 @@ watch(
|
||||||
</div>
|
</div>
|
||||||
<q-space />
|
<q-space />
|
||||||
<span class="text-body1 text-weight-bold col-8 text-center"
|
<span class="text-body1 text-weight-bold col-8 text-center"
|
||||||
>ประวัติการลงเวลา</span
|
>ประวัติการลงเวลา
|
||||||
>
|
</span>
|
||||||
<div class="col-2"></div>
|
<div class="col-2"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 q-pa-md text-grey-9">
|
<div class="col-12 q-pa-md text-grey-9">
|
||||||
<ToolBar
|
<ToolBar
|
||||||
:fetchData="fetchlistHistory"
|
:fetchData="functionFetch"
|
||||||
@update:year="updateYear"
|
@update:year="updateYear"
|
||||||
:tab="tab"
|
:tab="stores.tab"
|
||||||
/>
|
/>
|
||||||
<q-card bordered flat>
|
<q-card bordered flat>
|
||||||
<q-tabs
|
<q-tabs
|
||||||
v-model="tab"
|
v-model="stores.tab"
|
||||||
dense
|
dense
|
||||||
align="left"
|
align="left"
|
||||||
inline-label
|
inline-label
|
||||||
|
|
@ -171,30 +171,30 @@ watch(
|
||||||
|
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
||||||
<q-tab-panels v-model="tab" animated>
|
<q-tab-panels v-model="stores.tab" animated>
|
||||||
<q-tab-panel name="history">
|
<q-tab-panel name="history">
|
||||||
<TableHistory
|
<TableHistory
|
||||||
:fetchData="fetchlistHistory"
|
:fetchData="functionFetch"
|
||||||
:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page="page"
|
:page="page"
|
||||||
:paging="true"
|
:paging="true"
|
||||||
@update:change-page="changePage"
|
@update:change-page="changePage"
|
||||||
:max-page="maxPage"
|
:max-page="maxPage"
|
||||||
:tab="tab"
|
:tab="stores.tab"
|
||||||
/>
|
/>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
|
|
||||||
<q-tab-panel name="time">
|
<q-tab-panel name="time">
|
||||||
<TableHistory
|
<TableHistory
|
||||||
:fetchData="fetchlistHistory"
|
:fetchData="functionFetch"
|
||||||
:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page="page"
|
:page="page"
|
||||||
:paging="true"
|
:paging="true"
|
||||||
@update:change-page="changePage"
|
@update:change-page="changePage"
|
||||||
:max-page="maxPage"
|
:max-page="maxPage"
|
||||||
:tab="tab"
|
:tab="stores.tab"
|
||||||
/>
|
/>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
</q-tab-panels>
|
</q-tab-panels>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue