convertDate

This commit is contained in:
setthawutttty 2025-03-11 16:58:29 +07:00
parent b589f98bf1
commit c9ce8482b3
2 changed files with 12 additions and 4 deletions

View file

@ -34,6 +34,7 @@ const {
dialogConfirm, dialogConfirm,
dialogMessageNotify, dialogMessageNotify,
onSearchDataTable, onSearchDataTable,
convertDatetimeToAPI,
} = useCounterMixin(); } = useCounterMixin();
const { const {
getSchedule, getSchedule,
@ -64,6 +65,7 @@ const formDataschedule = ref<ScheduleCreate>({
name: "", name: "",
time: "", time: "",
schedule: "", schedule: "",
startAt: new Date(),
}); });
/** /**
@ -203,10 +205,16 @@ function onSubmit() {
dialogConfirm($q, async () => { dialogConfirm($q, async () => {
showLoader(); showLoader();
if (typeOnSubmit.value === "create") { if (typeOnSubmit.value === "create") {
await createSchedule(formDataschedule.value); await createSchedule({
...formDataschedule.value,
startAt: convertDatetimeToAPI(formDataschedule.value.startAt as Date),
});
} }
if (typeOnSubmit.value === "edit") { if (typeOnSubmit.value === "edit") {
await editSchedule(idEditSchedule.value, formDataschedule.value); await editSchedule(idEditSchedule.value, {
...formDataschedule.value,
startAt: convertDatetimeToAPI(formDataschedule.value.startAt as Date),
});
} }
getSchedule(); getSchedule();
hideLoader(); hideLoader();
@ -476,7 +484,7 @@ onMounted(async () => {
if (formDataschedule.startAt !== undefined) { if (formDataschedule.startAt !== undefined) {
formDataschedule.startAt = new Date( formDataschedule.startAt = new Date(
formDataschedule.startAt formDataschedule.startAt as Date
).toISOString(); ).toISOString();
} }
convertFormToCron(); convertFormToCron();

View file

@ -7,7 +7,7 @@ interface ScheduleCreate {
type: string; type: string;
date: string[]; date: string[];
schedule: string; schedule: string;
startAt?: string; startAt?: Date|null|string;
enabled?: boolean; enabled?: boolean;
} }