2023-11-14 17:47:43 +07:00
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
export const useChekIn = defineStore('checkin', () => {
|
|
|
|
|
const rows = ref<any>()
|
|
|
|
|
|
|
|
|
|
function fetchHistoryList(data: any) {
|
|
|
|
|
console.log(data)
|
|
|
|
|
const datalist = data.map((e: any) => ({
|
|
|
|
|
no: e.no,
|
|
|
|
|
date: e.date,
|
|
|
|
|
in: e.in,
|
|
|
|
|
loIn: e.loIn,
|
|
|
|
|
out: e.out,
|
|
|
|
|
loOut: e.loOut,
|
|
|
|
|
status: e.status,
|
|
|
|
|
Morningstatus: convertStatus(e.Morningstatus),
|
|
|
|
|
AfternoonStatus: convertStatus(e.AfternoonStatus),
|
|
|
|
|
statusEdit: e.statusEdit,
|
|
|
|
|
statusEditName: convertStatusEdit(e.statusEdit),
|
|
|
|
|
}))
|
|
|
|
|
rows.value = datalist
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function convertStatus(status: string) {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case '1':
|
|
|
|
|
return 'ขาดราชการ'
|
|
|
|
|
case '2':
|
|
|
|
|
return 'ปกติ'
|
|
|
|
|
case '3':
|
|
|
|
|
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'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
rows,
|
|
|
|
|
fetchHistoryList,
|
|
|
|
|
classColorStatus,
|
|
|
|
|
}
|
|
|
|
|
})
|