mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
numpad supports min and max value
This commit is contained in:
@@ -64,6 +64,8 @@
|
|||||||
export default {
|
export default {
|
||||||
props: [
|
props: [
|
||||||
'value',
|
'value',
|
||||||
|
'minValue',
|
||||||
|
'maxValue',
|
||||||
'show'
|
'show'
|
||||||
],
|
],
|
||||||
data() {
|
data() {
|
||||||
@@ -147,7 +149,27 @@ export default {
|
|||||||
return;
|
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() {
|
inputDot() {
|
||||||
if (this.currentValue.indexOf('.') >= 0) {
|
if (this.currentValue.indexOf('.') >= 0) {
|
||||||
@@ -165,7 +187,11 @@ export default {
|
|||||||
setSymbol(symbol) {
|
setSymbol(symbol) {
|
||||||
if (this.currentValue) {
|
if (this.currentValue) {
|
||||||
if (this.currentSymbol) {
|
if (this.currentSymbol) {
|
||||||
this.confirm();
|
const lastFormulaCalcResult = this.confirm();
|
||||||
|
|
||||||
|
if (!lastFormulaCalcResult) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.previousValue = this.currentValue;
|
this.previousValue = this.currentValue;
|
||||||
@@ -212,18 +238,42 @@ export default {
|
|||||||
finalValue = previousValue;
|
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.currentValue = this.getStringValue(finalValue);
|
||||||
this.previousValue = '';
|
this.previousValue = '';
|
||||||
this.currentSymbol = '';
|
this.currentSymbol = '';
|
||||||
|
|
||||||
|
return true;
|
||||||
} else if (this.currentSymbol && this.currentValue.length < 1) {
|
} else if (this.currentSymbol && this.currentValue.length < 1) {
|
||||||
this.currentValue = this.previousValue;
|
this.currentValue = this.previousValue;
|
||||||
this.previousValue = '';
|
this.previousValue = '';
|
||||||
this.currentSymbol = '';
|
this.currentSymbol = '';
|
||||||
|
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
const value = this.$utilities.stringCurrencyToNumeric(this.currentValue);
|
const value = this.$utilities.stringCurrencyToNumeric(this.currentValue);
|
||||||
|
|
||||||
this.$emit('input', value);
|
this.$emit('input', value);
|
||||||
this.$emit('update:show', false);
|
this.$emit('update:show', false);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSheetOpen() {
|
onSheetOpen() {
|
||||||
|
|||||||
@@ -630,4 +630,5 @@ export default {
|
|||||||
'License': 'License',
|
'License': 'License',
|
||||||
'An error has occurred': 'An error has occurred',
|
'An error has occurred': 'An error has occurred',
|
||||||
'Parameter Invalid': 'Parameter Invalid',
|
'Parameter Invalid': 'Parameter Invalid',
|
||||||
|
'Numeric Overflow': 'Numeric Overflow',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -630,4 +630,5 @@ export default {
|
|||||||
'License': '许可协议',
|
'License': '许可协议',
|
||||||
'An error has occurred': '发生错误',
|
'An error has occurred': '发生错误',
|
||||||
'Parameter Invalid': '参数错误',
|
'Parameter Invalid': '参数错误',
|
||||||
|
'Numeric Overflow': '数值溢出',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user