แก้ไข loader

This commit is contained in:
Thanit Konmek 2023-08-04 10:04:59 +07:00
parent f072224851
commit b663eedb09
147 changed files with 3095 additions and 3256 deletions

View file

@ -121,19 +121,19 @@ import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import type { RecruitDetailResponse } from "@/modules/03_recruiting/interface/response/Period";
import Table from "@/modules/03_recruiting/components/Table.vue";
import { useDataStore } from "@/stores/data";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
const $q = useQuasar();
const dataStore = useDataStore();
const router = useRouter();
const route = useRoute();
const { loaderPage } = dataStore;
const mixin = useCounterMixin();
const { messageError, success } = mixin;
const { messageError, success, showLoader, hideLoader } = mixin;
const year = ref<string>("");
const round = ref<string>("");
const name = ref<string>("");
@ -365,7 +365,7 @@ const columns = ref<QTableProps["columns"]>([
]);
onMounted(async () => {
loaderPage(false);
hideLoader();
await fetchData();
});
@ -374,7 +374,7 @@ const clickDetail = (examID: string) => {
};
const downloadExam = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.exportExam(importId.value), {
responseType: "blob",
@ -390,12 +390,12 @@ const downloadExam = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
const downloadPassExam = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.exportPassExam(importId.value), {
responseType: "blob",
@ -411,12 +411,12 @@ const downloadPassExam = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
const downloadPassResultExam = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.exportPassResultExam(importId.value), {
responseType: "blob",
@ -432,12 +432,12 @@ const downloadPassResultExam = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
const fetchData = async () => {
loaderPage(true);
showLoader();
await http
.post(config.API.getExamResultById(importId.value), {
examAttribute: "",
@ -474,7 +474,7 @@ const fetchData = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -489,7 +489,7 @@ const candidateToPlacement = async () => {
persistent: true,
})
.onOk(async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.periodRecruitToPlacement(importId.value))
.then((res) => {
@ -499,7 +499,7 @@ const candidateToPlacement = async () => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
router.go(-1);
});
})

View file

@ -236,17 +236,17 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useDataStore } from "@/stores/data";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
const $q = useQuasar();
const dataStore = useDataStore();
const router = useRouter();
const route = useRoute();
const { loaderPage } = dataStore;
const profile_id = ref<string>("");
const birthdate = ref<string>("");
const gender = ref<string>("");
@ -269,7 +269,7 @@ const examOrder = ref<string>("");
const number = ref<string>("");
const score_expired = ref<string>("");
const mixin = useCounterMixin();
const { messageError } = mixin;
const { messageError, showLoader, hideLoader } = mixin;
const examID = ref<string>("62150001");
const prefix = ref<string>("นาย");
const fullname = ref<string>("เกียรติศักดิ์ บัณฑิต");
@ -281,7 +281,7 @@ onMounted(async () => {
});
const fetchData = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.getExamDetail(importId.value, examId.value))
.then((res) => {
@ -319,12 +319,12 @@ const fetchData = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
const downloadScore = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.downloadScoreReport(importId.value, examId.value), {
responseType: "blob",
@ -340,12 +340,12 @@ const downloadScore = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
const downloadCertificate = async () => {
loaderPage(true);
showLoader();
let type = degree.value.includes("บัณฑิต") ? 2 : 1;
await http
.get(config.API.downloadExamReport(importId.value, examId.value, type), {
@ -362,7 +362,7 @@ const downloadCertificate = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
</script>

File diff suppressed because it is too large Load diff

View file

@ -806,15 +806,14 @@ import type {
} from "@/modules/02_organizational/interface/index/Main";
import http from "@/plugins/http";
import config from "@/app.config";
import { useDataStore } from "@/stores/data";
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const router = useRouter();
const route = useRoute();
const { date2Thai, success, dateToISO, notifyError } = mixin;
const { date2Thai, success, dateToISO, notifyError, showLoader, hideLoader } = mixin;
const myForm = ref<QForm | null>(null); //form data input
const name = ref<string>("");
const note = ref<string>("");
@ -925,7 +924,7 @@ watch(organizationName, (count: DataOption, prevCount: DataOption) => {
});
onMounted(async () => {
loaderPage(false);
hideLoader();
if (route.params.id != undefined) {
edit.value = true;
id.value = route.params.id.toString();
@ -940,7 +939,7 @@ const clickBack = () => {
};
const fetchData = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.getPeriodById(id.value))
.then((res) => {
@ -992,7 +991,7 @@ const fetchData = async () => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -1019,7 +1018,7 @@ const uploadDocData = async () => {
fileDocDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
loaderPage(true);
showLoader();
await http
.put(config.API.periodRecruitDoc(id.value), formData)
.then((res) => {})
@ -1027,7 +1026,7 @@ const uploadDocData = async () => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
success($q, "บันทึกข้อมูลสำเร็จ");
clickBack();
});
@ -1043,7 +1042,7 @@ const uploadImgData = async () => {
fileImgDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
loaderPage(true);
showLoader();
await http
.put(config.API.periodRecruitImg(id.value), formData)
.then((res) => {})
@ -1051,7 +1050,7 @@ const uploadImgData = async () => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
}
};
@ -1132,7 +1131,7 @@ const sendData = () => {
};
const deleteDocData = async (docId: string) => {
loaderPage(true);
showLoader();
await http
.delete(config.API.periodDeleteDoc(docId))
.then(async () => {
@ -1142,12 +1141,12 @@ const deleteDocData = async (docId: string) => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
};
const deleteImgData = async (docId: string) => {
loaderPage(true);
showLoader();
await http
.delete(config.API.periodDeleteImg(docId))
.then(async () => {
@ -1157,12 +1156,12 @@ const deleteImgData = async (docId: string) => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
};
const addData = async () => {
loaderPage(true);
showLoader();
await http
.post(config.API.savePeriod, sendData())
.then(async (res) => {
@ -1175,12 +1174,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.editPeriod(id), sendData())
.then(async () => {
@ -1191,7 +1190,7 @@ const editData = async (id: string) => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
};