fix: server side in daftar gangguan dialihkan ke posko lain
This commit is contained in:
parent
0710b2635d
commit
af4f6035f5
@ -1,4 +1,4 @@
|
|||||||
VITE_BASE_URL=http://localhost:5173
|
VITE_BASE_URL=http://localhost/:5173
|
||||||
VITE_BASE_DIRECTORY=/
|
VITE_BASE_DIRECTORY=/
|
||||||
VITE_APP_VERSION=0.0.1
|
VITE_APP_VERSION=0.0.1
|
||||||
VITE_APP_NAME='Executive Information System'
|
VITE_APP_NAME='Executive Information System'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Filters @reset-form="resetData" @run-search="() => filterData(filters)" class="mb-4">
|
<Filters @reset-form="resetData" @run-search="() => filterData()" class="mb-4">
|
||||||
<Type1 @update:filters="(value) => (filters = value)" />
|
<Type1 @update:filters="(value) => (filters = value)" />
|
||||||
</Filters>
|
</Filters>
|
||||||
|
|
||||||
@ -11,7 +11,6 @@
|
|||||||
class="max-h-[calc(100vh-140px)] mb-10"
|
class="max-h-[calc(100vh-140px)] mb-10"
|
||||||
:data-source="data"
|
:data-source="data"
|
||||||
:remote-operations="true"
|
:remote-operations="true"
|
||||||
v-if="loading == false"
|
|
||||||
key-expr="no_laporan"
|
key-expr="no_laporan"
|
||||||
:show-column-lines="true"
|
:show-column-lines="true"
|
||||||
:show-row-lines="false"
|
:show-row-lines="false"
|
||||||
@ -24,6 +23,7 @@
|
|||||||
:allow-column-resizing="true"
|
:allow-column-resizing="true"
|
||||||
column-resizing-mode="widget"
|
column-resizing-mode="widget"
|
||||||
>
|
>
|
||||||
|
<DxLoadPanel :enabled="true" />
|
||||||
<DxPaging :page-size="20" :enabled="true" :page-index="0" />
|
<DxPaging :page-size="20" :enabled="true" :page-index="0" />
|
||||||
<DxPager
|
<DxPager
|
||||||
:visible="true"
|
:visible="true"
|
||||||
@ -41,10 +41,12 @@
|
|||||||
:allow-export-selected-data="false"
|
:allow-export-selected-data="false"
|
||||||
/>
|
/>
|
||||||
<DxColumn
|
<DxColumn
|
||||||
|
:allow-sorting="false"
|
||||||
css-class="custom-table-column !text-right"
|
css-class="custom-table-column !text-right"
|
||||||
:width="50"
|
:width="50"
|
||||||
alignment="center"
|
alignment="center"
|
||||||
data-type="number"
|
data-type="number"
|
||||||
|
data-field="no"
|
||||||
caption="No"
|
caption="No"
|
||||||
/>
|
/>
|
||||||
<DxColumn
|
<DxColumn
|
||||||
@ -330,14 +332,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DetailDialog>
|
</DetailDialog>
|
||||||
|
|
||||||
<BufferDialog v-if="loading" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Filters from '@/components/Form/Filters.vue'
|
import Filters from '@/components/Form/Filters.vue'
|
||||||
import Type1 from '@/components/Form/FiltersType/Type1.vue'
|
import Type1 from '@/components/Form/FiltersType/Type1.vue'
|
||||||
import BufferDialog from '@/components/Dialogs/BufferDialog.vue'
|
|
||||||
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
|
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
|
||||||
import InputText from '@/components/InputText.vue'
|
import InputText from '@/components/InputText.vue'
|
||||||
import CustomStore from 'devextreme/data/custom_store'
|
import CustomStore from 'devextreme/data/custom_store'
|
||||||
@ -349,7 +348,8 @@ import {
|
|||||||
DxPager,
|
DxPager,
|
||||||
DxPaging,
|
DxPaging,
|
||||||
DxSearchPanel,
|
DxSearchPanel,
|
||||||
DxSelection
|
DxSelection,
|
||||||
|
DxLoadPanel
|
||||||
} from 'devextreme-vue/data-grid'
|
} from 'devextreme-vue/data-grid'
|
||||||
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive } from 'vue'
|
||||||
@ -367,7 +367,7 @@ const requestOptions = reactive<IRequestOptions>({
|
|||||||
})
|
})
|
||||||
const dataSelected = ref<any>()
|
const dataSelected = ref<any>()
|
||||||
const dialogDetail = ref(false)
|
const dialogDetail = ref(false)
|
||||||
const loading = ref(false)
|
const reportData: any = ref(null)
|
||||||
const dataGridRef = ref<DxDataGrid | null>(null)
|
const dataGridRef = ref<DxDataGrid | null>(null)
|
||||||
const filters = ref()
|
const filters = ref()
|
||||||
const reportMeta = ref({
|
const reportMeta = ref({
|
||||||
@ -379,28 +379,35 @@ const reportMeta = ref({
|
|||||||
|
|
||||||
const allowTableRequest = ref(false)
|
const allowTableRequest = ref(false)
|
||||||
const data = new CustomStore({
|
const data = new CustomStore({
|
||||||
load: (loadOptions: any) => {
|
load: async (loadOptions: any) => {
|
||||||
if (allowTableRequest.value) {
|
if (allowTableRequest.value) {
|
||||||
let query: any
|
loadOptions.requireTotalCount = true
|
||||||
|
|
||||||
if (Object.keys(loadOptions.userData).length === 0) {
|
const query = {
|
||||||
query = {
|
skip: loadOptions.skip,
|
||||||
skip: loadOptions.skip,
|
take: loadOptions.take,
|
||||||
take: loadOptions.take,
|
sort: loadOptions.sort ? loadOptions.sort : null,
|
||||||
sort: loadOptions.sort ? loadOptions.sort : null,
|
filter: loadOptions.filter ? mapSearchOptions(loadOptions.filter) : null,
|
||||||
filter: loadOptions.filter ? loadOptions.filter : null,
|
requireTotalCount: loadOptions.requireTotalCount,
|
||||||
requireTotalCount: loadOptions.requireTotalCount,
|
...createQuery(filters.value)
|
||||||
...createQuery(filters.value)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
query = loadOptions.userData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestGraphQl(queries.gangguan.daftar.dataDialihkanKePoskoLain, query)
|
return await requestGraphQl(
|
||||||
|
queries.gangguan.daftar.ssdaftarGangguanDialihkanKePoskoLain,
|
||||||
|
query
|
||||||
|
)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
const response = result.data.data.ssdaftarGangguanDialihkanKePoskoLain
|
||||||
|
|
||||||
|
let no = query.skip ?? 0
|
||||||
|
|
||||||
|
for (const data of response.data) {
|
||||||
|
data.no = ++no
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: result.data.data.daftarGangguanDialihkanKePoskoLain,
|
data: response.data,
|
||||||
totalCount: 0
|
totalCount: response.totalCount
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -408,7 +415,6 @@ const data = new CustomStore({
|
|||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
reportMeta.value = filters.value
|
reportMeta.value = filters.value
|
||||||
loading.value = false
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
@ -425,7 +431,11 @@ const closeDialog = () => (dialogDetail.value = false)
|
|||||||
|
|
||||||
const resetData = () => {
|
const resetData = () => {
|
||||||
allowTableRequest.value = false
|
allowTableRequest.value = false
|
||||||
data.load()
|
|
||||||
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
|
const dataGridDataSource = dataGrid.getDataSource()
|
||||||
|
|
||||||
|
dataGridDataSource.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRequestChange = (e: any) => {
|
const handleRequestChange = (e: any) => {
|
||||||
@ -461,29 +471,39 @@ const createSearchOptions = (keyword: string) => {
|
|||||||
const searchOptions = []
|
const searchOptions = []
|
||||||
|
|
||||||
for (const column of columns) {
|
for (const column of columns) {
|
||||||
if (column.dataField === 'number' || !column.dataField) {
|
if (column.dataField === 'no' || !column.dataField) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
searchOptions.push([column.dataField, '=', keyword])
|
searchOptions.push({
|
||||||
|
field: column.dataField,
|
||||||
if (column !== columns[columns.length - 1]) {
|
value: keyword
|
||||||
searchOptions.push('or')
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchOptions
|
return searchOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterData = (params: any) => {
|
const mapSearchOptions = (searchOptions: any) => {
|
||||||
allowTableRequest.value = true
|
const result = searchOptions.map((option: any) => {
|
||||||
|
if (Array.isArray(option) && option[0] !== 'no') {
|
||||||
data.load({
|
return {
|
||||||
userData: {
|
field: option[0],
|
||||||
...requestOptions,
|
value: option[2]
|
||||||
...createQuery(params)
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return result.filter((item: any) => item)
|
||||||
|
}
|
||||||
|
|
||||||
|
const filterData = () => {
|
||||||
|
allowTableRequest.value = true
|
||||||
|
|
||||||
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
|
const dataGridDataSource = dataGrid.getDataSource()
|
||||||
|
|
||||||
|
dataGridDataSource.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
const createQuery = (params: any) => {
|
const createQuery = (params: any) => {
|
||||||
@ -520,13 +540,29 @@ const showDetail = () => {
|
|||||||
clearSelection()
|
clearSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onExporting = (e: any) => {
|
const onExporting = async (e: any) => {
|
||||||
if (e.format === 'pdf') {
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
exportToPDF(reportMeta, data)
|
|
||||||
|
if (e.format === 'pdf' || e.format === 'document') {
|
||||||
|
reportData.value = await data.load()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.format === 'pdf' && reportData.value) {
|
||||||
|
dataGrid.beginCustomLoading('')
|
||||||
|
const pdf = await exportToPDF(reportMeta, reportData)
|
||||||
|
|
||||||
|
if (pdf) {
|
||||||
|
dataGrid.endCustomLoading()
|
||||||
|
}
|
||||||
} else if (e.format === 'xlsx') {
|
} else if (e.format === 'xlsx') {
|
||||||
exportToXLSX(reportMeta, e)
|
exportToXLSX(reportMeta, e)
|
||||||
} else {
|
} else if (e.format === 'document' && reportData.value) {
|
||||||
exportToDOCX(reportMeta, data)
|
dataGrid.beginCustomLoading('')
|
||||||
|
const doc = await exportToDOCX(reportMeta, reportData)
|
||||||
|
|
||||||
|
if (doc) {
|
||||||
|
dataGrid.endCustomLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -48,12 +48,13 @@ const formatMetaData = (reportMeta: any) => {
|
|||||||
return { dateFromFormat, dateToFormat, dayTo }
|
return { dateFromFormat, dateToFormat, dayTo }
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, data: any) => {
|
const exportToPDF = async (reportMeta: any, data: any) => {
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
|
const resultData = data.value.data
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -133,7 +134,7 @@ const exportToPDF = (reportMeta: any, data: any) => {
|
|||||||
'Posko'
|
'Posko'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
body: data.value.map((item: any, i: any) => [
|
body: resultData.map((item: any, i: any) => [
|
||||||
{ content: ++i, styles: { halign: 'right' } },
|
{ content: ++i, styles: { halign: 'right' } },
|
||||||
item.no_laporan,
|
item.no_laporan,
|
||||||
item.pembuat_laporan,
|
item.pembuat_laporan,
|
||||||
@ -204,9 +205,16 @@ const exportToPDF = (reportMeta: any, data: any) => {
|
|||||||
margin: { left: 230 }
|
margin: { left: 230 }
|
||||||
})
|
})
|
||||||
|
|
||||||
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
|
await doc
|
||||||
console.log('pdf berhasil disimpan')
|
.save(`Laporan ${reportName}.pdf`, { returnPromise: true })
|
||||||
})
|
.then(() => {
|
||||||
|
console.log('PDF Exported')
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error while exporting PDF', error)
|
||||||
|
})
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToXLSX = (reportMeta: any, e: any) => {
|
const exportToXLSX = (reportMeta: any, e: any) => {
|
||||||
@ -266,10 +274,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
component: e.component,
|
component: e.component,
|
||||||
worksheet,
|
worksheet,
|
||||||
autoFilterEnabled: true,
|
autoFilterEnabled: true,
|
||||||
topLeftCell: { row: 10, column: 1 },
|
topLeftCell: { row: 10, column: 1 }
|
||||||
loadPanel: {
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
||||||
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
|
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
|
||||||
@ -279,15 +284,16 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
e.cancel = true
|
e.cancel = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, data: any) => {
|
const exportToDOCX = async (reportMeta: any, data: any) => {
|
||||||
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
|
const resultData = data.value.data
|
||||||
|
|
||||||
const generateRows = () => {
|
const generateRows = () => {
|
||||||
return data.value.map((item: any, i: any) => {
|
return resultData.map((item: any, i: any) => {
|
||||||
return new TableRow({
|
return new TableRow({
|
||||||
children: [
|
children: [
|
||||||
{ text: `${++i}`, field: 'no' },
|
{ text: `${++i}`, field: 'no' },
|
||||||
@ -530,11 +536,17 @@ const exportToDOCX = (reportMeta: any, data: any) => {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
Packer.toBlob(doc).then((blob) => {
|
await Packer.toBlob(doc)
|
||||||
console.log(blob)
|
.then((blob) => {
|
||||||
saveAs(blob, `Laporan ${reportName}.docx`)
|
saveAs(blob, `Laporan ${reportName}.docx`)
|
||||||
console.log('Document created successfully')
|
|
||||||
})
|
console.log('DOCX Exported')
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error while exporting DOCX', error)
|
||||||
|
})
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
export { exportToPDF, exportToXLSX, exportToDOCX }
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -3,7 +3,7 @@ interface IRequestOptions {
|
|||||||
take: number
|
take: number
|
||||||
requireTotalCount: boolean
|
requireTotalCount: boolean
|
||||||
sort: null | Array<object>
|
sort: null | Array<object>
|
||||||
filter: null | Array<any>
|
filter: null | Array<object>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { IRequestOptions }
|
export type { IRequestOptions }
|
||||||
|
@ -2532,20 +2532,20 @@ export const queries = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
dataDialihkanKePoskoLain: gql`
|
ssdaftarGangguanDialihkanKePoskoLain: gql`
|
||||||
query DaftarGangguan(
|
query ssdaftarGangguanDialihkanKePoskoLain(
|
||||||
$dateFrom: Date!
|
$dateFrom: Date!
|
||||||
$dateTo: Date!
|
$dateTo: Date!
|
||||||
$posko: Int
|
$posko: Int!
|
||||||
$idUid: Int
|
$idUid: Int!
|
||||||
$idUp3: Int
|
$idUp3: Int!
|
||||||
$skip: Int
|
$skip: Int
|
||||||
$take: Int
|
$take: Int
|
||||||
$requireTotalCount: Boolean
|
$requireTotalCount: Boolean
|
||||||
$sort: [SortInput]
|
$sort: [SortInput]
|
||||||
$filter: [FilterInput]
|
$filter: [FilterInput]
|
||||||
) {
|
) {
|
||||||
daftarGangguanDialihkanKePoskoLain(
|
ssdaftarGangguanDialihkanKePoskoLain(
|
||||||
dateFrom: $dateFrom
|
dateFrom: $dateFrom
|
||||||
dateTo: $dateTo
|
dateTo: $dateTo
|
||||||
posko: $posko
|
posko: $posko
|
||||||
@ -2557,25 +2557,28 @@ export const queries = {
|
|||||||
sort: $sort
|
sort: $sort
|
||||||
filter: $filter
|
filter: $filter
|
||||||
) {
|
) {
|
||||||
alamat_pelapor
|
totalCount
|
||||||
pembuat_laporan
|
data {
|
||||||
durasi_recovery_time
|
no_laporan
|
||||||
durasi_response_time
|
pembuat_laporan
|
||||||
waktu_lapor
|
waktu_lapor
|
||||||
waktu_dialihkan
|
waktu_dialihkan
|
||||||
waktu_recovery
|
waktu_response
|
||||||
waktu_response
|
waktu_recovery
|
||||||
idpel_nometer
|
durasi_response_time
|
||||||
keterangan_pelapor
|
durasi_recovery_time
|
||||||
media
|
id_posko_lama
|
||||||
nama_pelapor
|
nama_posko_lama
|
||||||
no_laporan
|
id_posko_baru
|
||||||
no_telp_pelapor
|
nama_posko_baru
|
||||||
nama_posko_lama
|
status_akhir
|
||||||
nama_posko_baru
|
idpel_nometer
|
||||||
status_akhir
|
nama_pelapor
|
||||||
waktu_recovery
|
alamat_pelapor
|
||||||
waktu_response
|
no_telp_pelapor
|
||||||
|
keterangan_pelapor
|
||||||
|
media
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user