yangc 7 years ago
parent
commit
38ec02f5a4
1 changed files with 24 additions and 1 deletions
  1. 24 1
      components/applyPurchase/ApplyInfo.vue

+ 24 - 1
components/applyPurchase/ApplyInfo.vue

@@ -146,7 +146,7 @@
           <div class="content-line" v-for="(reply, index) in sayPriceObj.replies">
             <div class="form-item form-left">
               <span><i>*</i>价格梯度:</span>
-              <input type="number" class="form-control" @bulr="onReplyLapQtyBlur(index)" v-model="reply.lapQty" placeholder="数量">
+              <input type="number" class="form-control" @blur="onReplyLapQtyBlur(index)" v-model="reply.lapQty" placeholder="数量">
              <!-- -
               <input type="text" class="form-control" placeholder="数量">-->
             </div>
@@ -383,10 +383,33 @@
       },
       onReplyLapQtyBlur: function (index) {
         let lapQty = this.sayPriceObj.replies[index].lapQty
+        let limitDownObj = this.getLimitDown()
         if (!lapQty || lapQty < 1) {
           this.sayPriceObj.replies[index].lapQty = ''
           this.$message.error('输入值必须为正整数')
+          this.validSayPrice.repliesLapQty = false
+        } else if (limitDownObj.index !== index && limitDownObj.lapQty > lapQty) {
+          this.$message.error('输入值必须大于#该梯度的下限#')
+          this.sayPriceObj.replies[index].lapQty = ''
+          this.validSayPrice.repliesLapQty = false
+        } else if ((index - 1 >= 0 && this.sayPriceObj.replies[index - 1].lapQty >= lapQty) || (index + 1 <= 4 && this.sayPriceObj.replies[index + 1].lapQty <= lapQty)) {
+          this.$message.error('输入值会导致梯度重叠,请重新修改')
+          this.sayPriceObj.replies[index].lapQty = ''
+          this.validSayPrice.repliesLapQty = false
+        } else {
+          this.validSayPrice.repliesLapQty = true
+        }
+      },
+      getLimitDown: function () {
+        for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
+          if (this.sayPriceObj.replies[i].lapQty) {
+            return {
+              lapQty: this.sayPriceObj.replies[i].lapQty,
+              index: i
+            }
+          }
         }
+        return {index: -1}
       },
 //      onUnitPriceBlur: function () {
 //        if (this.sayPriceObj.unitPrice) {