| | |
| | | </view> |
| | | <view |
| | | class="c-filter-more" |
| | | :class="itemsChanged?'on':''" |
| | | :class="itemsFilled?'on':''" |
| | | v-if="items && items.length > 0" |
| | | @tap="evt => handleOpen()" |
| | | > |
| | |
| | | return { |
| | | filterRes: {}, |
| | | drawerShow: false, |
| | | // 面板项有已选 |
| | | itemsFilled: false, |
| | | // 本次打开是否有改变 |
| | | itemsChanged: false, |
| | | }; |
| | | }, |
| | |
| | | this.onChange(this.filterRes); |
| | | }, |
| | | handleItemChange(name, value) { |
| | | this.handleBarChange(name, value); |
| | | if (value || typeof value !== 'undefined') { |
| | | this.itemsChanged = true; |
| | | } else { |
| | | console.log(name, value); |
| | | this.$set(this.filterRes, name, value); |
| | | this.itemsChanged = true; |
| | | // 如果变化值不为空 |
| | | if (typeof value !== 'undefined') { |
| | | this.itemsFilled = true; |
| | | } |
| | | // 为空是检查所有面板值是否为空 |
| | | else { |
| | | let valuehas = false; |
| | | for (let item of items) { |
| | | if ( |
| | | this.filterRes[item.name] || |
| | | typeof this.filterRes[item.name] !== 'undefined' |
| | | ) { |
| | | for (let item of this.items) { |
| | | if (typeof this.filterRes[item.name] !== 'undefined') { |
| | | valuehas = true; |
| | | break; |
| | | } |
| | | } |
| | | this.itemsChanged = valuehas; |
| | | this.itemsFilled = valuehas; |
| | | } |
| | | }, |
| | | handleClean() { |
| | | Object.keys(this.filterRes).forEach(key => { |
| | | this.filterRes[key] = [][0]; |
| | | }); |
| | | this.itemsFilled = false; |
| | | this.itemsChanged = false; |
| | | this.onChange(this.filterRes); |
| | | }, |
| | | handleFinish() { |
| | | this.drawerShow = false; |
| | | // 有项目改变时,发送变化 |
| | | if (this.itemsChanged) { |
| | | this.itemsChanged = false; |
| | | this.onChange(this.filterRes); |
| | | } |
| | | }, |
| | | }, |
| | | }; |