Merge branch 'main' of github.com:defuj/eis into dev-bagus
This commit is contained in:
@ -5,11 +5,19 @@ import HomeView from '@/views/HomeView.vue'
|
||||
import TestView from '@/views/TestView.vue'
|
||||
import LoginView from '@/views/LoginView.vue'
|
||||
import NotFoundView from '@/views/NotFoundView.vue'
|
||||
import EmptyPage from '@/components/Pages/HomeEmpty.vue'
|
||||
import WelcomePage from '@/components/Pages/Welcome.vue'
|
||||
import TestPage from '@/components/Pages/TestPage.vue'
|
||||
import { hasMoreThanTwoSlashes, removeExtraSlashes } from '@/utils/route'
|
||||
import qs from 'qs'
|
||||
import {
|
||||
GangguanDaftar1,
|
||||
GangguanDaftar2,
|
||||
GangguanDaftar3
|
||||
} from '@/components/Pages/Gangguan/Daftar'
|
||||
import {
|
||||
GangguanRekap1,
|
||||
} from '@/components/Pages/Gangguan/Rekapitulasi'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
export const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'Home',
|
||||
@ -18,61 +26,61 @@ const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '',
|
||||
name: 'Home Page',
|
||||
component: EmptyPage,
|
||||
component: WelcomePage,
|
||||
},
|
||||
{
|
||||
path: 'gangguan',
|
||||
name: 'Gangguan',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'daftar',
|
||||
name: 'Daftar',
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'Daftar Keluhan Dialihkan Ke Posko Lain',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar1,
|
||||
},
|
||||
{
|
||||
path: '2',
|
||||
name: 'Daftar Gangguan Melapor Lebih Dari 1 Kali',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar2,
|
||||
},
|
||||
{
|
||||
path: '3',
|
||||
name: 'Daftar Gangguan Response Time',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar3,
|
||||
},
|
||||
{
|
||||
path: '4',
|
||||
name: 'Daftar Gangguan Recovery Time',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar3,
|
||||
},
|
||||
{
|
||||
path: '5',
|
||||
name: 'Daftar Gangguan Selesai Tanpa ID Pelanggan',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar3,
|
||||
},
|
||||
{
|
||||
path: '6',
|
||||
name: 'Daftar Gangguan Berdasarkan Media',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar3,
|
||||
},
|
||||
{
|
||||
path: '7',
|
||||
name: 'Daftar Gangguan Diselesaikan Mobile APKT',
|
||||
component: TestPage,
|
||||
component: GangguanDaftar3,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'b',
|
||||
path: 'rekapitulasi',
|
||||
name: 'Rekapitulasi',
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'Rekapitulasi Gangguan All',
|
||||
component: TestPage,
|
||||
component: GangguanRekap1,
|
||||
},
|
||||
{
|
||||
path: '2',
|
||||
@ -148,7 +156,7 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'Keluhan',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'daftar',
|
||||
name: 'Daftar',
|
||||
children: [
|
||||
{
|
||||
@ -189,7 +197,7 @@ const routes: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'b',
|
||||
path: 'rekapitulasi',
|
||||
name: 'Rekapitulasi',
|
||||
children: [
|
||||
{
|
||||
@ -241,11 +249,11 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'Monalisa',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'gangguan',
|
||||
name: 'Gangguan',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'rekapitulasi',
|
||||
name: 'Rekapitulasi',
|
||||
children: [
|
||||
{
|
||||
@ -255,31 +263,41 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
{
|
||||
path: '2',
|
||||
name: 'Recovery Time (RCT) Gangguan',
|
||||
name: 'Dispacthing Time (DT) Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '3',
|
||||
name: 'Response Time (RPT) Gangguan',
|
||||
name: 'Recovery Time (RCT) Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '4',
|
||||
name: 'Rekapitulasi Gangguan Per Jenis Gangguan',
|
||||
name: 'Response Time (RPT) Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '5',
|
||||
name: 'Rekapitulasi Lapor Ulang Gangguan',
|
||||
name: 'Jumlah dan Durasi RPT RCT Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '6',
|
||||
name: 'Rekapitulasi ENS Gangguan',
|
||||
name: 'Rekapitulasi Gangguan Per Jenis Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '7',
|
||||
name: 'Rekapitulasi Lapor Ulang Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '8',
|
||||
name: 'Rekapitulasi ENS Gangguan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '9',
|
||||
name: 'Rekapitulasi Gangguan Belum Selesai',
|
||||
component: TestPage,
|
||||
},
|
||||
@ -288,11 +306,11 @@ const routes: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'b',
|
||||
path: 'keluhan',
|
||||
name: 'Keluhan',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'rekapitulasi',
|
||||
name: 'Rekapitulasi',
|
||||
children: [
|
||||
{
|
||||
@ -312,16 +330,21 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
{
|
||||
path: '4',
|
||||
name: 'Rekapitulasi Gangguan Per Jenis Keluhan',
|
||||
name: 'Jumlah dan Durasi RPT RCT Keluhan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '5',
|
||||
name: 'Rekapitulasi Lapor Ulang Keluhan',
|
||||
name: 'Rekapitulasi Gangguan Per Jenis Keluhan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '6',
|
||||
name: 'Rekapitulasi Lapor Ulang Keluhan',
|
||||
component: TestPage,
|
||||
},
|
||||
{
|
||||
path: '7',
|
||||
name: 'Rekapitulasi Keluhan Belum Selesai',
|
||||
component: TestPage,
|
||||
},
|
||||
@ -330,11 +353,11 @@ const routes: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'c',
|
||||
path: 'kpi',
|
||||
name: 'Laporan KPI',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'bulanan',
|
||||
name: 'Bulanan',
|
||||
children: [
|
||||
{
|
||||
@ -360,7 +383,7 @@ const routes: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '2',
|
||||
path: 'kumulatif',
|
||||
name: 'Kumulatif',
|
||||
children: [
|
||||
{
|
||||
@ -394,7 +417,7 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'Check In OutCheck In Dan Check Out',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'laporan',
|
||||
name: 'Laporan Check In /Check Out (CICO)',
|
||||
children: [
|
||||
{
|
||||
@ -411,7 +434,7 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'Anomali Penangan Pengaduan',
|
||||
children: [
|
||||
{
|
||||
path: 'a',
|
||||
path: 'gangguan',
|
||||
name: 'Gangguan',
|
||||
children: [
|
||||
{
|
||||
@ -427,7 +450,7 @@ const routes: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'b',
|
||||
path: 'keluhan',
|
||||
name: 'Keluhan',
|
||||
children: [
|
||||
{
|
||||
@ -450,6 +473,56 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'material',
|
||||
name: 'Material',
|
||||
children: [
|
||||
{
|
||||
path: 'daftar',
|
||||
name: 'Daftar',
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'Daftar Gangguan Dan Material Yang Dipakai',
|
||||
component: TestPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'rekapitulasi',
|
||||
name: 'Rekapitulasi',
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'Rekapitulasi Pemakaian Material',
|
||||
component: TestPage,
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'transaksi',
|
||||
name: 'Transaksi',
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'Transaksi APKT',
|
||||
component: TestPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'pencarian-data',
|
||||
name: 'Pencarian Data',
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'Pencarian Report Number',
|
||||
component: TestPage,
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -469,50 +542,50 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
]
|
||||
|
||||
// const createRoute = (route: RouteRecordRaw[]): RouteRecordRaw[] => {
|
||||
// var newRoute: RouteRecordRaw[] = []
|
||||
export const mergeChildrenRoutes = (routes: RouteRecordRaw[]): RouteRecordRaw[] => {
|
||||
const mergedRoutes: RouteRecordRaw[] = [];
|
||||
|
||||
// const getRoute = (route: RouteRecordRaw[], parent: string = '') => {
|
||||
// route.forEach((r) => {
|
||||
// if (r.children) {
|
||||
// if (r.component) {
|
||||
// var fullPath = `${parent.replace('/', '')}/${r.path.replace('/', '')}`
|
||||
// fullPath = hasMoreThanTwoSlashes(fullPath) ? removeExtraSlashes(fullPath) : fullPath
|
||||
// newRoute.push({
|
||||
// path: fullPath,
|
||||
// name: r.name,
|
||||
// component: r.component
|
||||
// } as RouteRecordRaw)
|
||||
// }
|
||||
// getRoute(r.children, `${parent}/${r.path}`)
|
||||
// } else {
|
||||
// var fullPath = `${parent.replace('/', '')}/${r.path.replace('/', '')}`
|
||||
// if (newRoute.find((nr) => nr.path !== '/' && nr.path === '/home' && fullPath.includes(nr.path))) {
|
||||
// const index = newRoute.findIndex((nr) => nr.path !== '/' && fullPath.includes(nr.path))
|
||||
// newRoute[index] = {
|
||||
// ...newRoute[index], children: [...newRoute[index].children ?? [], {
|
||||
// path: fullPath === '/home/' ? '' : fullPath.includes('/home/') ? fullPath.replace('/home/', '').split('/').join('-') : fullPath.split('/').join('-'),
|
||||
// name: r.name,
|
||||
// component: r.component
|
||||
// } as RouteRecordRaw]
|
||||
// }
|
||||
// } else {
|
||||
// newRoute.push({
|
||||
// path: fullPath,
|
||||
// name: r.name,
|
||||
// component: r.component
|
||||
// } as RouteRecordRaw)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// getRoute(route)
|
||||
// console.log(newRoute);
|
||||
for (const route of routes) {
|
||||
if (route.children && route.children.length > 0) {
|
||||
// Buat salinan route tanpa children
|
||||
const topLevelRoute: RouteRecordRaw = { ...route, children: [] };
|
||||
|
||||
// return newRoute
|
||||
// }
|
||||
// Salin setiap route children ke children route paling atas
|
||||
for (const childRoute of route.children) {
|
||||
const fullPath = `${route.path}/${childRoute.path}`.replace(/\/+/g, '/');
|
||||
const mergedChildRoute: RouteRecordRaw = { ...childRoute, path: fullPath };
|
||||
topLevelRoute.children?.push(mergedChildRoute);
|
||||
}
|
||||
|
||||
const createRoute = (route: RouteRecordRaw[]): RouteRecordRaw[] => {
|
||||
mergedRoutes.push(topLevelRoute);
|
||||
} else {
|
||||
// Jika route tidak memiliki children, tambahkan as is
|
||||
mergedRoutes.push(route);
|
||||
}
|
||||
}
|
||||
|
||||
return mergedRoutes;
|
||||
}
|
||||
|
||||
export const extractLeafRoutes = (routes: RouteRecordRaw[], parentPath = ''): RouteRecordRaw[] => {
|
||||
const leafRoutes: RouteRecordRaw[] = [];
|
||||
|
||||
for (const route of routes) {
|
||||
|
||||
const fullPath = `${parentPath}/${route.path}`.replace(/\/+/g, '/');
|
||||
|
||||
if (route.children && route.children.length > 0) {
|
||||
leafRoutes.push(...extractLeafRoutes(route.children, fullPath));
|
||||
} else {
|
||||
const leafRoute = { ...route, path: fullPath };
|
||||
leafRoutes.push(leafRoute);
|
||||
}
|
||||
}
|
||||
|
||||
return leafRoutes;
|
||||
}
|
||||
|
||||
export const fixRoute = (route: RouteRecordRaw[]): RouteRecordRaw[] => {
|
||||
var newRoute: RouteRecordRaw[] = []
|
||||
|
||||
const getRoute = (route: RouteRecordRaw[], parent: string = '') => {
|
||||
@ -556,13 +629,13 @@ const createRoute = (route: RouteRecordRaw[]): RouteRecordRaw[] => {
|
||||
return uniqueRoute
|
||||
}
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
linkActiveClass: 'active',
|
||||
routes: createRoute(routes)
|
||||
stringifyQuery: qs.stringify,
|
||||
routes: fixRoute(routes)
|
||||
})
|
||||
console.log(router.getRoutes());
|
||||
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
// redirect to login page if not logged in and trying to access a restricted page
|
||||
@ -600,6 +673,3 @@ router.beforeEach((to, from, next) => {
|
||||
})
|
||||
|
||||
export default router
|
||||
export {
|
||||
routes
|
||||
}
|
||||
|
Reference in New Issue
Block a user