|
|
@@ -6,7 +6,7 @@
|
|
|
type="number"
|
|
|
:min="minNum"
|
|
|
:max="max"
|
|
|
- :readonly="readonly"
|
|
|
+ :readonly="readonly || !this.isLegal"
|
|
|
:value="num | maxv(minNum, max)"
|
|
|
:style="{ visibility: showNum ? 'visible' : 'hidden' }"
|
|
|
@input="numchange"
|
|
|
@@ -42,7 +42,7 @@
|
|
|
<div>{{ animNum[0] }}</div>
|
|
|
<div>{{ animNum[1] }}</div>
|
|
|
</div>
|
|
|
- <div class="oper-wrapper add-wrapper" @click="add()"><span :class="{ 'nut-stepper-grey': max && Number(num) > max - step }" v-html="require('../../assets/svg/add.svg')"> </span></div>
|
|
|
+ <div class="oper-wrapper add-wrapper" @click="add()"><span :class="{ 'nut-stepper-grey': max && Number(num) > (max - step) || !this.isLegal}" v-html="require('../../assets/svg/add.svg')"> </span></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -93,7 +93,8 @@ export default {
|
|
|
showReduceAnim: false,
|
|
|
animNum: [this.value, this.value],
|
|
|
animTranslate_add: 0,
|
|
|
- animTranslate_: -100
|
|
|
+ animTranslate_: -100,
|
|
|
+ isLegal:true //是否合法 isLegal
|
|
|
};
|
|
|
},
|
|
|
filters: {
|
|
|
@@ -116,8 +117,20 @@ export default {
|
|
|
},
|
|
|
min: {
|
|
|
handler(v, ov) {
|
|
|
+ this.isLegal = true
|
|
|
if (v < this.max) {
|
|
|
this.minNum = v;
|
|
|
+ }else{
|
|
|
+ this.isLegal = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ },
|
|
|
+ max: {
|
|
|
+ handler(v, ov) {
|
|
|
+ this.isLegal = true
|
|
|
+ if (v <= this.min) {
|
|
|
+ this.isLegal = false
|
|
|
}
|
|
|
},
|
|
|
immediate: true
|
|
|
@@ -130,7 +143,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
focus(e) {
|
|
|
- if (this.readonly) return;
|
|
|
+ if (this.readonly || !this.isLegal) return;
|
|
|
// clear val temporary when focus, e...s
|
|
|
//选中选择框值
|
|
|
this.$refs.number.select();
|
|
|
@@ -142,7 +155,7 @@ export default {
|
|
|
this.$emit('focus', e, this.num);
|
|
|
},
|
|
|
blur(e) {
|
|
|
- if (this.readonly) return this.$emit('blur', e, this.num);
|
|
|
+ if (this.readonly || !this.isLegal) return this.$emit('blur', e, this.num);
|
|
|
let v = e.target.value;
|
|
|
this.minNum = this.min;
|
|
|
this.focusing = false;
|