diff --git a/src/components/mobile/NumberPadSheet.vue b/src/components/mobile/NumberPadSheet.vue index d3985b8b..0282a42a 100644 --- a/src/components/mobile/NumberPadSheet.vue +++ b/src/components/mobile/NumberPadSheet.vue @@ -64,6 +64,8 @@ export default { props: [ 'value', + 'minValue', + 'maxValue', 'show' ], data() { @@ -147,7 +149,27 @@ export default { return; } - this.currentValue = this.currentValue + num.toString(); + const newValue = this.currentValue + num.toString(); + + if (this.$utilities.isString(this.minValue) && this.minValue !== '') { + const min = this.$utilities.stringCurrencyToNumeric(this.minValue); + const current = this.$utilities.stringCurrencyToNumeric(newValue); + + if (current < min) { + return; + } + } + + if (this.$utilities.isString(this.maxValue) && this.maxValue !== '') { + const max = this.$utilities.stringCurrencyToNumeric(this.maxValue); + const current = this.$utilities.stringCurrencyToNumeric(newValue); + + if (current > max) { + return; + } + } + + this.currentValue = newValue; }, inputDot() { if (this.currentValue.indexOf('.') >= 0) { @@ -165,7 +187,11 @@ export default { setSymbol(symbol) { if (this.currentValue) { if (this.currentSymbol) { - this.confirm(); + const lastFormulaCalcResult = this.confirm(); + + if (!lastFormulaCalcResult) { + return; + } } this.previousValue = this.currentValue; @@ -212,18 +238,42 @@ export default { finalValue = previousValue; } + if (this.$utilities.isString(this.minValue) && this.minValue !== '') { + const min = this.$utilities.stringCurrencyToNumeric(this.minValue); + + if (finalValue < min) { + this.$toast('Numeric Overflow'); + return false; + } + } + + if (this.$utilities.isString(this.maxValue) && this.maxValue !== '') { + const max = this.$utilities.stringCurrencyToNumeric(this.maxValue); + + if (finalValue > max) { + this.$toast('Numeric Overflow'); + return false; + } + } + this.currentValue = this.getStringValue(finalValue); this.previousValue = ''; this.currentSymbol = ''; + + return true; } else if (this.currentSymbol && this.currentValue.length < 1) { this.currentValue = this.previousValue; this.previousValue = ''; this.currentSymbol = ''; + + return true; } else { const value = this.$utilities.stringCurrencyToNumeric(this.currentValue); this.$emit('input', value); this.$emit('update:show', false); + + return true; } }, onSheetOpen() { diff --git a/src/locales/en.js b/src/locales/en.js index fea3e193..15f8e8f8 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -630,4 +630,5 @@ export default { 'License': 'License', 'An error has occurred': 'An error has occurred', 'Parameter Invalid': 'Parameter Invalid', + 'Numeric Overflow': 'Numeric Overflow', }; diff --git a/src/locales/zh_Hans.js b/src/locales/zh_Hans.js index cd8d670a..2a9686dd 100644 --- a/src/locales/zh_Hans.js +++ b/src/locales/zh_Hans.js @@ -630,4 +630,5 @@ export default { 'License': '许可协议', 'An error has occurred': '发生错误', 'Parameter Invalid': '参数错误', + 'Numeric Overflow': '数值溢出', };