|
@@ -20,6 +20,7 @@
|
|
|
class="min-input"
|
|
|
name="minprice"
|
|
|
maxlength="9"
|
|
|
+ oninput="value=value.replace(/[^\d]/g, '')"
|
|
|
v-model.number="inputGroupCache.min"
|
|
|
/>
|
|
|
<span class="unit">万元</span>
|
|
@@ -31,6 +32,7 @@
|
|
|
class="max-input"
|
|
|
name="maxprice"
|
|
|
maxlength="9"
|
|
|
+ oninput="value=value.replace(/[^\d]/g, '')"
|
|
|
v-model.number="inputGroupCache.max"
|
|
|
/>
|
|
|
<span class="unit">万元</span>
|
|
@@ -69,7 +71,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- value: '',
|
|
|
+ checkedAll: true,
|
|
|
inputGroupCache: {
|
|
|
min: '',
|
|
|
max: ''
|
|
@@ -88,24 +90,19 @@ export default {
|
|
|
} else {
|
|
|
return `${this.placeholder}`
|
|
|
}
|
|
|
- },
|
|
|
- checkedAll() {
|
|
|
- const exact = this.price.min || this.price.max
|
|
|
- return !exact
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
resetStatePrice() {
|
|
|
- this.price.min = ''
|
|
|
- this.price.max = ''
|
|
|
- },
|
|
|
- resetPrice() {
|
|
|
+ this.checkedAll = true
|
|
|
this.inputGroupCache.min = ''
|
|
|
this.inputGroupCache.max = ''
|
|
|
+ this.price.min = ''
|
|
|
+ this.price.max = ''
|
|
|
},
|
|
|
clickAll() {
|
|
|
this.resetStatePrice()
|
|
|
- this.onChange()
|
|
|
+ // this.onChange()
|
|
|
},
|
|
|
compareMinMax() {
|
|
|
const { min, max } = this.inputGroupCache
|
|
@@ -119,9 +116,11 @@ export default {
|
|
|
this.price.min = min
|
|
|
this.price.max = max
|
|
|
if (min !== '') {
|
|
|
+ this.checkedAll = false
|
|
|
this.inputGroupCache.min = min
|
|
|
}
|
|
|
if (max !== '') {
|
|
|
+ this.checkedAll = false
|
|
|
this.inputGroupCache.max = max
|
|
|
}
|
|
|
if (min !== '' && max !== '') {
|
|
@@ -130,18 +129,25 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (min === '' && max === '') {
|
|
|
- this.resetPrice()
|
|
|
- this.onChange()
|
|
|
+ this.resetStatePrice()
|
|
|
}
|
|
|
},
|
|
|
getState() {
|
|
|
- return this.price
|
|
|
+ if (this.checkedAll) {
|
|
|
+ return { min: '', max: '' }
|
|
|
+ } else {
|
|
|
+ return this.inputGroupCache
|
|
|
+ }
|
|
|
},
|
|
|
syncToPrice() {
|
|
|
Object.assign(this.price, this.inputGroupCache)
|
|
|
},
|
|
|
onConfirm() {
|
|
|
this.compareMinMax()
|
|
|
+ const { min, max } = this.inputGroupCache
|
|
|
+ if (min || max) {
|
|
|
+ this.checkedAll = false
|
|
|
+ }
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.selectprice.blur()
|
|
|
this.syncToPrice()
|
|
@@ -155,8 +161,6 @@ export default {
|
|
|
if (min === '' || max === '') {
|
|
|
return this.$toast('最小值和最大值均为必填')
|
|
|
}
|
|
|
- } else {
|
|
|
- if (min === '' && max === '') return
|
|
|
}
|
|
|
this.$emit('change', state)
|
|
|
}
|