เพิ่ม api check ฟอร์มลา

This commit is contained in:
AnandaTon 2023-12-08 15:41:18 +07:00
parent 3fe083f222
commit 7b0aefe2cd
15 changed files with 386 additions and 59 deletions

View file

@ -123,10 +123,10 @@ export const useLeaveStore = defineStore("Leave", () => {
{ id: "s3", name: "ลาดูงาน", code: "s3" },
])
/** รายการประเภทการลาของ ลาอุปสมบทหรือลาประกอบพิธีฮัจย์ฯ*/
/** รายการประเภทการลาของ ลาอุปสมบทหรือลาประกอบพิธีฮัจญ์*/
const optionsOrdination = ref([
{ id: "0", name: "ลาอุปสมบท", code: "0" },
{ id: "1", name: "ลาประกอบพิธีฮัจย์ฯ", code: "1" },
{ id: "1", name: "ลาประกอบพิธีฮัจญ์", code: "1" },
])
/** data table filter & column ของรายการลา */
@ -223,6 +223,27 @@ export const useLeaveStore = defineStore("Leave", () => {
return options.value.find(x => x.code == val)?.id
}
/**
* profile
*/
const dateSendLeave = ref<Date>() //วันที่ยื่นใบลา
const leaveTypeName = ref<string>("") //Name ประเภทการลา
const dear = ref<string>("") //เรียน
const fullname = ref<string>("") //คำนำหน้า ชื่อ นามสกุล ผู้ยื่นขอ
const positionName = ref<string>("") //ตำแหน่งผู้ยื่นขอ
const positionLevelName = ref<string>("") //ระดับผู้ยื่นขอ
const organizationName = ref<string>("") //สังกัดผู้ยื่นขอ
const leaveLimit = ref<number>(0) //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
const leaveTotal = ref<number>(0) //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
const leaveRemain = ref<number>(0) //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
const restDayTotalOld = ref<number>(0) //จำนวนวันลาพักผ่อนสะสม จากปีที่ผ่านมา
const birthDate = ref<Date>() //วันเกิด
const dateAppoint = ref<Date>() //วันที่เข้ารับราชการ
const salary = ref<number>(0) //เงินเดือนปัจจุบัน
const salaryText = ref<string>("") //เงินเดือนปัจจุบัน(ภาษาไทย)
const leaveLast = ref<string>("")
const restDayCurrentTotal = ref<string>("")
//ดึงข้อมูล profile จาก API
async function fetchProfile() {
console.log("profile")
@ -230,7 +251,24 @@ export const useLeaveStore = defineStore("Leave", () => {
.post(config.API.leaveProfile(), { type: typeId.value })
.then((res: any) => {
const data = res.data.result
console.log(data.va)
dateSendLeave.value = data.dateSendLeave
leaveTypeName.value = data.leaveTypeName
dear.value = data.dear
fullname.value = data.fullname
positionName.value = data.positionName
positionLevelName.value = data.positionLevelName
organizationName.value = data.organizationName
leaveLimit.value = data.leaveLimit
leaveTotal.value = data.leaveTotal
leaveRemain.value = data.leaveRemain
restDayTotalOld.value = data.restDayTotalOld
birthDate.value = data.birthDate
dateAppoint.value = data.dateAppoint
salary.value = data.salary
salaryText.value = data.salaryText
leaveLast.value = data.leaveLast
restDayCurrentTotal.value = data.restDayCurrentTotal
console.log(data)
})
.catch((e: any) => {
messageError($q, e)
@ -260,5 +298,24 @@ export const useLeaveStore = defineStore("Leave", () => {
fetchLeaveType,
filterOption,
fetchProfile,
//ส่งออกตัวแปร profileที่ได้จาก Api
dateSendLeave,
leaveTypeName,
dear,
fullname,
positionName,
positionLevelName,
organizationName,
leaveLimit, //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
leaveTotal, //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
leaveRemain, //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
restDayTotalOld,
birthDate,
dateAppoint,
salary,
salaryText,
leaveLast,
restDayCurrentTotal,
}
})