fix: adjust filter for sep
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { Ref } from 'vue'
|
||||
|
||||
// Components
|
||||
import type { DataTableLoader } from '~/components/pub/my-ui/data-table/type'
|
||||
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
|
||||
@@ -14,7 +16,7 @@ import AppSepList from '~/components/app/sep/list.vue'
|
||||
import RangeCalendar from '~/components/pub/ui/range-calendar/RangeCalendar.vue'
|
||||
import type { DateRange } from 'radix-vue'
|
||||
import { CalendarDate, getLocalTimeZone } from '@internationalized/date'
|
||||
import type { Ref } from 'vue'
|
||||
import { toast } from "~/components/pub/ui/toast"
|
||||
|
||||
// Icons
|
||||
import { X, Check } from 'lucide-vue-next'
|
||||
@@ -30,12 +32,13 @@ import { serviceTypes } from '~/lib/constants.vclaim'
|
||||
|
||||
// Services
|
||||
import { getList as geMonitoringVisitList } from '~/services/vclaim-monitoring-visit.service'
|
||||
import { remove as removeSepData, makeSepDataForRemove } from "~/services/vclaim-sep.service"
|
||||
|
||||
const search = ref('')
|
||||
|
||||
const userStore = useUserStore()
|
||||
const today = new Date()
|
||||
// DateRange (radix) selection using CalendarDate
|
||||
const initCalDate = (d: Date) => new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate())
|
||||
const search = ref('')
|
||||
const dateSelection = ref({ start: initCalDate(today), end: initCalDate(today) }) as Ref<DateRange>
|
||||
const dateRange = ref(`${getFormatDateId(today)} - ${getFormatDateId(today)}`)
|
||||
const serviceType = ref('2')
|
||||
@@ -108,9 +111,18 @@ async function getMonitoringVisitMappers() {
|
||||
isLoading.dataListLoading = true
|
||||
data.value = []
|
||||
|
||||
let dateFilter = '';
|
||||
const isTimeLocal = true
|
||||
const dateFirst = dateSelection.value && dateSelection.value.start ? dateSelection.value.start.toDate(getLocalTimeZone()) : new Date()
|
||||
if (isTimeLocal && dateSelection.value && dateSelection.value.end) {
|
||||
const { year, month, day } = dateSelection.value.end
|
||||
dateFilter = `${year}-${month}-${day}`
|
||||
} else {
|
||||
dateFilter = dateFirst.toISOString().substring(0, 10)
|
||||
}
|
||||
|
||||
const result = await geMonitoringVisitList({
|
||||
date: dateFirst.toISOString().substring(0, 10),
|
||||
date: dateFilter,
|
||||
serviceType: serviceType.value,
|
||||
})
|
||||
|
||||
@@ -166,8 +178,14 @@ function exportExcel() {
|
||||
// tambahkan logic untuk generate Excel
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
async function handleRemove() {
|
||||
console.log('Data dihapus:', sepData)
|
||||
const result = await removeSepData(makeSepDataForRemove({ ...sepData.value, userName: userStore.user?.user_name }))
|
||||
if (result && result.success && result.body) {
|
||||
toast({ title: 'Berhasil', description: 'Data berhasil dihapus', variant: 'default' })
|
||||
} else {
|
||||
toast({ title: 'Gagal', description: 'Gagal menghapus data', variant: 'destructive' })
|
||||
}
|
||||
open.value = false
|
||||
}
|
||||
|
||||
@@ -319,7 +337,7 @@ provide('table_data_loader', isLoading)
|
||||
<Button
|
||||
variant="outline"
|
||||
class="border-green-600 text-green-600 hover:bg-green-50"
|
||||
@click="open = false"
|
||||
@click="handleRemove"
|
||||
>
|
||||
<X class="mr-1 h-4 w-4" />
|
||||
Tidak
|
||||
@@ -327,7 +345,7 @@ provide('table_data_loader', isLoading)
|
||||
<Button
|
||||
variant="destructive"
|
||||
class="bg-red-600 hover:bg-red-700"
|
||||
@click="handleDelete"
|
||||
@click="handleRemove"
|
||||
>
|
||||
<Check class="mr-1 h-4 w-4" />
|
||||
Ya
|
||||
|
||||
@@ -20,6 +20,11 @@ export function getList(params: any = null) {
|
||||
return base.getList(url, params, name)
|
||||
}
|
||||
|
||||
export function remove(payload: any) {
|
||||
const url = `${path}`
|
||||
return base.custom(url, payload, name)
|
||||
}
|
||||
|
||||
export function makeSepData(
|
||||
data: IntegrationBpjsFormData & {
|
||||
referralFrom?: string
|
||||
@@ -52,7 +57,7 @@ export function makeSepData(
|
||||
assesmentPel: data.serviceAssessment || '',
|
||||
skdp: {
|
||||
noSurat: ['3'].includes(data.admissionType) ? data.referralLetterNumber : '',
|
||||
kodeDPJP: ['3'].includes(data.admissionType)? data.attendingDoctor : '',
|
||||
kodeDPJP: ['3'].includes(data.admissionType) ? data.attendingDoctor : '',
|
||||
},
|
||||
rujukan: {
|
||||
// Handle referral data for admissionType !== '3'
|
||||
@@ -95,3 +100,14 @@ export function makeSepData(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function makeSepDataForRemove(data: any) {
|
||||
return {
|
||||
request: {
|
||||
t_sep: {
|
||||
noSep: data.sepNumber,
|
||||
user: data.userName,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user