<van-field
@input="handle"
@blur="blurAmounPrice"
v-model="amounPrice"
type="number"
placeholder="请输入收款金额"
/>
//methods
handle(value) {
if (value.indexOf(".") >= 0) {
let index = value.indexOf(".");
let valueLen = value.length;
if (value.length >= 2 && valueLen - (index + 1) > 2) {
this.amounPrice = value.substring(0, index + 1 + 2);
} else {
}
}
this.blurAmounPrice()
},
blurAmounPrice() {
let amounPrice = this.amounPrice;
let financeListData = this.financeListData;
let totalAmount = 0;
financeListData.forEach((v) => {
if (v.checked) {
totalAmount = floatAdd(v.receivablesAmount, totalAmount);
}
});
if (amounPrice) {
if (Number(totalAmount) <= Number(amounPrice)) {
this.amounPrice = totalAmount;
}
}
},
balancePrice() {
let totalPrice = this.totalPrice.replace(/\,/g, "");
totalPrice = Number(totalPrice);
let amounPrice = this.amounPrice ? this.amounPrice + "" : "0";
if (amounPrice.indexOf(".") == 0) {
amounPrice = 0 + amounPrice;
this.amounPrice = amounPrice;
}
this.amounPrice = `${this.amounPrice}`.replace(/-/g, "");
amounPrice = Number(amounPrice);
let balance = floatSub(totalPrice, amounPrice);
balance = numberFormat(balance, "2", ".", ",", "round");
return balance;
},
页面中只能输入金额字
最新推荐文章于 2024-05-22 10:34:30 发布