See999 5 years ago
parent
commit
7150b4cb4b
1 changed files with 104 additions and 69 deletions
  1. 104 69
      src/views/layout/components/Sidebar/SidebarItem.vue

+ 104 - 69
src/views/layout/components/Sidebar/SidebarItem.vue View File

6
           :index="resolvePath(item.src)"
6
           :index="resolvePath(item.src)"
7
           :class="{ 'submenu-title-noDropdown': !isNest }"
7
           :class="{ 'submenu-title-noDropdown': !isNest }"
8
         >
8
         >
9
-          <i v-if="item.name == 'slow'" class="icon iconfont icon-manbing-xuanzhong" style="margin-right:4px"></i>
10
-          <i v-if="item.name == 'scrm'" class="icon iconfont icon-pengyou" style="margin-right:4px"></i>
11
-          <i v-if="item.name == 'shop'" class="icon iconfont icon-service_fill" style="margin-right:4px"></i>
9
+          <i
10
+            v-if="item.name == 'slow'"
11
+            class="icon iconfont icon-manbing-xuanzhong"
12
+            style="margin-right: 4px;"
13
+          ></i>
14
+          <i
15
+            v-if="item.name == 'scrm'"
16
+            class="icon iconfont icon-pengyou"
17
+            style="margin-right: 4px;"
18
+          ></i>
19
+          <i
20
+            v-if="item.name == 'shop'"
21
+            class="icon iconfont icon-service_fill"
22
+            style="margin-right: 4px;"
23
+          ></i>
12
           <span slot="title">{{ generateTitle(item.name) }}</span>
24
           <span slot="title">{{ generateTitle(item.name) }}</span>
13
         </el-menu-item>
25
         </el-menu-item>
14
       </a>
26
       </a>
17
       <div
29
       <div
18
         v-if="
30
         v-if="
19
           hasOneShowingChild(item.children) &&
31
           hasOneShowingChild(item.children) &&
20
-            !onlyOneChild.children &&
21
-            !item.alwaysShow
32
+          !onlyOneChild.children &&
33
+          !item.alwaysShow
22
         "
34
         "
23
         @click="onClick(item)"
35
         @click="onClick(item)"
24
       >
36
       >
34
             <span
46
             <span
35
               v-if="onlyOneChild.meta && onlyOneChild.meta.title"
47
               v-if="onlyOneChild.meta && onlyOneChild.meta.title"
36
               slot="title"
48
               slot="title"
37
-            >{{ generateTitle(onlyOneChild.meta.title) }}</span>
49
+              >{{ generateTitle(onlyOneChild.meta.title) }}</span
50
+            >
38
           </el-menu-item>
51
           </el-menu-item>
39
         </router-link>
52
         </router-link>
40
-        
41
       </div>
53
       </div>
42
 
54
 
43
       <div v-else>
55
       <div v-else>
44
-        <el-submenu v-if="item.meta.isChild" id="mySubmenu" :index="item.name || item.path">
56
+        <el-submenu
57
+          v-if="item.meta.isChild"
58
+          id="mySubmenu"
59
+          :index="item.name || item.path"
60
+        >
45
           <template slot="title">
61
           <template slot="title">
46
-            <svg-icon v-if="item.meta && item.meta.icon" :icon-class="item.meta.icon"></svg-icon>
62
+            <svg-icon
63
+              v-if="item.meta && item.meta.icon"
64
+              :icon-class="item.meta.icon"
65
+            ></svg-icon>
47
             <span v-if="item.meta && item.meta.title" slot="title">
66
             <span v-if="item.meta && item.meta.title" slot="title">
48
-              {{
49
-              generateTitle(item.meta.title)
50
-              }}
67
+              {{ generateTitle(item.meta.title) }}
51
             </span>
68
             </span>
52
           </template>
69
           </template>
53
           <template v-for="child in item.children" v-if="!child.hidden">
70
           <template v-for="child in item.children" v-if="!child.hidden">
56
               v-if="child.meta.isChild != true"
73
               v-if="child.meta.isChild != true"
57
               :key="child.name"
74
               :key="child.name"
58
             >
75
             >
59
-              <el-menu-item @click="onClick(item)" :index="resolvePath(child.path)">
60
-                <svg-icon v-if="child.meta && child.meta.icon" :icon-class="child.meta.icon"></svg-icon>
76
+              <el-menu-item
77
+                @click="onClick(item)"
78
+                :index="resolvePath(child.path)"
79
+              >
80
+                <svg-icon
81
+                  v-if="child.meta && child.meta.icon"
82
+                  :icon-class="child.meta.icon"
83
+                ></svg-icon>
61
                 <span v-if="child.meta && child.meta.title" slot="title">
84
                 <span v-if="child.meta && child.meta.title" slot="title">
62
-                  {{
63
-                  generateTitle(child.meta.title)
64
-                  }}
85
+                  {{ generateTitle(child.meta.title) }}
65
                 </span>
86
                 </span>
66
               </el-menu-item>
87
               </el-menu-item>
67
             </router-link>
88
             </router-link>
68
 
89
 
69
-            <router-link v-else :to="child.path" :key="child.name">
70
-              <el-menu-item @click="onClick(item,child.parentNum)" :index="resolvePath(child.path)">
71
-                <svg-icon v-if="child.meta && child.meta.icon" :icon-class="child.meta.icon"></svg-icon>
90
+            <router-link
91
+              v-if="child.meta.isChild == true"
92
+              :to="child.path"
93
+              :key="child.name"
94
+            >
95
+              <el-menu-item
96
+                @click="onClick(item, child.parentNum)"
97
+                :index="resolvePath(child.path)"
98
+              >
99
+                <svg-icon
100
+                  v-if="child.meta && child.meta.icon"
101
+                  :icon-class="child.meta.icon"
102
+                ></svg-icon>
72
                 <span v-if="child.meta && child.meta.title" slot="title">
103
                 <span v-if="child.meta && child.meta.title" slot="title">
73
-                  {{
74
-                  generateTitle(child.meta.title)
75
-                  }}
104
+                  {{ generateTitle(child.meta.title) }}
76
                 </span>
105
                 </span>
77
               </el-menu-item>
106
               </el-menu-item>
78
             </router-link>
107
             </router-link>
82
           <router-link :to="resolvePath(item.children[0].path)">
111
           <router-link :to="resolvePath(item.children[0].path)">
83
             <el-menu-item :index="item.name || item.path">
112
             <el-menu-item :index="item.name || item.path">
84
               <template slot="title">
113
               <template slot="title">
85
-                <svg-icon v-if="item.meta && item.meta.icon" :icon-class="item.meta.icon"></svg-icon>
114
+                <svg-icon
115
+                  v-if="item.meta && item.meta.icon"
116
+                  :icon-class="item.meta.icon"
117
+                ></svg-icon>
86
                 <span v-if="item.meta && item.meta.title" slot="title">
118
                 <span v-if="item.meta && item.meta.title" slot="title">
87
-                  {{
88
-                  generateTitle(item.meta.title)
89
-                  }}
119
+                  {{ generateTitle(item.meta.title) }}
90
                 </span>
120
                 </span>
91
               </template>
121
               </template>
92
 
122
 
93
               <!-- <template v-for="child in item.children" v-if="!child.hidden">
123
               <!-- <template v-for="child in item.children" v-if="!child.hidden">
94
-          <sidebar-item
95
-            :is-nest="true"
96
-            class="nest-menu"
97
-            v-if="child.children && child.children.length > 0"
98
-            :item="child"
99
-            :key="child.path"
100
-            :base-path="resolvePath(child.path)"
101
-          ></sidebar-item>
124
+                <sidebar-item
125
+                  :is-nest="true"
126
+                  class="nest-menu"
127
+                  v-if="child.children && child.children.length > 0"
128
+                  :item="child"
129
+                  :key="child.path"
130
+                  :base-path="resolvePath(child.path)"
131
+                ></sidebar-item>
102
 
132
 
103
-          <router-link v-else :to="resolvePath(child.path)" :key="child.name">
104
-            <el-menu-item :index="resolvePath(child.path)">
105
-              <svg-icon
106
-                v-if="child.meta && child.meta.icon"
107
-                :icon-class="child.meta.icon"
108
-              ></svg-icon>
109
-              <span v-if="child.meta && child.meta.title" slot="title">{{
110
-                generateTitle(child.meta.title)
111
-              }}</span>
112
-            </el-menu-item>
113
-          </router-link>
114
-              </template>-->
133
+                <router-link
134
+                  v-else
135
+                  :to="resolvePath(child.path)"
136
+                  :key="child.name"
137
+                >
138
+                  <el-menu-item :index="resolvePath(child.path)">
139
+                    <svg-icon
140
+                      v-if="child.meta && child.meta.icon"
141
+                      :icon-class="child.meta.icon"
142
+                    ></svg-icon>
143
+                    <span v-if="child.meta && child.meta.title" slot="title">{{
144
+                      generateTitle(child.meta.title)
145
+                    }}</span>
146
+                  </el-menu-item>
147
+                </router-link>
148
+              </template> -->
115
             </el-menu-item>
149
             </el-menu-item>
116
           </router-link>
150
           </router-link>
117
         </div>
151
         </div>
131
     // route object
165
     // route object
132
     item: {
166
     item: {
133
       type: Object,
167
       type: Object,
134
-      required: true
168
+      required: true,
135
     },
169
     },
136
     isNest: {
170
     isNest: {
137
       type: Boolean,
171
       type: Boolean,
138
-      default: false
172
+      default: false,
139
     },
173
     },
140
     basePath: {
174
     basePath: {
141
       type: String,
175
       type: String,
142
-      default: ""
176
+      default: "",
143
     },
177
     },
144
     index: {
178
     index: {
145
-      type: Number
146
-    }
179
+      type: Number,
180
+    },
147
   },
181
   },
148
   computed: {
182
   computed: {
149
-    ...mapGetters(["permission_routers"])
183
+    ...mapGetters(["permission_routers"]),
150
   },
184
   },
151
   data() {
185
   data() {
152
     return {
186
     return {
153
-      onlyOneChild: null
187
+      onlyOneChild: null,
154
     };
188
     };
155
   },
189
   },
156
   methods: {
190
   methods: {
157
     hasOneShowingChild(children) {
191
     hasOneShowingChild(children) {
158
-      const showingChildren = children.filter(item => {
192
+      const showingChildren = children.filter((item) => {
159
         if (item.hidden) {
193
         if (item.hidden) {
160
           return false;
194
           return false;
161
         } else {
195
         } else {
201
       }
235
       }
202
 
236
 
203
       return true;
237
       return true;
204
-    }
238
+    },
239
+  },
240
+  created() {
241
+    console.log(this.permission_routers);
205
   },
242
   },
206
-  created() {}
207
 };
243
 };
208
 </script>
244
 </script>
209
 
245
 
219
       min-width: 0;
255
       min-width: 0;
220
       padding: 0 5px !important;
256
       padding: 0 5px !important;
221
       font-size: 12px;
257
       font-size: 12px;
222
-      background-color:#1F2D3D !important;
258
+      background-color: #1f2d3d !important;
223
     }
259
     }
224
   }
260
   }
225
 }
261
 }
226
-.menu-wrapper{
227
-  .el-menu-item{
228
-   background-color:#1F2D3D !important;
229
-   color: #fff !important;
262
+.menu-wrapper {
263
+  .el-menu-item {
264
+    background-color: #1f2d3d !important;
265
+    color: #fff !important;
230
   }
266
   }
231
-  .el-menu{
232
-    background-color:#1F2D3D !important;
267
+  .el-menu {
268
+    background-color: #1f2d3d !important;
233
   }
269
   }
234
-  .el-submenu__title{
235
-    background-color:#1F2D3D !important;
270
+  .el-submenu__title {
271
+    background-color: #1f2d3d !important;
236
     color: #fff !important;
272
     color: #fff !important;
237
     height: 32px !important;
273
     height: 32px !important;
238
     line-height: 32px !important;
274
     line-height: 32px !important;
239
   }
275
   }
240
-  .router-link-exact-active{
276
+  .router-link-exact-active {
241
     color: rgb(64, 158, 255) !important;
277
     color: rgb(64, 158, 255) !important;
242
-    .el-menu-item{
278
+    .el-menu-item {
243
       color: rgb(64, 158, 255) !important;
279
       color: rgb(64, 158, 255) !important;
244
     }
280
     }
245
   }
281
   }
246
 }
282
 }
247
-
248
 </style>
283
 </style>