uu
This commit is contained in:
parent
56b3998a60
commit
f7eeca8d82
@ -60,19 +60,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
cargoQtyMaxNum(){
|
cargoQtyMaxNum(){
|
||||||
// 限制数量的最大值
|
// 限制数量的最大值
|
||||||
let { cargoList, parcelQty } = this.submitVal
|
let { cargoList, parcelQty } = this.submitVal
|
||||||
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) {
|
qtMaxNum = 0
|
||||||
qtMaxNum = 0
|
}
|
||||||
}
|
|
||||||
return qtMaxNum
|
return qtMaxNum
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -125,13 +125,21 @@
|
|||||||
},
|
},
|
||||||
formatter(val) {
|
formatter(val) {
|
||||||
let newVal = val
|
let newVal = val
|
||||||
if(this._digit) {
|
if((this.type == 'number' || this._digit || this._maxNum) && (typeof val == 'string' && val)) {
|
||||||
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
|
newVal = Number(val) // 需要格式化输入框的格式
|
||||||
newVal = val.match(reg)[0]
|
// 判断是否输入了数字
|
||||||
}
|
if(!isNaN(newVal)) {
|
||||||
if(typeof this._maxNum != 'undefined') {
|
if(this._digit) {
|
||||||
if(val > this._maxNum) {
|
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
|
||||||
newVal = this._maxNum
|
newVal = val.match(reg)[0]
|
||||||
|
}
|
||||||
|
if(typeof this._maxNum != 'undefined') {
|
||||||
|
if(newVal > Number(this._maxNum)) {
|
||||||
|
newVal = this._maxNum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newVal = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newVal
|
return newVal
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user