This commit is contained in:
aihe 2024-12-13 01:12:58 +08:00
parent 56b3998a60
commit f7eeca8d82
2 changed files with 26 additions and 19 deletions

View File

@ -65,9 +65,8 @@
let curQty = (+this.modelInfo.cargoQty) || 0 let curQty = (+this.modelInfo.cargoQty) || 0
let qtMaxNum = parcelQty + curQty let qtMaxNum = parcelQty + curQty
cargoList.map(t=> { cargoList.map(t=> {
let _itemQty = (+t.cargoQty) || 0 if(t.cargoQty) {
if(_itemQty) { qtMaxNum = qtMaxNum - t.cargoQty
qtMaxNum = qtMaxNum - _itemQty
} }
}) })
if(qtMaxNum < 0) { if(qtMaxNum < 0) {

View File

@ -125,15 +125,23 @@
}, },
formatter(val) { formatter(val) {
let newVal = val let newVal = val
if((this.type == 'number' || this._digit || this._maxNum) && (typeof val == 'string' && val)) {
newVal = Number(val) // 需要格式化输入框的格式
// 判断是否输入了数字
if(!isNaN(newVal)) {
if(this._digit) { if(this._digit) {
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g') let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
newVal = val.match(reg)[0] newVal = val.match(reg)[0]
} }
if(typeof this._maxNum != 'undefined') { if(typeof this._maxNum != 'undefined') {
if(val > this._maxNum) { if(newVal > Number(this._maxNum)) {
newVal = this._maxNum newVal = this._maxNum
} }
} }
} else {
newVal = ''
}
}
return newVal return newVal
} }
} }