| <!--导航组件--> | 
| <template> | 
|   <div class="app-sidebar"> | 
|     <div class="box"> | 
|       <el-menu | 
|         router | 
|         unique-opened | 
|         :default-active="$route.path" | 
|         class="el-menu-vertical-demo" | 
|         @select="handleOpen" | 
|         @close="handleClose" | 
|         background-color="#314255" | 
|         text-color="#bfcbd9" | 
|         active-text-color="#fff" | 
|       > | 
|         <el-submenu v-for="item in menus" :key="item.id" :index="item.id.toString()" > | 
|           <template slot="title"> | 
|             <i class="el-icon-money icon"></i> | 
|             <span>{{ item.title }}</span> | 
|           </template> | 
|           <el-menu-item v-for="itm in item.children" :key="itm.id" :index="itm.path">{{ itm.title }}</el-menu-item> | 
|            | 
|           <!-- <el-menu-item index="/client/salesLead">销售线索</el-menu-item> | 
|           <el-menu-item index="/client/clientManage">客户管理</el-menu-item> | 
|           <el-menu-item index="/client/contacts">联系人</el-menu-item> | 
|           <el-menu-item index="/client/followupRecords">跟进记录</el-menu-item> --> | 
|         </el-submenu> | 
|          | 
|   | 
|         <!-- <el-submenu index="4"> | 
|           <template slot="title"> | 
|             <i class="el-icon-location"></i> | 
|             <span>后台配置</span> | 
|           </template> | 
|           <el-menu-item index="/backgroundConfig/memberManage">成员管理</el-menu-item> | 
|           <el-menu-item index="/backgroundConfig/rolePermssion">角色权限</el-menu-item> | 
|         </el-submenu> --> | 
|       </el-menu> | 
|       <el-empty v-if="this.menus===null||this.menus===undefined||this.menus.length===0" :image-size="130" description="没有侧栏菜单"></el-empty> | 
|     </div> | 
|   </div> | 
| </template> | 
|   | 
| <script> | 
| export default { | 
|   name: "AppSidebar", | 
|   props: {}, | 
|   data() { | 
|     return { | 
|       menus:[] | 
|     } | 
|   }, | 
|   watch: { | 
|     // $route: { | 
|     //   handler: "initNavMenu", | 
|     //   immediate: true | 
|     // } | 
|   }, | 
|   created() { | 
|     this.initNavMenu() | 
|     this.getMenuTreeByRole() | 
|   }, | 
|   methods: { | 
|     getMenuTreeByRole(){ | 
|       let newList=this.$store.state.menus | 
|       console.log(newList,"newList") | 
|       // 隐藏了 生成计划 和 服务收费管理模块 | 
|       if(newList[1]){ | 
|         const found = newList[1].children.find(obj => obj.title === "生成计划") | 
|         if(found){ | 
|           newList[1].children=[...newList[1].children.slice(0, -1)];   | 
|         } | 
|       } | 
|       if(newList[2]){ | 
|         const found1 = newList[2].children.find(obj => obj.title === "服务收费管理") | 
|         if(found1){ | 
|           newList[2].children=[...newList[2].children.slice(0, -1)];   | 
|         } | 
|       } | 
|       this.menus=newList | 
|     }, | 
|     // 监听路由 | 
|     initNavMenu() { | 
|       // console.log(this.$route.name) | 
|     }, | 
|     handleOpen(index) { | 
|       console.log(index) | 
|     }, | 
|     handleClose() {} | 
|   } | 
| } | 
| </script> | 
|   | 
| <!-- Add "scoped" attribute to limit CSS to this component only --> | 
| <style lang="scss" scoped> | 
| @import "./index.scss"; | 
| ::v-deep .el-empty{ | 
|   .el-empty__description{ | 
|     p{ | 
|       color: #dddd; | 
|     } | 
|   } | 
| } | 
| </style> |