comment code retirement

This commit is contained in:
AnandaTon 2023-11-17 14:21:53 +07:00
parent 45fc4848ac
commit 45ef9649e1
15 changed files with 295 additions and 64 deletions

View file

@ -6,20 +6,22 @@ import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogF
import DialogHeader from "@/modules/05_placement/components/PersonalList/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useRetirementDataStore } from "@/modules/06_retirement/store";
import CurrencyInput from "@/components/CurruncyInput.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import type { TypeFile, rowFile } from "@/modules/06_retirement/interface/response/Main";
import type {
TypeFile,
rowFile,
} from "@/modules/06_retirement/interface/response/Main";
import type { QTableProps } from "quasar";
/** Use */
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const mixin = useCounterMixin();
const RetirementData = useRetirementDataStore();
const {
messageError,
date2Thai,
@ -31,6 +33,7 @@ const {
} = mixin;
const { statusText } = RetirementData;
/** ตัวแปร */
const roleUser = ref<string>("");
const id = ref<string>(route.params.id.toString());
const myForm = ref<QForm | null>(null);
@ -58,7 +61,6 @@ const dataDetail = ref<any>({
statustext: "",
fullname: "",
});
const organizationPositionOld = ref<string>("");
const positionTypeOld = ref<string>("");
const positionLevelOld = ref<string>("");
@ -70,12 +72,12 @@ const reason = ref<string>("");
const location = ref<string>("");
const status = ref<string>("");
const remarkHorizontal = ref<string>("");
const modal = ref<boolean>(false);
const actionPass = ref<boolean>(false);
const reasonReign = ref<string>("");
const dateBreak = ref<Date | null>(null);
/** คอลัมน์ */
const rows = ref<TypeFile[]>([]);
const columns = ref<QTableProps["columns"]>([
{
@ -107,9 +109,11 @@ const columns = ref<QTableProps["columns"]>([
},
]);
/**เปิด-ปิด modal */
const closeModal = () => (modal.value = false);
const openModal = () => (modal.value = true);
/** Hook */
onMounted(async () => {
fetchData(id.value);
if (keycloak.tokenParsed !== undefined) {
@ -139,6 +143,9 @@ const diffDate = () => {
return false;
};
/**
* นำขอมลมาจาก API
*/
const fetchData = async (id: string) => {
showLoader();
await http
@ -187,13 +194,14 @@ const fetchData = async (id: string) => {
// document.body.removeChild(link);
// };
/**Pop up */
const popUp = (action: "pass" | "passNot") => {
reasonReign.value = "";
dateBreak.value = null;
actionPass.value = action === "pass";
openModal();
};
//pop up
const conditionPopup = () => {
if (myFormConfirm.value !== null) {
myFormConfirm.value.validate().then(async (check) => {
@ -208,6 +216,7 @@ const conditionPopup = () => {
}
};
//pop up
const confirmpopUp = async () => {
dialogConfirm(
$q,
@ -233,6 +242,7 @@ const confirmpopUp = async () => {
);
};
//pop up
const rejectpopUp = async () => {
dialogConfirm(
$q,
@ -258,15 +268,26 @@ const rejectpopUp = async () => {
"ต้องการยืนยันการยับยั้งนี้หรือไม่ ?"
);
};
/**
* ไปยงขอม
* @param id ไอดอม
*/
const redirectToRegistry = (id: string) => {
router.push(`/registry/${id}`);
};
/**
* กดยกเล
*/
const clickCancel = async () => {
await fetchData(id.value);
edit.value = false;
};
/**
* Functionบนท
*/
const conditionSave = () => {
if (myForm.value !== null) {
myForm.value.validate().then((success) => {
@ -285,7 +306,7 @@ const conditionSave = () => {
});
}
};
//Save Api
const saveData = async () => {
const formData = new FormData();
const send = date.value !== null ? new Date(date.value).toUTCString() : "";
@ -317,12 +338,18 @@ const saveData = async () => {
});
};
/**
* Function เพ Class เวลา Edit
* @param val เมอเปนEdit จะเปลยน Class
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
/** แปลง StatusOrder */
const statusOrder = (val: boolean) => {
switch (val) {
case true:
@ -335,12 +362,12 @@ const statusOrder = (val: boolean) => {
//
const rowsFileDownload = ref<rowFile[]>([
{
fileName:
"แบบฟอร์มหนังสือขอลาออกจากราชการ",
fileName: "แบบฟอร์มหนังสือขอลาออกจากราชการ",
pathName: "",
}
},
]);
//
const fileDownload = async (type: string, fileName: string) => {
showLoader();
await http
@ -358,6 +385,7 @@ const fileDownload = async (type: string, fileName: string) => {
});
};
//
const downloadFile = (response: any, filename: string) => {
const link = document.createElement("a");
var fileName = filename;