WIP Добавил max и min парамметры для инпута
This commit is contained in:
@@ -52,7 +52,7 @@ import { v_model } from "@/shared/mixins/v-model";
|
||||
import BaseInputContainer from "@/components/base/BaseInputContainer.vue";
|
||||
|
||||
export default {
|
||||
name: "BaseNumberInput",
|
||||
name: "BaseInputNumber",
|
||||
components: { BaseInput, BaseInputContainer },
|
||||
mixins: [v_model],
|
||||
data() {
|
||||
@@ -65,6 +65,15 @@ export default {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
max: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
min: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
reverseValue: Boolean,
|
||||
multiple: Boolean,
|
||||
circle: Boolean,
|
||||
doc: Boolean,
|
||||
@@ -128,14 +137,26 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
increment() {
|
||||
this.value = Number.parseFloat(Number(this.value) + this.step).toFixed(
|
||||
this.rounding
|
||||
);
|
||||
if (this.value < this.max) {
|
||||
this.value = Number.parseFloat(Number(this.value) + this.step).toFixed(
|
||||
this.rounding
|
||||
);
|
||||
} else {
|
||||
if (this.reverseValue) {
|
||||
this.value = this.min;
|
||||
}
|
||||
}
|
||||
},
|
||||
decrement() {
|
||||
this.value = Number.parseFloat(this.value - this.step).toFixed(
|
||||
this.rounding
|
||||
);
|
||||
if (this.min < this.value) {
|
||||
this.value = Number.parseFloat(this.value - this.step).toFixed(
|
||||
this.rounding
|
||||
);
|
||||
} else {
|
||||
if (this.reverseValue) {
|
||||
this.value = this.max;
|
||||
}
|
||||
}
|
||||
},
|
||||
fastIncrement() {
|
||||
this.intervalId = setInterval(() => this.increment(), 100);
|
||||
Reference in New Issue
Block a user