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

@ -60,19 +60,18 @@
}
},
cargoQtyMaxNum(){
// 限制数量的最大值
let { cargoList, parcelQty } = this.submitVal
let curQty = (+this.modelInfo.cargoQty) || 0
let qtMaxNum = parcelQty + curQty
// 限制数量的最大值
let { cargoList, parcelQty } = this.submitVal
let curQty = (+this.modelInfo.cargoQty) || 0
let qtMaxNum = parcelQty + curQty
cargoList.map(t=> {
let _itemQty = (+t.cargoQty) || 0
if(_itemQty) {
qtMaxNum = qtMaxNum - _itemQty
}
})
if(qtMaxNum < 0) {
qtMaxNum = 0
}
if(t.cargoQty) {
qtMaxNum = qtMaxNum - t.cargoQty
}
})
if(qtMaxNum < 0) {
qtMaxNum = 0
}
return qtMaxNum
}
},

View File

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