ปรับรายการลาออก และ dialog confrim

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-05-21 10:21:38 +07:00
parent c1db58e570
commit 19da1d284a
5 changed files with 558 additions and 519 deletions

View file

@ -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<string>("");
const fileDocDataUpload = ref<File[]>([]);
const files = ref<any>();
//
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<any>();
//
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) {
<div v-if="routeName == 'AddRetire'">เพิ่มเรื่องลาออก</div>
<div v-else>รายละเอียดเรื่องลาออก</div>
</div>
<q-form ref="myform" class="col-12">
<q-form
ref="myform"
class="col-12"
greedy
@submit.prevent
@validation-success="onSubmit"
>
<q-card bordered>
<div class="col-12 row q-col-gutter-sm q-pa-md">
<div class="col-xs-12 col-sm-12">
@ -353,7 +298,23 @@ function downloadFile(data: string) {
/>
<div class="col-12 row" v-if="routeName == 'AddRetire'">
<q-uploader
<q-file
v-model="files"
class="col-xs-12 col-sm-12"
outlined
dense
lazy-rules
hide-bottom-space
accept=".pdf"
:rules="[
(val) => !!val || 'กรุณากรอกอัพโหลดเอกสารเพิ่มเติม',
]"
label="เอกสารเพิ่มเติม"
>
<template v-slot:prepend>
<q-icon name="attach_file" /> </template
></q-file>
<!-- <q-uploader
flat
bordered
class="col-xs-12 col-sm-12"
@ -364,7 +325,7 @@ function downloadFile(data: string) {
@added="fileUploadDoc"
@removed="filesNull"
style="max-width: px"
/>
/> -->
</div>
<div class="col-12 row">
<q-card
@ -571,8 +532,7 @@ function downloadFile(data: string) {
class="q-px-md items-center"
color="primary"
label="ยื่นเรื่องขอลาออก"
@click="saveData"
:disable="tranferOrg == '' && noteReason == ''"
type="submit"
/>
</div>
</q-card>