Merge branch 'ASTRA-85' into 'master'
WIP Исправил ошибки ввода в числовой инпут See merge request andrusyakka/urban-couscous!382
This commit is contained in:
@@ -1,21 +1,22 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
base-input-container.gap-y-2(:label="label", :style="{width: width + 'px' }")
|
base-input-container.gap-y-2(:label="label", :style="{width: width + 'px' }")
|
||||||
q-input(
|
q-input(
|
||||||
|
ref="numberInput"
|
||||||
v-model="value",
|
v-model="value",
|
||||||
:name="name",
|
:name="name",
|
||||||
:multiple="multiple"
|
:multiple="multiple",
|
||||||
:class="{'circle': circle, 'font-input': true, 'doc': doc}",
|
:class="{'circle': circle, 'font-input': true, 'doc': doc}",
|
||||||
:input-style="{ color: textColor, borderColor: borderColor, resize: resize}",
|
:input-style="{ color: textColor, borderColor: borderColor, resize: resize }",
|
||||||
:borderless="borderless",
|
:borderless="borderless",
|
||||||
:placeholder="placeholder",
|
:placeholder="placeholder",
|
||||||
:outlined="outlined",
|
:outlined="outlined",
|
||||||
:dense="dense",
|
:dense="dense",
|
||||||
:type="type",
|
type="number",
|
||||||
:readonly="readonly",
|
:readonly="readonly",
|
||||||
:disable="disabled",
|
:disable="disabled",
|
||||||
:filled="filled",
|
:filled="filled",
|
||||||
:bg-color="filled || standout ? '' : 'white'",
|
:bg-color="filled || standout ? '' : 'white'",
|
||||||
:rules="rule",
|
:rules="rule || ruleNumberInput",
|
||||||
:lazy-rules="lazyRule",
|
:lazy-rules="lazyRule",
|
||||||
:item-aligned="itemAligned",
|
:item-aligned="itemAligned",
|
||||||
:no-error-icon="noErrorIcon",
|
:no-error-icon="noErrorIcon",
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
:square="square",
|
:square="square",
|
||||||
:standout="standout"
|
:standout="standout"
|
||||||
:accept="accept",
|
:accept="accept",
|
||||||
:debounce="debounce",
|
:debounce="null",
|
||||||
:shadow-text="shadowText"
|
:shadow-text="shadowText"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
)
|
)
|
||||||
@@ -48,16 +49,16 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BaseInput from "@/components/base/BaseInput";
|
import BaseInput from "@/components/base/BaseInput";
|
||||||
import { v_model } from "@/shared/mixins/v-model";
|
|
||||||
import BaseInputContainer from "@/components/base/BaseInputContainer.vue";
|
import BaseInputContainer from "@/components/base/BaseInputContainer.vue";
|
||||||
|
import { ruleNumberInput } from "@/shared/utils/rulesInputs";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "BaseInputNumber",
|
name: "BaseInputNumber",
|
||||||
components: { BaseInput, BaseInputContainer },
|
components: { BaseInput, BaseInputContainer },
|
||||||
mixins: [v_model],
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
intervalId: 0,
|
intervalId: 0,
|
||||||
|
ruleNumberInput: [(val) => ruleNumberInput(val, this.max, this.min)],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -101,9 +102,6 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
type: {
|
|
||||||
default: "text",
|
|
||||||
},
|
|
||||||
standout: {
|
standout: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false,
|
default: false,
|
||||||
@@ -124,10 +122,13 @@ export default {
|
|||||||
textColor: String,
|
textColor: String,
|
||||||
borderColor: String,
|
borderColor: String,
|
||||||
rule: Array,
|
rule: Array,
|
||||||
lazyRule: [Boolean, String],
|
lazyRule: String,
|
||||||
noErrorIcon: Boolean,
|
noErrorIcon: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
itemAligned: Boolean,
|
itemAligned: Boolean,
|
||||||
modelValue: [String, Date, Number],
|
modelValue: [Number],
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
label: String,
|
label: String,
|
||||||
@@ -135,26 +136,29 @@ export default {
|
|||||||
iconLeft: Boolean,
|
iconLeft: Boolean,
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
emits: ["update:modelValue"],
|
||||||
methods: {
|
methods: {
|
||||||
increment() {
|
increment() {
|
||||||
if (this.value < this.max) {
|
if (this.modelValue < this.max) {
|
||||||
this.value = Number.parseFloat(Number(this.value) + this.step).toFixed(
|
this.$emit(
|
||||||
this.rounding
|
"update:modelValue",
|
||||||
|
Number((this.modelValue + this.step).toFixed(this.rounding))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (this.reverseValue) {
|
if (this.reverseValue) {
|
||||||
this.value = this.min;
|
this.$emit("update:modelValue", this.min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
decrement() {
|
decrement() {
|
||||||
if (this.min < this.value) {
|
if (this.min < this.modelValue) {
|
||||||
this.value = Number.parseFloat(this.value - this.step).toFixed(
|
this.$emit(
|
||||||
this.rounding
|
"update:modelValue",
|
||||||
|
Number((this.modelValue - this.step).toFixed(this.rounding))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (this.reverseValue) {
|
if (this.reverseValue) {
|
||||||
this.value = this.max;
|
this.$emit("update:modelValue", this.max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -168,7 +172,20 @@ export default {
|
|||||||
clearInterval(this.intervalId);
|
clearInterval(this.intervalId);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
value(val) {
|
||||||
|
this.value = Number(val).toFixed(this.rounding);
|
||||||
|
},
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
value: {
|
||||||
|
get() {
|
||||||
|
return this.modelValue ? this.modelValue : 0;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.$emit("update:modelValue", Number(value));
|
||||||
|
},
|
||||||
|
},
|
||||||
rounding() {
|
rounding() {
|
||||||
return String(this.step).split(".")[1]?.length || 0;
|
return String(this.step).split(".")[1]?.length || 0;
|
||||||
},
|
},
|
||||||
@@ -180,6 +197,8 @@ export default {
|
|||||||
.q-field .q-field__control-container
|
.q-field .q-field__control-container
|
||||||
display: flex
|
display: flex
|
||||||
align-items: center
|
align-items: center
|
||||||
|
input[type=number]::-webkit-inner-spin-button
|
||||||
|
-webkit-appearance: none
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
outlined,
|
outlined,
|
||||||
:shadow-text="data.config[key].shadowText",
|
:shadow-text="data.config[key].shadowText",
|
||||||
:placeholder="`0${data.config[key].shadowText}`"
|
:placeholder="`0${data.config[key].shadowText}`"
|
||||||
mask="###"
|
|
||||||
)
|
)
|
||||||
.flex.flex-col.gap-y-2.w-full(v-if="data.key === 'thermometry'")
|
.flex.flex-col.gap-y-2.w-full(v-if="data.key === 'thermometry'")
|
||||||
base-input.w-full(
|
base-input.w-full(
|
||||||
|
|||||||
@@ -819,8 +819,8 @@ export const protocolForms = [
|
|||||||
title: "Реакция на холод",
|
title: "Реакция на холод",
|
||||||
label: "Температура",
|
label: "Температура",
|
||||||
shadowText: "º",
|
shadowText: "º",
|
||||||
max: 100,
|
max: 25,
|
||||||
min: 1,
|
min: -40,
|
||||||
color: "var(--font-cold-color)",
|
color: "var(--font-cold-color)",
|
||||||
bg: "var(--bg-cold-color)",
|
bg: "var(--bg-cold-color)",
|
||||||
icon: "ac_unit",
|
icon: "ac_unit",
|
||||||
@@ -833,7 +833,7 @@ export const protocolForms = [
|
|||||||
label: "Температура",
|
label: "Температура",
|
||||||
shadowText: "º",
|
shadowText: "º",
|
||||||
max: 100,
|
max: 100,
|
||||||
min: 1,
|
min: 45,
|
||||||
color: "var(--font-heat-color)",
|
color: "var(--font-heat-color)",
|
||||||
bg: "var(--bg-heat-color)",
|
bg: "var(--bg-heat-color)",
|
||||||
icon: "local_fire_department",
|
icon: "local_fire_department",
|
||||||
|
|||||||
@@ -27,3 +27,6 @@ export function ruleDateValue(val, text) {
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export function ruleNumberInput(val, max, min, text) {
|
||||||
|
return (val <= max && val >= min) || text || false;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user