diff --git a/src/modules/14_KPI/components/Tab/01_Assessment.vue b/src/modules/14_KPI/components/Tab/01_Assessment.vue index fcc0573ee..c8bb6abff 100644 --- a/src/modules/14_KPI/components/Tab/01_Assessment.vue +++ b/src/modules/14_KPI/components/Tab/01_Assessment.vue @@ -21,7 +21,7 @@ const dataListCriteria = ref([]); const modalCriteria = ref(false); const $q = useQuasar(); const route = useRoute(); -const { messageError } = useCounterMixin(); +const { messageError, showLoader, hideLoader } = useCounterMixin(); const store = useKpiDataStore(); const evaluationId = ref(route.params.id.toString()); @@ -42,11 +42,11 @@ const resultPlanned = ref(0); const resultRole = ref(0); const resultAssigned = ref(0); -function fetchListPlanned() { - http +async function fetchListPlanned() { + await http .get(config.API.kpiAchievement("planned") + `?id=${evaluationId.value}`) - .then((res) => { - const data = res.data.result; + .then(async (res) => { + const data = await res.data.result; const newRow = data.map((e: any) => ({ ...e, evaluationResults: (e.point / 5) * e.weight, @@ -78,11 +78,11 @@ function fetchListPlanned() { }); } -function fetchListRole() { - http +async function fetchListRole() { + await http .get(config.API.kpiAchievement("role") + `?id=${evaluationId.value}`) - .then((res) => { - const data = res.data.result; + .then(async (res) => { + const data = await res.data.result; const newRow = data.map((e: any) => ({ ...e, evaluationResults: (e.point / 5) * e.weight, @@ -108,11 +108,11 @@ function fetchListRole() { }); } -function fetchAssigned() { - http +async function fetchAssigned() { + await http .get(config.API.kpiAchievement("special") + `?id=${evaluationId.value}`) - .then((res) => { - const data = res.data.result; + .then(async (res) => { + const data = await res.data.result; const newRow = data.map((e: any) => ({ ...e, evaluationResults: (e.point / 5) * e.weight, @@ -146,11 +146,11 @@ function fetchAssigned() { }); } -function getCriteria() { - http +async function getCriteria() { + await http .get(config.API.KpiEvaluationInfo) - .then((res) => { - const data = res.data.result.data; + .then(async (res) => { + const data = await res.data.result.data; dataListCriteria.value = data; }) .catch((e) => { @@ -206,12 +206,17 @@ watch( ); onMounted(async () => { + showLoader(); await Promise.all([ getCriteria(), fetchListPlanned(), fetchListRole(), fetchAssigned(), - ]); + ]).finally(() => { + setTimeout(() => { + hideLoader(); + }, 1000); + }); }); diff --git a/src/modules/14_KPI/components/Tab/04_Result.vue b/src/modules/14_KPI/components/Tab/04_Result.vue index a2f529859..de5b6d351 100644 --- a/src/modules/14_KPI/components/Tab/04_Result.vue +++ b/src/modules/14_KPI/components/Tab/04_Result.vue @@ -54,10 +54,9 @@ function onSubmit() { timeEvaluator: developmentPeriod.value, reasonEvaluator: evaluatorComment.value, }) - .then((res) => { + .then(async () => { + await Promise.all([fetchEvaluation(), getData()]); success($q, "บันทึกข้อมูลสำเร็จ"); - fetchEvaluation(); - getData(); }) .catch((e) => { messageError($q, e); @@ -79,10 +78,9 @@ function onSubmitCommander() { isReason: superiorCommentCheck.value == "true" ? true : false, reason: superiorComment.value, }) - .then((res) => { + .then(async () => { + await Promise.all([fetchEvaluation(), getData()]); success($q, "บันทึกข้อมูลสำเร็จ"); - fetchEvaluation(); - getData(); }) .catch((e) => { messageError($q, e); @@ -93,6 +91,7 @@ function onSubmitCommander() { }); } } + function onSubmitCommanderHigh() { if (additionalSuperiorCheck.value == "") { dialogMessageNotify($q, "กรุณาเลือกความคิดเห็น"); @@ -104,10 +103,9 @@ function onSubmitCommanderHigh() { isReason: additionalSuperiorCheck.value == "true" ? true : false, reason: additionalSuperiorComment.value, }) - .then((res) => { + .then(async () => { + await Promise.all([fetchEvaluation(), getData()]); success($q, "บันทึกข้อมูลสำเร็จ"); - fetchEvaluation(); - getData(); }) .catch((e) => { messageError($q, e); @@ -157,16 +155,15 @@ async function fetchEvaluation() { } function userOpen() { - http.get(config.API.openPoint(id.value)).then(async (res) => { - // success($q, "เปิดการประเมินสำเร็จ"); - }); + http.get(config.API.openPoint(id.value)).then(async () => {}); } -function getData() { - http +async function getData() { + showLoader(); + await http .get(config.API.kpiSendToGet(id.value)) - .then((res) => { - const data = res.data.result; + .then(async (res) => { + const data = await res.data.result; title.value = data.topicEvaluator; developmentMethod.value = data.developEvaluator; developmentPeriod.value = data.timeEvaluator; @@ -175,9 +172,7 @@ function getData() { data.isReasonCommander != null ? data.isReasonCommander.toString() : null; - superiorComment.value = data.reasonCommander; - additionalSuperiorCheck.value = data.isReasonCommanderHigh != null ? data.isReasonCommanderHigh.toString() @@ -194,16 +189,13 @@ function getData() { .catch((e) => { messageError($q, e); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); } -onMounted(() => { - showLoader(); - Promise.all([fetchEvaluation(), getData()]).finally(() => { - setTimeout(() => { - hideLoader(); - }, 3000); - }); +onMounted(async () => { + await Promise.all([fetchEvaluation(), getData()]); }); diff --git a/src/modules/14_KPI/views/detailView.vue b/src/modules/14_KPI/views/detailView.vue index 97530190c..ced26c6e5 100644 --- a/src/modules/14_KPI/views/detailView.vue +++ b/src/modules/14_KPI/views/detailView.vue @@ -164,7 +164,7 @@ function onSubmit() { } async function getOrgOp() { - http + await http .get(config.API.Kpiorg + `/${store.dataProfile.profileId}`) .then((res) => { const data = res.data.result; @@ -202,8 +202,7 @@ async function getOrgOp() { }) .catch((e) => { messageError($q, e); - }) - .finally(() => {}); + }); } function filterOption(val: any, update: Function, refData: string) { @@ -240,19 +239,13 @@ async function getProfile() { .then(async (res) => { const data = await res.data.result; store.dataProfile = await data; - setTimeout(() => { - store.checkStep(); - }, 1000); + store.checkStep(); }) .catch((e) => { messageError($q, e); }); } -async function getAll() { - await fetchEvaluation(); -} - function sendToEvaluatore() { dialogConfirm( $q, @@ -337,6 +330,7 @@ function requireEdit() { function openGovernment() { modalGovernment.value = true; } + function openStatus() { router.push(`/probation-detail/${store.dataEvaluation.profileId}`); } @@ -350,7 +344,7 @@ function sendToEvauator() { id: [store.dataEvaluation.id], }) .then(async () => { - await getAll(); + await fetchEvaluation(); store.tabMain = "3"; }) .catch((e) => { @@ -369,7 +363,7 @@ function goToSummary() { showLoader(); http .get(config.API.sendToSummary(store.dataEvaluation.id)) - .then(async (res) => { + .then(async () => { await fetchEvaluation(); store.tabMain = "4"; store.tabOpen = 4; @@ -435,8 +429,8 @@ async function fetchProfileEvaluator(id: string) { } onMounted(async () => { - store.isUpdate = await false; - await getAll(); + store.isUpdate = false; + await fetchEvaluation(); }); onUnmounted(() => { diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 2b12ae178..6be7fd209 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -243,7 +243,6 @@ onMounted(async () => { } await fetchmsgNoread(); - // await getDataNotification(1, "NOMAL"); myEventHandler(null, false); window.addEventListener("resize", (e: any) => { myEventHandler(e, true); @@ -328,14 +327,10 @@ const tagClick = (tag: string) => { const hash = `#${tag}`; const items = document.getElementById(tag); const offset = Math.max(0, items == null ? 0 : items.offsetTop - 84); - // router.replace({ hash }); + if (route.hash !== hash) { const check = activeBtn(); if (check) { - // router.replace({ hash, position: { x: 0, y: 0 } }); - // router.replace({ hash }).then(() => { - // setVerticalScrollPosition(window, offset, 300); - // }); drawerR.value = !drawerR.value; setVerticalScrollPosition(window, offset, 300); } else { @@ -498,8 +493,8 @@ const handleButtonClick = () => { /** * function fetch รายการเมนูทั้งหมด */ -function fetchSys() { - http +async function fetchSys() { + await http .get(config.API.orgPermissions) .then((res) => { storeMenu.fetchListMenu(res.data.result); @@ -512,8 +507,8 @@ function fetchSys() { /** * function fetch รายการเมนูทั้งหมด */ -function fetchPermissionsSys() { - http +async function fetchPermissionsSys() { + await http .get(config.API.orgPermissionsSys) .then((res) => { storeMenu.fetchDataPermission(res.data.result);