Refactoring code module 01_masterdata
This commit is contained in:
parent
82f5380f3e
commit
71be6d095f
22 changed files with 272 additions and 209 deletions
|
|
@ -1,16 +1,16 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import type { CompetencySumary } from "@/modules/01_masterdata/interface/index/Main";
|
||||
const $q = useQuasar();
|
||||
const { showLoader, hideLoader, dialogRemove, success, messageError } =
|
||||
useCounterMixin();
|
||||
const { messageError } = useCounterMixin();
|
||||
|
||||
const competencyTotal = ref<any[]>([
|
||||
const competencyTotal = ref<CompetencySumary[]>([
|
||||
{
|
||||
value: "HEAD",
|
||||
label: "สมรรถนะหลัก",
|
||||
|
|
@ -49,13 +49,17 @@ function getTotal() {
|
|||
.get(config.API.capacitySummary)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
competencyTotal.value.forEach((i) => {
|
||||
competencyTotal.value.forEach((i: CompetencySumary) => {
|
||||
const map = data.find((item: any) => item.type === i.value);
|
||||
if (map) i.total = map.total;
|
||||
});
|
||||
const totalSum = data.reduce((i: any, j: any) => i + +j.total, 0);
|
||||
competencyTotal.value.find((i) => i.value === "total").total =
|
||||
totalSum.toString();
|
||||
const totalItem = competencyTotal.value.find(
|
||||
(i: CompetencySumary) => i.value === "total"
|
||||
);
|
||||
if (totalItem) {
|
||||
totalItem.total = totalSum.toString();
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue