การลา >> ช่องประเภทใบลา (user)
This commit is contained in:
parent
58cd5b57de
commit
b9ece25920
1 changed files with 322 additions and 302 deletions
|
|
@ -1,25 +1,31 @@
|
||||||
import { defineStore } from "pinia"
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue"
|
import { ref } from "vue";
|
||||||
import { useQuasar } from "quasar"
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
import type { QTableProps } from "quasar"
|
import type { QTableProps } from "quasar";
|
||||||
import type { OptionData, TypeLeave } from "@/modules/05_leave/interface/index/main"
|
import type {
|
||||||
import type { ListLeave, ListLeaveTable } from "@/modules/05_leave/interface/response/leave"
|
OptionData,
|
||||||
import http from "@/plugins/http"
|
TypeLeave,
|
||||||
import config from "@/app.config"
|
} 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"
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
const mixin = useCounterMixin()
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai, messageError } = mixin
|
const { date2Thai, messageError } = mixin;
|
||||||
const $q = useQuasar()
|
const $q = useQuasar();
|
||||||
|
|
||||||
export const useLeaveStore = defineStore("Leave", () => {
|
export const useLeaveStore = defineStore("Leave", () => {
|
||||||
const tabValue = ref<string>("calendar")
|
const tabValue = ref<string>("calendar");
|
||||||
const typeLeave = ref<string | undefined>("")
|
const typeLeave = ref<string | undefined>("");
|
||||||
const LeaveType = ref<string | null>("0")
|
const LeaveType = ref<string | null>("0");
|
||||||
const LeaveStatus = ref<string | null>("0")
|
const LeaveStatus = ref<string | null>("0");
|
||||||
const fiscalYearyear = ref<Number | null>(new Date().getFullYear())
|
const fiscalYearyear = ref<Number | null>(new Date().getFullYear());
|
||||||
const rows = ref<ListLeaveTable[]>([])
|
const rows = ref<ListLeaveTable[]>([]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function เรียกข้อมูลรายการลา Table
|
* function เรียกข้อมูลรายการลา Table
|
||||||
|
|
@ -35,33 +41,33 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
status: e.status,
|
status: e.status,
|
||||||
statusConvert: convertStatud(e.status),
|
statusConvert: convertStatud(e.status),
|
||||||
isDelete: e.isDelete,
|
isDelete: e.isDelete,
|
||||||
}))
|
}));
|
||||||
rows.value = datalist
|
rows.value = datalist;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ฟังก์ชั่นแปลง Status
|
//ฟังก์ชั่นแปลง Status
|
||||||
function convertStatud(val: string) {
|
function convertStatud(val: string) {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case "NEW":
|
case "NEW":
|
||||||
return "ใหม่"
|
return "ใหม่";
|
||||||
case "PENDING":
|
case "PENDING":
|
||||||
return "กำลังดำเนินการ"
|
return "กำลังดำเนินการ";
|
||||||
case "APPROVE":
|
case "APPROVE":
|
||||||
return "อนุมัติ"
|
return "อนุมัติ";
|
||||||
case "REJECT":
|
case "REJECT":
|
||||||
return "ไม่อนุมัติ"
|
return "ไม่อนุมัติ";
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
return "ยกเลิก"
|
return "ยกเลิก";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ประเภทการลา */
|
/** ประเภทการลา */
|
||||||
const typeOptions = ref<OptionData[]>([])
|
const typeOptions = ref<OptionData[]>([]);
|
||||||
const typeId = ref<string | undefined>("")
|
const typeId = ref<string | undefined>("");
|
||||||
const typeOptionsMain = ref<OptionData[]>([])
|
const typeOptionsMain = ref<OptionData[]>([]);
|
||||||
const typeOptionsAdd = ref<OptionData[]>([])
|
const typeOptionsAdd = ref<OptionData[]>([]);
|
||||||
/** รายการข้อมูลประเภทใบลา */
|
/** รายการข้อมูลประเภทใบลา */
|
||||||
const options = ref<OptionData[]>([])
|
const options = ref<OptionData[]>([]);
|
||||||
/**
|
/**
|
||||||
* function เรียกข้อมูลประเภทการลา
|
* function เรียกข้อมูลประเภทการลา
|
||||||
* @param data ประเภทการลา
|
* @param data ประเภทการลา
|
||||||
|
|
@ -73,19 +79,21 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
name: "ทั้งหมด",
|
name: "ทั้งหมด",
|
||||||
code: "LV-000",
|
code: "LV-000",
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
|
console.log(typeOptionsMain.value);
|
||||||
|
|
||||||
const optionType = data.map((e: TypeLeave) => ({
|
const optionType = data.map((e: TypeLeave) => ({
|
||||||
id: e.id,
|
id: e.id,
|
||||||
name: e.name,
|
name: e.name,
|
||||||
code: e.code,
|
code: e.code,
|
||||||
}))
|
}));
|
||||||
typeOptionsMain.value = []
|
|
||||||
typeOptionsMain.value.push(...optionType)
|
|
||||||
typeOptions.value = typeOptionsMain.value
|
|
||||||
|
|
||||||
typeOptionsAdd.value = []
|
typeOptionsMain.value.push(...optionType);
|
||||||
typeOptionsAdd.value.push(...optionType)
|
typeOptions.value = typeOptionsMain.value;
|
||||||
options.value = typeOptionsAdd.value
|
|
||||||
|
typeOptionsAdd.value = [];
|
||||||
|
typeOptionsAdd.value.push(...optionType);
|
||||||
|
options.value = typeOptionsAdd.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** สถานะของการลา */
|
/** สถานะของการลา */
|
||||||
|
|
@ -96,8 +104,8 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
{ id: "APPROVE", name: "อนุมัติ " },
|
{ id: "APPROVE", name: "อนุมัติ " },
|
||||||
{ id: "REJECT", name: "ไม่อนุมัติ" },
|
{ id: "REJECT", name: "ไม่อนุมัติ" },
|
||||||
{ id: "DELETE", name: "ยกเลิก" },
|
{ id: "DELETE", name: "ยกเลิก" },
|
||||||
])
|
]);
|
||||||
const statusOptions = ref<any[]>(statusOptionsMain.value)
|
const statusOptions = ref<any[]>(statusOptionsMain.value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function ต้นหาข้อมูลของ Option
|
* function ต้นหาข้อมูลของ Option
|
||||||
|
|
@ -109,16 +117,20 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
switch (refData) {
|
switch (refData) {
|
||||||
case "LeaveTypeOption":
|
case "LeaveTypeOption":
|
||||||
update(() => {
|
update(() => {
|
||||||
typeOptions.value = typeOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1)
|
typeOptions.value = typeOptionsMain.value.filter(
|
||||||
})
|
(v: any) => v.name.indexOf(val) > -1
|
||||||
break
|
);
|
||||||
|
});
|
||||||
|
break;
|
||||||
case "LeaveStatusOption":
|
case "LeaveStatusOption":
|
||||||
update(() => {
|
update(() => {
|
||||||
statusOptions.value = statusOptionsMain.value.filter((v: any) => v.name.indexOf(val) > -1)
|
statusOptions.value = statusOptionsMain.value.filter(
|
||||||
})
|
(v: any) => v.name.indexOf(val) > -1
|
||||||
break
|
);
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** รายการประเภทการลาของ ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน*/
|
/** รายการประเภทการลาของ ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน*/
|
||||||
|
|
@ -127,16 +139,21 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
{ id: "s1", name: "ลาฝึกอบรม", code: "s1" },
|
{ id: "s1", name: "ลาฝึกอบรม", code: "s1" },
|
||||||
{ id: "s2", name: "ลาปฎิบัติการวิจัย", code: "s2" },
|
{ id: "s2", name: "ลาปฎิบัติการวิจัย", code: "s2" },
|
||||||
{ id: "s3", name: "ลาดูงาน", code: "s3" },
|
{ id: "s3", name: "ลาดูงาน", code: "s3" },
|
||||||
])
|
]);
|
||||||
|
|
||||||
/** รายการประเภทการลาของ ลาอุปสมบทหรือลาประกอบพิธีฮัจญ์*/
|
/** รายการประเภทการลาของ ลาอุปสมบทหรือลาประกอบพิธีฮัจญ์*/
|
||||||
const optionsOrdination = ref([
|
const optionsOrdination = ref([
|
||||||
{ id: "0", name: "ลาอุปสมบท", code: "0" },
|
{ id: "0", name: "ลาอุปสมบท", code: "0" },
|
||||||
{ id: "1", name: "ลาประกอบพิธีฮัจญ์", code: "1" },
|
{ id: "1", name: "ลาประกอบพิธีฮัจญ์", code: "1" },
|
||||||
])
|
]);
|
||||||
|
|
||||||
/** data table filter & column ของรายการลา */
|
/** data table filter & column ของรายการลา */
|
||||||
const visibleColumns = ref<String[]>(["no", "leaveTypeName", "dateSendLeave", "status"])
|
const visibleColumns = ref<String[]>([
|
||||||
|
"no",
|
||||||
|
"leaveTypeName",
|
||||||
|
"dateSendLeave",
|
||||||
|
"status",
|
||||||
|
]);
|
||||||
const columns = ref<QTableProps["columns"]>([
|
const columns = ref<QTableProps["columns"]>([
|
||||||
{
|
{
|
||||||
name: "no",
|
name: "no",
|
||||||
|
|
@ -174,7 +191,7 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px; width:10%;",
|
style: "font-size: 14px; width:10%;",
|
||||||
},
|
},
|
||||||
])
|
]);
|
||||||
/**
|
/**
|
||||||
*ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา
|
*ฟังก์ชั่นแปลงประเภทแบบฟอร์มลา
|
||||||
* @param item ประเภทแบบฟอร์ม
|
* @param item ประเภทแบบฟอร์ม
|
||||||
|
|
@ -183,13 +200,13 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
function typeConvert(item: string, subitem: any) {
|
function typeConvert(item: string, subitem: any) {
|
||||||
// console.log('first',item)
|
// console.log('first',item)
|
||||||
if (item !== "LV-006" && item !== "LV-008") {
|
if (item !== "LV-006" && item !== "LV-008") {
|
||||||
typeLeave.value = convertSubtitle(item)
|
typeLeave.value = convertSubtitle(item);
|
||||||
} else if (item === "LV-006") {
|
} else if (item === "LV-006") {
|
||||||
typeLeave.value = convertSubtitleInfo(subitem)
|
typeLeave.value = convertSubtitleInfo(subitem);
|
||||||
} else if (item === "LV-008") {
|
} else if (item === "LV-008") {
|
||||||
typeLeave.value = convertSubtitleInfo2(subitem)
|
typeLeave.value = convertSubtitleInfo2(subitem);
|
||||||
}
|
}
|
||||||
typeId.value = convertId(item)
|
typeId.value = convertId(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -198,7 +215,7 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
* @returns ส่งค่าที่แปลงแล้ว
|
* @returns ส่งค่าที่แปลงแล้ว
|
||||||
*/
|
*/
|
||||||
function convertSubtitle(val: string) {
|
function convertSubtitle(val: string) {
|
||||||
return options.value.find(x => x.code == val)?.name
|
return options.value.find((x) => x.code == val)?.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -207,7 +224,7 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
* @returns ส่งค่าที่แปลงแล้ว
|
* @returns ส่งค่าที่แปลงแล้ว
|
||||||
*/
|
*/
|
||||||
function convertSubtitleInfo(val: string) {
|
function convertSubtitleInfo(val: string) {
|
||||||
return optionsOrdination.value.find(x => x.id == val)?.name
|
return optionsOrdination.value.find((x) => x.id == val)?.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -216,7 +233,7 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
* @returns ส่งค่าที่แปลงแล้ว
|
* @returns ส่งค่าที่แปลงแล้ว
|
||||||
*/
|
*/
|
||||||
function convertSubtitleInfo2(val: string) {
|
function convertSubtitleInfo2(val: string) {
|
||||||
return optionsSpecific.value.find(x => x.id == val)?.name
|
return optionsSpecific.value.find((x) => x.id == val)?.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -225,56 +242,59 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
* @returns ส่งค่าที่แปลงแล้ว
|
* @returns ส่งค่าที่แปลงแล้ว
|
||||||
*/
|
*/
|
||||||
function convertId(val: string) {
|
function convertId(val: string) {
|
||||||
return options.value.find(x => x.code == val)?.id
|
return options.value.find((x) => x.code == val)?.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*ตัวแปร profile ที่จะส่งออก
|
*ตัวแปร profile ที่จะส่งออก
|
||||||
*/
|
*/
|
||||||
const dateSendLeave = ref<Date>() //วันที่ยื่นใบลา
|
const dateSendLeave = ref<Date>(); //วันที่ยื่นใบลา
|
||||||
const leaveTypeName = ref<string>("") //Name ประเภทการลา
|
const leaveTypeName = ref<string>(""); //Name ประเภทการลา
|
||||||
const dear = ref<string>("") //เรียน
|
const dear = ref<string>(""); //เรียน
|
||||||
const fullName = ref<string>("") //คำนำหน้า ชื่อ นามสกุล ผู้ยื่นขอ
|
const fullName = ref<string>(""); //คำนำหน้า ชื่อ นามสกุล ผู้ยื่นขอ
|
||||||
const positionName = ref<string>("") //ตำแหน่งผู้ยื่นขอ
|
const positionName = ref<string>(""); //ตำแหน่งผู้ยื่นขอ
|
||||||
const positionLevelName = ref<string>("") //ระดับผู้ยื่นขอ
|
const positionLevelName = ref<string>(""); //ระดับผู้ยื่นขอ
|
||||||
const organizationName = ref<string>("") //สังกัดผู้ยื่นขอ
|
const organizationName = ref<string>(""); //สังกัดผู้ยื่นขอ
|
||||||
const leaveLimit = ref<number>(0) //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
|
const leaveLimit = ref<number>(0); //โควต้าลา(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
|
||||||
const leaveTotal = ref<number>(0) //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
|
const leaveTotal = ref<number>(0); //ลาไปแล้ว(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
|
||||||
const leaveRemain = ref<number>(0) //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
|
const leaveRemain = ref<number>(0); //คงเหลือโควต้า(แต่ละประเภท)หน่วยเป็นวัน(ภายในปีนั้น)
|
||||||
const restDayTotalOld = ref<number>(0) //จำนวนวันลาพักผ่อนสะสม จากปีที่ผ่านมา
|
const restDayTotalOld = ref<number>(0); //จำนวนวันลาพักผ่อนสะสม จากปีที่ผ่านมา
|
||||||
const birthDate = ref<Date>() //วันเกิด
|
const birthDate = ref<Date>(); //วันเกิด
|
||||||
const dateAppoint = ref<Date>() //วันที่เข้ารับราชการ
|
const dateAppoint = ref<Date>(); //วันที่เข้ารับราชการ
|
||||||
const salary = ref<number>(0) //เงินเดือนปัจจุบัน
|
const salary = ref<number>(0); //เงินเดือนปัจจุบัน
|
||||||
const salaryText = ref<string>("") //เงินเดือนปัจจุบัน(ภาษาไทย)
|
const salaryText = ref<string>(""); //เงินเดือนปัจจุบัน(ภาษาไทย)
|
||||||
const leaveLast = ref<any>()
|
const leaveLast = ref<any>();
|
||||||
const restDayCurrentTotal = ref<string>("")
|
const restDayCurrentTotal = ref<string>("");
|
||||||
//ดึงข้อมูล profile จาก API
|
//ดึงข้อมูล profile จาก API
|
||||||
async function fetchProfile() {
|
async function fetchProfile() {
|
||||||
await http
|
await http
|
||||||
.post(config.API.leaveProfile(), { type: typeId.value })
|
.post(config.API.leaveProfile(), { type: typeId.value })
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
const data = res.data.result
|
const data = res.data.result;
|
||||||
dateSendLeave.value = data.dateSendLeave
|
dateSendLeave.value = data.dateSendLeave;
|
||||||
leaveTypeName.value = data.leaveTypeName
|
leaveTypeName.value = data.leaveTypeName;
|
||||||
dear.value = data.dear
|
dear.value = data.dear;
|
||||||
fullName.value = data.fullName
|
fullName.value = data.fullName;
|
||||||
positionName.value = data.positionName
|
positionName.value = data.positionName;
|
||||||
positionLevelName.value = data.positionLevelName
|
positionLevelName.value = data.positionLevelName;
|
||||||
organizationName.value = data.organizationName
|
organizationName.value = data.organizationName;
|
||||||
leaveLimit.value = data.leaveLimit
|
leaveLimit.value = data.leaveLimit;
|
||||||
leaveTotal.value = data.leaveTotal
|
leaveTotal.value = data.leaveTotal;
|
||||||
leaveRemain.value = data.leaveRemain
|
leaveRemain.value = data.leaveRemain;
|
||||||
restDayTotalOld.value = data.restDayTotalOld
|
restDayTotalOld.value = data.restDayTotalOld;
|
||||||
birthDate.value = data.birthDate
|
birthDate.value = data.birthDate;
|
||||||
dateAppoint.value = data.dateAppoint
|
dateAppoint.value = data.dateAppoint;
|
||||||
salary.value = data.salary
|
salary.value = data.salary;
|
||||||
salaryText.value = data.salaryText
|
salaryText.value = data.salaryText;
|
||||||
leaveLast.value = date2Thai(data.leaveLast) !== "0001-01-01T00:00:00" ? date2Thai(data.leaveLast) : "-"
|
leaveLast.value =
|
||||||
restDayCurrentTotal.value = data.restDayCurrentTotal
|
date2Thai(data.leaveLast) !== "0001-01-01T00:00:00"
|
||||||
|
? date2Thai(data.leaveLast)
|
||||||
|
: "-";
|
||||||
|
restDayCurrentTotal.value = data.restDayCurrentTotal;
|
||||||
})
|
})
|
||||||
.catch((e: any) => {
|
.catch((e: any) => {
|
||||||
messageError($q, e)
|
messageError($q, e);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -320,5 +340,5 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
leaveLast,
|
leaveLast,
|
||||||
restDayCurrentTotal,
|
restDayCurrentTotal,
|
||||||
convertStatud,
|
convertStatud,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue