Просмотр исходного кода

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

RuoYi лет назад: 2
Родитель
Сommit
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
     change(val) {
72
     change(val) {
73
       const path = val.path;
73
       const path = val.path;
74
+      const query = val.query;
74
       if(this.ishttp(val.path)) {
75
       if(this.ishttp(val.path)) {
75
         // http(s):// 路径新窗口打开
76
         // http(s):// 路径新窗口打开
76
         const pindex = path.indexOf("http");
77
         const pindex = path.indexOf("http");
77
         window.open(path.substr(pindex, path.length), "_blank");
78
         window.open(path.substr(pindex, path.length), "_blank");
78
       } else {
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
       this.search = ''
86
       this.search = ''
82
       this.options = []
87
       this.options = []
@@ -102,7 +107,7 @@ export default {
102
     },
107
     },
103
     // Filter out the routes that can be displayed in the sidebar
108
     // Filter out the routes that can be displayed in the sidebar
104
     // And generate the internationalized title
109
     // And generate the internationalized title
105
-    generateRoutes(routes, basePath = '/', prefixTitle = []) {
110
+    generateRoutes(routes, basePath = '/', prefixTitle = [], query = {}) {
106
       let res = []
111
       let res = []
107
 
112
 
108
       for (const router of routes) {
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
         // recursive child routes
136
         // recursive child routes
128
         if (router.children) {
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
           if (tempRoutes.length >= 1) {
139
           if (tempRoutes.length >= 1) {
131
             res = [...res, ...tempRoutes]
140
             res = [...res, ...tempRoutes]
132
           }
141
           }