ปรับ fe sprint2

This commit is contained in:
Kittapath 2023-06-19 15:50:50 +07:00
parent 8576f3c387
commit 0d6ff7be0a
83 changed files with 6932 additions and 2571 deletions

View file

@ -112,8 +112,9 @@
outlined
dense
class="full-width datepicker q-mb-md"
:model-value="date2Thai(dateExam)"
:model-value="dateExam != null ? date2Thai(dateExam) : null"
:label="`${'วันที่สอบ'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่สอบ'}`]"
>
<template v-slot:prepend>
<q-icon
@ -149,8 +150,13 @@
outlined
dense
class="full-width datepicker q-mb-md"
:model-value="dateThaiRange(dateAnnouncement)"
:model-value="
dateAnnouncement != null
? dateThaiRange(dateAnnouncement)
: null
"
:label="`${'วันที่ประกาศ'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ประกาศ'}`]"
>
<template v-slot:prepend>
<q-icon
@ -186,8 +192,11 @@
outlined
dense
class="full-width datepicker q-mb-md"
:model-value="dateThaiRange(dateRegister)"
:model-value="
dateRegister != null ? dateThaiRange(dateRegister) : null
"
:label="`${'วันที่สมัคร'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่สมัคร'}`]"
>
<template v-slot:prepend>
<q-icon
@ -223,8 +232,11 @@
outlined
dense
class="full-width datepicker q-mb-md"
:model-value="dateThaiRange(datePayment)"
:model-value="
datePayment != null ? dateThaiRange(datePayment) : null
"
:label="`${'วันที่ชำระเงิน'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ชำระเงิน'}`]"
>
<template v-slot:prepend>
<q-icon
@ -260,8 +272,11 @@
outlined
dense
class="full-width datepicker q-mb-md"
:model-value="date2Thai(dateAnnounce)"
:model-value="
dateAnnounce != null ? date2Thai(dateAnnounce) : null
"
:label="`${'วันประกาศผลสอบ'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันประกาศผลสอบ'}`]"
>
<template v-slot:prepend>
<q-icon
@ -669,8 +684,7 @@ const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const router = useRouter();
const route = useRoute();
const { date2Thai, success, dateToISO, notifyError, showLoader, hideLoader } =
mixin;
const { date2Thai, success, dateToISO, notifyError } = mixin;
const myForm = ref<QForm | null>(null); //form data input
const name = ref<string>("");
const note = ref<string>("");
@ -679,11 +693,11 @@ const announcementExam = ref<boolean>(true);
const fee = ref<number>(0);
const round = ref<number>(1);
const yearly = ref<number>(new Date().getFullYear());
const dateRegister = ref<[Date, Date]>([new Date(), new Date()]); //
const datePayment = ref<[Date, Date]>([new Date(), new Date()]); //
const dateAnnouncement = ref<[Date, Date]>([new Date(), new Date()]); //
const dateExam = ref<Date>(new Date()); //
const dateAnnounce = ref<Date>(new Date()); //
const dateRegister = ref<[Date, Date] | null>(null); //
const datePayment = ref<[Date, Date] | null>(null); //
const dateAnnouncement = ref<[Date, Date] | null>(null); //
const dateExam = ref<Date | null>(null); //
const dateAnnounce = ref<Date | null>(null); //
const positionPathOptions = ref<DataOption[]>([]);
const organizationShortName = ref<DataOption>({ id: "", name: "" });
const organizationName = ref<DataOption>({ id: "", name: "" });
@ -766,7 +780,7 @@ watch(organizationName, (count: DataOption, prevCount: DataOption) => {
});
onMounted(async () => {
hideLoader();
loaderPage(false);
if (route.params.id != undefined) {
edit.value = true;
id.value = route.params.id.toString();
@ -781,7 +795,7 @@ const clickBack = () => {
};
const fetchData = async () => {
showLoader();
loaderPage(true);
await http
.get(config.API.getPeriodById(id.value))
.then((res) => {
@ -794,22 +808,27 @@ const fetchData = async () => {
round.value = data.order;
yearly.value = data.year;
fee.value = data.fee;
dateAnnouncement.value = [
new Date(data.announcementStartDate),
new Date(data.announcementEndDate),
];
dateExam.value = new Date(data.examDate);
dateRegister.value = [
new Date(data.registerStartDate),
new Date(data.registerEndDate),
];
datePayment.value = [
new Date(data.paymentStartDate),
new Date(data.paymentEndDate),
];
dateAnnouncement.value =
data.announcementStartDate != null && data.announcementEndDate != null
? [
new Date(data.announcementStartDate),
new Date(data.announcementEndDate),
]
: null;
dateExam.value = data.examDate != null ? new Date(data.examDate) : null;
dateRegister.value =
data.registerStartDate != null && data.registerEndDate != null
? [new Date(data.registerStartDate), new Date(data.registerEndDate)]
: null;
datePayment.value =
data.paymentStartDate != null && data.paymentEndDate != null
? [new Date(data.paymentStartDate), new Date(data.paymentEndDate)]
: null;
editor.value = data.detail;
note.value = data.note;
dateAnnounce.value = new Date(data.announcementDate);
dateAnnounce.value =
data.announcementDate != null ? new Date(data.announcementDate) : null;
fileDocs.value = files;
fileImgs.value = images;
@ -818,7 +837,7 @@ const fetchData = async () => {
messageError($q, e);
})
.finally(() => {
hideLoader();
loaderPage(false);
});
};
@ -845,7 +864,7 @@ const uploadDocData = async () => {
fileDocDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
loaderPage(true);
await http
.put(config.API.periodRecruitDoc(id.value), formData)
.then((res) => {})
@ -853,7 +872,7 @@ const uploadDocData = async () => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
loaderPage(false);
success($q, "บันทึกข้อมูลสำเร็จ");
clickBack();
});
@ -869,7 +888,7 @@ const uploadImgData = async () => {
fileImgDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
loaderPage(true);
await http
.put(config.API.periodRecruitImg(id.value), formData)
.then((res) => {})
@ -877,7 +896,7 @@ const uploadImgData = async () => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
loaderPage(false);
});
}
};
@ -923,27 +942,38 @@ const checkSave = async () => {
const sendData = () => {
const valueData: RequestPeriodCompete = {
announcementEndDate: dateToISO(dateAnnouncement.value[1]),
announcementStartDate: dateToISO(dateAnnouncement.value[0]),
examDate: dateToISO(dateExam.value),
announcementEndDate:
dateAnnouncement.value !== null
? dateToISO(dateAnnouncement.value[1])
: null,
announcementStartDate:
dateAnnouncement.value !== null
? dateToISO(dateAnnouncement.value[0])
: null,
examDate: dateExam.value !== null ? dateToISO(dateExam.value) : null,
detail: editor.value,
fee: fee.value,
id: "",
name: name.value,
note: note.value,
paymentEndDate: dateToISO(datePayment.value[1]),
paymentStartDate: dateToISO(datePayment.value[0]),
registerEndDate: dateToISO(dateRegister.value[1]),
registerStartDate: dateToISO(dateRegister.value[0]),
paymentEndDate:
datePayment.value !== null ? dateToISO(datePayment.value[1]) : null,
paymentStartDate:
datePayment.value !== null ? dateToISO(datePayment.value[0]) : null,
registerEndDate:
dateRegister.value !== null ? dateToISO(dateRegister.value[1]) : null,
registerStartDate:
dateRegister.value !== null ? dateToISO(dateRegister.value[0]) : null,
order: round.value,
year: yearly.value,
announcementDate: dateToISO(dateAnnounce.value),
announcementDate:
dateAnnounce.value !== null ? dateToISO(dateAnnounce.value) : null,
};
return valueData;
};
const deleteDocData = async (docId: string) => {
showLoader();
loaderPage(true);
await http
.delete(config.API.periodDeleteDoc(docId))
.then(async () => {
@ -953,12 +983,12 @@ const deleteDocData = async (docId: string) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
loaderPage(false);
});
};
const deleteImgData = async (docId: string) => {
showLoader();
loaderPage(true);
await http
.delete(config.API.periodDeleteImg(docId))
.then(async () => {
@ -968,12 +998,12 @@ const deleteImgData = async (docId: string) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
loaderPage(false);
});
};
const addData = async () => {
showLoader();
loaderPage(true);
await http
.post(config.API.savePeriod, sendData())
.then(async (res) => {
@ -986,12 +1016,12 @@ const addData = async () => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
loaderPage(false);
});
};
const editData = async (id: string) => {
showLoader();
loaderPage(true);
await http
.put(config.API.editPeriod(id), sendData())
.then(async () => {
@ -1002,7 +1032,7 @@ const editData = async (id: string) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
loaderPage(false);
});
};