161 lines
4.2 KiB
Vue
Executable File
161 lines
4.2 KiB
Vue
Executable File
<script setup lang="ts">
|
|
import Select from '@/components/Select.vue'
|
|
import DatePicker from '@/components/DatePicker.vue'
|
|
import InputWithSuffix from '../InputWithSuffix.vue'
|
|
import {
|
|
selectedUid,
|
|
selectedUp3Posko,
|
|
selectedPosko,
|
|
fetchUid,
|
|
itemsUid,
|
|
itemsUp3,
|
|
itemsPosko
|
|
} from './reference'
|
|
import { onMounted, ref, watch } from 'vue'
|
|
|
|
const emit = defineEmits(['update:filters'])
|
|
const uidPlaceholder = 'Semua Unit Induk Distribusi/Wilayah'
|
|
const up3Placeholder = 'Semua Unit Pelaksanaan Pelayanan Pelanggan'
|
|
const poskoPlaceholder = 'Semua Posko'
|
|
const up3 = ref({ id: 0, name: up3Placeholder })
|
|
const uid = ref({ id: 0, name: uidPlaceholder })
|
|
const posko = ref({ id: 0, name: poskoPlaceholder })
|
|
const totalMin = ref('1 Menit')
|
|
const totalMax = ref('5 Menit')
|
|
|
|
const setDataMin = (value: any) => (totalMin.value = value)
|
|
const getDataMin = () => totalMin.value
|
|
const setDataMax = (value: any) => (totalMax.value = value)
|
|
const getDataMax = () => totalMax.value
|
|
|
|
const data = ref({
|
|
uid: uid.value,
|
|
up3: up3.value,
|
|
posko: posko.value,
|
|
periode: '',
|
|
minTime: getDataMin().split(' ')[0],
|
|
maxTime: getDataMax().split(' ')[0]
|
|
})
|
|
|
|
const setUid = (value: any) => {
|
|
uid.value = value
|
|
selectedUid(value)
|
|
up3.value = { id: 0, name: up3Placeholder }
|
|
data.value.uid = value
|
|
}
|
|
|
|
const setUp3 = (value: any) => {
|
|
up3.value = value
|
|
selectedUp3Posko(value)
|
|
posko.value = { id: 0, name: poskoPlaceholder }
|
|
data.value.up3 = value
|
|
}
|
|
|
|
const setPosko = (value: any) => {
|
|
posko.value = value
|
|
selectedPosko(value)
|
|
data.value.posko = value
|
|
}
|
|
const sla = [
|
|
{
|
|
id: 1,
|
|
name: 'Dibawah / Sesuai SLA (<= 45 menit)'
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'Melebihi SLA (> 45 menit)'
|
|
}
|
|
]
|
|
|
|
const setMin = (value: any) => {
|
|
console.log(value)
|
|
data.value.minTime = value
|
|
setDataMin(value)
|
|
}
|
|
const setMax = (value: any) => {
|
|
data.value.maxTime = value
|
|
setDataMax(value)
|
|
}
|
|
const triggerInput = ref(false)
|
|
const changeDuration = (value: any) => {
|
|
if (value.id === 0) {
|
|
setMin('1')
|
|
setMax('5')
|
|
console.log('Durasi Menit')
|
|
triggerInput.value = false
|
|
} else if (value.id === 1) {
|
|
setMin('1')
|
|
setMax('45')
|
|
console.log('Dibawah / Sesuai SLA (<= 45 menit)')
|
|
triggerInput.value = true
|
|
} else {
|
|
setMin('45')
|
|
setMax(99999 * 60 * 24)
|
|
triggerInput.value = true
|
|
console.log('Melebihi SLA (> 45 menit)')
|
|
}
|
|
}
|
|
watch(data, (newValue) => {
|
|
emit('update:filters', newValue)
|
|
})
|
|
|
|
onMounted(() => {
|
|
fetchUid()
|
|
emit('update:filters', data.value)
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="sm:grid sm:grid-cols-2 lg:grid-cols-3 sm:items-center">
|
|
<label class="block mb-2 font-semibold text-gray-800 sm:mb-0"
|
|
>Unit Induk Distribusi/Wilayah:</label
|
|
>
|
|
|
|
<Select @update:selected="setUid($event)" :data="itemsUid" :placeholder="uidPlaceholder" />
|
|
</div>
|
|
|
|
<div class="sm:grid sm:grid-cols-2 lg:grid-cols-3 sm:items-center">
|
|
<label class="block mb-2 font-semibold text-gray-800 sm:mb-0"
|
|
>Unit Pelaksanaan Pelayanan Pelanggan:</label
|
|
>
|
|
|
|
<Select
|
|
@update:selected="setUp3($event)"
|
|
:data="itemsUp3"
|
|
:selected="up3"
|
|
:placeholder="up3Placeholder"
|
|
/>
|
|
</div>
|
|
|
|
<div class="sm:grid sm:grid-cols-2 lg:grid-cols-3 sm:items-center">
|
|
<label class="block mb-2 font-semibold text-gray-800 sm:mb-0">Posko:</label>
|
|
|
|
<Select
|
|
@update:selected="setPosko($event)"
|
|
:data="itemsPosko"
|
|
:selected="posko"
|
|
:placeholder="poskoPlaceholder"
|
|
/>
|
|
</div>
|
|
|
|
<div class="sm:grid sm:grid-cols-2 lg:grid-cols-3 sm:items-center">
|
|
<label class="block mb-2 font-semibold text-gray-800 sm:mb-0">Periode Tanggal:</label>
|
|
|
|
<DatePicker @update:date-value="(value) => (data.periode = value)" />
|
|
</div>
|
|
|
|
<div class="sm:grid sm:grid-cols-2 lg:grid-cols-3 sm:items-center">
|
|
<label class="block mb-2 font-semibold text-gray-800 sm:mb-0">Durasi:</label>
|
|
|
|
<div class="flex flex-col gap-y-1">
|
|
<Select @update:selected="changeDuration($event)" :data="sla" placeholder="Durasi Menit" />
|
|
|
|
<div class="grid grid-flow-col auto-cols-auto gap-x-1.5">
|
|
<InputWithSuffix :value="`${data.minTime} Menit`" />
|
|
<small class="flex items-center">s/d</small>
|
|
<InputWithSuffix :value="`${data.maxTime} Menit`" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|