Shannon_mu пре 3 година
родитељ
комит
ae667799ed

+ 1 - 0
energyManagement/src/main.js

@@ -9,6 +9,7 @@
 import Vue from 'vue';
 import App from './App.vue';
 import router from './router';
+import { funcRouter } from './router/dynamicMuen';
 import Vuex from 'vuex';
 import ElementUI from 'element-ui';
 import commonComponents from './components/common';

+ 44 - 29
energyManagement/src/router/dynamicMuen.js

@@ -1,43 +1,58 @@
-import store from "../store/store.js";
+import store from '../store/store.js';
 const staticMuen = [
-
-]
+  {
+    path: '/msg',
+    component: () => import(/* webpackChunkName: "messages" */ '@views/messages'),
+    meta: { title: '消息中心' }
+  },
+  {
+    path: '/403',
+    component: () => import(/* webpackChunkName: "404" */ '@views/error/403.vue'),
+    meta: { title: '403' }
+  },
+  {
+    path: '/404',
+    component: () => import(/* webpackChunkName: "404" */ '@views/error/404.vue'),
+    meta: { title: '404' }
+  },
+  {
+    path: '*',
+    redirect: '/404'
+  }
+];
 //路由格式
 // 自定义路由文件
 const setListMunt = (arrList, item) => {
-  let newOb = {}
+  let newOb = {};
   newOb = {
-    path: `/${item.linkPath}`, component: () => import(`@/views/${item.linkPath}.vue`), meta: { title: item.name }
-  }
-  arrList.push(newOb)
-}
+    path: `/${item.linkPath}`,
+    component: () => import(`@/views/${item.linkPath}.vue`),
+    meta: { title: item.name }
+  };
+  arrList.push(newOb);
+};
 const dimension = (arrList, arr) => {
   arr.forEach((item, index) => {
-    //默认去掉第一个添加路由
-    if (item.linkPath !== 'workbench/index') {
-      if (!!item.children) {
-        dimension(arrList, item.children)
-      } else {
-        setListMunt(arrList, item)
-      }
+    if (!!item.children) {
+      dimension(arrList, item.children);
+    } else {
+      setListMunt(arrList, item);
     }
-
-  })
-}
+  });
+};
 //添加路由
 const AddRt = (router, dynamicMuenList) => {
-  let NEWdynamicMuenList = [...dynamicMuenList, ...staticMuen]
+  let NEWdynamicMuenList = [...dynamicMuenList, ...staticMuen];
   if (NEWdynamicMuenList.length !== 0) {
-    NEWdynamicMuenList.forEach(item => {
-      router.options.routes[0].children.push(item)
-    })
-    router.options.routes[0].redirect = router.options.routes[0].children[0].path
-    router.addRoutes(router.options.routes)
+    NEWdynamicMuenList.forEach((item) => {
+      router.options.routes[0].children.push(item);
+    });
+    router.addRoutes(router.options.routes);
   }
-}
+};
 
 export const funcRouter = (arr, data, router) => {
-  dimension(arr, data)
-  store.commit('setMenuList', data)
-  AddRt(router, arr)
-}
+  dimension(arr, data);
+  store.commit('setMenuList', data);
+  AddRt(router, arr);
+};

+ 98 - 74
energyManagement/src/router/index.js

@@ -1,88 +1,112 @@
-import Vue from 'vue';
-import Router from 'vue-router';
+// import Vue from 'vue';
+// import Router from 'vue-router';
 
-const original = Router.prototype.push
-Router.prototype.push = function push(location) {
-    return original.call(this, location).catch(err => err)
-}
-Vue.use(Router);
+// const original = Router.prototype.push
+// Router.prototype.push = function push(location) {
+//     return original.call(this, location).catch(err => err)
+// }
+// Vue.use(Router);
+
+
+
+// const quietRoute = [
+//     {
+//         path: '/',
+//         component: () => import(/* webpackChunkName: "home" */ '@/components/common/Home.vue'),
+//         children: [
+//             {
+//                 path: '/msg',
+//                 component: () => import(/* webpackChunkName: "messages" */ '@views/messages'),
+//                 meta: { title: '消息中心' }
+//             },
+//             {
+//                 path: '/403',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/error/403'),
+//                 meta: { title: '403' }
+//             },
+//             {
+//                 path: '/404',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/error/404'),
+//                 meta: { title: '404' }
+//             },
+//             {
+//                 path: '/Overview',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/overview'),
+//                 meta: { title: '概览' }
+//             },
+//             {
+//                 path: '/MeterReadingManagement',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/meterReadingManagement'),
+//                 meta: { title: '抄表管理' }
+//             },
+//             {
+//                 path: '/valveControlRecords',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/valveControlRecords'),
+//                 meta: { title: '阀控记录' }
+//             },
+//             {
+//                 path: '/WaterMeterManagement',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/waterMeter.vue'),
+//                 meta: { title: '水表管理' }
+//             },
+//             {
+//                 path: '/ElectricityMeterManagement',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/electricityMeter.vue'),
+//                 meta: { title: '电表管理' }
+//             },
+//             {
+//                 path: '/instrumentViewDetail',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/setPage/viewDetail.vue'),
+//                 meta: { title: '设备详情' }
+//             },
+//             {
+//                 path: '/WaterAudit',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/settlementAudit/waterAudit.vue'),
+//                 meta: { title: '水量审核' }
+//             },
+//             {
+//                 path: '/ElectricityAudit',
+//                 component: () => import(/* webpackChunkName: "404" */ '@views/settlementAudit/electricityAudit.vue'),
+//                 meta: { title: '电量审核' }
+//             }
+//         ],
+//         redirect: '/Overview'
+//     },
+//     {
+//         path: '*',
+//         redirect: '/404'
+//     }
+// ]
+
+// const route = new Router({
+//     mode: 'history',
+//     base: process.env.BASE_URL,
+//     routes: [
+//         ...quietRoute
+//     ]
+// });
+// export default route
 
 
 
+import Vue from 'vue';
+import Router from 'vue-router';
+
+const original = Router.prototype.replace;
+Router.prototype.replace = function replace(location) {
+    return original.call(this, location).catch((err) => err);
+};
+Vue.use(Router);
 const quietRoute = [
     {
         path: '/',
         component: () => import(/* webpackChunkName: "home" */ '@/components/common/Home.vue'),
-        children: [
-            {
-                path: '/msg',
-                component: () => import(/* webpackChunkName: "messages" */ '@views/messages'),
-                meta: { title: '消息中心' }
-            },
-            {
-                path: '/403',
-                component: () => import(/* webpackChunkName: "404" */ '@views/error/403'),
-                meta: { title: '403' }
-            },
-            {
-                path: '/404',
-                component: () => import(/* webpackChunkName: "404" */ '@views/error/404'),
-                meta: { title: '404' }
-            },
-            {
-                path: '/Overview',
-                component: () => import(/* webpackChunkName: "404" */ '@views/overview'),
-                meta: { title: '概览' }
-            },
-            {
-                path: '/MeterReadingManagement',
-                component: () => import(/* webpackChunkName: "404" */ '@views/meterReadingManagement'),
-                meta: { title: '抄表管理' }
-            },
-            {
-                path: '/valveControlRecords',
-                component: () => import(/* webpackChunkName: "404" */ '@views/valveControlRecords'),
-                meta: { title: '阀控记录' }
-            },
-            {
-                path: '/WaterMeterManagement',
-                component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/waterMeter.vue'),
-                meta: { title: '水表管理' }
-            },
-            {
-                path: '/ElectricityMeterManagement',
-                component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/electricityMeter.vue'),
-                meta: { title: '电表管理' }
-            },
-            {
-                path: '/instrumentViewDetail',
-                component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/setPage/viewDetail.vue'),
-                meta: { title: '设备详情' }
-            },
-            {
-                path: '/WaterAudit',
-                component: () => import(/* webpackChunkName: "404" */ '@views/settlementAudit/waterAudit.vue'),
-                meta: { title: '水量审核' }
-            },
-            {
-                path: '/ElectricityAudit',
-                component: () => import(/* webpackChunkName: "404" */ '@views/settlementAudit/electricityAudit.vue'),
-                meta: { title: '电量审核' }
-            }
-        ],
-        redirect: '/Overview'
+        children: [],
     },
-    {
-        path: '*',
-        redirect: '/404'
-    }
 ]
-
 const route = new Router({
     mode: 'history',
     base: process.env.BASE_URL,
-    routes: [
-        ...quietRoute
-    ]
+    routes: [...quietRoute]
 });
-export default route
+export default route;

+ 0 - 51
userCenter/src/components/common/Sidebar.vue

@@ -19,47 +19,6 @@
                 :style="collapse ? 'width:84px' : 'width:220px'"
             >
                 <menu-tree :menuList="thisMenuList" :collapse="collapse" :openArray="openArray"></menu-tree>
-                <!-- <template v-for="item in thisMenuList">
-                    <template v-if="item.children">
-                        <el-submenu :index="item.linkPath" :key="item.linkPath">
-                            <template slot="title">
-                                <img :src="envConfig.baseImgApi + item.menuImage" style="width: 14px; height: 14px; margin-right: 10px" />
-                                <span slot="title">{{ item.name }}</span>
-                            </template>
-                            <template v-for="subItem in item.children">
-                                <el-submenu v-if="subItem.children" :index="subItem.linkPath" :key="subItem.linkPath">
-                                    <img
-                                        slot="title"
-                                        :src="envConfig.baseImgApi + subItem.menuImage"
-                                        style="width: 14px; height: 14px; margin-right: 10px"
-                                    />
-                                    <template slot="title">{{ subItem.name }}</template>
-                                    <el-menu-item
-                                        style="padding-left: 88px"
-                                        v-for="threeItem in subItem.children"
-                                        :key="threeItem.linkPath"
-                                        :index="threeItem.linkPath"
-                                    >
-                                        <template slot="title">{{ threeItem.name }}</template>
-                                    </el-menu-item>
-                                </el-submenu>
-                                <el-menu-item v-else :index="subItem.linkPath" :key="subItem.linkPath">
-                                    <img
-                                        :src="envConfig.baseImgApi + subItem.menuImage"
-                                        style="width: 14px; height: 14px; margin-right: 10px"
-                                    />
-                                    <template slot="title"> {{ subItem.name }}</template>
-                                </el-menu-item>
-                            </template>
-                        </el-submenu>
-                    </template>
-                    <template v-else>
-                        <el-menu-item :index="item.linkPath" :key="item.linkPath">
-                            <img :src="envConfig.baseImgApi + item.menuImage" style="width: 14px; height: 14px; margin-right: 10px" />
-                            <span slot="title">{{ item.name }}</span>
-                        </el-menu-item>
-                    </template>
-                </template> -->
             </el-menu>
         </div>
         <div class="menu-footer" :class="theme == 'dark' ? 'dark' : 'light'" :style="collapse ? 'width:84px' : 'width:220px'">
@@ -78,9 +37,6 @@
 <script>
 import envConfig from '@/config';
 import MenuTree from './MenuTree.vue';
-import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';
-const darkTheme = new Set(['/dispatchCenter', '/waterSupplyMap', '/operation/video', '/operation/pipe-network']);
-const collapsePages = new Set(['/viewDetail', '/installplanView']);
 export default {
     data() {
         return {
@@ -100,13 +56,6 @@ export default {
         },
         onRoutes() {
             return this.$route.path;
-            if (this.$route.path) {
-                let theme = darkTheme.has(this.$route.path) ? 'dark' : 'light';
-                this.$store.commit('setTheme', darkTheme.has(this.$route.path) ? 'dark' : 'light');
-                let iscollapse = collapsePages.has(this.$route.path);
-                this.$store.dispatch('collapse', iscollapse);
-            }
-            return this.$route.path.replace('/', '');
         },
         collapse() {
             return this.$store.getters['getCollapse'];