From 46f1b8353c19742ddf30fa716e4a2146686f0200 Mon Sep 17 00:00:00 2001 From: kur0nek-o Date: Thu, 18 Apr 2024 09:42:15 +0700 Subject: [PATCH] fix: anomali gangguan --- .../Anomali/Gangguan/Anomali_LAPPGP_LPT.vue | 12 +- .../Pages/Anomali/Gangguan/Anomali_LAPPGU.vue | 56 +++ .../Anomali/Gangguan/Anomali_LAPPGU_LPT.vue | 380 +++++++++++++++--- 3 files changed, 385 insertions(+), 63 deletions(-) diff --git a/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGP_LPT.vue b/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGP_LPT.vue index eab9e8b..ff003d1 100755 --- a/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGP_LPT.vue +++ b/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGP_LPT.vue @@ -349,7 +349,7 @@ column="anomali_pln_mobile_marking" name="anomali_pln_mobile_marking" summary-type="custom" - css-class="!text-right" + css-class="!text-right cursor-pointer" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -60,11 +61,66 @@ const resetData = () => { dataSecond.value = [] } +const grouping = ref([ + { + data: '', + caption: 'Semua Unit' + }, + { + data: 'nama_uid', + caption: 'UID' + }, + { + data: 'nama_up3', + caption: 'UP3' + } +]) + const filterData = async (params: any) => { resetData() const { ulp, uid, up3, jenisLaporan } = params console.table('LAPPGU', jenisLaporan) + var groupList: any[] = [ + { + data: '', + caption: 'Semua Unit' + }, + { + data: 'nama_uid', + caption: 'UID' + }, + { + data: 'nama_up3', + caption: 'UP3' + } + ] + + if (uid?.id != 0) { + groupList.forEach((item, index) => { + if (item.caption == 'Semua Unit') { + groupList.splice(index, 1) + } + }) + + if (up3?.id != 0) { + groupList.forEach((item, index) => { + if (item.caption == 'UID') { + groupList.splice(index, 1) + } + }) + + if (ulp?.id != 0) { + groupList.forEach((item, index) => { + if (item.caption == 'UP3') { + groupList.splice(index, 1) + } + }) + } + } + } + grouping.value = groupList + const dateValue = params.periode.split(' s/d ') const query = { dateFrom: dateValue[0] diff --git a/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGU_LPT.vue b/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGU_LPT.vue index 76d5f2c..4d62093 100755 --- a/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGU_LPT.vue +++ b/src/components/Pages/Anomali/Gangguan/Anomali_LAPPGU_LPT.vue @@ -4,6 +4,7 @@ - + @@ -44,35 +45,15 @@ /> - - @@ -400,12 +381,13 @@

- + @@ -413,7 +395,8 @@ :show-in-group-footer="false" :align-by-column="true" column="wo_pln_mobile" - summary-type="sum" + name="wo_pln_mobile" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -421,7 +404,8 @@ :show-in-group-footer="false" :align-by-column="true" column="wo_loket" - summary-type="sum" + name="wo_loket" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -429,7 +413,8 @@ :show-in-group-footer="false" :align-by-column="true" column="wo_lainnya" - summary-type="sum" + summary-type="custom" + name="wo_lainnya" css-class="!text-right" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -437,7 +422,8 @@ :show-in-group-footer="false" :align-by-column="true" column="wo_total" - summary-type="sum" + name="wo_total" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -445,55 +431,62 @@ :show-in-group-footer="false" :align-by-column="true" column="anomali_pln_mobile_marking" - summary-type="sum" - css-class="!text-right" + name="anomali_pln_mobile_marking" + summary-type="custom" + css-class="!text-right cursor-pointer" :customize-text="(e: any) => formatNumber(e.value)" /> @@ -501,7 +494,8 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_anomali_pln_mobile_non_marking" - summary-type="avg" + name="persen_anomali_pln_mobile_non_marking" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> @@ -509,7 +503,8 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_anomali_cc123_marking" - summary-type="avg" + name="persen_anomali_cc123_marking" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> @@ -517,7 +512,8 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_anomali_cc123_non_marking" - summary-type="avg" + name="persen_anomali_cc123_non_marking" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> @@ -525,7 +521,8 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_anomali_marking" - summary-type="avg" + name="persen_anomali_marking" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> @@ -533,7 +530,8 @@ :show-in-group-footer="false" :align-by-column="true" column="persen_anomali_non_marking" - summary-type="avg" + name="persen_anomali_non_marking" + summary-type="custom" css-class="!text-right" :customize-text="(e: any) => formatPercentage(e.value)" /> @@ -1077,6 +1075,7 @@ import { exportDetailToDOCX } from '@/report/Anomali/Gangguan/Anomali_LAPPGU_LPT' import BufferDialog from '@/components/Dialogs/BufferDialog.vue' +import { getDataRowGroup } from '@/utils/helper' const position = { of: '#data' } const showIndicator = ref(true) @@ -1085,7 +1084,11 @@ const showPane = ref(true) const props = defineProps({ data: Array as () => any[], filters: Object as () => any, - loadingData: Boolean + loadingData: Boolean, + grouping: { + type: Array as () => any[], + default: [] + } }) const emit = defineEmits(['update:loadingSubData']) const filters = ref(computed(() => props.filters)) @@ -1102,6 +1105,9 @@ const parameterRequest = ref({ media: null, marking: null }) +const groupDialog = ref(false) +const groupData = ref(null) +const groupIndex = ref(0) const setParameterRequest = (data: any) => { parameterRequest.value = data @@ -1113,6 +1119,234 @@ const setParameterRequest = (data: any) => { } } +const onCellClicked = (e: any) => { + if (e.rowType == 'group') { + groupDialog.value = true + groupIndex.value = e.row.groupIndex + + if (e.column.dataField == 'anomali_pln_mobile_marking') { + setParameterRequest({ media: 'PLN Mobile', marking: 1 }) + } else if (e.column.dataField == 'anomali_pln_mobile_non_marking') { + setParameterRequest({ media: 'PLN Mobile', marking: 2 }) + } else if (e.column.dataField == 'anomali_cc123_marking') { + setParameterRequest({ media: 'Call PLN 123', marking: 1 }) + } else if (e.column.dataField == 'anomali_cc123_non_marking') { + setParameterRequest({ media: 'Call PLN 123', marking: 2 }) + } else if (e.column.dataField == 'total_anomali_marking') { + setParameterRequest({ media: '', marking: 1 }) + } else if (e.column.dataField == 'total_anomali_non_marking') { + setParameterRequest({ media: '', marking: 2 }) + } else { + setParameterRequest({ media: null, marking: null }) + } + groupData.value = getDataRowGroup(e.data) + showDetail() + } else { + groupDialog.value = false + } +} + +let wo_cc123 = 0 +let wo_pln_mobile = 0 +let wo_loket = 0 +let wo_lainnya = 0 +let wo_total = 0 +let anomali_pln_mobile_marking = 0 +let anomali_pln_mobile_non_marking = 0 +let anomali_cc123_marking = 0 +let anomali_cc123_non_marking = 0 +let total_anomali_marking = 0 +let total_anomali_non_marking = 0 +let persen_anomali_pln_mobile_marking = 0 +let persen_anomali_pln_mobile_non_marking = 0 +let persen_anomali_cc123_marking = 0 +let persen_anomali_cc123_non_marking = 0 +let persen_anomali_marking = 0 +let persen_anomali_non_marking = 0 + +const calculateCustomSummary = (options: any) => { + if (options.name === 'wo_cc123') { + if (options.summaryProcess === 'calculate') { + wo_cc123 += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = wo_cc123 + } + } + + if (options.name === 'wo_pln_mobile') { + if (options.summaryProcess === 'calculate') { + wo_pln_mobile += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = wo_pln_mobile + } + } + + if (options.name === 'wo_loket') { + if (options.summaryProcess === 'calculate') { + wo_loket += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = wo_loket + } + } + + if (options.name === 'wo_lainnya') { + if (options.summaryProcess === 'calculate') { + wo_lainnya += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = wo_lainnya + } + } + + if (options.name === 'wo_total') { + if (options.summaryProcess === 'start') { + wo_cc123 = 0 + wo_pln_mobile = 0 + wo_loket = 0 + wo_lainnya = 0 + } else if (options.summaryProcess === 'calculate') { + wo_total = wo_cc123 + wo_pln_mobile + wo_loket + wo_lainnya + } else if (options.summaryProcess === 'finalize') { + options.totalValue = wo_cc123 + wo_pln_mobile + wo_loket + wo_lainnya + } + } + + if (options.name === 'anomali_pln_mobile_marking') { + if (options.summaryProcess === 'calculate') { + anomali_pln_mobile_marking += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = anomali_pln_mobile_marking + } + } + + if (options.name === 'anomali_pln_mobile_non_marking') { + if (options.summaryProcess === 'calculate') { + anomali_pln_mobile_non_marking += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = anomali_pln_mobile_non_marking + } + } + + if (options.name === 'anomali_cc123_marking') { + if (options.summaryProcess === 'calculate') { + anomali_cc123_marking += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = anomali_cc123_marking + } + } + + if (options.name === 'anomali_cc123_non_marking') { + if (options.summaryProcess === 'calculate') { + anomali_cc123_non_marking += options.value + } else if (options.summaryProcess === 'finalize') { + options.totalValue = anomali_cc123_non_marking + } + } + + if (options.name === 'total_anomali_marking') { + if (options.summaryProcess === 'start') { + anomali_pln_mobile_marking = 0 + anomali_cc123_marking = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = anomali_pln_mobile_marking + anomali_cc123_marking + } + } + + if (options.name === 'total_anomali_non_marking') { + if (options.summaryProcess === 'start') { + anomali_pln_mobile_non_marking = 0 + anomali_cc123_non_marking = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = anomali_pln_mobile_non_marking + anomali_cc123_non_marking + } + } + + if (options.name === 'persen_anomali_pln_mobile_marking') { + if (options.summaryProcess === 'start') { + anomali_pln_mobile_marking = 0 + wo_total = 0 + } else if (options.summaryProcess === 'calculate') { + persen_anomali_pln_mobile_marking = + !isFinite(anomali_pln_mobile_marking / wo_total) || anomali_pln_mobile_marking == 0 + ? 0 + : (anomali_pln_mobile_marking / wo_total) * 100 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = + !isFinite(anomali_pln_mobile_marking / wo_total) || anomali_pln_mobile_marking == 0 + ? 0 + : (anomali_pln_mobile_marking / wo_total) * 100 + } + } + + if (options.name === 'persen_anomali_pln_mobile_non_marking') { + if (options.summaryProcess === 'start') { + anomali_pln_mobile_non_marking = 0 + wo_total = 0 + } else if (options.summaryProcess === 'calculate') { + persen_anomali_pln_mobile_non_marking = + !isFinite(anomali_pln_mobile_non_marking / wo_total) || anomali_pln_mobile_non_marking == 0 + ? 0 + : (anomali_pln_mobile_non_marking / wo_total) * 100 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = + !isFinite(anomali_pln_mobile_non_marking / wo_total) || anomali_pln_mobile_non_marking == 0 + ? 0 + : (anomali_pln_mobile_non_marking / wo_total) * 100 + } + } + + if (options.name === 'persen_anomali_cc123_marking') { + if (options.summaryProcess === 'start') { + anomali_cc123_marking = 0 + wo_total = 0 + } else if (options.summaryProcess === 'calculate') { + persen_anomali_cc123_marking = + !isFinite(anomali_cc123_marking / wo_total) || anomali_cc123_marking == 0 + ? 0 + : (anomali_cc123_marking / wo_total) * 100 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = + !isFinite(anomali_cc123_marking / wo_total) || anomali_cc123_marking == 0 + ? 0 + : (anomali_cc123_marking / wo_total) * 100 + } + } + + if (options.name === 'persen_anomali_cc123_non_marking') { + if (options.summaryProcess === 'start') { + anomali_cc123_non_marking = 0 + wo_total = 0 + } else if (options.summaryProcess === 'calculate') { + persen_anomali_cc123_non_marking = + !isFinite(anomali_cc123_non_marking / wo_total) || anomali_cc123_non_marking == 0 + ? 0 + : (anomali_cc123_non_marking / wo_total) * 100 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = + !isFinite(anomali_cc123_non_marking / wo_total) || anomali_cc123_non_marking == 0 + ? 0 + : (anomali_cc123_non_marking / wo_total) * 100 + } + } + + if (options.name === 'persen_anomali_marking') { + if (options.summaryProcess === 'start') { + persen_anomali_pln_mobile_marking = 0 + persen_anomali_cc123_marking = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = persen_anomali_pln_mobile_marking + persen_anomali_cc123_marking + } + } + + if (options.name === 'persen_anomali_non_marking') { + if (options.summaryProcess === 'start') { + persen_anomali_cc123_non_marking = 0 + persen_anomali_pln_mobile_non_marking = 0 + } else if (options.summaryProcess === 'finalize') { + options.totalValue = persen_anomali_pln_mobile_non_marking + persen_anomali_cc123_non_marking + } + } +} + const resetData = () => { dataSub.value = [] dataSubSelected.value = null @@ -1124,21 +1358,53 @@ const getDetail = async () => { const dateValue = periode.split(' s/d ') const selected = dataSelected.value - const query = { + let query = { dateFrom: dateValue[0] ? dateValue[0].split('-').reverse().join('-') : new Date().toISOString().slice(0, 10), dateTo: dateValue[1] ? dateValue[1].split('-').reverse().join('-') : new Date().toISOString().slice(0, 10), - idUlp: selected?.id_ulp ? selected?.id_ulp : 0, - idUid: selected?.id_uid ? selected?.id_uid : 0, - idUp3: selected?.id_up3 ? selected?.id_up3 : 0, + idUlp: 0, + idUid: 0, + idUp3: 0, namaRegional: '', media: parameterRequest.value?.media, isMarking: parameterRequest.value?.marking } + if (groupDialog.value) { + if (props.grouping[groupIndex.value].data == 'nama_uid') { + query = { + ...query, + idUid: groupData.value?.id_uid ? groupData.value?.id_uid : 0, + namaRegional: groupData.value?.nama_regional ? groupData.value?.nama_regional : '' + } + } else if (props.grouping[groupIndex.value].data == 'nama_up3') { + query = { + ...query, + idUid: groupData.value?.id_uid ? groupData.value?.id_uid : 0, + idUp3: groupData.value?.id_up3 ? groupData.value?.id_up3 : 0, + namaRegional: groupData.value?.nama_regional ? groupData.value?.nama_regional : '' + } + } + } else { + query = { + dateFrom: dateValue[0] + ? dateValue[0].split('-').reverse().join('-') + : new Date().toISOString().slice(0, 10), + dateTo: dateValue[1] + ? dateValue[1].split('-').reverse().join('-') + : new Date().toISOString().slice(0, 10), + idUlp: selected?.id_ulp ? selected?.id_ulp : 0, + idUid: selected?.id_uid ? selected?.id_uid : 0, + idUp3: selected?.id_up3 ? selected?.id_up3 : 0, + namaRegional: selected?.nama_regional ? selected?.nama_regional : '', + media: parameterRequest.value?.media, + isMarking: parameterRequest.value?.marking + } + } + loadingSubData.value = true emit('update:loadingSubData', true) await requestGraphQl(