From db757a65bba449bd8102ca0280cd3835ca61b63e Mon Sep 17 00:00:00 2001 From: Eko Haryadi Date: Thu, 4 Apr 2024 21:34:42 +0700 Subject: [PATCH] Update function to handle edge case --- .../Pages/Gangguan/Rekap/RGangguan_ALL.vue | 320 ++++++++++++++++-- 1 file changed, 291 insertions(+), 29 deletions(-) diff --git a/src/components/Pages/Gangguan/Rekap/RGangguan_ALL.vue b/src/components/Pages/Gangguan/Rekap/RGangguan_ALL.vue index 30eb498..6bb3634 100755 --- a/src/components/Pages/Gangguan/Rekap/RGangguan_ALL.vue +++ b/src/components/Pages/Gangguan/Rekap/RGangguan_ALL.vue @@ -70,6 +70,36 @@ css-class="custom-table-column" cell-template="formatDPT" /> + + + + + + @@ -229,7 +320,8 @@ :show-in-group-footer="false" :align-by-column="true" column="total_selesai" - summary-type="sum" + name="total_selesai" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -237,23 +329,17 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_selesai" - summary-type="avg" + name="persen_selesai" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> - @@ -261,7 +347,8 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_inproses" - summary-type="avg" + name="persen_inproses" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> @@ -269,7 +356,26 @@ :show-in-group-footer="false" :align-by-column="true" column="avg_durasi_dispatch" - summary-type="avg" + name="avg_durasi_dispatch" + summary-type="custom" + css-class="!text-right" + :customize-text="(e: any) => formatNumber(e.value)" + /> + + @@ -310,7 +416,26 @@ :show-in-group-footer="false" :align-by-column="true" column="avg_durasi_response" - summary-type="avg" + name="avg_durasi_response" + summary-type="custom" + css-class="!text-right" + :customize-text="(e: any) => formatNumber(e.value)" + /> + + @@ -350,7 +475,26 @@ :show-in-group-footer="false" :align-by-column="true" column="avg_durasi_recovery" - summary-type="avg" + name="avg_durasi_recovery" + summary-type="custom" + css-class="!text-right" + :customize-text="(e: any) => formatNumber(e.value)" + /> + + @@ -804,21 +948,139 @@ const setAgreementDialog = (column: string) => { } } +let total = 0 +let total_selesai = 0 +let total_inproses = 0 +let count_durasi_dispatch = 0 +let total_durasi_dispatch = 0 +let count_durasi_response = 0 +let total_durasi_response = 0 +let count_durasi_recovery = 0 +let total_durasi_recovery = 0 const calculateCustomSummary = (options: any) => { - if (options.name == 'persenSelesai') { - console.log(options.component.persen_selesai) + if (options.name === 'total') { + if (options.summaryProcess === 'calculate') { + total += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total + } + } - switch (options.summaryProcess) { - case 'start': - // Initializing "totalValue" here - options.totalValue = 1 - break - case 'calculate': - // Modifying "totalValue" here - break - case 'finalize': - // Assigning the final value to "totalValue" here - break + if (options.name === 'total_selesai') { + if (options.summaryProcess === 'calculate') { + total_selesai += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_selesai + } + } + + if (options.name === 'total_inproses') { + if (options.summaryProcess === 'calculate') { + total_inproses += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_inproses + } + } + + if (options.name === 'persen_selesai') { + if (options.summaryProcess === 'start') { + total = 0 + total_selesai = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = (total_selesai / total) * 100 + } + } + + if (options.name === 'persen_inproses') { + if (options.summaryProcess === 'start') { + total = 0 + total_inproses = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = (total_inproses / total) * 100 + } + } + + if (options.name === 'persen_selesai') { + if (options.summaryProcess === 'start') { + total = 0 + total_selesai = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = (total_selesai / total) * 100 + } + } + + if (options.name === 'count_durasi_dispatch') { + if (options.summaryProcess === 'calculate') { + count_durasi_dispatch += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = count_durasi_dispatch + } + } + + if (options.name === 'total_durasi_dispatch') { + if (options.summaryProcess === 'calculate') { + total_durasi_dispatch += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_durasi_dispatch + } + } + + if (options.name === 'avg_durasi_dispatch') { + if (options.summaryProcess === 'start') { + count_durasi_dispatch = 0 + total_durasi_dispatch = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_durasi_dispatch / count_durasi_dispatch + } + } + + if (options.name === 'count_durasi_response') { + if (options.summaryProcess === 'calculate') { + count_durasi_response += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = count_durasi_response + } + } + + if (options.name === 'total_durasi_response') { + if (options.summaryProcess === 'calculate') { + total_durasi_response += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_durasi_response + } + } + + if (options.name === 'avg_durasi_response') { + if (options.summaryProcess === 'start') { + count_durasi_response = 0 + total_durasi_response = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_durasi_response / count_durasi_response + } + } + + if (options.name === 'count_durasi_recovery') { + if (options.summaryProcess === 'calculate') { + count_durasi_recovery += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = count_durasi_recovery + } + } + + if (options.name === 'total_durasi_recovery') { + if (options.summaryProcess === 'calculate') { + total_durasi_recovery += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_durasi_recovery + } + } + + if (options.name === 'avg_durasi_recovery') { + if (options.summaryProcess === 'start') { + count_durasi_recovery = 0 + total_durasi_recovery = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = total_durasi_recovery / count_durasi_recovery } } }