Procházet zdrojové kódy

修复导出含params属性对象参数问题

RuoYi před 4 roky
rodič
revize
892065003d
2 změnil soubory, kde provedl 16 přidání a 21 odebrání
  1. 1 16
      ruoyi-ui/src/utils/request.js
  2. 15 5
      ruoyi-ui/src/utils/ruoyi.js

+ 1 - 16
ruoyi-ui/src/utils/request.js

@@ -23,22 +23,7 @@ service.interceptors.request.use(config => {
23
   }
23
   }
24
   // get请求映射params参数
24
   // get请求映射params参数
25
   if (config.method === 'get' && config.params) {
25
   if (config.method === 'get' && config.params) {
26
-    let url = config.url + '?';
27
-    for (const propName of Object.keys(config.params)) {
28
-      const value = config.params[propName];
29
-      var part = encodeURIComponent(propName) + "=";
30
-      if (value !== null && typeof(value) !== "undefined") {
31
-        if (typeof value === 'object') {
32
-          for (const key of Object.keys(value)) {
33
-            let params = propName + '[' + key + ']';
34
-            var subPart = encodeURIComponent(params) + "=";
35
-            url += subPart + encodeURIComponent(value[key]) + "&";
36
-          }
37
-        } else {
38
-          url += part + encodeURIComponent(value) + "&";
39
-        }
40
-      }
41
-    }
26
+    let url = config.url + '?' + tansParams(config.params);
42
     url = url.slice(0, -1);
27
     url = url.slice(0, -1);
43
     config.params = {};
28
     config.params = {};
44
     config.url = url;
29
     config.url = url;

+ 15 - 5
ruoyi-ui/src/utils/ruoyi.js

@@ -179,11 +179,21 @@ export function handleTree(data, id, parentId, children) {
179
 * @param {*} params  参数
179
 * @param {*} params  参数
180
 */
180
 */
181
 export function tansParams(params) {
181
 export function tansParams(params) {
182
-	let result = ''
183
-	Object.keys(params).forEach((key) => {
184
-		if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) {
185
-			result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + '&'
182
+    let result = ''
183
+    for (const propName of Object.keys(params)) {
184
+        const value = params[propName];
185
+        var part = encodeURIComponent(propName) + "=";
186
+        if (value !== null && typeof(value) !== "undefined") {
187
+            if (typeof value === 'object') {
188
+				for (const key of Object.keys(value)) {
189
+					let params = propName + '[' + key + ']';
190
+					var subPart = encodeURIComponent(params) + "=";
191
+					result += subPart + encodeURIComponent(value[key]) + "&";
192
+				}
193
+            } else {
194
+				result += part + encodeURIComponent(value) + "&";
195
+            }
186
 		}
196
 		}
187
-	})
197
+    }
188
 	return result
198
 	return result
189
 }
199
 }