Bläddra i källkod

修复动态路由+分析全选

liujiejie 11 månader sedan
förälder
incheckning
665c55cb2f

+ 15 - 77
src/router/index.js

@@ -30,92 +30,17 @@ const createRouter = () =>
               import(
                 /*webpackChunkName:'home-cockpitManage'*/ "../views/admin/cockpitManage/Index.vue"
               ),
-            // children: [
-            //   // 电子地图
-            //   {
-            //     id: 11,
-            //     path: "electronic-map",
-            //     name: "electronicMap",
-            //     component: () =>
-            //       import(
-            //         /*webpackChunkName:'home-cockpitManage'*/ "../views/admin/cockpitManage/electronicMap.vue"
-            //       ),
-            //   },
-            // ],
           },
           {
             // 电子地图
             id: 11,
-            path: "cockpitManage/electronic-map",
+            path: "/home/cockpitManage/electronic-map",
             name: "电子地图",
             component: () =>
               import(
                 /*webpackChunkName:'home-cockpitManage'*/ "../views/admin/cockpitManage/electronicMap.vue"
               ),
           },
-          // 电子地图
-          // {
-          //   path: "electronic-map",
-          //   name: "electronicMap",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'electronic-map'*/ "../views/admin/cockpitManage/electronicMap.vue"
-          //     ),
-          // },
-          // // 数据操作
-          // {
-          //   path: "dataAdministration",
-          //   name: "dataAdministration",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'dataAdministration'*/ "../views/dataAdministration/index.vue"
-          //     ),
-          // },
-          // // 企业信息
-          // {
-          //   path: "enterprise",
-          //   name: "enterprise",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'enterprise'*/ "../views/ledger/enterprise.vue"
-          //     ),
-          // },
-          // 风场信息
-          // {
-          //   path: "windsite",
-          //   name: "windsite",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'windsite'*/ "../views/ledger/windsite.vue"
-          //     ),
-          // },
-          // 风机信息
-          // {
-          //   path: "draught",
-          //   name: "draught",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'draught'*/ "../views/ledger/draught.vue"
-          //     ),
-          // },
-          // // 机型信息
-          // {
-          //   path: "milltype",
-          //   name: "milltype",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'milltype'*/ "../views/ledger/milltype.vue"
-          //     ),
-          // },
-          // // 测风塔信息
-          // {
-          //   path: "anemometer",
-          //   name: "anemometer",
-          //   component: () =>
-          //     import(
-          //       /*webpackChunkName:'anemometer'*/ "../views/ledger/anemometer.vue"
-          //     ),
-          // },
         ],
       },
       {
@@ -123,6 +48,12 @@ const createRouter = () =>
         name: "login",
         component: () => import("../views/login/Index.vue"),
       },
+      // 404 Page Not Found
+      // {
+      //   path: "*",
+      //   name: "NotFound",
+      //   component: () => import("../views/error/404.vue"),
+      // },
     ],
   });
 
@@ -137,7 +68,14 @@ VueRouter.prototype.push = function push(location) {
 export function resetRouter() {
   const newRouter = createRouter();
   router.matcher = newRouter.matcher; // reset router
-  console.log(router.getRoutes(), "重置后的路由");
 }
+router.beforeEach((to, from, next) => {
+  console.log(to, "to");
+  if (to.matched.length === 0) {
+    return next("/login");
+  } else {
+    next();
+  }
+});
 
 export default router;

+ 1 - 0
src/store/auth.js

@@ -51,6 +51,7 @@ export default {
         // 清空原有的动态子路由
         homeRoute.children = originalChildren;
         const { authRouterList } = getAuthRouterFn(resultRouter);
+        console.log();
         commit("SET_DYNAMIC_ROUTER", authRouterList);
         authRouterList.forEach((item) => {
           // 动态路由的父路径设置为home

+ 69 - 52
src/utils/getAuth.js

@@ -1,62 +1,79 @@
-import { orgList } from "@/views/home/components/mockData";
+//import { orgList } from "@/views/home/components/mockData";
 
 // 返回可动态添加的路由
 export const getAuthRouterFn = (list) => {
-  // 将list 转成一维数组,按钮级别权限拿到 返回为[]格式
-  const { result, anthBtnList } = flattenTree(list);
-  const arr = filterTreeByPermissions(result, orgList);
-  return { authRouterList: arr, anthBtnList };
-};
-
-const flattenTree = (tree) => {
-  let result = [];
-  let anthBtnList = [];
-  const flattenRecursive = (nodes) => {
-    nodes.forEach((node) => {
-      result.push(node);
-      if (node.children && node.children.length > 0) {
-        flattenRecursive(node.children);
-      }
-      if (node.permissionDepth === 2) {
-        anthBtnList.push(node);
-      }
-    });
-  };
-
-  flattenRecursive(tree);
-  return { result, anthBtnList };
-};
-
-const filterTreeByPermissions = (permissions, tree) => {
-  const permissionSet = new Set(permissions.map((item) => item.permissionName));
-
   const filterTreeRecursive = (nodes) => {
     return nodes.reduce((filteredNodes, node) => {
       const newNode = { ...node };
-      if (newNode.children && newNode.children.length > 0) {
-        newNode.children = filterTreeRecursive(newNode.children);
-      }
-      if (
-        permissionSet.has(newNode.name) ||
-        (newNode.children && newNode.children.length > 0)
-      ) {
-        // 找到对应的iconName
-        const permission = permissions.find(
-          (perm) => perm.permissionName === newNode.name
-        );
-        if (permission && permission.permissionShow) {
-          newNode.meta.hidden = permission.permissionShow == 1 ? false : true;
-        }
-        if (permission && permission.permissionIconUrl) {
-          newNode.iconName = permission.permissionIconUrl;
-        } else {
-          newNode.iconName = "";
-        }
-        filteredNodes.push(newNode);
-      }
+      filteredNodes.push({
+        id: node.permissionId,
+        name: node.permissionName,
+        path: node.permissionCode,
+        meta: {
+          hidden: node.permissionShow == 1 ? false : true,
+        },
+        iconName: node.permissionIconUrl ? node.permissionIconUrl : "",
+        component: () =>
+          import(/*webpackChunkName:'system'*/ `@/views${node.permissionUrl}`),
+        children:
+          newNode.children && newNode.children.length > 0
+            ? filterTreeRecursive(newNode.children)
+            : undefined,
+      });
       return filteredNodes;
     }, []);
   };
-
-  return filterTreeRecursive(tree);
+  return { authRouterList: filterTreeRecursive(list) };
+  // 将list 转成一维数组,按钮级别权限拿到 返回为[]格式
+  //   const { result, anthBtnList } = flattenTree(list);
+  //   const arr = filterTreeByPermissions(result, orgList);
+  //   return { authRouterList: arr, anthBtnList };
+  // };
+  // const flattenTree = (tree) => {
+  //   let result = [];
+  //   let anthBtnList = [];
+  //   const flattenRecursive = (nodes) => {
+  //     nodes.forEach((node) => {
+  //       result.push(node);
+  //       if (node.children && node.children.length > 0) {
+  //         flattenRecursive(node.children);
+  //       }
+  //       if (node.permissionDepth === 2) {
+  //         anthBtnList.push(node);
+  //       }
+  //     });
+  //   };
+  //   flattenRecursive(tree);
+  //   return { result, anthBtnList };
+  // };
+  // const filterTreeByPermissions = (permissions, tree) => {
+  //   const permissionSet = new Set(permissions.map((item) => item.permissionName));
+  //   const filterTreeRecursive = (nodes) => {
+  //     return nodes.reduce((filteredNodes, node) => {
+  //       const newNode = { ...node };
+  //       if (newNode.children && newNode.children.length > 0) {
+  //         newNode.children = filterTreeRecursive(newNode.children);
+  //       }
+  //       if (
+  //         permissionSet.has(newNode.name) ||
+  //         (newNode.children && newNode.children.length > 0)
+  //       ) {
+  //         // 找到对应的iconName
+  //         const permission = permissions.find(
+  //           (perm) => perm.permissionName === newNode.name
+  //         );
+  //         if (permission && permission.permissionShow) {
+  //           newNode.meta.hidden = permission.permissionShow == 1 ? false : true;
+  //         }
+  //         if (permission && permission.permissionIconUrl) {
+  //           newNode.iconName = permission.permissionIconUrl;
+  //         } else {
+  //           newNode.iconName = "";
+  //         }
+  //         filteredNodes.push(newNode);
+  //       }
+  //       return filteredNodes;
+  //     }, []);
+  //   };
+  //   return filterTreeRecursive(tree);
 };

+ 7 - 7
src/views/error/405.vue

@@ -3,16 +3,16 @@
 </template>
 
 <script>
-import Page405 from '@/assets/error/405.svg'
-import ErrorPage from './components/ErrorPage.vue'
+import Page405 from "@/assets/error/404.svg";
+import ErrorPage from "./components/ErrorPage.vue";
 export default {
   components: {
-    ErrorPage
+    ErrorPage,
   },
   data() {
     return {
-      Page405: Page405
-    }
-  }
-}
+      Page405: Page405,
+    };
+  },
+};
 </script>

+ 6 - 11
src/views/home/components/Menu.vue

@@ -63,13 +63,8 @@
             v-for="child in item.children"
             v-if="child.meta?.hidden === false"
             :key="child.id"
-            :index="`/home/${item.path}/${child.path}?id=${child.id}`"
-            @click="
-              handleChangeMenuUrl(
-                child,
-                `/home/${item.path}/${child.path}?id=${child.id}`
-              )
-            "
+            :index="`${child.path}?id=${child.id}`"
+            @click="handleChangeMenuUrl(child, `${child.path}?id=${child.id}`)"
           >
             <i v-if="isElPrefix(child.iconName)" class="el-icon-menu"></i>
             <i v-else class="svnIcon">
@@ -81,8 +76,8 @@
         <el-menu-item
           v-else-if="item.meta?.hidden === false"
           :key="item.id"
-          :index="`/home/${item.path}?id=${item.id}`"
-          @click="handleChangeMenuUrl(item, `/home/${item.path}?id=${item.id}`)"
+          :index="`${item.path}?id=${item.id}`"
+          @click="handleChangeMenuUrl(item, `${item.path}?id=${item.id}`)"
         >
           <i v-if="isElPrefix(item.iconName)" class="el-icon-menu"></i>
           <i v-else class="svnIcon">
@@ -127,7 +122,7 @@ export default {
       routerList: [
         {
           id: 1,
-          path: "cockpitManage",
+          path: "/home/cockpitManage",
           name: "驾驶舱",
           iconName: "gps",
           meta: {
@@ -140,7 +135,7 @@ export default {
               meta: {
                 hidden: false,
               },
-              path: "electronic-map",
+              path: "/home/cockpitManage/electronic-map",
               name: "电子地图",
             },
           ],

+ 44 - 3
src/views/performance/components/analysisEvent.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2024-05-29 09:13:51
- * @LastEditTime: 2024-06-26 16:15:40
+ * @LastEditTime: 2024-07-04 10:37:21
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/analysisEvent.vue
@@ -43,6 +43,9 @@
                   multiple
                   clearable
                 >
+                  <el-checkbox v-model="checked" @change="selectAll"
+                    >全选</el-checkbox
+                  >
                   <el-option
                     v-for="item in analysisTypeList"
                     :key="item.typeCode"
@@ -64,6 +67,11 @@
                   size="small"
                   clearable
                 >
+                  <el-checkbox
+                    v-model="checkedTurbines"
+                    @change="selectAllTurbines"
+                    >全选</el-checkbox
+                  >
                   <el-option
                     v-for="item in windEngineGroupList"
                     :key="item.engineCode"
@@ -682,6 +690,8 @@ import { getWindEngineGroup } from "@/api/ledger";
 export default {
   data() {
     return {
+      checkedTurbines: false,
+      checked: false,
       htmlLoading: true,
       engineCode: null, //台账机组编号
       picker: [],
@@ -735,6 +745,26 @@ export default {
     this.getWindCodeList();
   },
   methods: {
+    selectAllTurbines() {
+      this.form.turbines = [];
+      if (this.checkedTurbines) {
+        this.windEngineGroupList.map((item) => {
+          this.form.turbines.push(item.engineCode);
+        });
+      } else {
+        this.form.turbines = [];
+      }
+    },
+    selectAll() {
+      this.form.configAnalysis = [];
+      if (this.checked) {
+        this.analysisTypeList.map((item) => {
+          this.form.configAnalysis.push(item.typeCode);
+        });
+      } else {
+        this.form.configAnalysis = [];
+      }
+    },
     iframeLoad() {
       this.htmlLoading = false;
     },
@@ -955,13 +985,24 @@ export default {
     }
   }
 }
+.el-select-dropdown__wrap {
+  .el-select-dropdown__list {
+    .el-checkbox {
+      display: flex;
+      justify-content: end;
+      margin: 0px 20px;
+    }
+  }
+}
+
 // .setting {
 //   font-size: 20px;
 //   font-weight: 900;
 // }
 ::v-deep.el-select--small,
 ::v-deep.el-select__tags {
-  width: 200px !important;
+  width: 220px !important;
+  // min-width: 180px !important;
   .el-tag--light {
     display: flex;
     justify-content: space-between;
@@ -1026,7 +1067,7 @@ export default {
   }
 }
 ::v-deep.el-input--small .el-input__inner {
-  width: 200px !important;
+  width: 220px !important;
 }
 .demo-input-suffix {
   display: flex !important;

+ 1 - 0
src/views/system/menuMag/components/editDialog.vue

@@ -256,6 +256,7 @@ export default {
           if (this.title === "编辑" && this.row) {
             updateMenuFn({
               ...this.menuForm,
+              ptype: this.activeName,
               permissionId: this.row.permissionId,
             })
               .then((res) => {