Browse Source

fix 处理数字输入问题

wangcz 7 years ago
parent
commit
ea55edd3f9

+ 8 - 6
components/applyPurchase/SayPrice.vue

@@ -62,11 +62,11 @@
           <div class="content-line">
             <div class="form-item form-left">
               <span><i>*</i>交期(天):</span>
-              <input type="number" class="form-control" placeholder="最长交期" @input="onLeadtimeInput" @blur="onLeadtimeBlur" v-model="sayPriceObj.leadtime">
+              <input type="text" class="form-control" placeholder="最长交期" @input="onLeadtimeInput" @blur="onLeadtimeBlur" v-model="sayPriceObj.leadtime">
             </div>
             <div class="form-item form-right">
               <span><i>*</i>税率:</span>
-              <input type="number" class="form-control" placeholder="税率" @input="onTaxrateInput" @blur="onTaxrateBlur" v-model="sayPriceObj.taxrate">%
+              <input type="text" class="form-control" placeholder="税率" @input="onTaxrateInput" @blur="onTaxrateBlur" v-model="sayPriceObj.taxrate">%
             </div>
             <!--<div class="form-item form-upload">
               <label>
@@ -83,7 +83,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" @blur="onReplyLapQtyBlur(index)" @input="onReplyLapQtyInput(index)" v-model="reply.lapQty" placeholder="分段数量">
+              <input type="text" class="form-control" @blur="onReplyLapQtyBlur(index)" @input="onReplyLapQtyInput(index)" v-model="reply.lapQty" placeholder="分段数量">
               <!-- -
                <input type="text" class="form-control" placeholder="数量">-->
             </div>
@@ -94,7 +94,7 @@
                 <option value="RMB">¥</option>
                 <option value="USD">$</option>
               </select>
-              <input type="number" class="form-control" @input="onReplyPriceInput(index)" @blur="onReplyPriceBlur(index)" placeholder="分段单价" v-model="reply.price">
+              <input type="text" class="form-control" @input="onReplyPriceInput(index)" @blur="onReplyPriceBlur(index)" placeholder="分段单价" v-model="reply.price">
               <i class="fa fa-minus-circle" v-if="sayPriceObj.replies.length > 1" @click="setReplies('sub', index)"></i>
               <i class="fa fa-plus-circle" v-if="sayPriceObj.replies.length < 5" @click="setReplies('add', index)"></i>
             </div>
@@ -244,7 +244,7 @@
         }
       },
       onLeadtimeInput: function () {
-        this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.replace(/[^\d]/g, '')
+        this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.replace(/[^0-9]*$/g, '')
         if (this.sayPriceObj.leadtime.length > 3) {
           this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.substring(0, 3)
         }
@@ -258,7 +258,7 @@
         }
       },
       onTaxrateInput () {
-        this.sayPriceObj.taxrate = this.sayPriceObj.taxrate.replace(/[^\d]/g, '')
+        this.sayPriceObj.taxrate = this.sayPriceObj.taxrate.replace(/[^0-9]*$/g, '')
         if (this.sayPriceObj.taxrate.length > 2) {
           this.sayPriceObj.taxrate = this.sayPriceObj.taxrate.substring(0, 2)
         }
@@ -272,6 +272,7 @@
         }
       },
       onReplyPriceInput: function (index) {
+        this.sayPriceObj.replies[index].price = this.sayPriceObj.replies[index].price.replace(/[^0-9.]*$/g, '')
         let price = this.sayPriceObj.replies[index].price
         if (price >= 10000) {
           this.sayPriceObj.replies[index].price = price.substring(0, 4)
@@ -318,6 +319,7 @@
         }
       },
       onReplyLapQtyInput: function (index) {
+        this.sayPriceObj.replies[index].lapQty = this.sayPriceObj.replies[index].lapQty.replace(/[^0-9]*$/g, '')
         let lapQty = this.sayPriceObj.replies[index].lapQty
         if (lapQty.length > 9) {
           this.sayPriceObj.replies[index].lapQty = lapQty.substring(0, 9)

+ 4 - 4
components/mobile/applyPurchase/SayPrice.vue

@@ -253,7 +253,7 @@
         }
       },
       onLeadtimeInput: function () {
-        this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.replace(/[^\d]/g, '')
+        this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.replace(/[^0-9]*$/g, '')
         if (this.sayPriceObj.leadtime.length > 3) {
           this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.substring(0, 3)
         }
@@ -267,7 +267,7 @@
         }
       },
       onTaxrateInput () {
-        this.sayPriceObj.taxrate = this.sayPriceObj.taxrate.replace(/[^\d]/g, '')
+        this.sayPriceObj.taxrate = this.sayPriceObj.taxrate.replace(/[^0-9]*$/g, '')
         if (this.sayPriceObj.taxrate.length > 2) {
           this.sayPriceObj.taxrate = this.sayPriceObj.taxrate.substring(0, 2)
         }
@@ -281,7 +281,7 @@
         }
       },
       onReplyPriceInput: function (index) {
-        this.sayPriceObj.replies[index].price = this.sayPriceObj.replies[index].price.replace(/[^\-?\d.]/g, '')
+        this.sayPriceObj.replies[index].price = this.sayPriceObj.replies[index].price.replace(/[^0-9.]*$/g, '')
         let price = this.sayPriceObj.replies[index].price
         if (price >= 10000) {
           this.sayPriceObj.replies[index].price = price.substring(0, 4)
@@ -328,7 +328,7 @@
         }
       },
       onReplyLapQtyInput: function (index) {
-        this.sayPriceObj.replies[index].lapQty = this.sayPriceObj.replies[index].lapQty.replace(/[^\-?\d.]/g, '')
+        this.sayPriceObj.replies[index].lapQty = this.sayPriceObj.replies[index].lapQty.replace(/[^0-9]*$/g, '')
         let lapQty = this.sayPriceObj.replies[index].lapQty
         if (lapQty.length > 9) {
           this.sayPriceObj.replies[index].lapQty = lapQty.substring(0, 9)