เพิ่ม from submit

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-03-01 13:46:10 +07:00
parent e4835425c0
commit 2dabb6d6a8

View file

@ -251,67 +251,38 @@ function checkEndDate() {
} }
} }
watch( // watch(
() => formData.date, // () => formData.date,
() => { // () => {
if (formData.date) { // if (formData.date) {
dateRef.value.resetValidation(); // dateRef.value.resetValidation();
} // }
} // }
); // );
watch( // watch(
() => formData.startDate, // () => formData.startDate,
() => { // () => {
if (formData.startDate) { // if (formData.startDate) {
startDateRef.value.resetValidation(); // startDateRef.value.resetValidation();
} // }
} // }
); // );
watch( // watch(
() => formData.endDate, // () => formData.endDate,
() => { // () => {
if (formData.endDate) { // if (formData.endDate) {
endDateRef.value.resetValidation(); // endDateRef.value.resetValidation();
} // }
} // }
); // );
/**
* function เรยกไฟล PDF
* @param url link PDF
* @param type ประเภทไฟล
* @param fileName อไฟล
*/
async function downloadFile(url: string, type: string, fileName: string) {
await axios
.get(url, {
method: "GET",
responseType: "blob",
headers: {
"Content-Type": "application/json",
Accept: type, //
},
})
.then(async (res) => {
const a = document.createElement("a");
a.href = window.URL.createObjectURL(res.data);
a.download = fileName;
a.click();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
</script> </script>
<template> <template>
<q-dialog v-model="modal" persistent> <q-dialog v-model="modal" persistent>
<q-card class="col-12" style="width: 80%"> <q-card class="col-12" style="width: 80%">
<form @submit.prevent.stop="onClickSubmit">
<Header :tittle="title" :close="closeDialog" /> <Header :tittle="title" :close="closeDialog" />
<q-separator /> <q-separator />
@ -378,7 +349,11 @@ async function downloadFile(url: string, type: string, fileName: string) {
</div> </div>
<div class="col-xs-12 col-md-1"> <div class="col-xs-12 col-md-1">
<q-checkbox size="md" v-model="formData.isSpecial" label="ฉ" /> <q-checkbox
size="md"
v-model="formData.isSpecial"
label="ฉ"
/>
</div> </div>
<div <div
@ -415,7 +390,9 @@ async function downloadFile(url: string, type: string, fileName: string) {
dense dense
hide-bottom-space hide-bottom-space
:model-value=" :model-value="
formData.date != null ? date2Thai(formData.date) : null formData.date != null
? date2Thai(formData.date)
: null
" "
label="ให้ไว้ ณ วันที่" label="ให้ไว้ ณ วันที่"
:rules="[ :rules="[
@ -467,7 +444,8 @@ async function downloadFile(url: string, type: string, fileName: string) {
" "
label="วันที่มีผลบังคับใช้" label="วันที่มีผลบังคับใช้"
:rules="[ :rules="[
(val) => !!val || `${'กรุณาเลือกวันที่มีผลบังคับใช้'}`, (val) =>
!!val || `${'กรุณาเลือกวันที่มีผลบังคับใช้'}`,
]" ]"
lazy-rules lazy-rules
> >
@ -547,10 +525,11 @@ async function downloadFile(url: string, type: string, fileName: string) {
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
<div class="text-right q-ma-sm"> <div class="text-right q-ma-sm">
<q-btn label="บันทึก" color="secondary" @click="onClickSubmit"> <q-btn label="บันทึก" type="submit" color="secondary">
<q-tooltip>นทกขอม</q-tooltip> <q-tooltip>นทกขอม</q-tooltip>
</q-btn> </q-btn>
</div> </div>
</form>
</q-card> </q-card>
</q-dialog> </q-dialog>
</template> </template>