บรรจุ แต่งตั้ง ย้าย โอน => ปรับ code และ load

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-19 16:14:43 +07:00
parent 9f4aeec575
commit 34dc306288
30 changed files with 1154 additions and 1429 deletions

View file

@ -30,7 +30,7 @@ const {
success,
dateToISO,
messageError,
dialogMessage,
dialogMessageNotify,
showLoader,
hideLoader,
dialogConfirm,
@ -39,7 +39,6 @@ const {
const profileStore = useProfileDataStore();
const { changeRetireText } = profileStore;
const prefixOps = ref<DataOption[]>([]);
const age = ref<string | null>("");
const informaData = ref<FormAddPerson>({
@ -61,7 +60,6 @@ const informaData = ref<FormAddPerson>({
profileType: null,
});
const myform = ref<QForm | null>(null);
const dateBefore = ref<Date>(new Date());
//
const Ops = ref<InformationOps>({
@ -142,7 +140,9 @@ const fetchPerson = async () => {
Ops.value.religionOps = optionreligions;
OpsFilter.value.religionOps = optionreligions;
})
.catch((e: any) => {})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
@ -176,30 +176,23 @@ const changeCardID = async (value: string | number | null) => {
}
};
/**
* function เชคเลขประจำตวประชาชนช
* @param id เลขประจำตวประชาชน
*/
const checkCitizen = async (id: string) => {
showLoader();
await http
.get(config.API.profileCitizenId(id))
.then((res) => {
const data = res.data.result.citizen;
if (!data) {
dialogMessage(
$q,
"ข้อความแจ้งเตือน",
"เลขประจำตัวประชาชนนี้มีการใช้งานแล้ว",
"warning",
undefined,
"orange",
undefined,
undefined,
true
);
informaData.value.citizenId = defaultCitizenData.value;
}
.put(config.API.profileNewCitizenId(id), {
citizenId: id,
})
.catch((e) => {
messageError($q, e);
.then(() => {})
.catch((err) => {
if (err.response.data.status === 500) {
dialogMessageNotify($q, err.response.data.message);
} else {
messageError($q, err);
}
})
.finally(() => {
hideLoader();
@ -257,37 +250,6 @@ const calculateMaxDate = () => {
return today;
};
//
const handleDate = async (modelData: Date) => {
informaData.value.birthDate = modelData;
await calRetire(modelData);
};
const calRetire = async (birth: Date) => {
const body = {
birthDate: dateToISO(birth),
};
if (dateToISO(dateBefore.value) != dateToISO(birth)) {
showLoader();
await http
.post(config.API.profileCalRetire, body)
.then((res: any) => {
const data = res.data.result;
informaData.value.age = data.age;
changeRetireText(data.retireDate);
dateBefore.value = birth;
})
.catch((e: any) => {
messageError($q, e);
informaData.value.birthDate = null;
informaData.value.age = "";
})
.finally(() => {
hideLoader();
});
}
};
// post api
const onSubmit = async () => {
const formData = new FormData();
@ -330,7 +292,6 @@ const onSubmit = async () => {
.post(config.API.receiveData(), formData)
.then(async (res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
// await changeBirth(informaData.value.birthDate ?? new Date());
await clickBack();
})
.catch((e) => {

View file

@ -1,10 +1,9 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, ref, watch } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useProfileDataStore } from "@/modules/08_registryEmployee/store";
import type { QTableProps, QForm } from "quasar";
import type {
ResponseTitle,
@ -42,9 +41,6 @@ const {
dialogConfirm,
} = mixin;
// const profileStore = useProfileDataStore();
// const { changeRetireText } = profileStore;
const title = ref<ResponseTitle>({
fullname: "",
organizationPositionOld: "",
@ -189,7 +185,9 @@ const fetchPerson = async () => {
Ops.value.religionOps = optionreligions;
OpsFilter.value.religionOps = optionreligions;
})
.catch((e: any) => {})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
@ -223,7 +221,7 @@ const getData = async () => {
defaultCitizenData.value = data.citizenId == null ? "" : data.citizenId;
informaData.value = {
cardid: data.citizenId ?? "",
age: "",
age: calculateAge(data.dateOfBirth),
prefix: "",
prefixId:
(data.prefix == "00000000-0000-0000-0000-000000000000"
@ -265,7 +263,8 @@ const getData = async () => {
reason.value = data.reason ?? "";
status.value = data.status ?? "";
await calRetire(new Date(dateToISO(new Date(data.dateOfBirth))));
calculateAge(data.dateOfBirth);
dateBefore.value = new Date(data.dateOfBirth);
})
.catch((e) => {
@ -281,6 +280,7 @@ const cancel = async () => {
if (myForm.value !== null) {
await getData();
myForm.value?.resetValidation();
} else {
}
};
@ -379,36 +379,6 @@ const filterSelector = (val: any, update: Function, refData: string) => {
}
};
const handleDate = async (modelData: Date) => {
informaData.value.birthDate = modelData;
await calRetire(modelData);
};
const calRetire = async (birth: Date) => {
const body = {
birthDate: dateToISO(birth),
};
showLoader();
await http
.post(config.API.profileCalRetire, body)
.then((res: any) => {
const data = res.data.result;
informaData.value.age = data.age;
// changeRetireText(data.retireDate);
dateBefore.value = birth;
})
.catch((e: any) => {
messageError($q, e);
const retire = new Date(`${birth.getFullYear() + 60}-09-30`);
informaData.value.birthDate = dateBefore.value;
// changeRetireText(date2Thai(retire));
})
.finally(() => {
hideLoader();
});
// }
};
function saveData() {
dialogConfirm(
$q,
@ -441,10 +411,10 @@ function saveData() {
showLoader();
http
.put(config.API.receiveDataId(route.params.id.toString()), body)
.then((res: any) => {
success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ");
.then(async () => {
await getData();
await success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ");
edit.value = false;
getData();
})
.catch((e) => {
messageError($q, e);
@ -465,6 +435,44 @@ const getClass = (val: boolean) => {
};
};
/**
* function เชคอายไมเก 18
*/
function calculateMaxDate() {
const today = new Date();
today.setFullYear(today.getFullYear() - 18);
return today;
}
function calculateAge(birthDate: Date | null) {
if (!birthDate) return null;
const birthDateTimeStamp = new Date(birthDate).getTime();
const now = new Date();
const diff = now.getTime() - birthDateTimeStamp;
const ageDate = new Date(diff);
const years = ageDate.getUTCFullYear() - 1970;
const months = ageDate.getUTCMonth();
const days = ageDate.getUTCDate() - 1;
const retire = new Date(birthDate);
retire.setFullYear(retire.getFullYear() + 60);
if (years > 60) {
return "อายุเกิน 60 ปี";
}
return `${years} ปี ${months} เดือน ${days} วัน`;
}
watch(
() => informaData.value.birthDate,
(v) => {
if (v) {
informaData.value.age = calculateAge(v);
}
}
);
onMounted(async () => {
await fetchPerson();
await getData();
@ -483,7 +491,7 @@ onMounted(async () => {
class="q-mr-sm"
@click="router.push(`/placement/receive`)"
/>
รายละเอยดการรบโอนของ {{ title.fullname }}
รายละเอยดการรบโอนของ{{ title.fullname }}
</div>
<CardProfile :data="dataProfile as DataProfile" />
@ -610,9 +618,8 @@ onMounted(async () => {
autoApply
:enableTimePicker="false"
week-start="0"
:max-date="new Date()"
:max-date="calculateMaxDate()"
:disabled="!edit"
@update:model-value="handleDate"
>
<template #year="{ year }">
{{ year + 543 }}
@ -928,6 +935,7 @@ onMounted(async () => {
</div>
<div class="col-xs-6 col-sm-3">
<q-input
:class="getClass(edit)"
v-model="salary"
:outlined="edit"
dense
@ -938,7 +946,6 @@ onMounted(async () => {
:rules="[(val:number) => !!val || `${'กรุณากรอกเงินเดือน'}`]"
lazy-rules
mask="###,###,###,###"
class="inputgreen"
reverse-fill-mask
/>
</div>

View file

@ -172,14 +172,14 @@ const SaveData = async () => {
showLoader();
http
.put(config.API.receiveFile(personalId.value), formData)
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
.then(async () => {
await success($q, "บันทึกข้อมูลสำเร็จ");
await clickCloseUpload();
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await clickCloseUpload();
.finally(() => {
hideLoader();
});
}
@ -245,31 +245,21 @@ const openUpload = (id: string) => {
personalId.value = id;
modalupload.value = true;
};
//
//
const openDelete = (id: string) => {
dialogRemove($q, async () => await fetchDataDelete(id));
};
//
const fetchDataDelete = async (id: string) => {
showLoader();
await http
.delete(config.API.receiveDataId(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
fecthlistRecevice();
hideLoader();
});
};
//
const closeModalTree = async () => {
await fecthlistRecevice();
modalTree.value = false;
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.receiveDataId(id))
.then(async () => {
await fecthlistRecevice();
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
hideLoader();
});
});
};
//
@ -282,8 +272,7 @@ const nextPage = (id: string) => {
function onSave(data: any) {
console.log("not save", data);
const dataAppoint = {
// personalId: data.personalId,
node: data.node,
node: data.node,
nodeId: data.nodeId,
orgRevisionId: data.orgRevisionId,
positionId: data.positionId,
@ -301,15 +290,15 @@ function onSave(data: any) {
showLoader();
http
.put(config.API.receivePosition(personalId.value), dataAppoint)
.then((res) => {
.then(async () => {
await fecthlistRecevice();
await success($q, "บันทึกข้อมูลสำเร็จ");
modalTree.value = false;
success($q, "บันทึกสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
fecthlistRecevice();
.finally(() => {
hideLoader();
});
}
@ -561,6 +550,7 @@ onMounted(() => {
</div>
</q-card>
<!-- ออกคำส -->
<Dialogbody
v-model:Modal="modal"
:clickClose="clickClose"
@ -569,6 +559,8 @@ onMounted(() => {
:fecthlistRecevice="fecthlistRecevice"
:nextPage="nextPage"
/>
<!-- ปโหลดเอกสาร -->
<q-dialog v-model="modalupload">
<q-card style="width: 600px">
<DialogHeader title="อัปโหลดเอกสาร" :close="clickCloseUpload" />
@ -605,14 +597,7 @@ onMounted(() => {
</q-card>
</q-dialog>
<!-- <DialogOrgTree
v-model:modal="modalTree"
:close="closeModalTree"
:personal="personal"
:personalId="personalId"
:dataRows="dataRows"
/> -->
<!-- เลอกหนวยงานทบโอน -->
<DialogOrgSelect
:title="`เลือกหน่วยงานที่รับโอน`"
v-model:modal="modalTree"