diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 67a3118..ce7253a 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -55,16 +55,15 @@ 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]; - } + 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; }