Remove menuservice
parent
29ab8456a8
commit
47e42c8a37
|
@ -48,8 +48,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MenuService from './service/MenuService';
|
|
||||||
import {FilterService,FilterMatchMode} from 'primevue/api';
|
import {FilterService,FilterMatchMode} from 'primevue/api';
|
||||||
|
import menudata from '@/assets/menu/menu.json';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -58,33 +58,25 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeSubmenus: {},
|
activeSubmenus: {},
|
||||||
menu: null,
|
menu: menudata.data,
|
||||||
filteredRoutes: null,
|
filteredRoutes: null,
|
||||||
selectedRoute: null,
|
selectedRoute: null,
|
||||||
routes: []
|
routes: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
menuService: null,
|
|
||||||
created() {
|
|
||||||
this.menuService = new MenuService();
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.menuService.getMenu().then(data => {
|
this.menu.forEach((route) => {
|
||||||
this.menu = data;
|
let childRoute = {...route};
|
||||||
|
childRoute.children = childRoute.children.filter((child) => {
|
||||||
|
if (child.meta) {
|
||||||
|
this.routes.push(child);
|
||||||
|
}
|
||||||
|
|
||||||
data.forEach((route) => {
|
return !child.meta;
|
||||||
let childRoute = {...route};
|
})
|
||||||
childRoute.children = childRoute.children.filter((child) => {
|
|
||||||
if (child.meta) {
|
|
||||||
this.routes.push(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
return !child.meta;
|
this.routes.push(childRoute);
|
||||||
})
|
});
|
||||||
|
|
||||||
this.routes.push(childRoute);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleSubmenu(event, name) {
|
toggleSubmenu(event, name) {
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
export default class MenuService {
|
|
||||||
|
|
||||||
getMenu() {
|
|
||||||
return axios.get('demo/menu/menu.json').then(res => res.data.data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<div class="content-section implementation">
|
<div class="content-section implementation">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<Button type="button" icon="pi pi-search" :label="selectedProduct ? selectedProduct.name : 'Select a Product'" @click="toggle" aria:haspopup="true" aria-controls="overlay_panel" />
|
<Button ref="btn" type="button" icon="pi pi-search" :label="selectedProduct ? selectedProduct.name : 'Select a Product'" @click="toggle" aria:haspopup="true" aria-controls="overlay_panel" />
|
||||||
|
|
||||||
<OverlayPanel ref="op" appendTo="body" :showCloseIcon="true" id="overlay_panel" style="width:450px" :breakpoints="{'960px': '75vw'}">
|
<OverlayPanel ref="op" appendTo="body" :showCloseIcon="true" id="overlay_panel" style="width:450px" :breakpoints="{'960px': '75vw'}">
|
||||||
<DataTable :value="products" v-model:selection="selectedProduct" selectionMode="single" :paginator="true" :rows="5" @row-select="onProductSelect">
|
<DataTable :value="products" v-model:selection="selectedProduct" selectionMode="single" :paginator="true" :rows="5" @row-select="onProductSelect">
|
||||||
|
@ -50,6 +50,8 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.productService.getProductsSmall().then(data => this.products = data);
|
this.productService.getProductsSmall().then(data => this.products = data);
|
||||||
|
|
||||||
|
this.$refs.op.show({currentTarget: this.$refs.button.$el});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggle(event) {
|
toggle(event) {
|
||||||
|
|
Loading…
Reference in New Issue