ปรับ code ประวัติการลงเวลา
This commit is contained in:
parent
c78cc9b0bd
commit
5ec610fcc0
3 changed files with 57 additions and 43 deletions
|
|
@ -329,12 +329,12 @@ const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
color="cyan-6"
|
color="cyan-6"
|
||||||
@click="openPopup(props.row)"
|
@click="openPopup(props.row)"
|
||||||
/>
|
/>
|
||||||
<!-- <q-chip
|
<q-chip
|
||||||
v-else
|
v-else-if="props.row.editStatus != ''"
|
||||||
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
|
:color="`${stores.classColorStatus(props.row.editStatus)}-2`"
|
||||||
:text-color="`${stores.classColorStatus(props.row.statusEdit)}-7`"
|
:text-color="`${stores.classColorStatus(props.row.editStatus)}-7`"
|
||||||
>{{ props.row.statusEdit }}</q-chip
|
>{{ props.row.editStatus }}</q-chip
|
||||||
> -->
|
>
|
||||||
</q-td>
|
</q-td>
|
||||||
</q-tr>
|
</q-tr>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -391,12 +391,12 @@ const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
</div>
|
</div>
|
||||||
<div class="col" v-else>
|
<div class="col" v-else>
|
||||||
<q-chip
|
<q-chip
|
||||||
:color="`${stores.classColorStatus(props.row.statusEdit)}-1`"
|
:color="`${stores.classColorStatus(props.row.editStatus)}-2`"
|
||||||
:text-color="`${stores.classColorStatus(
|
:text-color="`${stores.classColorStatus(
|
||||||
props.row.statusEdit
|
props.row.editStatus
|
||||||
)}-7`"
|
)}-7`"
|
||||||
>
|
>
|
||||||
{{ props.row.statusEdit }}
|
{{ props.row.editStatus }}
|
||||||
</q-chip>
|
</q-chip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -404,19 +404,7 @@ const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<!-- <template v-slot:pagination="scope">
|
<template v-slot:pagination>
|
||||||
<q-pagination
|
|
||||||
v-model="currentPage"
|
|
||||||
active-color="primary"
|
|
||||||
color="dark"
|
|
||||||
:max="scope.pagesNumber"
|
|
||||||
:max-pages="5"
|
|
||||||
size="sm"
|
|
||||||
boundary-links
|
|
||||||
direction-links
|
|
||||||
></q-pagination>
|
|
||||||
</template> -->
|
|
||||||
<template v-slot:pagination="scope">
|
|
||||||
ทั้งหมด {{ props.total }} รายการ
|
ทั้งหมด {{ props.total }} รายการ
|
||||||
<q-pagination
|
<q-pagination
|
||||||
v-model="currentPage"
|
v-model="currentPage"
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ interface FormData {
|
||||||
checkOutStatus: string
|
checkOutStatus: string
|
||||||
checkInLocation: string
|
checkInLocation: string
|
||||||
checkOutLocation: string
|
checkOutLocation: string
|
||||||
|
editStatus: string
|
||||||
|
editReason: string
|
||||||
}
|
}
|
||||||
interface Datalist {
|
interface Datalist {
|
||||||
checkInId: string
|
checkInId: string
|
||||||
|
|
@ -25,6 +27,8 @@ interface Datalist {
|
||||||
checkOutStatus: string
|
checkOutStatus: string
|
||||||
checkInLocation: string
|
checkInLocation: string
|
||||||
checkOutLocation: string
|
checkOutLocation: string
|
||||||
|
editStatus: string
|
||||||
|
editReason: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FormTimeStemp {
|
interface FormTimeStemp {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,21 @@
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
import type { FormData, Datalist } from '@/interface/response/checkin'
|
import type { FormData, Datalist } from '@/interface/response/checkin'
|
||||||
|
|
||||||
// importStores
|
|
||||||
import { useCounterMixin } from '@/stores/mixin'
|
import { useCounterMixin } from '@/stores/mixin'
|
||||||
|
|
||||||
const mixin = useCounterMixin()
|
const mixin = useCounterMixin()
|
||||||
const { date2Thai } = mixin
|
const { date2Thai } = mixin
|
||||||
|
|
||||||
|
/** store for checkin history*/
|
||||||
export const useChekIn = defineStore('checkin', () => {
|
export const useChekIn = defineStore('checkin', () => {
|
||||||
const rows = ref<Datalist[]>()
|
const rows = ref<Datalist[]>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับ map ข้อมูล เพื่อแสดงรายการในตารางประวัติการลงเวลา
|
||||||
|
* @param data รายการข้อมูลทีต้องการ map เป็น array ที่ประกอบด้วย object ตาม FormData
|
||||||
|
*/
|
||||||
async function fetchHistoryList(data: FormData[]) {
|
async function fetchHistoryList(data: FormData[]) {
|
||||||
rows.value = []
|
rows.value = []
|
||||||
const datalist: Datalist[] = await data.map((e: FormData) => ({
|
const dataList: Datalist[] = await data.map((e: FormData) => ({
|
||||||
checkInId: e.checkInId,
|
checkInId: e.checkInId,
|
||||||
checkInDate: e.checkInDate ? date2Thai(e.checkInDate) : null,
|
checkInDate: e.checkInDate ? date2Thai(e.checkInDate) : null,
|
||||||
checkInDateTime: e.checkInDate,
|
checkInDateTime: e.checkInDate,
|
||||||
|
|
@ -25,11 +26,17 @@ export const useChekIn = defineStore('checkin', () => {
|
||||||
e.checkOutStatus != null ? convertStatus(e.checkOutStatus) : '-',
|
e.checkOutStatus != null ? convertStatus(e.checkOutStatus) : '-',
|
||||||
checkInLocation: e.checkInLocation,
|
checkInLocation: e.checkInLocation,
|
||||||
checkOutLocation: e.checkOutLocation != '' ? e.checkOutLocation : '-',
|
checkOutLocation: e.checkOutLocation != '' ? e.checkOutLocation : '-',
|
||||||
// statusEditName: convertStatusEdit(e.statusEdit),
|
editStatus: e.editStatus != '' ? convertEditStatus(e.editStatus) : '',
|
||||||
|
editReason: e.editReason,
|
||||||
}))
|
}))
|
||||||
rows.value = datalist
|
rows.value = dataList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับ convert ข้อความสถานะของการลงเวลา ปกติ, ขาดราชการ หรือสาย
|
||||||
|
* @param status ฟิลด์สถานะที่มาจาก API
|
||||||
|
* @returns ข้อความสถานะ ปกติ, ขาดราชการ หรือสาย
|
||||||
|
*/
|
||||||
function convertStatus(status: string) {
|
function convertStatus(status: string) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case '':
|
case '':
|
||||||
|
|
@ -42,24 +49,40 @@ export const useChekIn = defineStore('checkin', () => {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// function convertStatusEdit(val: string) {
|
|
||||||
// switch (val) {
|
/**
|
||||||
// case 'edit':
|
* ฟังก์ชั่นสำหรับ convert ข้อความสถานะการขอแก้ไข/การขอลงเวลาพิเศษ
|
||||||
// return 'ขอแก้ไข'
|
* @param val ฟิลด์สถานะการขอแก้ไข/การขอลงเวลาพิเศษที่มาจาก API
|
||||||
// case 'wait':
|
* @returns ข้อความสถานะการขอแก้ไข/การขอลงเวลาพิเศษ
|
||||||
// return 'รออนุมัติ'
|
*/
|
||||||
// case 'approve':
|
function convertEditStatus(val: string) {
|
||||||
// return 'อนุมัติ'
|
switch (val) {
|
||||||
// }
|
case 'PENDING':
|
||||||
// }
|
return 'รออนุมัติ'
|
||||||
|
case 'APPROVE':
|
||||||
|
return 'อนุมัติ'
|
||||||
|
case 'REJECT':
|
||||||
|
return 'ไม่อนุมัติ'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับแสดง class กรณีสถานะการขอลงเวลาพิเศษ
|
||||||
|
* @param val ข้อความสถานะการขอลงเวลาพิเศษที่ convert แล้ว
|
||||||
|
* @returns ค่าสีที่ต้องการแสดงตามข้อความสถานะ
|
||||||
|
*/
|
||||||
function classColorStatus(val: string) {
|
function classColorStatus(val: string) {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 'wait':
|
case 'รออนุมัติ':
|
||||||
return 'orange'
|
return 'orange'
|
||||||
case 'approve':
|
case 'อนุมัติ':
|
||||||
return 'green'
|
return 'green'
|
||||||
case 'reject':
|
case 'ไม่อนุมัติ':
|
||||||
return 'red'
|
return 'red'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +90,5 @@ export const useChekIn = defineStore('checkin', () => {
|
||||||
rows,
|
rows,
|
||||||
fetchHistoryList,
|
fetchHistoryList,
|
||||||
classColorStatus,
|
classColorStatus,
|
||||||
// fetchlistHistory,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue