แก้ load ระบบ kpi

This commit is contained in:
Warunee Tamkoo 2024-05-02 16:13:34 +07:00
parent 1ae9e85af9
commit d642f663f3
4 changed files with 48 additions and 61 deletions

View file

@ -16,13 +16,20 @@ import { useKpiDataStore } from "@/modules/08_KPI/store";
import type { ListCriteria } from "@/modules/08_KPI/interface/request/index"; import type { ListCriteria } from "@/modules/08_KPI/interface/request/index";
const score = defineModel("score", { type: Number, default: 0 }); const indicatorScore = defineModel("indicatorScore", {
type: Number,
default: 0,
});
const competencyScore = defineModel("competencyScore", {
type: Number,
default: 0,
});
const dataListCriteria = ref<ListCriteria[]>([]); const dataListCriteria = ref<ListCriteria[]>([]);
const modalCriteria = ref<boolean>(false); const modalCriteria = ref<boolean>(false);
const $q = useQuasar(); const $q = useQuasar();
const route = useRoute(); const route = useRoute();
const { showLoader, hideLoader, messageError } = useCounterMixin(); const { hideLoader, messageError } = useCounterMixin();
const store = useKpiDataStore(); const store = useKpiDataStore();
const evaluationId = ref<string>(route.params.id.toString()); const evaluationId = ref<string>(route.params.id.toString());
@ -37,7 +44,6 @@ const totalResults3 = ref<number>(0);
// const resultWork = ref<number>(0); // const resultWork = ref<number>(0);
function fetchListPlanned() { function fetchListPlanned() {
showLoader();
http http
.get(config.API.kpiAchievement("planned") + `?id=${evaluationId.value}`) .get(config.API.kpiAchievement("planned") + `?id=${evaluationId.value}`)
.then((res) => { .then((res) => {
@ -64,14 +70,10 @@ function fetchListPlanned() {
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader();
}); });
} }
function fetchListRole() { function fetchListRole() {
showLoader();
http http
.get(config.API.kpiAchievement("role") + `?id=${evaluationId.value}`) .get(config.API.kpiAchievement("role") + `?id=${evaluationId.value}`)
.then((res) => { .then((res) => {
@ -98,14 +100,10 @@ function fetchListRole() {
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader();
}); });
} }
function fetchAssigned() { function fetchAssigned() {
showLoader();
http http
.get(config.API.kpiAchievement("special") + `?id=${evaluationId.value}`) .get(config.API.kpiAchievement("special") + `?id=${evaluationId.value}`)
.then((res) => { .then((res) => {
@ -133,9 +131,6 @@ function fetchAssigned() {
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader();
}); });
} }
@ -143,10 +138,9 @@ function onInfo() {
modalCriteria.value = true; modalCriteria.value = true;
} }
const totalCompetency = ref<number>(0);
const resultWork = computed(() => { const resultWork = computed(() => {
const total = totalResults1.value + totalResults2.value + totalResults3.value; const total = totalResults1.value + totalResults2.value + totalResults3.value;
score.value = total; indicatorScore.value = total;
return total.toFixed(2); return total.toFixed(2);
}); });
@ -159,25 +153,9 @@ function getCriteria() {
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
})
.finally(() => {
hideLoader();
}); });
} }
watch(
() => totalCompetency.value,
(newValue, oldValue) => {
if (newValue !== oldValue) {
score.value =
totalResults1.value +
totalResults2.value +
totalResults3.value +
newValue;
}
}
);
watch( watch(
() => store.dataEvaluation.plannedPoint, () => store.dataEvaluation.plannedPoint,
(newValue, oldValue) => { (newValue, oldValue) => {
@ -210,6 +188,9 @@ onMounted(() => {
fetchListPlanned(); fetchListPlanned();
fetchListRole(); fetchListRole();
fetchAssigned(); fetchAssigned();
setTimeout(() => {
hideLoader();
}, 1000);
}); });
</script> </script>
@ -286,7 +267,7 @@ onMounted(() => {
<Competency <Competency
v-model:dataListCriteria="dataListCriteria" v-model:dataListCriteria="dataListCriteria"
v-model:total-competency="totalCompetency" v-model:competencyScore="competencyScore"
/> />
</div> </div>
</q-scroll-area> </q-scroll-area>

View file

@ -12,8 +12,14 @@ import File from "@/modules/08_KPI/components/Tab/05_File.vue";
const store = useKpiDataStore(); const store = useKpiDataStore();
const route = useRoute(); const route = useRoute();
const isReadonly = <boolean>(route.name === "KPIEditEvaluator" ? true : false); const isReadonly = <boolean>(route.name === "KPIEditEvaluator" ? true : false);
const score = defineModel("score", { type: Number, default: 0 }); const indicatorScore = defineModel("indicatorScore", {
type: Number,
default: 0,
});
const competencyScore = defineModel("competencyScore", {
type: Number,
default: 0,
});
const itemsTab = ref<any>([ const itemsTab = ref<any>([
{ {
name: "1", name: "1",
@ -84,7 +90,11 @@ const splitterModel = ref<number>(12);
:name="tab.name" :name="tab.name"
class="q-pa-none" class="q-pa-none"
> >
<Assessment v-if="store.tabMain === '1'" v-model:score="score" /> <Assessment
v-if="store.tabMain === '1'"
v-model:indicatorScore="indicatorScore"
v-model:competencyScore="competencyScore"
/>
<Evaluator v-if="store.tabMain === '2'" :type="'evaluator'" /> <Evaluator v-if="store.tabMain === '2'" :type="'evaluator'" />
<Evaluator v-if="store.tabMain === '3'" :type="'commander'" /> <Evaluator v-if="store.tabMain === '3'" :type="'commander'" />
<Evaluator v-if="store.tabMain === '4'" :type="'commanderHigh'" /> <Evaluator v-if="store.tabMain === '4'" :type="'commanderHigh'" />

View file

@ -18,7 +18,7 @@ import type {
const dataListCriteria = defineModel<ListCriteria[]>("dataListCriteria", { const dataListCriteria = defineModel<ListCriteria[]>("dataListCriteria", {
required: true, required: true,
}); });
const totalCompetency = defineModel("totalCompetency", { const competencyScore = defineModel("competencyScore", {
type: Number, type: Number,
default: 0, default: 0,
}); });
@ -118,7 +118,6 @@ const lists = ref<any>([]);
const resultEvaluation = ref<string | 0>(0); const resultEvaluation = ref<string | 0>(0);
function getData(type: string) { function getData(type: string) {
showLoader();
http http
.get(config.API.kpiUserCapacity + `?id=${id.value}&type=${type}`) .get(config.API.kpiUserCapacity + `?id=${id.value}&type=${type}`)
.then(async (res) => { .then(async (res) => {
@ -163,11 +162,8 @@ function getData(type: string) {
? (resultAvg / weightAvg) * store.dataEvaluation.capacityPoint ? (resultAvg / weightAvg) * store.dataEvaluation.capacityPoint
: 0; : 0;
resultEvaluation.value = sum.toFixed(2); resultEvaluation.value = sum.toFixed(2);
totalCompetency.value = sum; competencyScore.value = sum;
} }
// end cal summary
hideLoader();
}); });
} }

View file

@ -49,7 +49,8 @@ const commanderHighMainOp = ref<DataOptions[]>([]);
const evaluatorId = ref<any>(null); const evaluatorId = ref<any>(null);
const commanderId = ref<any>(null); const commanderId = ref<any>(null);
const commanderHighId = ref<any>(null); const commanderHighId = ref<any>(null);
const score = ref<number>(0); const indicatorScore = ref<number>(0);
const competencyScore = ref<number>(0);
const formProfile = reactive<FormProfile>({ const formProfile = reactive<FormProfile>({
fullName: "", fullName: "",
@ -65,7 +66,6 @@ const formProfile = reactive<FormProfile>({
const router = useRouter(); const router = useRouter();
function fetchEvaluation() { function fetchEvaluation() {
showLoader();
http http
.get(config.API.kpiEvaluation + `/${id.value}`) .get(config.API.kpiEvaluation + `/${id.value}`)
.then((res) => { .then((res) => {
@ -83,14 +83,13 @@ function fetchEvaluation() {
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
})
.finally(() => {
hideLoader();
}); });
// .finally(() => {
// hideLoader();
// });
} }
function getProfile() { function getProfile() {
showLoader();
http http
.get(config.API.profilePosition()) .get(config.API.profilePosition())
.then((res) => { .then((res) => {
@ -106,14 +105,13 @@ function getProfile() {
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
})
.finally(() => {
hideLoader();
}); });
// .finally(() => {
// hideLoader();
// });
} }
async function fetchProfile(id: string) { async function fetchProfile(id: string) {
showLoader();
await http await http
.get( .get(
config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`) config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`)
@ -123,9 +121,6 @@ async function fetchProfile(id: string) {
}) })
.catch(() => { .catch(() => {
// profilePicture.value = avatar; // profilePicture.value = avatar;
})
.finally(() => {
hideLoader();
}); });
} }
@ -251,9 +246,10 @@ watch(
} else { } else {
scoreTotal.value = true; scoreTotal.value = true;
} }
} else {
console.log(2);
} }
// else {
// console.log(2);
// }
} }
); );
@ -296,8 +292,9 @@ async function getAll() {
await getOrgOp(); await getOrgOp();
} }
onMounted(() => { onMounted(async () => {
getAll(); showLoader();
await getAll();
}); });
</script> </script>
@ -441,7 +438,7 @@ onMounted(() => {
<div class="column"> <div class="column">
<span class="text-grey-6">คะแนนประเม</span> <span class="text-grey-6">คะแนนประเม</span>
<span class="text-weight-medium text-primary">{{ <span class="text-weight-medium text-primary">{{
score.toFixed(2) (indicatorScore + competencyScore).toFixed(2)
}}</span> }}</span>
</div> </div>
</div> </div>
@ -452,7 +449,10 @@ onMounted(() => {
</q-card> </q-card>
<q-card class="q-mt-md rounded"> <q-card class="q-mt-md rounded">
<TabMain v-model:score="score" /> <TabMain
v-model:indicatorScore="indicatorScore"
v-model:competencyScore="competencyScore"
/>
</q-card> </q-card>
</div> </div>
</div> </div>