fix: 연산단위 최소값 지정

This commit is contained in:
2022-06-15 23:11:07 +09:00
parent d38ddcd79e
commit dca341f35e
2 changed files with 16 additions and 1 deletions
+2
View File
@@ -102,6 +102,7 @@
<NumberInputWithInfo <NumberInputWithInfo
v-model="nationPolicy.minimumResourceActionAmount" v-model="nationPolicy.minimumResourceActionAmount"
:step="100" :step="100"
:min="100"
title="포상/몰수/헌납/삼/팜 최소 단위" title="포상/몰수/헌납/삼/팜 최소 단위"
> >
연산결과가 단위보다 적다면 수행하지 않습니다. 연산결과가 단위보다 적다면 수행하지 않습니다.
@@ -111,6 +112,7 @@
<NumberInputWithInfo <NumberInputWithInfo
v-model="nationPolicy.maximumResourceActionAmount" v-model="nationPolicy.maximumResourceActionAmount"
:step="100" :step="100"
:min="100"
title="포상/몰수/헌납/삼/팜 최대 단위" title="포상/몰수/헌납/삼/팜 최대 단위"
> >
연산결과가 단위보다 크다면, 값에 맞춥니다. 연산결과가 단위보다 크다면, 값에 맞춥니다.
+13
View File
@@ -30,6 +30,7 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { clamp } from "lodash";
import { defineComponent } from "vue"; import { defineComponent } from "vue";
export default defineComponent({ export default defineComponent({
@@ -98,11 +99,23 @@ export default defineComponent({
this.rawValue = Math.floor(this.rawValue); this.rawValue = Math.floor(this.rawValue);
} }
this.printValue = this.rawValue.toLocaleString(); this.printValue = this.rawValue.toLocaleString();
if (this.min !== undefined || this.max !== undefined) {
const clampedValue = clamp(this.rawValue, this.min ?? this.rawValue, this.max ?? this.rawValue);
this.$emit("update:modelValue", clampedValue);
} else {
this.$emit("update:modelValue", this.rawValue); this.$emit("update:modelValue", this.rawValue);
}
}, },
onBlurNumber() { onBlurNumber() {
this.editmode = false; this.editmode = false;
this.printValue = this.rawValue.toLocaleString(); this.printValue = this.rawValue.toLocaleString();
if (this.min !== undefined || this.max !== undefined) {
const clampedValue = clamp(this.rawValue, this.min ?? this.rawValue, this.max ?? this.rawValue);
if (clampedValue !== this.rawValue) {
this.rawValue = clampedValue;
this.updateValue();
}
}
}, },
onFocusText() { onFocusText() {
if (this.readonly) { if (this.readonly) {