WIP Добавил max и min парамметры для инпута

This commit is contained in:
DwCay
2023-05-17 10:54:07 +03:00
parent 9917efd2ae
commit 277681804d
2 changed files with 34 additions and 10 deletions

View File

@@ -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);