|
22 | 22 | </template> |
23 | 23 |
|
24 | 24 | <script> |
25 | | -import { mapGetters, mapMutations } from 'vuex' |
26 | | -import AsideComponent from '@/view/layout/aside/asideComponent' |
| 25 | +import { mapGetters, mapMutations } from "vuex"; |
| 26 | +import AsideComponent from "@/view/layout/aside/asideComponent"; |
27 | 27 | export default { |
28 | | - name: 'Aside', |
| 28 | + name: "Aside", |
29 | 29 | data() { |
30 | 30 | return { |
31 | | - active: '', |
| 31 | + active: "", |
32 | 32 | isCollapse: false |
33 | | - } |
| 33 | + }; |
34 | 34 | }, |
35 | 35 | methods: { |
36 | | - ...mapMutations('history', ['addHistory']), |
37 | | - selectMenuItem(index) { |
38 | | - if (index === this.$route.name) return |
39 | | - this.$router.push({ name: index }) |
| 36 | + ...mapMutations("history", ["addHistory"]), |
| 37 | + selectMenuItem(index, _, ele) { |
| 38 | + const query = {}; |
| 39 | + const params = {}; |
| 40 | + ele.route.parameters && |
| 41 | + ele.route.parameters.map(item => { |
| 42 | + if (item.type == "query") { |
| 43 | + query[item.key] = item.value; |
| 44 | + } else { |
| 45 | + params[item.key] = item.value; |
| 46 | + } |
| 47 | + }); |
| 48 | + console.log(query, params); |
| 49 | + if (index === this.$route.name) return; |
| 50 | + this.$router.push({ name: index, query, params }); |
40 | 51 | } |
41 | 52 | }, |
42 | 53 | computed: { |
43 | | - ...mapGetters('router', ['asyncRouters']) |
| 54 | + ...mapGetters("router", ["asyncRouters"]) |
44 | 55 | }, |
45 | 56 | components: { |
46 | 57 | AsideComponent |
47 | 58 | }, |
48 | 59 | created() { |
49 | | - this.active = this.$route.name |
50 | | - let screenWidth = document.body.clientWidth |
| 60 | + this.active = this.$route.name; |
| 61 | + let screenWidth = document.body.clientWidth; |
51 | 62 | if (screenWidth < 1000) { |
52 | | - this.isCollapse = !this.isCollapse |
| 63 | + this.isCollapse = !this.isCollapse; |
53 | 64 | } |
54 | 65 |
|
55 | | - this.$bus.on('collapse', item => { |
56 | | - this.isCollapse = item |
57 | | - }) |
| 66 | + this.$bus.on("collapse", item => { |
| 67 | + this.isCollapse = item; |
| 68 | + }); |
58 | 69 | }, |
59 | 70 | watch: { |
60 | 71 | $route() { |
61 | | - this.active = this.$route.name |
| 72 | + this.active = this.$route.name; |
62 | 73 | } |
63 | 74 | }, |
64 | 75 | beforeDestroy() { |
65 | | - this.$bus.off('collapse') |
| 76 | + this.$bus.off("collapse"); |
66 | 77 | } |
67 | | -} |
| 78 | +}; |
68 | 79 | </script> |
69 | 80 |
|
70 | 81 | <style lang="scss"> |
|
0 commit comments