72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
import http from '@/plugins/http'
|
|
import config from '@/app.config'
|
|
|
|
// importStores
|
|
import { useCounterMixin } from '@/stores/mixin'
|
|
|
|
const mixin = useCounterMixin()
|
|
const { date2Thai } = mixin
|
|
|
|
export const useChekIn = defineStore('checkin', () => {
|
|
const rows = ref<any>()
|
|
|
|
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 : '-',
|
|
// statusEditName: convertStatusEdit(e.statusEdit),
|
|
}))
|
|
rows.value = datalist
|
|
}
|
|
|
|
function convertStatus(status: string) {
|
|
switch (status) {
|
|
case '':
|
|
return 'ขาดราชการ'
|
|
case 'NORMAL':
|
|
return 'ปกติ'
|
|
case 'LATE':
|
|
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'
|
|
}
|
|
}
|
|
|
|
return {
|
|
rows,
|
|
fetchHistoryList,
|
|
classColorStatus,
|
|
// fetchlistHistory,
|
|
}
|
|
})
|