hrms-checkin/src/stores/chekin.ts

73 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-11-14 17:47:43 +07:00
import { defineStore } from 'pinia'
import { ref } from 'vue'
2023-11-20 12:14:32 +07:00
import http from '@/plugins/http'
import config from '@/app.config'
2023-11-14 17:47:43 +07:00
2023-11-20 18:01:34 +07:00
// importStores
import { useCounterMixin } from '@/stores/mixin'
const mixin = useCounterMixin()
const { date2Thai } = mixin
2023-11-14 17:47:43 +07:00
export const useChekIn = defineStore('checkin', () => {
const rows = ref<any>()
2023-11-20 12:14:32 +07:00
async function fetchHistoryList(data: any) {
// console.log(data)
rows.value = []
const datalist = await data.map((e: any) => ({
checkInId: e.checkInId,
checkInDate: date2Thai(e.checkInDate),
checkInTime: e.checkInTime,
checkOutTime: e.checkOutTime != '' ? e.checkOutTime : '-',
checkInStatus: convertStatus(e.checkInStatus),
checkOutStatus:
e.checkOutStatus != null ? convertStatus(e.checkOutStatus) : '-',
checkInLocation: e.checkInLocation,
checkOutLocation: e.checkOutLocation != '' ? e.checkOutLocation : '-',
2023-11-20 12:14:32 +07:00
// statusEditName: convertStatusEdit(e.statusEdit),
2023-11-14 17:47:43 +07:00
}))
rows.value = datalist
}
function convertStatus(status: string) {
switch (status) {
2023-11-20 18:01:34 +07:00
case '':
2023-11-14 17:47:43 +07:00
return 'ขาดราชการ'
2023-11-20 18:01:34 +07:00
case 'NORMAL':
2023-11-14 17:47:43 +07:00
return 'ปกติ'
2023-11-20 18:01:34 +07:00
case 'LATE':
2023-11-14 17:47:43 +07:00
return 'สาย'
default:
return ''
}
}
function convertStatusEdit(val: string) {
switch (val) {
case 'edit':
return 'ขอแก้ไข'
case 'wait':
return 'รออนุมัติ'
case 'approve':
return 'อนุมัติ'
}
}
function classColorStatus(val: string) {
switch (val) {
case 'wait':
return 'orange'
case 'approve':
return 'green'
case 'reject':
return 'red'
2023-11-14 17:47:43 +07:00
}
}
return {
rows,
fetchHistoryList,
classColorStatus,
2023-11-20 12:14:32 +07:00
// fetchlistHistory,
2023-11-14 17:47:43 +07:00
}
})