From 37a0f984c373fc3dee4d25d3df549bc4cc1af1db Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Mon, 8 Jan 2024 18:05:30 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=9F=E0=B8=AD=E0=B8=A3=E0=B9=8C=E0=B8=A1=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/leave/api.leave.ts | 1 + src/modules/05_leave/components/ListView.vue | 376 ++++------ src/modules/05_leave/views/AddPage.vue | 345 ++++----- src/modules/05_leave/views/EditPage.vue | 716 ++++++++----------- 4 files changed, 591 insertions(+), 847 deletions(-) diff --git a/src/api/leave/api.leave.ts b/src/api/leave/api.leave.ts index 29515f2..313770b 100644 --- a/src/api/leave/api.leave.ts +++ b/src/api/leave/api.leave.ts @@ -21,6 +21,7 @@ export default { leaveStats: () => `${leave}/user/summary`, leaveUser: () => `${leave}/user`, leaveUserId: (id: string) => `${leave}/user/${id}`, + leaveUserSendId: (id: string) => `${leave}/user/send/${id}`, leaveProfile: () => `${leave}/user/profile`, leaveCheck: () => `${leave}/user/check`, leaveReport: (id: string) => `${leave}/report/${id}`, diff --git a/src/modules/05_leave/components/ListView.vue b/src/modules/05_leave/components/ListView.vue index cea050d..486ffd3 100644 --- a/src/modules/05_leave/components/ListView.vue +++ b/src/modules/05_leave/components/ListView.vue @@ -1,83 +1,82 @@ diff --git a/src/modules/05_leave/views/AddPage.vue b/src/modules/05_leave/views/AddPage.vue index 8105f40..344836e 100644 --- a/src/modules/05_leave/views/AddPage.vue +++ b/src/modules/05_leave/views/AddPage.vue @@ -1,235 +1,164 @@ diff --git a/src/modules/05_leave/views/EditPage.vue b/src/modules/05_leave/views/EditPage.vue index 842f503..7f4cbb1 100644 --- a/src/modules/05_leave/views/EditPage.vue +++ b/src/modules/05_leave/views/EditPage.vue @@ -1,456 +1,334 @@ From cae195c7bd2d2de0d9f29387861afd76cbcbeda2 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Mon, 8 Jan 2024 18:10:26 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=E0=B9=83=E0=B8=99=E0=B8=95=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../05_leave/interface/response/leave.ts | 2 + src/modules/05_leave/store.ts | 730 +++++++++--------- 2 files changed, 363 insertions(+), 369 deletions(-) diff --git a/src/modules/05_leave/interface/response/leave.ts b/src/modules/05_leave/interface/response/leave.ts index 7649691..3b9427b 100644 --- a/src/modules/05_leave/interface/response/leave.ts +++ b/src/modules/05_leave/interface/response/leave.ts @@ -2,6 +2,8 @@ interface ListLeave { id: string //*Id การยื่นขอลา leaveTypeName: string //Name ประเภทการลา leaveTypeId: string //Id ประเภทการลา + leaveStartDate: Date + leaveEndDate: Date fullName: string //คำนำหน้า ชื่อ นามสกุล คนขอลา dateSendLeave: Date | null //วันที่ยื่นใบลา status: string //สถานะการของลา diff --git a/src/modules/05_leave/store.ts b/src/modules/05_leave/store.ts index f73155b..5e41cfc 100644 --- a/src/modules/05_leave/store.ts +++ b/src/modules/05_leave/store.ts @@ -1,400 +1,392 @@ -import { defineStore } from "pinia"; -import { ref } from "vue"; -import { useQuasar } from "quasar"; +import { defineStore } from "pinia" +import { ref } from "vue" +import { useQuasar } from "quasar" -import type { QTableProps } from "quasar"; -import type { - OptionData, - TypeLeave, -} from "@/modules/05_leave/interface/index/main"; -import type { - ListLeave, - ListLeaveTable, -} from "@/modules/05_leave/interface/response/leave"; -import http from "@/plugins/http"; -import config from "@/app.config"; +import type { QTableProps } from "quasar" +import type { OptionData, TypeLeave } from "@/modules/05_leave/interface/index/main" +import type { ListLeave, ListLeaveTable } from "@/modules/05_leave/interface/response/leave" +import http from "@/plugins/http" +import config from "@/app.config" -import { useCounterMixin } from "@/stores/mixin"; -const mixin = useCounterMixin(); -const { date2Thai, messageError } = mixin; -const $q = useQuasar(); +import { useCounterMixin } from "@/stores/mixin" +const mixin = useCounterMixin() +const { date2Thai, messageError } = mixin +const $q = useQuasar() export const useLeaveStore = defineStore("Leave", () => { - const tabValue = ref("calendar"); - const typeLeave = ref(""); - const LeaveType = ref("0"); - const LeaveStatus = ref("0"); - const fiscalYearyear = ref(new Date().getFullYear()); - const rows = ref([]); + const tabValue = ref("calendar") + const typeLeave = ref("") + const LeaveType = ref("0") + const LeaveStatus = ref("0") + const fiscalYearyear = ref(new Date().getFullYear()) + const rows = ref([]) - /** - * function เรียกข้อมูลรายการลา Table - * @param data ข้อมูลรายการลา Table - */ - async function fetchListLeave(data: ListLeave[]) { - let datalist: ListLeaveTable[] = data.map((e: ListLeave) => ({ - id: e.id, - leaveTypeName: e.leaveTypeName, - leaveTypeId: e.leaveTypeId, - fullName: e.fullName, - dateSendLeave: e.dateSendLeave && date2Thai(e.dateSendLeave), - status: e.status, - statusConvert: convertStatud(e.status), - isDelete: e.isDelete, - })); - rows.value = datalist; - } + /** + * function เรียกข้อมูลรายการลา Table + * @param data ข้อมูลรายการลา Table + */ + async function fetchListLeave(data: ListLeave[]) { + let datalist: ListLeaveTable[] = data.map((e: ListLeave) => ({ + id: e.id, + leaveTypeName: e.leaveTypeName, + leaveTypeId: e.leaveTypeId, + fullName: e.fullName, + dateSendLeave: e.dateSendLeave && date2Thai(e.dateSendLeave), + dateLeave: date2Thai(e.leaveStartDate) + " - " + date2Thai(e.leaveEndDate), + status: e.status, + statusConvert: convertStatud(e.status), + isDelete: e.isDelete, + })) + rows.value = datalist + } - //ฟังก์ชั่นแปลง Status - function convertStatud(val: string) { - switch (val) { - case "DRAFT": - return "แบบร่าง"; - case "NEW": - return "ใหม่"; - case "PENDING": - return "กำลังดำเนินการ"; - case "APPROVE": - return "อนุมัติ"; - case "REJECT": - return "ไม่อนุมัติ"; - case "DELETE": - return "ยกเลิก"; - } - } + //ฟังก์ชั่นแปลง Status + function convertStatud(val: string) { + switch (val) { + case "DRAFT": + return "แบบร่าง" + case "NEW": + return "ใหม่" + case "PENDING": + return "กำลังดำเนินการ" + case "APPROVE": + return "อนุมัติ" + case "REJECT": + return "ไม่อนุมัติ" + case "DELETE": + return "ยกเลิก" + } + } - /** ประเภทการลา */ - const typeOptions = ref([]); - const typeId = ref(""); - const typeOptionsMain = ref([]); - const typeOptionsAdd = ref([]); - /** รายการข้อมูลประเภทใบลา */ - const options = ref([]); - /** - * function เรียกข้อมูลประเภทการลา - * @param data ประเภทการลา - */ - async function fetchLeaveType(data: TypeLeave[]) { - typeOptionsMain.value = [ - { - id: "00000000-0000-0000-0000-000000000000", - name: "ทั้งหมด", - code: "LV-000", - }, - ]; + /** ประเภทการลา */ + const typeOptions = ref([]) + const typeId = ref("") + const typeOptionsMain = ref([]) + const typeOptionsAdd = ref([]) + /** รายการข้อมูลประเภทใบลา */ + const options = ref([]) + /** + * function เรียกข้อมูลประเภทการลา + * @param data ประเภทการลา + */ + async function fetchLeaveType(data: TypeLeave[]) { + typeOptionsMain.value = [ + { + id: "00000000-0000-0000-0000-000000000000", + name: "ทั้งหมด", + code: "LV-000", + }, + ] - const optionType = data.map((e: TypeLeave) => ({ - id: e.id, - name: e.name, - code: e.code, - })); + const optionType = data.map((e: TypeLeave) => ({ + id: e.id, + name: e.name, + code: e.code, + })) - typeOptionsMain.value.push(...optionType); - typeOptions.value = typeOptionsMain.value; + typeOptionsMain.value.push(...optionType) + typeOptions.value = typeOptionsMain.value - typeOptionsAdd.value = []; - typeOptionsAdd.value.push(...optionType); - options.value = typeOptionsAdd.value; - } + typeOptionsAdd.value = [] + typeOptionsAdd.value.push(...optionType) + options.value = typeOptionsAdd.value + } - /** สถานะของการลา */ - const statusOptionsMain = ref([ - { id: "ALL", name: "ทั้งหมด" }, - { id: "DRAFT", name: "แบบร่าง" }, - { id: "NEW", name: "ใหม่" }, - { id: "PENDING", name: "กำลังดำเนินการ" }, - { id: "APPROVE", name: "อนุมัติ " }, - { id: "REJECT", name: "ไม่อนุมัติ" }, - { id: "DELETE", name: "ยกเลิก" }, - ]); - const statusOptions = ref(statusOptionsMain.value); + /** สถานะของการลา */ + const statusOptionsMain = ref([ + { id: "ALL", name: "ทั้งหมด" }, + { id: "DRAFT", name: "แบบร่าง" }, + { id: "NEW", name: "ใหม่" }, + { id: "PENDING", name: "กำลังดำเนินการ" }, + { id: "APPROVE", name: "อนุมัติ " }, + { id: "REJECT", name: "ไม่อนุมัติ" }, + { id: "DELETE", name: "ยกเลิก" }, + ]) + const statusOptions = ref(statusOptionsMain.value) - /** - * function ต้นหาข้อมูลของ Option - * @param val ค่าที่ต้องการฟิลเตอร์ - * @param update อัพเดทค่า - * @param refData ดาต้าที่ต้องการฟิลเตอร์ - */ - function filterOption(val: any, update: Function, refData: string) { - switch (refData) { - case "LeaveTypeOption": - update(() => { - typeOptions.value = typeOptionsMain.value.filter( - (v: any) => v.name.indexOf(val) > -1 - ); - }); - break; - case "LeaveStatusOption": - update(() => { - statusOptions.value = statusOptionsMain.value.filter( - (v: any) => v.name.indexOf(val) > -1 - ); - }); - break; - default: - break; - } - } + /** + * function ต้นหาข้อมูลของ Option + * @param val ค่าที่ต้องการฟิลเตอร์ + * @param update อัพเดทค่า + * @param refData ดาต้าที่ต้องการฟิลเตอร์ + */ + function filterOption(val: any, update: Function, refData: string) { + switch (refData) { + case "LeaveTypeOption": + update(() => { + typeOptions.value = typeOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1) + }) + break + case "LeaveStatusOption": + update(() => { + statusOptions.value = statusOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1) + }) + break + default: + break + } + } - /** รายการประเภทการลาของ ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน*/ - const optionsSpecific = ref([ - { id: "s1", name: "ลาไปศึกษาต่อ", code: "s1" }, - { id: "s2", name: "ลาฝึกอบรม/ปฎิบัติการวิจัย/ดูงาน", code: "s2" }, - ]); + /** รายการประเภทการลาของ ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน*/ + const optionsSpecific = ref([ + { id: "s1", name: "ลาไปศึกษาต่อ", code: "s1" }, + { id: "s2", name: "ลาฝึกอบรม/ปฎิบัติการวิจัย/ดูงาน", code: "s2" }, + ]) - /** รายการประเภทการลาของ ลาอุปสมบทหรือลาประกอบพิธีฮัจญ์*/ - const optionsOrdination = ref([ - { id: "b1", name: "ลาอุปสมบท", code: "b1" }, - { id: "b2", name: "ลาประกอบพิธีฮัจญ์", code: "b2" }, - ]); + /** รายการประเภทการลาของ ลาอุปสมบทหรือลาประกอบพิธีฮัจญ์*/ + const optionsOrdination = ref([ + { id: "b1", name: "ลาอุปสมบท", code: "b1" }, + { id: "b2", name: "ลาประกอบพิธีฮัจญ์", code: "b2" }, + ]) - /** data table filter & column ของรายการลา */ - const visibleColumns = ref([ - "no", - "leaveTypeName", - "dateSendLeave", - "status", - ]); + /** data table filter & column ของรายการลา */ + const visibleColumns = ref(["no", "leaveTypeName", "dateSendLeave", "status", "dateLeave"]) - const columns = ref([ - { - name: "no", - align: "left", - label: "ลำดับ", - sortable: true, - field: "no", - headerStyle: "font-size: 14px", - style: "font-size: 14px; width:5%;", - }, - { - name: "leaveTypeName", - align: "left", - label: "ประเภทการลา", - sortable: true, - field: "leaveTypeName", - headerStyle: "font-size: 14px", - style: "font-size: 14px; width:15%;", - }, - { - name: "dateSendLeave", - align: "left", - label: "วันที่ยื่นใบลา", - sortable: true, - field: "dateSendLeave", - headerStyle: "font-size: 14px", - style: "font-size: 14px; width:15%;", - }, - { - name: "status", - align: "left", - label: "สถานะ", - sortable: true, - field: "status", - headerStyle: "font-size: 14px", - style: "font-size: 14px; width:10%;", - }, - ]); + const columns = ref([ + { + name: "no", + align: "left", + label: "ลำดับ", + sortable: true, + field: "no", + headerStyle: "font-size: 14px", + style: "font-size: 14px; width:5%;", + }, + { + name: "leaveTypeName", + align: "left", + label: "ประเภทการลา", + sortable: true, + field: "leaveTypeName", + headerStyle: "font-size: 14px", + style: "font-size: 14px; width:15%;", + }, + { + name: "dateLeave", + align: "left", + label: "วันที่ลา", + sortable: true, + field: "dateLeave", + headerStyle: "font-size: 14px", + style: "font-size: 14px; width:15%;", + }, + { + name: "dateSendLeave", + align: "left", + label: "วันที่ยื่นใบลา", + sortable: true, + field: "dateSendLeave", + headerStyle: "font-size: 14px", + style: "font-size: 14px; width:15%;", + }, - /** - *ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา - * @param item ประเภทแบบฟอร์ม - * @param subitem ประเภทแบบฟอร์มย่อย - */ - function typeConvert(item: string, subitem: any) { - // console.log('first',item) - // if (item !== "LV-006" && item !== "LV-008") { - typeLeave.value = convertSubtitle(item); - // } else if (item === "LV-006") { - // typeLeave.value = convertSubtitleInfo(subitem); - // } else if (item === "LV-008") { - // typeLeave.value = convertSubtitleInfo2(subitem); - // } - typeId.value = convertId(item); - } + { + name: "status", + align: "left", + label: "สถานะ", + sortable: true, + field: "status", + headerStyle: "font-size: 14px", + style: "font-size: 14px; width:10%;", + }, + ]) - /** - *ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา ลาอุปสมบท/ลาประกอบพิธีฮัจญ์ - * @param val ค่า string - * @returns ส่งค่าที่แปลงแล้ว - */ - function convertSubtitle(val: string) { - return options.value.find((x) => x.code == val)?.name; - } + /** + *ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา + * @param item ประเภทแบบฟอร์ม + * @param subitem ประเภทแบบฟอร์มย่อย + */ + function typeConvert(item: string, subitem: any) { + // console.log('first',item) + // if (item !== "LV-006" && item !== "LV-008") { + typeLeave.value = convertSubtitle(item) + // } else if (item === "LV-006") { + // typeLeave.value = convertSubtitleInfo(subitem); + // } else if (item === "LV-008") { + // typeLeave.value = convertSubtitleInfo2(subitem); + // } + typeId.value = convertId(item) + } - /** - *ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา ลาอุปสมบท/ลาประกอบพิธีฮัจญ์ ย่อย - * @param val ค่า string - * @returns ส่งค่าที่แปลงแล้ว - */ - function convertSubtitleInfo(val: string) { - return optionsOrdination.value.find((x) => x.id == val)?.name; - } + /** + *ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา ลาอุปสมบท/ลาประกอบพิธีฮัจญ์ + * @param val ค่า string + * @returns ส่งค่าที่แปลงแล้ว + */ + function convertSubtitle(val: string) { + return options.value.find(x => x.code == val)?.name + } - /** - *ฟังก์ชั่นแปลง ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน - * @param val ค่า string - * @returns ส่งค่าที่แปลงแล้ว - */ - function convertSubtitleInfo2(val: string) { - return optionsSpecific.value.find((x) => x.id == val)?.name; - } + /** + *ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา ลาอุปสมบท/ลาประกอบพิธีฮัจญ์ ย่อย + * @param val ค่า string + * @returns ส่งค่าที่แปลงแล้ว + */ + function convertSubtitleInfo(val: string) { + return optionsOrdination.value.find(x => x.id == val)?.name + } - /** - *ฟังก์ชั่นหา id จาก api - * @param val ค่า string - * @returns ส่งค่าที่แปลงแล้ว - */ - function convertId(val: string) { - return options.value.find((x) => x.code == val)?.id; - } + /** + *ฟังก์ชั่นแปลง ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน + * @param val ค่า string + * @returns ส่งค่าที่แปลงแล้ว + */ + function convertSubtitleInfo2(val: string) { + return optionsSpecific.value.find(x => x.id == val)?.name + } - /** - *ตัวแปร profile ที่จะส่งออก - */ - const dateSendLeave = ref(); //วันที่ยื่นใบลา - const leaveTypeName = ref(""); //Name ประเภทการลา - const dear = ref(""); //เรียน - const fullName = ref(""); //คำนำหน้า ชื่อ นามสกุล ผู้ยื่นขอ - const positionName = ref(""); //ตำแหน่งผู้ยื่นขอ - const positionLevelName = ref(""); //ระดับผู้ยื่นขอ - const organizationName = ref(""); //สังกัดผู้ยื่นขอ - const leaveLimit = ref(0); //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) - const leaveTotal = ref(0); //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) - const leaveRemain = ref(0); //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) - const restDayTotalOld = ref(0); //จำนวนวันลาพักผ่อนสะสม จากปีที่ผ่านมา - const birthDate = ref(); //วันเกิด - const dateAppoint = ref(); //วันที่เข้ารับราชการ - const salary = ref(0); //เงินเดือนปัจจุบัน - const salaryText = ref(""); //เงินเดือนปัจจุบัน(ภาษาไทย) - const leaveLast = ref(); - const restDayCurrentTotal = ref(""); + /** + *ฟังก์ชั่นหา id จาก api + * @param val ค่า string + * @returns ส่งค่าที่แปลงแล้ว + */ + function convertId(val: string) { + return options.value.find(x => x.code == val)?.id + } - //ดึงข้อมูล profile จาก API - async function fetchProfile() { - await http - .post(config.API.leaveProfile(), { type: typeId.value }) - .then((res: any) => { - const data = res.data.result; - 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 ? data.salary.toLocaleString("th-TH") : ""; - salaryText.value = data.salaryText; - leaveLast.value = - data.leaveLast != "0001-01-01T00:00:00" - ? date2Thai(data.leaveLast) - : "-"; - restDayCurrentTotal.value = data.restDayCurrentTotal; - }) - .catch((e: any) => { - messageError($q, e); - }); - } + /** + *ตัวแปร profile ที่จะส่งออก + */ + const dateSendLeave = ref() //วันที่ยื่นใบลา + const leaveTypeName = ref("") //Name ประเภทการลา + const dear = ref("") //เรียน + const fullName = ref("") //คำนำหน้า ชื่อ นามสกุล ผู้ยื่นขอ + const positionName = ref("") //ตำแหน่งผู้ยื่นขอ + const positionLevelName = ref("") //ระดับผู้ยื่นขอ + const organizationName = ref("") //สังกัดผู้ยื่นขอ + const leaveLimit = ref(0) //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) + const leaveTotal = ref(0) //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) + const leaveRemain = ref(0) //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) + const restDayTotalOld = ref(0) //จำนวนวันลาพักผ่อนสะสม จากปีที่ผ่านมา + const birthDate = ref() //วันเกิด + const dateAppoint = ref() //วันที่เข้ารับราชการ + const salary = ref(0) //เงินเดือนปัจจุบัน + const salaryText = ref("") //เงินเดือนปัจจุบัน(ภาษาไทย) + const leaveLast = ref() + const restDayCurrentTotal = ref("") - async function fetchProfileOld(data: any) { - await http - .post(config.API.leaveProfile(), { type: typeId.value }) - .then((res: any) => { - const data = res.data.result; - 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 ? data.salary.toLocaleString("th-TH") : ""; - salaryText.value = data.salaryText; - }) - .catch((e: any) => { - messageError($q, e); - }); + //ดึงข้อมูล profile จาก API + async function fetchProfile() { + await http + .post(config.API.leaveProfile(), { type: typeId.value }) + .then((res: any) => { + const data = res.data.result + 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 ? data.salary.toLocaleString("th-TH") : "" + salaryText.value = data.salaryText + leaveLast.value = data.leaveLast != "0001-01-01T00:00:00" ? date2Thai(data.leaveLast) : "-" + restDayCurrentTotal.value = data.restDayCurrentTotal + }) + .catch((e: any) => { + messageError($q, e) + }) + } - dateSendLeave.value = data.dateSendLeave; - typeLeave.value = data.leaveTypeName; - dear.value = data.dear; - fullName.value = data.fullName; - positionName.value = data.positionName; - positionLevelName.value = data.positionLevelName; - organizationName.value = data.organizationName; - leaveLast.value = - data.leaveLast != "0001-01-01T00:00:00" ? date2Thai(data.leaveLast) : "-"; - restDayCurrentTotal.value = data.restDayCurrentTotal; - } + async function fetchProfileOld(data: any) { + await http + .post(config.API.leaveProfile(), { type: typeId.value }) + .then((res: any) => { + const data = res.data.result + 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 ? data.salary.toLocaleString("th-TH") : "" + salaryText.value = data.salaryText + }) + .catch((e: any) => { + messageError($q, e) + }) - function resetForm2() { - dateSendLeave.value = undefined; - leaveTypeName.value = ""; - dear.value = ""; - fullName.value = ""; - positionName.value = ""; - positionLevelName.value = ""; - organizationName.value = ""; - leaveLimit.value = 0; - leaveTotal.value = 0; - leaveRemain.value = 0; - restDayTotalOld.value = 0; - birthDate.value = undefined; - dateAppoint.value = undefined; - salary.value = 0; - salaryText.value = ""; - leaveLast.value = undefined; - restDayCurrentTotal.value = ""; - } + dateSendLeave.value = data.dateSendLeave + typeLeave.value = data.leaveTypeName + dear.value = data.dear + fullName.value = data.fullName + positionName.value = data.positionName + positionLevelName.value = data.positionLevelName + organizationName.value = data.organizationName + leaveLast.value = data.leaveLast != "0001-01-01T00:00:00" ? date2Thai(data.leaveLast) : "-" + restDayCurrentTotal.value = data.restDayCurrentTotal + } - return { - tabValue, - typeOptions, - optionsSpecific, - statusOptions, + function resetForm2() { + dateSendLeave.value = undefined + leaveTypeName.value = "" + dear.value = "" + fullName.value = "" + positionName.value = "" + positionLevelName.value = "" + organizationName.value = "" + leaveLimit.value = 0 + leaveTotal.value = 0 + leaveRemain.value = 0 + restDayTotalOld.value = 0 + birthDate.value = undefined + dateAppoint.value = undefined + salary.value = 0 + salaryText.value = "" + leaveLast.value = undefined + restDayCurrentTotal.value = "" + } - visibleColumns, - columns, - rows, - LeaveType, - LeaveStatus, + return { + tabValue, + typeOptions, + optionsSpecific, + statusOptions, - fiscalYearyear, - options, - optionsOrdination, - typeConvert, - typeLeave, - typeId, + visibleColumns, + columns, + rows, + LeaveType, + LeaveStatus, - fetchListLeave, - fetchLeaveType, - filterOption, - fetchProfile, + fiscalYearyear, + options, + optionsOrdination, + typeConvert, + typeLeave, + typeId, - //ส่งออกตัวแปร profileที่ได้จาก Api - dateSendLeave, - leaveTypeName, - dear, - fullName, - positionName, - positionLevelName, - organizationName, - leaveLimit, //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) - leaveTotal, //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) - leaveRemain, //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) - restDayTotalOld, - birthDate, - dateAppoint, - salary, - salaryText, - leaveLast, - restDayCurrentTotal, - convertStatud, - resetForm2, - fetchProfileOld, - }; -}); + fetchListLeave, + fetchLeaveType, + filterOption, + fetchProfile, + + //ส่งออกตัวแปร profileที่ได้จาก Api + dateSendLeave, + leaveTypeName, + dear, + fullName, + positionName, + positionLevelName, + organizationName, + leaveLimit, //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) + leaveTotal, //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) + leaveRemain, //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น) + restDayTotalOld, + birthDate, + dateAppoint, + salary, + salaryText, + leaveLast, + restDayCurrentTotal, + convertStatud, + resetForm2, + fetchProfileOld, + } +})