linan 4 年之前
父节点
当前提交
71f292c9ab
共有 2 个文件被更改,包括 18 次插入147 次删除
  1. 18 110
      src/views/Home/Home.vue
  2. 0 37
      src/views/Home/mencCofig.js

+ 18 - 110
src/views/Home/Home.vue

@@ -2,7 +2,7 @@
     <div class="home">
         <header class="header">
             <div class="left">
-                慧牧科技
+                智能耳标 
                 <el-button
                     @click="onMenuCollapse"
                     circle
@@ -49,31 +49,30 @@
                         :unique-opened="true"
                         :default-openeds="defaultUnfoldedMenu"
                         select="1-1"
-                        background-color="rgba(46,38,87)"
+                        background-color="#545c64"
                         text-color="#fff"
                         active-text-color="#ffd04b"
                     >
-                        <div v-for="(item) in menuData " :key="item.index">
+                        <div v-for="(item, index1) in menuData " :key="index1">
                             <el-submenu
                                 v-if="item.childList && item.childList.length > 0"
-                                :index="item.index"
+                                :index="`${index1}`"
                             >
                                 <template slot="title">
                                     <i :class="item.iconClassName"></i>
                                     <span slot="title">{{ !menuCollapse? item.optionName : '' }}</span>
-                                    <!-- <span slot="title">{{ item.oneMenuName }}</span> -->
                                 </template>
                                 <el-menu-item
-                                    v-for="(item1) in item.childList"
-                                    :key="item1.index"
-                                    :index="item1.index"
+                                    v-for="(item1, index2) in item.childList"
+                                    :key="`${index1}-${index2}`"
+                                    :index="`${index1}-${index2}`"
                                     :routerName="item1.routerName"
                                     @click="onClickMenu(item1)"
                                 >{{ item1.optionName }}</el-menu-item>
                             </el-submenu>
                             <el-menu-item
                                 v-else
-                                :index="item.index"
+                                :index="`${index1}`"
                                 :disabled="item.disabled"
                                 :routerName="item.routerName"
                                 @click="onClickMenu(item)"
@@ -84,22 +83,13 @@
                         </div>
                     </el-menu>
                 </div>
+
                 <div class="col2">
-                    <header class="col2_header">
-                        <el-tag
-                            v-for="tag in tags"
-                            :key="tag.routerName"
-                            closable
-                            @close="close(tag)"
-                            @click="clickTag(tag)"
-                            :type="tag.type?tag.type:'info'"
-                            class="item"
-                        >{{tag.name}}</el-tag>
-                    </header>
                     <div class="warp">
                         <router-view />
                     </div>
                 </div>
+
             </div>
         </section>
     </div>
@@ -115,16 +105,14 @@ export default {
             menuData,
             menuCollapse: false, //是否水平折叠收起菜单
             defaultUnfoldedMenu: [menuData[0].index], // 默认展开第一项
-            tags: []
         };
     },
     created() {
-        console.log(process.env.NODE_ENV)
         this.defaultUnfoldedMenu = [
             localStorage.getItem("defaultUnfoldedMenu")
         ];
         this.menuCollapse = JSON.parse(localStorage.getItem("menuCollapse"));
-        this.tags = JSON.parse(localStorage.getItem("tagsNavList")) || [];
+        
     },
     methods: {
         // 收取菜单按钮
@@ -137,13 +125,10 @@ export default {
         },
         // 菜单展开
         handleOpen(key, keyPath) {
-            console.log(key, keyPath);
             localStorage.setItem("defaultUnfoldedMenu", "" + key);
         },
         // 菜单收取
-        handleClose(key, keyPath) {
-            console.log(key, keyPath);
-        },
+        handleClose(key, keyPath) {},
         // 点击菜单项
         onClickMenu(item) {
             let _this = this;
@@ -152,67 +137,9 @@ export default {
             this.$router.push({
                 name: item.routerName
             });
-            // 如果tags中已经存在 return
-            let temp = includes(item.routerName);
-            if (temp) {
-                this.tags.forEach(item => {
-                    item.type = "info";
-                });
-                temp.type = "success";
-                return;
-            }
-            this.tags.forEach(item => {
-                item.type = "info";
-            });
-            this.tags.push({
-                name: item.optionName,
-                routerName: item.routerName,
-                type: "success"
-            });
-
-            this.changeTagColor(item.routerName);
-            localStorage.setItem("tagsNavList", JSON.stringify(this.tags));
-            // 查看当前 tags里有没有传进来的路由,返回 true false
-
-            function includes(routerName) {
-                let tags = _this.tags;
-                return tags.find(item => {
-                    return item.routerName == routerName;
-                });
-            }
-        },
-        // 点击 tag
-        clickTag(tag) {
-            console.log(tag.routerName);
-            if (this.$router.history.current.name == tag.routerName) return;
-            this.$router.push({
-                name: tag.routerName
-            });
-            this.changeTagColor(tag.routerName);
-            localStorage.setItem("tagsNavList", JSON.stringify(this.tags));
-        },
-        // 点击 tag 的小×
-        close(tag) {
-            console.log(tag);
-            let spliceIndex = this.tags.findIndex(item => {
-                return item.routerName == tag.routerName;
-            });
-            console.log(spliceIndex);
-            this.tags.splice(spliceIndex, 1);
-            localStorage.setItem("tagsNavList", JSON.stringify(this.tags));
-        },
-        // 改变tag的颜色 公用的
-        changeTagColor(routerName) {
-            this.tags.forEach(item => {
-                if (item.routerName == routerName) {
-                    item.type = "success";
-                } else {
-                    item.type = "info";
-                }
-            });
         },
         onLogOut() {
-            this.$router.push('login')
+            this.$router.redirect('login')
         }
     }
 };
@@ -226,10 +153,8 @@ export default {
     background-color: #eee;
     display: flex;
     flex-direction: column;
-    .header {
-        // background-color: #029b62;
-        // background-color: rgb(46,38,87);
-        background-color: rgb(85, 70, 148);
+    >.header {
+        background-color: #4b545e;
         height: 40px;
         padding: 10px 20px;
         margin-bottom: 5px;
@@ -260,7 +185,8 @@ export default {
             box-sizing: border-box;
             .col1 {
                 margin-right: 5px;
-                background-color: rgb(46,38,87);
+                background-color: #545c64;
+                border-radius: 15px;
                 // background-image: linear-gradient(to bottom, rgb(85, 70, 148) , rgb(41, 33, 85), rgb(41, 33, 85));
             }
             .col2 {
@@ -271,27 +197,9 @@ export default {
                 margin-right: 5px;
                 height: 100%;
                 overflow: auto;
-                .col2_header {
-                    position: relative;
-                    width: 85%;
-                    height: 50px;
-                    overflow: hidden;
-                    border-bottom: 2px solid #eee;
-                    background-color: #fff;
-                    padding: 10px;
-                    display: flex;
-                    align-items: center;
-                    box-sizing: border-box;
-                    z-index: 1;
-                    position: fixed;
-                    .item {
-                        margin-right: 8px;
-                        cursor: pointer;
-                    }
-                }
+                
                 .warp {
                     margin: 15px;
-                    padding-top: 55px;
                 }
             }
         }

+ 0 - 37
src/views/Home/mencCofig.js

@@ -4,27 +4,22 @@ export const menuData = [
     {
         optionName: "档案管理",
         iconClassName: "el-icon-setting",
-        index: '1',
         disabled: false, // 是否禁用
         childList: [
             {
                 optionName: '企业信息',
-                index: '1-1',
                 routerName: "aa"
             },
             {
                 optionName: '牧场信息',
-                index: '1-2',
                 routerName: "aa"
             },
             {
                 optionName: '猪舍信息',
-                index: '1-3',
                 routerName: "aa"
             },
             {
                 optionName: '人员信息',
-                index: '1-4',
                 routerName: "aa"
             }
             
@@ -34,27 +29,22 @@ export const menuData = [
     {
         optionName: "群体管理",
         iconClassName: "el-icon-s-flag",
-        index: '2',
         disabled: false,
         childList: [ 
             {
                 optionName: '群体档案',
-                index: '2-1',
                 routerName: "GroupRecord"
             },
             {
                 optionName: '健康分析',
-                index: '2-2',
                 routerName: "aa"
             },
             {
                 optionName: '转群记录',
-                index: '2-3',
                 routerName: "aa"
             },
             {
                 optionName: '群体盘点',
-                index: '2-4',
                 routerName: "aa"
             }
         ]
@@ -63,17 +53,14 @@ export const menuData = [
     {
         optionName: "个体管理",
         iconClassName: "el-icon-message",
-        index: '3',
         disabled: false,
         childList: [ 
             {
                 optionName: '种猪档案',
-                index: '3-1',
                 routerName: "aa"
             },
             {
                 optionName: '个体追踪',
-                index: '3-2',
                 routerName: "UnityTrace"
             }
             
@@ -83,27 +70,22 @@ export const menuData = [
     {
         optionName: "系统配置",
         iconClassName: "el-icon-coordinate",
-        index: '4',
         disabled: false,
         childList: [ 
             {
                 optionName: '设备配置',
-                index: '4-1',
                 routerName: "aa"
             },
             {
                 optionName: '软件设置',
-                index: '4-2',
                 routerName: "aa"
             },
             {
                 optionName: '角色设置',
-                index: '4-3',
                 routerName: "aa"
             },
             {
                 optionName: '权限管理',
-                index: '4-4',
                 routerName: "aa"
             }
         ]
@@ -111,32 +93,26 @@ export const menuData = [
     {
         optionName: "系统设置",
         iconClassName: "el-icon-monitor",
-        index: '5',
         disabled: false, // 是否禁用
         childList: [ 
             {
                 optionName: '群体广播',
-                index: '5-1',
                 routerName: "aa"
             },
             {
                 optionName: '设备配置',
-                index: '5-2',
                 routerName: "aa"
             },
             {
                 optionName: '系统参数',
-                index: '5-3',
                 routerName: "aa"
             },
             {
                 optionName: '角色配置',
-                index: '5-4',
                 routerName: "aa"
             },
             {
                 optionName: '权限分配',
-                index: '5-5',
                 routerName: "aa"
             }
         ]
@@ -144,37 +120,30 @@ export const menuData = [
     {
         optionName: "开发用模板",
         iconClassName: "el-icon-menu",
-        index: '100',
         disabled: false, // 是否禁用
         childList: [ 
             {
                 optionName: '模板 1',
-                index: '100-1',
                 routerName: "aa"
             },
             {
                 optionName: '普通表格',
-                index: '100-2',
                 routerName: "ab"
             },
             {
                 optionName: '模板 3',
-                index: '100-3',
                 routerName: "ac"
             },
             {
                 optionName: '模板 4',
-                index: '100-4',
                 routerName: "ad"
             },
             {
                 optionName: '模板 5',
-                index: '100-5',
                 routerName: "ee"
             },
             {
                 optionName: '模板 6',
-                index: '100-6',
                 routerName: "af"
             }
             
@@ -194,11 +163,9 @@ const menuData描述 = [
     {
         oneMenuName: "导航一", // 一级菜单名
         iconClassName: "aaa", // element-ui图标名
-        index: '1', // 唯一标志
         childList: [ // 分组的
             {
                 groupName: '组名一',
-                index: '1-1-1',
                 list: [
                     {
                         optionName: '选项1',
@@ -209,7 +176,6 @@ const menuData描述 = [
             },
             {
                 groupName: '组名二',
-                index: '1-1-2',
                 list: [
                     {
                         optionName: '选项1',
@@ -224,12 +190,10 @@ const menuData描述 = [
     {
         oneMenuName: "导航二",
         iconClassName: "el-icon-menu",
-        index: '2',
         disabled: false, // 是否禁用
         childList: [ // 不分组的
             {
                 optionName: '选项1',
-                index: '2-1',
                 routerName: "home"
             },
             {}
@@ -240,7 +204,6 @@ const menuData描述 = [
         oneMenuName: "导航三",
         iconClassName: "el-icon-document",
         routerName: "home",
-        index: '3',
         disabled: false
     },