!289 添加日期范围支持重复添加多组日期范围,请求参数中对象的属性为null、undefined不进行拼接

Merge pull request !289 from wangzhaoqiang/master
master
若依 3 years ago committed by Gitee
commit 6f51f729ba

@ -28,9 +28,11 @@ service.interceptors.request.use(config => {
if (value !== null && typeof(value) !== "undefined") { if (value !== null && typeof(value) !== "undefined") {
if (typeof value === 'object') { if (typeof value === 'object') {
for (const key of Object.keys(value)) { for (const key of Object.keys(value)) {
let params = propName + '[' + key + ']'; if (value[key] !== null && typeof (value[key]) !== 'undefined') {
var subPart = encodeURIComponent(params) + "="; let params = propName + '[' + key + ']'
url += subPart + encodeURIComponent(value[key]) + "&"; let subPart = encodeURIComponent(params) + '='
url += subPart + encodeURIComponent(value[key]) + '&'
}
} }
} else { } else {
url += part + encodeURIComponent(value) + "&"; url += part + encodeURIComponent(value) + "&";

@ -55,18 +55,17 @@ export function resetForm(refName) {
// 添加日期范围 // 添加日期范围
export function addDateRange(params, dateRange, propName) { export function addDateRange(params, dateRange, propName) {
var search = params; let search = params
search.params = {}; search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}
if (null != dateRange && '' != dateRange) { dateRange = Array.isArray(dateRange) ? dateRange : []
if (typeof (propName) === "undefined") { if (typeof (propName) === 'undefined') {
search.params["beginTime"] = dateRange[0]; search.params['beginTime'] = dateRange[0]
search.params["endTime"] = dateRange[1]; search.params['endTime'] = dateRange[1]
} else { } else {
search.params["begin" + propName] = dateRange[0]; search.params['begin' + propName] = dateRange[0]
search.params["end" + propName] = dateRange[1]; search.params['end' + propName] = dateRange[1]
} }
} return search
return search;
} }
// 回显数据字典 // 回显数据字典

Loading…
Cancel
Save