new loader

This commit is contained in:
Thanit Konmek 2023-06-09 14:25:41 +07:00
parent fd7aae2f5d
commit fe6c712a18
95 changed files with 1189 additions and 950 deletions

View file

@ -671,7 +671,15 @@ const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const router = useRouter();
const route = useRoute();
const { date2Thai, success, dateToISO, notifyError, messageError } = mixin;
const {
date2Thai,
success,
dateToISO,
notifyError,
messageError,
showLoader,
hideLoader,
} = mixin;
const myForm = ref<QForm | null>(null); //form data input
const name = ref<string>("");
const note = ref<string>("");
@ -719,7 +727,7 @@ onMounted(async () => {
if (route.params.id != undefined) {
edit.value = true;
id.value = route.params.id.toString();
loaderPage(false);
hideLoader();
await fetchData();
} else {
edit.value = false;
@ -731,7 +739,7 @@ const clickBack = () => {
};
const fetchData = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.getDisablePeriodById(id.value))
.then((res) => {
@ -764,7 +772,7 @@ const fetchData = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -808,7 +816,7 @@ const sendData = () => {
};
const addData = async () => {
loaderPage(true);
showLoader();
await http
.post(config.API.saveDisablePeriod, sendData())
.then(async (res) => {
@ -823,12 +831,12 @@ const addData = async () => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
};
const editData = async (id: string) => {
loaderPage(true);
showLoader();
await http
.put(config.API.editDisablePeriod(id), sendData())
.then(async () => {
@ -841,7 +849,7 @@ const editData = async (id: string) => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
};
@ -868,7 +876,7 @@ const uploadImgData = async () => {
fileImgDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
loaderPage(true);
showLoader();
await http
.put(config.API.periodExamImg(id.value), formData)
.then((res) => {})
@ -876,7 +884,7 @@ const uploadImgData = async () => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
}
};
@ -885,7 +893,7 @@ const deleteDocData = async (docId: string) => {
const params = {
documentId: docId,
};
loaderPage(true);
showLoader();
await http
.delete(config.API.periodExamDoc(id.value.toString()), {
params,
@ -898,7 +906,7 @@ const deleteDocData = async (docId: string) => {
})
.finally(async () => {
await fetchData();
loaderPage(false);
hideLoader();
});
};
@ -929,7 +937,7 @@ const uploadDocData = async () => {
fileDocDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
loaderPage(true);
showLoader();
await http
.put(config.API.periodExamDoc(id.value), formData)
.then((res) => {})
@ -937,7 +945,7 @@ const uploadDocData = async () => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
} else {
clickBack();