From 6961e719f044cb5f1207932c7f80d9f3eb1b19ee Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Tue, 19 Sep 2023 18:04:54 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B9=81=E0=B8=95=E0=B9=88=E0=B8=87=E0=B8=95=E0=B8=B1?= =?UTF-8?q?=E0=B9=89=E0=B8=87-=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=99-=E0=B8=A2=E0=B9=89=E0=B8=B2=E0=B8=A2=20?= =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=E0=B9=82=E0=B8=84=E0=B9=89=E0=B8=94?= =?UTF-8?q?=20+=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppointMent/AppointmentModal.vue | 22 +- .../components/AppointMent/Detail.vue | 94 ++-- .../components/AppointMent/Dialogbody.vue | 233 +++++++++ .../components/AppointMent/Main.vue | 469 +++++------------- .../05_placement/components/Other/Main.vue | 3 - 5 files changed, 401 insertions(+), 420 deletions(-) create mode 100644 src/modules/05_placement/components/AppointMent/Dialogbody.vue diff --git a/src/modules/05_placement/components/AppointMent/AppointmentModal.vue b/src/modules/05_placement/components/AppointMent/AppointmentModal.vue index 834e8bba6..e4ea460dd 100644 --- a/src/modules/05_placement/components/AppointMent/AppointmentModal.vue +++ b/src/modules/05_placement/components/AppointMent/AppointmentModal.vue @@ -9,7 +9,7 @@ import config from "@/app.config"; const $q = useQuasar(); const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง -const { date2Thai, hideLoader, messageError, showLoader, success } = mixin; //ฟังก์ชันกลางที่เรียกใช้ +const { date2Thai, hideLoader, messageError, showLoader, success,dialogConfirm } = mixin; //ฟังก์ชันกลางที่เรียกใช้ const notFound = ref("ไม่พบข้อมูลที่ค้นหา"); const noData = ref("ไม่พบข้อมูลผังโครงสร้าง"); @@ -199,19 +199,17 @@ const editDataStatus = ref(false); const clickEditRow = () => { editDataStatus.value = true; }; - const closeModal = () => { if (editDataStatus.value == true) { - $q.dialog({ - title: `ข้อมูลมีการแก้ไข`, - message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`, - cancel: "ยกเลิก", - ok: "ยืนยัน", - persistent: true, - }).onOk(() => { - editDataStatus.value = false; - closeAndClear(); - }); + dialogConfirm( + $q, + async () => { + editDataStatus.value = false; + await closeAndClear(); + }, + `ข้อมูลมีการแก้ไข`, + `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?` + ); } else { closeAndClear(); } diff --git a/src/modules/05_placement/components/AppointMent/Detail.vue b/src/modules/05_placement/components/AppointMent/Detail.vue index 979cb23a0..913122cdb 100644 --- a/src/modules/05_placement/components/AppointMent/Detail.vue +++ b/src/modules/05_placement/components/AppointMent/Detail.vue @@ -4,7 +4,6 @@ import { useQuasar } from "quasar"; import { useRoute, useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import CurrencyInput from "@/components/CurruncyInput.vue"; - import type { ResponseTitle } from "@/modules/05_placement/interface/response/Receive"; import http from "@/plugins/http"; @@ -15,6 +14,21 @@ const route = useRoute(); const router = useRouter(); const mixin = useCounterMixin(); +const appointment = ref([]); +const myform = ref(); +const edit = ref(false); +const profileId = ref(""); +const organizationPositionOld = ref(""); +const positionTypeOld = ref(""); +const positionLevelOld = ref(""); +const posNo = ref(""); +const salary = ref(0); +const educationOld = ref(""); +const reason = ref(""); +const date = ref(null); +const status = ref(""); +const avatar = ref(""); + const paramsId = route.params.id; const { date2Thai, @@ -31,24 +45,9 @@ const title = ref({ positionLevelOld: "", positionTypeOld: "", }); -const appointment = ref([]); -const myform = ref(); -const edit = ref(false); -const profileId = ref(""); -const organizationPositionOld = ref(""); -const positionTypeOld = ref(""); -const positionLevelOld = ref(""); -const posNo = ref(""); -const salary = ref(""); -const educationOld = ref(""); -const reason = ref(""); -const date = ref(null); -const status = ref(""); -const avatar = ref(""); -onMounted(async () => { - await fecthappointmentByid(); -}); + +//เรียกข้อมูลตาม id const fecthappointmentByid = async () => { showLoader(); await http @@ -56,22 +55,18 @@ const fecthappointmentByid = async () => { .then((res: any) => { const data = res.data.result; appointment.value = data; - // console.log(data); - profileId.value = data.profileId; - title.value.fullname = `${data.firstname ?? "-"} ${data.lastname ?? "-"}`; + title.value.fullname = `${data.prefix}${data.firstname ?? "-"} ${data.lastname ?? "-"}`; title.value.organizationPositionOld = data.organizationPositionOld ?? "-"; title.value.positionLevelOld = data.positionLevelOld ?? "-"; title.value.positionTypeOld = data.positionTypeOld ?? "-"; (status.value = data.status), - console.log("🚀 ~ file: Detail.vue:65 ~ .then ~ status:", status.value); - educationOld.value = data.educationOld; + educationOld.value = data.educationOld ?? "-"; organizationPositionOld.value = data.organizationPositionOld; positionTypeOld.value = data.positionTypeOld; positionLevelOld.value = data.positionLevelOld; posNo.value = data.positionNumberOld; - salary.value = data.salary; - // organization.value = data.organization; //ไม่มี + salary.value = data.salary ?? 0; reason.value = data.reason; date.value = data.positionDate; avatar.value = data.avatar ?? ""; @@ -83,8 +78,9 @@ const fecthappointmentByid = async () => { hideLoader(); }); }; + +//ยืนยันการเเก้ไข const clickSave = async () => { - console.log(reason.value); await myform.value.validate().then(async (success: boolean) => { if (success) { dialogConfirm($q, () => putAppointment()); @@ -92,21 +88,13 @@ const clickSave = async () => { } }); }; +// เเก้ไขข้อมูล const putAppointment = async () => { - console.log("บันทึกข้อมูล"); let data = { citizenId: appointment.value.citizenId, prefixId: appointment.value.prefixId, firstname: appointment.value.firstname, lastname: appointment.value.lastname, - // dateOfBirth: "2023-08-15T08:44:38.060Z", - // genderId: "3fa85f64-5717-4562-b3fc-2c963f66afa6", - // nationality: "string", - // race: "string", - // religionId: "3fa85f64-5717-4562-b3fc-2c963f66afa6", - // bloodGroupId: "3fa85f64-5717-4562-b3fc-2c963f66afa6", - // relationshipId: "3fa85f64-5717-4562-b3fc-2c963f66afa6", - // telephoneNumber: "string", educationOld: educationOld.value, organizationPositionOld: organizationPositionOld.value, positionTypeOld: positionTypeOld.value, @@ -115,10 +103,7 @@ const putAppointment = async () => { amountOld: Number(salary.value), reason: reason.value, positionDate: date.value, - // positionDate: "2023-08-15T08:44:38.060Z", - // file: ["string"], }; - console.log(data); showLoader(); await http .put(config.API.appointmentByid(paramsId.toString()), data) @@ -127,7 +112,6 @@ const putAppointment = async () => { }) .catch((e) => { messageError($q, e); - console.log(e); }) .finally(() => { fecthappointmentByid(); @@ -140,6 +124,10 @@ const getClass = (val: boolean) => { "full-width cursor-pointer": !val, }; }; + +onMounted(async () => { + await fecthappointmentByid(); +});