From 19da1d284a17dd9e04362794a8b8c43abecd7c3c Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 21 May 2024 10:21:38 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=20=E0=B9=81=E0=B8=A5=E0=B8=B0=20dia?= =?UTF-8?q?log=20confrim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/02_transfer/views/AddTransfer.vue | 30 - src/modules/03_retire/views/DialogRetire.vue | 26 +- src/modules/03_retire/views/addRetire.vue | 168 ++-- src/modules/03_retire/views/result.vue | 835 ++++++++++-------- src/views/MainLayout.vue | 18 +- 5 files changed, 558 insertions(+), 519 deletions(-) diff --git a/src/modules/02_transfer/views/AddTransfer.vue b/src/modules/02_transfer/views/AddTransfer.vue index 33a71a1..1294a70 100644 --- a/src/modules/02_transfer/views/AddTransfer.vue +++ b/src/modules/02_transfer/views/AddTransfer.vue @@ -51,36 +51,6 @@ const saveData = async () => { "ยืนยันการยื่นข้อมูลการโอน", "ต้องการยื่นข้อมูลการโอนนี้ใช่หรือไม่" ); - - // if (myform.value != null) { - // await myform.value.validate().then(async (saveDataTest: Boolean) => { - // if (saveDataTest) { - // saveTransfer(); - // } - // }); - // } -}; - -//บันทึกข้อมูลการโอน -const saveTransfer = () => { - $q.dialog({ - title: "ยืนยันการยื่นข้อมูลการโอน", - message: "ต้องการยื่นข้อมูลการโอนนี้ใช่หรือไม่?", - cancel: { - flat: true, - color: "negative", - }, - persistent: true, - }) - .onOk(async () => { - if (files.value == undefined) { - fails($q, "กรุณากรอกอัพโหลดเอกสารเพิ่มเติม"); - } else { - createTransfer(); - } - }) - .onCancel(() => {}) - .onDismiss(() => {}); }; /** diff --git a/src/modules/03_retire/views/DialogRetire.vue b/src/modules/03_retire/views/DialogRetire.vue index a2be573..427a4ee 100644 --- a/src/modules/03_retire/views/DialogRetire.vue +++ b/src/modules/03_retire/views/DialogRetire.vue @@ -13,7 +13,7 @@ const type = ref(""); const isReadonly = ref(false); // อ่านได้อย่างเดียว const mixin = useCounterMixin(); const { dialogConfirm, date2Thai, messageError } = mixin; -const reason = ref('') +const reason = ref(""); /*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */ function validateForm() { @@ -26,17 +26,15 @@ function close() { } function onSubmit() { - dialogConfirm($q,()=>{ - modal.value = false - reason.value = ""; - },"ยืนยันการยกเลิก", "ต้องการยืนยันการยกเลิกกนี้ใช่หรือไม่?") -} - -function inputEdit(val: boolean) { - return { - "full-width cursor-pointer inputgreen ": val, - "full-width cursor-pointer inputgreen": !val, - }; + dialogConfirm( + $q, + () => { + modal.value = false; + reason.value = ""; + }, + "ยืนยันการยกเลิก", + "ต้องการยืนยันการยกเลิกกนี้ใช่หรือไม่?" + ); } @@ -48,13 +46,13 @@ function inputEdit(val: boolean) {
- + />
diff --git a/src/modules/03_retire/views/addRetire.vue b/src/modules/03_retire/views/addRetire.vue index e38ae32..27a91dc 100644 --- a/src/modules/03_retire/views/addRetire.vue +++ b/src/modules/03_retire/views/addRetire.vue @@ -16,7 +16,7 @@ const { messageError, showLoader, hideLoader, - fails, + dialogConfirm, } = mixin; const router = useRouter(); const route = useRoute(); @@ -90,105 +90,44 @@ onMounted(() => { /** * บันทึกข้อมูลการลาออก */ -const saveData = async () => { - if (myform.value != null) { - await myform.value.validate().then(async (saveDataTest: Boolean) => { - if (saveDataTest) { - saveResing(); - } - }); - } -}; +const onSubmit = async () => { + dialogConfirm( + $q, + () => { + showLoader(); + const formData = new FormData(); + formData.append("Location", tranferOrg.value); + formData.append("SendDate", dateToISO(dateCommand.value)); + formData.append("ActiveDate", dateToISO(dateLeave.value)); + formData.append("Reason", noteReason.value); + formData.append("file", files.value); -/** - * ฟังก์ชั่นดาว์โหลดอัพโหลดไฟล์ - */ -const filesNull = () => { - files.value = null; -}; -const nameFile = ref(""); -const fileDocDataUpload = ref([]); -const files = ref(); -//อัพโหลดไฟล์ -const fileUploadDoc = async (file: any) => { - fileDocDataUpload.value.push(file); - nameFile.value = file[0].name; - files.value = file; -}; - -/** - * ฟังก์ชั่นเซฟข้อมูลลาออกเเล้วเรียกใช้งานApi - */ -const saveResing = () => { - $q.dialog({ - title: "ยืนยันการยื่นข้อมูลลาออก", - message: "ต้องการยื่นข้อมูลลาออกนี้ใช่หรือไม่?", - cancel: { - flat: true, - color: "negative", + http + .post(config.API.listResign(), formData) + .then((res) => { + let data = res.data.result.id; + success($q, "บันทึกข้อมูลสำเร็จ"); + router.push(`/retire/result/${data}`); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); }, - persistent: true, - }) - .onOk(() => { - createFormresign(); - }) - .onCancel(() => {}) - .onDismiss(() => {}); + "ยืนยันการยื่นข้อมูลลาออก", + "ต้องการยื่นข้อมูลลาออกนี้ใช่หรือไม่" + ); }; +const files = ref(); + //ยกเลิกการลาออก const cancelResing = () => { modal.value = true; }; -/** - * ฟังก์ชั่นลบ - * @param id ไอดีของข้อมูลการลาออก - */ -const deleteResting = async (id: string) => { - showLoader(); - await http - .delete(config.API.resingByid(id)) - .then(() => { - success($q, "ยกเลิกการลาออกขอสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - clickBack(); - }); -}; - -//บันทึกข้อมูล -const createFormresign = async () => { - const formData = new FormData(); - if (files.value.length > 0) { - const blob = files.value.slice(0, files.value[0].size); - const newFile = new File(blob, nameFile.value, { - type: files.value[0].type, - }); - formData.append("file", newFile); - } - - formData.append("Location", tranferOrg.value); - formData.append("SendDate", dateToISO(dateCommand.value)); - formData.append("ActiveDate", dateToISO(dateLeave.value)); - formData.append("Reason", noteReason.value); - - await http - .post(config.API.listResign(), formData) - .then((res: any) => { - let data = res.data.result.id; - success($q, "บันทึกข้อมูลสำเร็จ"); - router.push(`/retire/result/${data}`); - }) - .catch((e: any) => { - messageError($q, e); - }); -}; - /** * ฟังก์ชั่นเรียกข้อมูลจาก Api * @param id ไอดีของข้อมูล @@ -197,16 +136,16 @@ const fectDataresign = async (id: string) => { showLoader(); await http .get(config.API.resingByid(id)) - .then((res: any) => { + .then((res) => { let data = res.data.result; - (tranferOrg.value = data.location), - (dateCommand.value = data.sendDate), - (dateLeave.value = data.activeDate), - (noteReason.value = data.reason), - (files.value = data.docs), - (dataDetail.value = data); + tranferOrg.value = data.location; + dateCommand.value = data.sendDate; + dateLeave.value = data.activeDate; + noteReason.value = data.reason; + files.value = data.docs; + dataDetail.value = data; }) - .catch((e: any) => { + .catch((e) => { messageError($q, e); }) .finally(() => { @@ -235,7 +174,13 @@ function downloadFile(data: string) {
เพิ่มเรื่องลาออก
รายละเอียดเรื่องลาออก
- +
@@ -353,7 +298,23 @@ function downloadFile(data: string) { />
- + +
diff --git a/src/modules/03_retire/views/result.vue b/src/modules/03_retire/views/result.vue index 36b2994..954bc5b 100644 --- a/src/modules/03_retire/views/result.vue +++ b/src/modules/03_retire/views/result.vue @@ -1,35 +1,46 @@ diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 5035a60..1356817 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -20,6 +20,7 @@ const { hideLoader, messageError, success, + dialogConfirm, } = mixin; const fullname = ref(""); @@ -88,15 +89,14 @@ const fetchlistNotification = async (index: number, type: string) => { * confirm ก่อนออกจากระบบ */ const doLogout = () => { - $q.dialog({ - title: "ยืนยันการออกจากระบบ", - message: `ต้องการออกจากระบบใช่หรือไม่?`, - cancel: "ยกเลิก", - ok: "ยืนยัน", - persistent: true, - }).onOk(() => { - keycloak.logout(); - }); + dialogConfirm( + $q, + () => { + keycloak.logout(); + }, + "ยืนยันการออกจากระบบ", + "ต้องการออกจากระบบใช่หรือไม่" + ); }; const clickDelete = async (id: string, index: number) => {