การลา API

This commit is contained in:
setthawutttty 2024-03-25 14:08:04 +07:00
parent 9f6f1afdd2
commit 4f93c38fc0
5 changed files with 252 additions and 171 deletions

View file

@ -109,4 +109,17 @@ profileNewDutyByDutyId: (dutyId: string) =>
`${registryNew}duty/${dutyId}`,
profileNewDutyHisByDutyId: (dutyId: string) =>
`${registryNew}duty/history/${dutyId}`,
//ข้อมูลราชการ
profileNewGovernment:()=>`${registryNew}government`,
profileNewGovernmentById:(id:string)=>`${registryNew}government/${id}`,
profileNewGovernmentHistory:(id:string)=>`${registryNew}government/history/${id}`,
//การลา
profileNewLeave:()=>`${registryNew}leave`,
profileNewLeaveById:(id:string)=>`${registryNew}leave/${id}`,
profileNewLeaveHistory:(id:string)=>`${registryNew}leave/history/${id}`,
profileCheckDate:()=>`${env.API_URI}/leave/user/check`,
profileNewLeaveType:()=>`${env.API_URI}/leave/type`,
};

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { ref, reactive, watch,onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import type {
MyObjectRef,
@ -27,6 +27,7 @@ const {
hideLoader,
} = mixin;
const profileId = ref<string>(route.params.id.toString())
/** ตัวแปรข้อมูลหลัก */
const formMain = reactive<FormMain>({
ocId: "สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร/กองบริหารทั่วไป/กลุ่มงานช่วยนักบริหาร", //
@ -68,6 +69,18 @@ const objectRef: MyObjectRef = {
reasonSameDate: reasonSameDateRef,
};
const fieldLabels = {
ocId: "สังกัด",
positionId: "ตำแหน่ง",
numberId: "เลขที่ตำแหน่ง",
positionExecutive: "ตำแหน่งทางการบริหาร",
positionExecutiveSide: "ด้านทางการบริหาร",
positionLine: "สายงาน",
positionLevel: "ระดับ",
positionType: "ประเภท",
positionPathSide: "ด้าน/สาขา",
};
const visibleColumnsHistory = ref<String[]>([
"oc",
"position",
@ -297,6 +310,7 @@ function openDialogEdit() {
function openDialogHistory() {
modalHistory.value = true;
getDataHistory()
}
/** ปิด dialog */
function closeDialog() {
@ -325,59 +339,98 @@ function validateForm() {
function onSubmit() {
dialogConfirm($q, () => {
// showLoader()
// http
// .put(config.API.???)
// .then((res)=>{
// closeDialog()
// getData()
// }).catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
// hideLoader()
// })
showLoader()
http
.patch(config.API.profileNewGovernmentById(profileId.value),{
dateAppoint:containDate.value,
dateStart:workDate.value,
reasonSameDate:reasonSameDate.value
})
.then((res)=>{
closeDialog()
getData()
}).catch((e)=>{
messageError($q,e)
}).finally(()=>{
hideLoader()
})
closeDialog();
});
}
/** ดึงข้อมูลราชการ */
function getData(){
showLoader()
http
.get(config.API.profileNewGovernmentById(profileId.value))
.then((res)=>{
console.log(res.data.result)
const data = res.data.result
formMain.ocId = data.oc //
formMain.positionId = data.position //
formMain.positionLine = data.positionLine //
formMain.positionLevel = data.positionLevel //
formMain.numberId = data.posNo //
formMain.positionType = data.positionType //
formMain.positionExecutive = data.positionExecutive //
formMain.positionPathSide = data.positionPathSide //
formMain.positionExecutiveSide = data.positionExecutiveSide //
formMain.containDate = data.dateAppoint
formMain.workDate = data.dateStart
formMain.reasonSameDate = data.reasonSameDate
formMain.retireDate = data.retireDate
formMain.ageAll = data.govAge
formMain.absent = data.govAgeAbsent
formMain.age = data.govAgePlus
}).catch((e)=>{
messageError($q,e)
}).finally(()=>{
hideLoader()
})
}
/** ดึงข้อมูลประวัติ */
function getDataHistory() {
// showLoader();
// http
// .get(config.API.profileGovHisId(route.params.id.toString()))
// .then((res) => {
// let data = res.data.result;
// rowsHistory.value = [];
// data.map((e: RequestItemsHistoryObject) => {
// rowsHistory.value.push({
// oc: e.oc,
// position: e.position,
// positionPathSide: e.positionPathSide,
// posNo: e.posNo,
// positionLine: e.positionLine,
// positionType: e.positionType,
// positionLevel: e.positionLevel,
// positionExecutive: e.positionExecutive,
// positionExecutiveSide: e.positionExecutiveSide,
// dateAppoint: new Date(e.dateAppoint),
// dateStart: new Date(e.dateStart),
// retireDate: e.retireDate,
// govAge: e.govAge,
// govAgeAbsent: e.govAgeAbsent,
// govAgePlus: e.govAgePlus,
// reasonSameDate: e.reasonSameDate,
// createdFullName: e.createdFullName,
// createdAt: new Date(e.createdAt),
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
showLoader();
http
.get(config.API.profileNewGovernmentHistory(profileId.value))
.then((res) => {
let data = res.data.result;
rowsHistory.value = [];
data.map((e: RequestItemsHistoryObject) => {
rowsHistory.value.push({
oc: e.oc,
position: e.position,
positionPathSide: e.positionPathSide,
posNo: e.posNo,
positionLine: e.positionLine,
positionType: e.positionType,
positionLevel: e.positionLevel,
positionExecutive: e.positionExecutive,
positionExecutiveSide: e.positionExecutiveSide,
dateAppoint: new Date(e.dateAppoint),
dateStart: new Date(e.dateStart),
retireDate: e.retireDate,
govAge: e.govAge,
govAgeAbsent: e.govAgeAbsent,
govAgePlus: e.govAgePlus,
reasonSameDate: e.reasonSameDate,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
watch(
@ -390,17 +443,9 @@ watch(
}
);
const fieldLabels = {
ocId: "สังกัด",
positionId: "ตำแหน่ง",
numberId: "เลขที่ตำแหน่ง",
positionExecutive: "ตำแหน่งทางการบริหาร",
positionExecutiveSide: "ด้านตำแหน่งทางการบริหาร",
positionLine: "สายงาน",
positionLevel: "ระดับ",
positionType: "ประเภท",
positionPathSide: "ด้าน/สาขา",
};
onMounted(()=>{
getData()
})
</script>
<template>
<div class="row">
@ -439,7 +484,7 @@ const fieldLabels = {
}}</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{ formMain[field] !== "" ? formMain[field] : "-" }}</span>
<span>{{ formMain[field] ? formMain[field] : "-" }}</span>
</div>
</div>
</div>
@ -455,7 +500,7 @@ const fieldLabels = {
}}</span>
</div>
<div class="col-12 col-sm-12 col-md-8">
<span>{{ formMain[field] !== "" ? formMain[field] : "-" }}</span>
<span>{{ formMain[field] ? formMain[field] : "-" }}</span>
</div>
</div>
</div>
@ -772,7 +817,8 @@ const fieldLabels = {
v-if="
col.name == 'dateStart' ||
col.name == 'dateAppoint' ||
col.name == 'createdAt'
col.name == 'createdAt' ||
col.name == 'retireDate'
"
class="table_ellipsis"
>

View file

@ -55,18 +55,6 @@ const formFilter = reactive<FormFilter>({
isProbation: false,
});
const formData = reactive<DetailData>({
id: "",
typeLeave: "",
dateStartLeave: null,
dateEndLeave: null,
numLeave: 0,
sumLeave: 0,
totalLeave: 0,
status: "",
reason: "",
typeLeaveId: "",
});
const modal = ref<boolean>(false);
const edit = ref<boolean>(false);
@ -76,7 +64,7 @@ const reason = ref<string>(""); //เหตุผล
const numLeave = ref<number>(0);
const dateRange = ref<[Date, Date]>([new Date(), new Date()]);
const numUsedLeave = ref<number>(0);
const typeLeave = ref<string>("");
const typeLeave = ref<any>();
const typeLeaveOption = ref<DataOptionLeave[]>([]);
const typeLeaveOptionFilter = ref<DataOptionLeave[]>([]);
@ -235,23 +223,20 @@ const columns = ref<QTableProps["columns"]>([
function openDialogAdd() {
modal.value = true;
edit.value = false;
showLoader();
http
.get(config.API.profileLeaveTotalId(profileId.value))
.get(config.API.profileNewLeaveType())
.then((res) => {
let data = res.data.result;
typeLeaveOption.value = data;
typeLeaveOptionFilter.value = data;
data.map((e: ResponseTotalObject) => {
rowsTotal.value.push({
typeLeaveId: e.typeLeaveId,
totalLeave: e.totalLeave,
limitLeave: e.limitLeave,
remainLeave: e.remainLeave,
typeLeave: e.typeLeave,
});
});
console.log(res.data.result);
const dataOp = res.data.result.map((item: any) => ({
id: item.id,
name: item.name,
code: item.code,
}));
typeLeaveOption.value = dataOp;
typeLeaveOptionFilter.value = dataOp;
})
.catch((e) => {
messageError($q, e);
@ -269,20 +254,15 @@ function clickTotal() {
rowsTotal.value = [];
showLoader();
http
.get(config.API.profileLeaveTotalId(profileId.value))
.get(config.API.profileNewLeaveType())
.then((res) => {
let data = res.data.result;
typeLeaveOption.value = data;
typeLeaveOptionFilter.value = data;
data.map((e: ResponseTotalObject) => {
rowsTotal.value.push({
typeLeaveId: e.typeLeaveId,
totalLeave: e.totalLeave,
limitLeave: e.limitLeave,
remainLeave: e.remainLeave,
typeLeave: e.typeLeave,
});
});
const dataOp = res.data.result.map((item: DataOption) => ({
id: item.id,
name: item.name,
}));
typeLeaveOption.value = dataOp;
typeLeaveOptionFilter.value = dataOp;
})
.catch((e) => {
messageError($q, e);
@ -293,10 +273,10 @@ function clickTotal() {
}
function openDialogEdit(props: DetailData) {
edit.value = true;
modal.value = true;
formData.id = props.id;
id.value = props.id;
typeLeave.value = props.typeLeave;
typeLeave.value = {id:props.typeLeaveId,name:props.typeLeave,code:props.code};
statLeave.value = props.status;
reason.value = props.reason;
dateRange.value = [
@ -392,7 +372,7 @@ function validateForm() {
}
}
if (hasError.every((result) => result === true)) {
if ((edit.value = false)) {
if (edit.value == false) {
saveData();
} else {
editData();
@ -404,76 +384,113 @@ function validateForm() {
* นทกเพมขอม
*/
function saveData() {
// showLoader();
// await http
// .post(config.API.profileLeaveId(profileId.value), {
// dateStartLeave: dateToISO(dateRange.value[0]),
// dateEndLeave: dateToISO(dateRange.value[1]),
// numLeave: numLeave.value,
// sumLeave: numUsedLeave.value,
// totalLeave: sum,
// status: statLeave.value,
// reason: reason.value,
// typeLeaveId: typeLeave.value,
// })
// .then((res) => {
// success($q, "");
// modalAdd.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
showLoader();
http
.post(config.API.profileNewLeave(), {
profileId: profileId.value,
leaveTypeId: typeLeave.value.id,
dateLeave: dateRange.value[0],
// dateStartLeave: dateToISO(dateRange.value[0]),
// dateEndLeave: dateToISO(dateRange.value[1]),
leaveDays: numLeave.value,
leaveCount: 0,
totalLeave: 0,
status: statLeave.value,
reason: reason.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
getData();
});
}
/**
* นทกแกไขขอม
*/
const editData = async () => {
// showLoader();
// await http
// .put(config.API.profileLeaveId(id.value), {
// dateStartLeave: dateToISO(dateRange.value[0]),
// dateEndLeave: dateToISO(dateRange.value[1]),
// numLeave: numLeave.value,
// sumLeave: numUsedLeave.value,
// totalLeave: sum,
// status: statLeave.value,
// reason: reason.value,
// typeLeaveId: typeLeave.value,
// })
// .then((res) => {
// success($q, "");
// modalAdd.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
showLoader();
http
.patch(config.API.profileNewLeaveById(id.value), {
leaveTypeId: typeLeave.value.id,
dateLeave: dateRange.value[0],
// dateStartLeave: dateToISO(dateRange.value[0]),
// dateEndLeave: dateToISO(dateRange.value[1]),
leaveDays: numLeave.value,
leaveCount: 0,
totalLeave: 0,
status: statLeave.value,
reason: reason.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
getData();
});
};
function getData() {
showLoader();
http
.get(config.API.profileNewLeaveById(profileId.value))
.then((res) => {
console.log(res.data.result);
const data = res.data.result;
rows.value = data.map((item: any) => ({
id: item.id,
typeLeave: item.leaveType.name,
code: item.leaveType.refCommandDate,
dateStartLeave: item.dateStartLeave,
dateEndLeave: item.dateEndLeave,
numLeave: item.leaveDays,
sumLeave: item.leaveCount,
totalLeave: item.totalLeave,
status: item.status,
reason: item.reason,
typeLeaveId: item.leaveTypeId,
}));
})
.catch((e) => {
// messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function dateCheck() {
http
.post(config.API.profileCheckDate(), {
type: typeLeave.value.id,
StartLeaveDate: dateRange.value[0],
EndLeaveDate: dateRange.value[1],
})
.then((res) => {
const day = res.data.result;
if (
typeLeave.value.code !== "LV-001" &&
typeLeave.value.code !== "LV-002" &&
typeLeave.value.code !== "LV-004" &&
typeLeave.value.code !== "LV-005"
) {
numLeave.value = day.totalDate;
} else {
numLeave.value = day.totalDate - day.sumDateHoliday;
}
});
}
onMounted(() => {
const data = [
{
id: "test",
typeLeave: "ลาเข้ารับการตรวจเลือกหรือเข้ารับการเตรียมพล",
typeLeaveId: "08db52ec-d1c1-4ecc-868c-ff2a3bcdb32a",
dateStartLeave: new Date("2024-02-20T12:59:47.193103"),
dateEndLeave: new Date("2024-02-25T12:59:47.193103"),
numLeave: 0,
sumLeave: 0,
totalLeave: 0,
status: "reject",
reason: "test",
},
];
rows.value = data;
getData();
});
</script>
<template>
@ -748,7 +765,6 @@ onMounted(() => {
hide-bottom-space
:label="`${'ประเภทการลา'}`"
@update:modelValue="clickEditRowType"
emit-value
map-options
option-label="name"
:options="typeLeaveOption"
@ -762,6 +778,7 @@ onMounted(() => {
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
:readonly="!typeLeave"
menu-class-name="modalfix"
v-model="dateRange"
:locale="'th'"
@ -769,6 +786,7 @@ onMounted(() => {
:enableTimePicker="false"
week-start="0"
range
@update:modelValue="dateCheck"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
@ -776,6 +794,7 @@ onMounted(() => {
}}</template>
<template #trigger>
<q-input
:readonly="!typeLeave"
class="full-width inputgreen cursor-pointer"
outlined
dense
@ -803,6 +822,7 @@ onMounted(() => {
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<q-input
readonly
ref="numLeaveRef"
class="full-width inputgreen cursor-pointer"
outlined

View file

@ -138,15 +138,16 @@ const columns = ref<QTableProps["columns"]>([
]);
function getHistory() {
showLoader();
http
.get(config.API.profileLeaveHisId(id.value))
http
.get(config.API.profileNewLeaveHistory(id.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: DetailData) => {
data.map((e: any) => {
rows.value.push({
id: e.id,
typeLeave: e.typeLeave,
typeLeave: e.leaveType.name,
code: e.leaveType.refCommandDate,
dateStartLeave: new Date(e.dateStartLeave as Date),
dateEndLeave: new Date(e.dateEndLeave as Date),
numLeave: e.numLeave,
@ -162,7 +163,7 @@ http
});
})
.catch((e) => {
// messageError($q, e);
// messageError($q, e);
})
.finally(() => {
hideLoader();

View file

@ -9,6 +9,7 @@ interface DetailData {
status: string;
reason: string;
typeLeaveId: string;
code: string;
}
interface FormFilter {