diff --git a/components/buns-post-edit-templates/bpe-gooditemsize-tmp.vue b/components/buns-post-edit-templates/bpe-gooditemsize-tmp.vue index 2c5d5a2..c3b0907 100644 --- a/components/buns-post-edit-templates/bpe-gooditemsize-tmp.vue +++ b/components/buns-post-edit-templates/bpe-gooditemsize-tmp.vue @@ -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 } }, diff --git a/components/tpx-input/tpx-input.vue b/components/tpx-input/tpx-input.vue index 8f49020..0e4c324 100644 --- a/components/tpx-input/tpx-input.vue +++ b/components/tpx-input/tpx-input.vue @@ -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