Переглянути джерело

修复HeaderSearch组件跳转query参数丢失问题

RuoYi 2 роки тому
батько
коміт
c4cda3f4ad
1 змінених файлів з 12 додано та 3 видалено
  1. 12 3
      ruoyi-ui/src/components/HeaderSearch/index.vue

+ 12 - 3
ruoyi-ui/src/components/HeaderSearch/index.vue

@@ -71,12 +71,17 @@ export default {
71 71
     },
72 72
     change(val) {
73 73
       const path = val.path;
74
+      const query = val.query;
74 75
       if(this.ishttp(val.path)) {
75 76
         // http(s):// 路径新窗口打开
76 77
         const pindex = path.indexOf("http");
77 78
         window.open(path.substr(pindex, path.length), "_blank");
78 79
       } else {
79
-        this.$router.push(val.path)
80
+        if (query) {
81
+          this.$router.push({ path: path, query: JSON.parse(query) });
82
+        } else {
83
+          this.$router.push(path)
84
+        }
80 85
       }
81 86
       this.search = ''
82 87
       this.options = []
@@ -102,7 +107,7 @@ export default {
102 107
     },
103 108
     // Filter out the routes that can be displayed in the sidebar
104 109
     // And generate the internationalized title
105
-    generateRoutes(routes, basePath = '/', prefixTitle = []) {
110
+    generateRoutes(routes, basePath = '/', prefixTitle = [], query = {}) {
106 111
       let res = []
107 112
 
108 113
       for (const router of routes) {
@@ -124,9 +129,13 @@ export default {
124 129
           }
125 130
         }
126 131
 
132
+        if (router.query) {
133
+          data.query = router.query
134
+        }
135
+
127 136
         // recursive child routes
128 137
         if (router.children) {
129
-          const tempRoutes = this.generateRoutes(router.children, data.path, data.title)
138
+          const tempRoutes = this.generateRoutes(router.children, data.path, data.title, data.query)
130 139
           if (tempRoutes.length >= 1) {
131 140
             res = [...res, ...tempRoutes]
132 141
           }