From 57b159eb98577f910e586f3cf79356274d68db0f Mon Sep 17 00:00:00 2001 From: wangzhaoqiang Date: Mon, 16 Aug 2021 14:48:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E6=9C=9F=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E6=94=AF=E6=8C=81=E9=87=8D=E5=A4=8D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E7=BB=84=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4=EF=BC=8C?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0=E4=B8=AD=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E7=9A=84=E5=B1=9E=E6=80=A7=E4=B8=BAnull=E3=80=81undefined?= =?UTF-8?q?=E4=B8=8D=E8=BF=9B=E8=A1=8C=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/request.js | 8 +++++--- ruoyi-ui/src/utils/ruoyi.js | 23 +++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index 7a058e870..e95d01d91 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -28,9 +28,11 @@ service.interceptors.request.use(config => { if (value !== null && typeof(value) !== "undefined") { if (typeof value === 'object') { for (const key of Object.keys(value)) { - let params = propName + '[' + key + ']'; - var subPart = encodeURIComponent(params) + "="; - url += subPart + encodeURIComponent(value[key]) + "&"; + if (value[key] !== null && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']' + let subPart = encodeURIComponent(params) + '=' + url += subPart + encodeURIComponent(value[key]) + '&' + } } } else { url += part + encodeURIComponent(value) + "&"; diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index bf8390e97..db428850f 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -55,18 +55,17 @@ export function resetForm(refName) { // 添加日期范围 export function addDateRange(params, dateRange, propName) { - var search = params; - search.params = {}; - if (null != dateRange && '' != dateRange) { - if (typeof (propName) === "undefined") { - search.params["beginTime"] = dateRange[0]; - search.params["endTime"] = dateRange[1]; - } else { - search.params["begin" + propName] = dateRange[0]; - search.params["end" + propName] = dateRange[1]; - } - } - return search; + let search = params + search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {} + dateRange = Array.isArray(dateRange) ? dateRange : [] + if (typeof (propName) === 'undefined') { + search.params['beginTime'] = dateRange[0] + search.params['endTime'] = dateRange[1] + } else { + search.params['begin' + propName] = dateRange[0] + search.params['end' + propName] = dateRange[1] + } + return search } // 回显数据字典