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

View file

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