151 lines
3.6 KiB
Vue
Executable File
151 lines
3.6 KiB
Vue
Executable File
<script setup lang="ts">
|
|
import Select from '@/components/Select.vue'
|
|
import DatePicker from '@/components/DatePicker.vue'
|
|
import InlineRadioGroup from '@/components/Form/InlineRadioGroup.vue'
|
|
import {
|
|
selectedUid,
|
|
selectedUp3Ulp,
|
|
selectedUlp,
|
|
fetchUid,
|
|
itemsUid,
|
|
itemsUp3,
|
|
itemsUlp
|
|
} from './reference'
|
|
import { onMounted, ref, watch } from 'vue'
|
|
|
|
const uidPlaceholder = 'Semua Unit Induk Distribusi/Wilayah'
|
|
const up3Placeholder = 'Semua Unit Pelaksanaan Pelayanan Pelanggan'
|
|
const ulpPlaceholder = 'Semua Unit Layanan Pelanggan'
|
|
const emit = defineEmits(['update:filters'])
|
|
const data = ref({
|
|
uid: { id: 0, name: uidPlaceholder },
|
|
up3: { id: 0, name: up3Placeholder },
|
|
ulp: { id: 0, name: ulpPlaceholder },
|
|
periode: '',
|
|
groupBy: false
|
|
})
|
|
watch(data, (value) => {
|
|
emit('update:filters', value)
|
|
})
|
|
|
|
const renderUp3 = ref(false)
|
|
const renderUlp = ref(false)
|
|
|
|
const setUid = (value: any) => {
|
|
selectedUid(value)
|
|
data.value = {
|
|
...data.value,
|
|
uid: value,
|
|
up3: { id: 0, name: up3Placeholder },
|
|
ulp: { id: 0, name: ulpPlaceholder }
|
|
}
|
|
|
|
renderUp3.value = true
|
|
renderUlp.value = true
|
|
setTimeout(() => {
|
|
renderUp3.value = false
|
|
renderUlp.value = false
|
|
}, 200)
|
|
}
|
|
|
|
const setUp3 = (value: any) => {
|
|
selectedUp3Ulp(value)
|
|
data.value = {
|
|
...data.value,
|
|
up3: value,
|
|
ulp: { id: 0, name: ulpPlaceholder }
|
|
}
|
|
|
|
renderUlp.value = true
|
|
setTimeout(() => {
|
|
renderUlp.value = false
|
|
}, 200)
|
|
}
|
|
|
|
const setUlp = (value: any) => {
|
|
selectedUlp(value)
|
|
data.value = {
|
|
...data.value,
|
|
ulp: value
|
|
}
|
|
|
|
console.log('data.value', data.value)
|
|
}
|
|
|
|
onMounted(() => {
|
|
emit('update:filters', data.value)
|
|
fetchUid()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
|
<div class="flex flex-col flex-1 space-y-2">
|
|
<label class="filter-input-label">Unit Induk Distribusi/Wilayah:</label>
|
|
|
|
<Select @update:selected="setUid($event)" :data="itemsUid" :placeholder="uidPlaceholder" />
|
|
</div>
|
|
|
|
<div class="flex flex-col flex-1 space-y-2">
|
|
<label class="filter-input-label">Unit Pelaksanaan Pelayanan Pelanggan:</label>
|
|
|
|
<Select
|
|
v-if="renderUp3"
|
|
@update:selected="setUp3($event)"
|
|
:data="itemsUp3"
|
|
:placeholder="up3Placeholder"
|
|
/>
|
|
|
|
<Select
|
|
v-else
|
|
@update:selected="setUp3($event)"
|
|
:data="itemsUp3"
|
|
:placeholder="up3Placeholder"
|
|
/>
|
|
</div>
|
|
|
|
<div class="flex flex-col flex-1 space-y-2">
|
|
<label class="filter-input-label">Unit Layanan Pelanggan:</label>
|
|
<Select
|
|
v-if="renderUlp"
|
|
@update:selected="setUlp($event)"
|
|
:data="itemsUlp"
|
|
:placeholder="ulpPlaceholder"
|
|
/>
|
|
|
|
<Select
|
|
v-else
|
|
@update:selected="setUlp($event)"
|
|
:data="itemsUlp"
|
|
:placeholder="ulpPlaceholder"
|
|
/>
|
|
</div>
|
|
|
|
<div class="flex flex-col flex-1 space-y-2">
|
|
<label class="filter-input-label">Periode Tanggal:</label>
|
|
<DatePicker @update:date-value="(value) => (data.periode = value)" />
|
|
</div>
|
|
|
|
<div class="flex flex-col flex-1 space-y-2" v-if="data.ulp.id == 0">
|
|
<label class="filter-input-label"
|
|
>Group By
|
|
{{
|
|
data.uid.id != 0
|
|
? data.up3.id != 0
|
|
? 'Unit Layanan Pelanggan/Posko'
|
|
: 'Unit Pelaksanaan Pelayanan Pelanggan'
|
|
: 'Kode Unit Distribusi'
|
|
}}:</label
|
|
>
|
|
|
|
<InlineRadioGroup
|
|
@update:group-value="(value) => (data.groupBy = value.id === 2)"
|
|
:radio-items="[
|
|
{ id: 1, title: 'Tidak' },
|
|
{ id: 2, title: 'Ya, Grupkan' }
|
|
]"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|