diff --git a/src/components/scFilterBar/index.vue b/src/components/scFilterBar/index.vue index dc02e22..1a4d019 100644 --- a/src/components/scFilterBar/index.vue +++ b/src/components/scFilterBar/index.vue @@ -151,11 +151,16 @@ const obj = {} this.filter.forEach((item) => { - if (this.data[item.field.name]!==null && this.data[item.field.name]!=='') { - obj[item.field.name] = item.operator ? this.data[item.field.name]+`${config.separator}${item.operator}` : this.data[item.field.name] + if (!this.data[item.field.name] || this.data[item.field.name] === '') { + return; // 跳过当前迭代,继续下一次迭代 } + + obj[item.field.name] = item.operator ? this.data[item.field.name]+`${config.separator}${item.operator}` : this.data[item.field.name] }) + + console.log(obj, this.filter) + return obj } }, @@ -311,8 +316,15 @@ //清空过滤 clear(){ - this.data = Object.assign({}, this.defaultValue); - this.filter = [] + Object.keys(this.data).forEach(key => { + if (this.data[key] === this.defaultValue[key]) { + this.data[key] = this.defaultValue[key]; + } else { + this.data[key] = ''; + } + }); + + // this.filter = [] this.filterObjLength = 0 this.$emit('filterChange',this.filterObj) }