รายการลาออก

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-05-23 16:34:22 +07:00
parent 4c01e5aa0d
commit 3b90a9d69c
3 changed files with 415 additions and 388 deletions

View file

@ -9,6 +9,8 @@ import { useRetirementDataStore } from "@/modules/06_retirement/store";
import CurrencyInput from "@/components/CurruncyInput.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import axios from "axios";
import keycloak from "@/plugins/keycloak";
import type {
TypeFile,
@ -23,7 +25,6 @@ import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
/** importComponents*/
import CardProfile from "@/components/CardProfile.vue";
const avatar = ref<string>("");
const modalPersonal = ref<boolean>(false);
const personId = ref<string>("");
/** Use */
@ -38,7 +39,7 @@ const {
showLoader,
hideLoader,
success,
dialogMessage,
dialogConfirm,
dialogRemove,
} = mixin;
@ -133,16 +134,21 @@ const checkboxGroup = ref<CheckBoxType[]>([]);
const checkboxOp = ref<CheckBoxType[]>([
{ label: "ไม่เป็นหนี้สหกรณ์", value: "debt" },
]);
/** Hook */
onMounted(async () => {
fetchData(id.value);
fetchFile();
if (keycloak.tokenParsed !== undefined) {
const commander = await keycloak.tokenParsed.role.includes("commander");
const oligarch = await keycloak.tokenParsed.role.includes("oligarch");
const officer = await keycloak.tokenParsed.role.includes("officer");
if (commander) {
roleUser.value = "commander";
} else if (oligarch) {
roleUser.value = "oligarch";
} else if (officer) {
roleUser.value = "officer";
} else {
roleUser.value = "admin";
}
@ -154,7 +160,6 @@ const diffDate = () => {
const time = dateLeave.value.getTime() - date.value.getTime();
// -
const day = time / (1000 * 3600 * 24);
if (day < 30) {
return true;
}
@ -163,9 +168,7 @@ const diffDate = () => {
return false;
};
/**
* นำขอมลมาจาก API
*/
/** นำข้อมูลมาจาก API*/
const fetchData = async (id: string) => {
showLoader();
await http
@ -196,7 +199,6 @@ const fetchData = async (id: string) => {
location.value = data.location ?? "";
status.value = data.status ?? "";
remarkHorizontal.value = data.remarkHorizontal ?? "-";
// getAvatar(data.profileId);
})
.catch((e) => {
messageError($q, e);
@ -206,30 +208,6 @@ const fetchData = async (id: string) => {
});
};
// function getAvatar(id: string) {
// if (id) {
// http
// .get(config.API.profileAvaId(id))
// .then((res) => {
// console.log(res);
// const dataList = res.data.result;
// avatar.value = dataList.avatar;
// })
// .catch((e) => {})
// .finally(() => {});
// }
// }
// const downloadFile = (response: any, filename: string) => {
// const link = document.createElement("a");
// var fileName = filename;
// link.href = window.URL.createObjectURL(new Blob([response.data]));
// link.setAttribute("download", fileName);
// document.body.appendChild(link);
// link.click();
// document.body.removeChild(link);
// };
/**Pop up */
const popUp = (action: "pass" | "passNot") => {
reasonReign.value = "";
@ -237,6 +215,7 @@ const popUp = (action: "pass" | "passNot") => {
actionPass.value = action === "pass";
openModal();
};
//pop up
const conditionPopup = () => {
if (myFormConfirm.value !== null) {
@ -311,6 +290,7 @@ const rejectpopUp = async () => {
const clickCancel = async () => {
await fetchData(id.value);
edit.value = false;
myForm.value?.resetValidation();
};
/**
* กดยกเล
@ -320,86 +300,60 @@ const clickCancelConditions = async () => {
conditions.value = false;
};
const saveConditions = () => {
if (myForm.value !== null) {
myForm.value.validate().then((success) => {
if (success) {
dialogConfirm($q, () => {
dataSave();
});
// dialogMessage(
// $q,
// "?",
// "",
// "mdi-help-circle-outline",
// "",
// "public",
// async () => await dataSave(),
// undefined
// );
}
});
}
/** Function บันทึก รายการตรวจสอบเงื่อนไขต่าง ๆ*/
const onSubmitConditions = () => {
dialogConfirm($q, () => {
showLoader();
http
.put(config.API.resignConditions(id.value), {
IsNoDebt: checkboxGroup.value[0] ? true : false,
})
.then(() => {
fetchData(id.value);
success($q, "บันทึกเงื่อนไขต่าง ๆ สำเร็จ");
conditions.value = false;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
};
//Save Api
const dataSave = async () => {};
/**
* Functionบนท
*/
const conditionSave = () => {
if (myForm.value !== null) {
myForm.value.validate().then((success) => {
if (success) {
dialogConfirm($q, () => {
saveData();
});
// dialogMessage(
// $q,
// "?",
// "",
// "mdi-help-circle-outline",
// "",
// "public",
// async () => ,
// undefined
// );
}
});
}
};
//Save Api
const saveData = async () => {
const formData = new FormData();
const send = date.value !== null ? new Date(date.value).toUTCString() : "";
const activeDate =
dateLeave.value !== null ? new Date(dateLeave.value).toUTCString() : "";
formData.append("Location", location.value);
formData.append("SendDate", send);
formData.append("ActiveDate", activeDate);
formData.append("Reason", reason.value);
formData.append("OrganizationPositionOld", organizationPositionOld.value);
formData.append("PositionTypeOld", positionTypeOld.value);
formData.append("PositionLevelOld", positionLevelOld.value);
formData.append("PositionNumberOld", posNo.value);
formData.append("AmountOld", salary.value.toString());
formData.append("remarkHorizontal", remarkHorizontal.value);
showLoader();
await http
.put(config.API.resingByid(id.value), formData)
.then(() => {
success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ");
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(id.value);
hideLoader();
});
/** Function บันทึก ,แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/
const onSubmitAttached = () => {
dialogConfirm($q, () => {
const formData = new FormData();
const send = date.value !== null ? new Date(date.value).toUTCString() : "";
const activeDate =
dateLeave.value !== null ? new Date(dateLeave.value).toUTCString() : "";
formData.append("Location", location.value);
formData.append("SendDate", send);
formData.append("ActiveDate", activeDate);
formData.append("Reason", reason.value);
formData.append("OrganizationPositionOld", organizationPositionOld.value);
formData.append("PositionTypeOld", positionTypeOld.value);
formData.append("PositionLevelOld", positionLevelOld.value);
formData.append("PositionNumberOld", posNo.value);
formData.append("AmountOld", salary.value.toString());
formData.append("remarkHorizontal", remarkHorizontal.value);
showLoader();
http
.put(config.API.resingByid(id.value), formData)
.then(() => {
edit.value = false;
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(id.value);
await hideLoader();
});
});
};
/**
@ -464,52 +418,117 @@ function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal;
}
async function fetchFile() {
showLoader();
await http
.get(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value))
.then((res) => {
fileList.value = res.data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function uploadFiles() {
showLoader();
http
.post(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value), {
replace: true,
fileList: [
{
fileName: file.value.name,
},
],
})
.then(async (res) => {
const foundKey: string | undefined = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
foundKey && uploadFileURL(res.data[foundKey]?.uploadUrl);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function uploadFileURL(uploadUrl: string) {
const Data = new FormData();
Data.append("file", file.value);
showLoader();
http
.put(config.API.investigateRelevantUploadFile(id.value), Data)
await axios
.put(uploadUrl, file.value, {
headers: {
"Content-Type": file.value.type,
},
})
.then(() => {
success($q, "อัปโหลดไฟล์สำเร็จ");
fetchFile();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
file.value = null;
});
}
function downloadFiles(fileName: string) {
showLoader();
http
.get(
config.API.fileByFile("พ้นจากราชการ", "หลักฐานลาออก", id.value, fileName)
)
.then((res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
file.value = null;
});
}
function downloadFiles(link: string) {
window.open(link, "_blank");
}
/**
* ลบไฟล
* @param id id file
*/
function removeFile(id: string) {
dialogRemove($q, () => confirmRemove(id));
}
/**
* นย ลบ ไฟล
* @param id id file
*/
function confirmRemove(fileId: string) {
showLoader();
http
.delete(config.API.investigateRelevantFileDelete(id.value, fileId))
.then((res) => {
success($q, `ลบไฟล์สำเร็จ`);
fetchData(id.value);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
function removeFile(fileName: string) {
dialogRemove($q, () => {
showLoader();
http
.delete(
config.API.fileByFile(
"พ้นจากราชการ",
"หลักฐานลาออก",
id.value,
fileName
)
)
.then(() => {
success($q, `ลบไฟล์สำเร็จ`);
setTimeout(() => {
fetchFile();
hideLoader();
}, 1000);
})
.catch((e) => {
messageError($q, e);
hideLoader();
});
});
}
</script>
<template>
@ -596,10 +615,14 @@ function confirmRemove(fileId: string) {
<div
class="q-gutter-x-sm"
v-if="
(roleUser === 'commander' && dataDetail.commanderReject === null) ||
(roleUser === 'commander' &&
dataDetail.commanderReject === null &&
dataDetail.officerReject === null) ||
(roleUser === 'oligarch' &&
dataDetail.oligarchReject === null &&
dataDetail.commanderReject !== null)
dataDetail.commanderReject !== null &&
dataDetail.officerReject === null) ||
(roleUser === 'officer' && dataDetail.officerReject === null)
"
>
<q-btn
@ -768,121 +791,186 @@ function confirmRemove(fileId: string) {
<div class="q-pl-sm text-weight-bold text-dark">
รายการตรวจสอบเงอนไขตาง
</div>
<q-space />
<div v-if="!conditions">
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="conditions = !conditions"
/>
</div>
<div v-else class="q-gutter-x-sm">
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
@click="saveConditions"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="clickCancelConditions"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-7">
<q-option-group
:options="checkboxOp"
type="checkbox"
v-model="checkboxGroup"
:disable="!conditions"
/>
</div>
<div class="col-5">
<div class="row col-12 q-col-gutter-y-sm q-pa-sm">
<div class="col-12 row">
<q-file
class="col-12"
for="#evidenceFiles"
outlined
dense
v-model="file"
label="อัปโหลดเอกสารหลักฐานต่าง ๆ"
hide-bottom-space
:disable="!conditions"
>
<template v-slot:prepend>
<q-icon name="attach_file" color="primary" />
</template>
<template v-slot:after>
<div class="row col-12 q-pa-sm q-col-gutter-sm">
<div class="col-6">
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">เงอนไขตาง </div>
<q-space />
<div v-if="!conditions">
<q-btn
v-if="file"
size="14px"
flat
round
outline
color="primary"
dense
color="add"
icon="mdi-upload"
@click="uploadFiles"
><q-tooltip>ปโหลดเอกสาร</q-tooltip></q-btn
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="conditions = !conditions"
/>
</div>
<div v-else class="q-gutter-x-sm">
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
@click="onSubmitConditions"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="clickCancelConditions"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<!-- <q-checkbox v-model="teal" label="Teal" color="teal" :disable="!conditions" /> -->
<q-option-group
:options="checkboxOp"
type="checkbox"
v-model="checkboxGroup"
:disable="!conditions"
/>
</q-card>
</div>
<div class="col-6">
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
เอกสารหลกฐานตาง
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-col-gutter-y-sm q-pa-sm">
<div class="col-12 row">
<q-file
class="col-12"
for="#evidenceFiles"
outlined
dense
v-model="file"
label="อัปโหลดเอกสารหลักฐานต่าง ๆ"
hide-bottom-space
>
</template>
</q-file>
</div>
<template v-slot:prepend>
<q-icon name="attach_file" color="primary" />
</template>
<template v-slot:after>
<q-btn
v-if="file"
size="14px"
flat
round
dense
color="add"
icon="mdi-upload"
@click="uploadFiles"
><q-tooltip>ปโหลดเอกสาร</q-tooltip></q-btn
>
</template>
</q-file>
</div>
<div v-if="fileList.length > 0" class="col-xs-12 row">
<q-list class="full-width rounded-borders" bordered separator>
<q-item v-for="File in fileList" :key="File.id" clickable v-ripple>
<q-item-section>{{ File.fileName }}</q-item-section>
<q-item-section avatar>
<div class="row">
<div>
<q-btn
dense
flat
round
size="12px"
color="blue"
icon="mdi-download-outline"
@click="downloadFiles(File.pathName)"
>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip>
</q-btn>
</div>
<div>
<q-btn
dense
flat
round
size="12px"
color="red"
icon="mdi-delete-outline"
@click="removeFile(file.id)"
><q-tooltip>ลบไฟล</q-tooltip></q-btn
>
</div>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
<div v-if="fileList.length > 0" class="col-xs-12 row">
<q-list class="full-width rounded-borders" bordered separator>
<q-item
v-for="File in fileList"
:key="File.id"
clickable
v-ripple
>
<q-item-section>{{ File.title }}</q-item-section>
<q-item-section avatar>
<div class="row">
<div>
<q-btn
dense
flat
round
size="12px"
color="blue"
icon="mdi-download-outline"
@click="downloadFiles(File.fileName)"
>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip>
</q-btn>
</div>
<div>
<q-btn
dense
flat
round
size="12px"
color="red"
icon="mdi-delete-outline"
@click="removeFile(File.fileName)"
><q-tooltip>ลบไฟล</q-tooltip></q-btn
>
</div>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
<div class="col-12" v-else>
<q-card class="q-pa-sm" bordered> ไมรายการเอกสาร </q-card>
<div class="col-12" v-else>
<q-card class="q-pa-sm" bordered> ไมรายการเอกสาร </q-card>
</div>
</div>
</q-card>
</div>
</div>
</q-card>
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
ผลการพจารณาของการเจาหนาท
</div>
</div>
<q-separator />
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
<div class="col-xs-6 row items-start">
<div class="col-12 text-top">สถานะ</div>
<div class="col-12 text-detail">
{{
dataDetail.officerReject !== null
? statusOrder(dataDetail.officerReject)
: "-"
}}
</div>
</div>
<div class="col-xs-6 row items-start">
<div class="col-12 text-top">นสดทายทบย</div>
<div class="col-12 text-detail">
{{
dataDetail.officerRejectDate !== null
? date2Thai(dataDetail.officerRejectDate)
: "-"
}}
</div>
</div>
<div class="col-xs-12 row items-start">
<div class="col-12 text-top">ความคดเหนและเหตผล</div>
<div class="col-12 text-detail">
{{
dataDetail.commanderReject
? dataDetail.officerRejectReason || "-"
: dataDetail.officerApproveReason || "-"
}}
</div>
</div>
</div>
</div>
@ -919,24 +1007,11 @@ function confirmRemove(fileId: string) {
</div>
<div class="col-xs-12 row items-start">
<div class="col-12 text-top">ความคดเหนและเหตผล</div>
<div
class="col-12 text-detail"
v-if="dataDetail.commanderReject === false"
>
<div class="col-12 text-detail">
{{
dataDetail.commanderApproveReason !== null
? dataDetail.commanderApproveReason
: "-"
}}
</div>
<div
class="col-12 text-detail"
v-if="dataDetail.commanderReject === true"
>
{{
dataDetail.commanderRejectReason !== null
? dataDetail.commanderRejectReason
: "-"
dataDetail.commanderReject
? dataDetail.commanderRejectReason || "-"
: dataDetail.commanderApproveReason || "-"
}}
</div>
</div>
@ -975,24 +1050,11 @@ function confirmRemove(fileId: string) {
</div>
<div class="col-xs-12 row items-start">
<div class="col-12 text-top">ความคดเหนและเหตผล</div>
<div
class="col-12 text-detail"
v-if="dataDetail.oligarchReject == false"
>
<div class="col-12 text-detail">
{{
dataDetail.oligarchApproveReason !== null
? dataDetail.oligarchApproveReason
: "-"
}}
</div>
<div
class="col-12 text-detail"
v-else-if="dataDetail.oligarchReject == true"
>
{{
dataDetail.oligarchRejectReason !== null
? dataDetail.oligarchRejectReason
: "-"
dataDetail.commanderReject
? dataDetail.oligarchRejectReason || "-"
: dataDetail.oligarchApproveReason || "-"
}}
</div>
</div>
@ -1001,47 +1063,53 @@ function confirmRemove(fileId: string) {
</q-card>
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
แกไขขอมลเพอลงบญชแนบทาย
<q-form
ref="myForm"
greedy
@submit.prevent
@validation-success="onSubmitAttached"
>
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
แกไขขอมลเพอลงบญชแนบทาย
</div>
<q-space />
<div class="q-gutter-sm" v-if="!edit">
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="edit = !edit"
v-if="!(status == 'REPORT' || status == 'DONE')"
/>
</div>
<div class="q-gutter-sm" v-else>
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
type="submit"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="clickCancel"
/>
</div>
</div>
<q-space />
<div class="q-gutter-sm" v-if="!edit">
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="edit = !edit"
v-if="!(status == 'REPORT' || status == 'DONE')"
/>
</div>
<div class="q-gutter-sm" v-else>
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
@click="conditionSave"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="clickCancel"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<q-form ref="myForm">
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
<div class="col-xs-12 row items-center">
@ -1187,56 +1255,6 @@ function confirmRemove(fileId: string) {
</datepicker>
</div>
</div>
<!-- <div class="col-xs-4 row">
<div class="col-12">
<datepicker
menu-class-name="modalfix"
:readonly="!edit"
v-model="dateLeave"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
:readonly="!edit"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:borderless="!edit"
:model-value="
dateLeave !== null ? date2Thai(dateLeave) : null
"
:rules="[
(val) =>
!!val || `${'กรุณาเลือก วันที่ขอลาออกจากราชการ'}`,
]"
hide-bottom-space
:label="`${' วันที่ขอลาออกจากราชการ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
:style="
edit
? 'color: var(--q-primary)'
: 'color: var(--q-grey)'
"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
</div> -->
<div class="col-12">
<q-input
:class="getClass(edit)"
@ -1273,6 +1291,7 @@ function confirmRemove(fileId: string) {
</div>
</q-form>
</q-card>
<q-dialog v-model="modal" persistent>
<q-card style="width: 800px">
<q-form ref="myFormConfirm">

View file

@ -36,21 +36,26 @@ interface TypeFile {
}
interface rowFile {
fileName: string
pathName: string
fileName: string;
pathName: string;
}
interface FileList {
id: string
fileName: string
pathName: string
id: string;
fileName: string;
pathName: string;
title: string;
}
interface CheckBoxType {
label: string
value: string
label: string;
value: string;
}
export type { resMain, ResponseItems, TypeFile, rowFile,FileList,CheckBoxType };
export type {
resMain,
ResponseItems,
TypeFile,
rowFile,
FileList,
CheckBoxType,
};