Browse Source

报价验证

yangc 8 years ago
parent
commit
9f2edbca0e

+ 84 - 32
components/applyPurchase/ApplyInfo.vue

@@ -65,15 +65,15 @@
             <div>
             <div>
               <i>*</i>单价
               <i>*</i>单价
               <select v-if="!purchaseMan.currency" v-model="sayPriceObj.currency">
               <select v-if="!purchaseMan.currency" v-model="sayPriceObj.currency">
-                <option value="RMB"></option>
+                <option value="RMB">¥</option>
                 <option value="USD">$</option>
                 <option value="USD">$</option>
               </select>
               </select>
               <div v-if="purchaseMan.currency" v-text="purchaseMan.currency == 'RMB' ? '¥' : '$'"></div>
               <div v-if="purchaseMan.currency" v-text="purchaseMan.currency == 'RMB' ? '¥' : '$'"></div>
-              <input type="text" v-model="sayPriceObj.unitPrice" class="form-control">
+              <input type="number" v-model="sayPriceObj.unitPrice" class="form-control" @blur="onUnitPriceBlur" @input="onUnitPriceChange">
             </div>
             </div>
             <div>
             <div>
               <i>*</i>交期&nbsp;
               <i>*</i>交期&nbsp;
-              <input type="number" v-model="sayPriceObj.minDay" @blur="onMinDayInput" class="form-control">&nbsp;-&nbsp;<input type="number" v-model="sayPriceObj.maxDay" @blur="onMaxDayInput" class="form-control">&nbsp;天
+              <input type="number" v-model="sayPriceObj.minDay" @blur="onMinDayInput" @input="onMinDayChange" class="form-control">&nbsp;-&nbsp;<input type="number" v-model="sayPriceObj.maxDay" @blur="onMaxDayInput" @input="onMaxDayChange" class="form-control">&nbsp;天
             </div>
             </div>
             <div>
             <div>
               生产日期&nbsp;<input v-model="sayPriceObj.produceDate" @input="onProduceDateChange" type="text" class="form-control">
               生产日期&nbsp;<input v-model="sayPriceObj.produceDate" @input="onProduceDateChange" type="text" class="form-control">
@@ -116,6 +116,11 @@
           produceDate: '',
           produceDate: '',
           spId: ''
           spId: ''
         },
         },
+        validSayPrice: {
+          unitPrice: false,
+          minDay: false,
+          maxDay: false
+        },
         keyWord: '',
         keyWord: '',
         sorting: {}
         sorting: {}
       }
       }
@@ -168,14 +173,7 @@
         for (let i = 0; i < this.purchaseManList.content.length; i++) {
         for (let i = 0; i < this.purchaseManList.content.length; i++) {
           _this.purchaseManList.content[i].active = false
           _this.purchaseManList.content[i].active = false
         }
         }
-        this.sayPriceObj = {
-          currency: 'RMB',
-          unitPrice: '',
-          minDay: '',
-          maxDay: '',
-          produceDate: '',
-          spId: ''
-        }
+        this.resetSayPrice()
         purchaseMan.active = true
         purchaseMan.active = true
       },
       },
       cancelSayPrice: function (purchaseMan) {
       cancelSayPrice: function (purchaseMan) {
@@ -183,7 +181,7 @@
       },
       },
       commitSayPrice: function (purchaseMan) {
       commitSayPrice: function (purchaseMan) {
         if (this.user.logged) {
         if (this.user.logged) {
-          let valid = this.sayPriceObj.currency && this.sayPriceObj.unitPrice && this.sayPriceObj.minDay && this.sayPriceObj.maxDay
+          let valid = this.checkAllSayPrice()
           if (valid) {
           if (valid) {
             this.sayPriceObj.spId = purchaseMan.id
             this.sayPriceObj.spId = purchaseMan.id
             this.sayPriceObj.currency = purchaseMan.currency || this.sayPriceObj.currency
             this.sayPriceObj.currency = purchaseMan.currency || this.sayPriceObj.currency
@@ -201,7 +199,23 @@
               this.$message.error('系统错误')
               this.$message.error('系统错误')
             })
             })
           } else {
           } else {
-            this.$message.error('请填写正确的信息')
+            if (!this.validSayPrice.unitPrice) {
+              if (!this.sayPriceObj.unitPrice) {
+                this.$message.error('单价不能为空')
+              } else {
+                this.$message.error('单价必须是大于0的数字')
+              }
+            } else if (!this.validSayPrice.minDay || !this.validSayPrice.maxDay) {
+              if (!this.sayPriceObj.minDay || !this.sayPriceObj.maxDay) {
+                this.$message.error('交期不能为空')
+              } else {
+                if (this.sayPriceObj.minDay > 31 || this.sayPriceObj.minDay < 1 || this.sayPriceObj.minDay.indexOf('.') !== -1 || this.sayPriceObj.maxDay > 31 || this.sayPriceObj.maxDay < 1 || this.sayPriceObj.maxDay.indexOf('.') !== -1) {
+                  this.$message.error('交期只能填写1-31之间的整数值')
+                } else {
+                  this.$message.error('最短交期应小于等于最长交期')
+                }
+              }
+            }
           }
           }
         } else {
         } else {
           this.$router.push('/auth/login?returnUrl=' + window.location.href)
           this.$router.push('/auth/login?returnUrl=' + window.location.href)
@@ -220,28 +234,62 @@
           spId: ''
           spId: ''
         }
         }
       },
       },
-      onMinDayInput: function () {
-        this.sayPriceObj.minDay = Math.floor(this.sayPriceObj.minDay)
-        if (this.sayPriceObj.maxDay) {
-          if (this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
-            this.sayPriceObj.minDay = this.sayPriceObj.maxDay
+      onUnitPriceBlur: function () {
+        if (this.sayPriceObj.unitPrice) {
+          if (this.sayPriceObj.unitPrice < 0) {
+            this.$message.error('单价必须是大于0的数字')
+            this.validSayPrice.unitPrice = false
+          } else {
+            this.validSayPrice.unitPrice = true
           }
           }
-        } else if (this.sayPriceObj.minDay < 0) {
-          this.sayPriceObj.minDay = 0
-        } else if (this.sayPriceObj.minDay > 31) {
-          this.sayPriceObj.minDay = 31
+        } else {
+          this.$message.error('单价必须是大于0的数字')
+          this.validSayPrice.unitPrice = false
         }
         }
       },
       },
-      onMaxDayInput: function () {
-        this.sayPriceObj.maxDay = Math.floor(this.sayPriceObj.maxDay)
-        if (this.sayPriceObj.minDay) {
-          if (this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
-            this.sayPriceObj.maxDay = this.sayPriceObj.minDay
+      onUnitPriceChange: function () {
+        let price = this.sayPriceObj.unitPrice
+        if (price >= 9999) {
+          this.sayPriceObj.unitPrice = price.substring(0, 4)
+        } else if (price.indexOf('.') > -1) {
+          let arr = price.split('.')
+          if (arr[0].length > 4) {
+            this.sayPriceObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
+          } else if (arr[1].length > 6) {
+            this.sayPriceObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
           }
           }
-        } else if (this.sayPriceObj.maxDay < 0) {
-          this.sayPriceObj.maxDay = 0
-        } else if (this.sayPriceObj.maxDay > 31) {
-          this.sayPriceObj.maxDay = 31
+        }
+      },
+      onMinDayInput: function () {
+        if (this.sayPriceObj.minDay < 1 || this.sayPriceObj.minDay > 31 || this.sayPriceObj.minDay.indexOf('.') !== -1) {
+          this.validSayPrice.minDay = false
+          this.$message.error('交期只能填写1-31之间的整数值')
+        } else if (this.sayPriceObj.maxDay && this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
+          this.validSayPrice.minDay = false
+          this.$message.error('最短交期应小于等于最长交期')
+        } else {
+          this.validSayPrice.minDay = true
+        }
+      },
+      onMinDayChange: function () {
+        if (this.sayPriceObj.minDay.length > 2) {
+          this.sayPriceObj.minDay = this.sayPriceObj.minDay.substring(0, 2)
+        }
+      },
+      onMaxDayInput: function () {
+        if (this.sayPriceObj.maxDay < 1 || this.sayPriceObj.maxDay > 31 || this.sayPriceObj.maxDay.indexOf('.') !== -1) {
+          this.validSayPrice.maxDay = false
+          this.$message.error('交期只能填写1-31之间的整数值')
+        } else if (this.sayPriceObj.minDay && this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
+          this.validSayPrice.maxDay = false
+          this.$message.error('最短交期应小于等于最长交期')
+        } else {
+          this.validSayPrice.maxDay = true
+        }
+      },
+      onMaxDayChange: function () {
+        if (this.sayPriceObj.maxDay.length > 2) {
+          this.sayPriceObj.maxDay = this.sayPriceObj.maxDay.substring(0, 2)
         }
         }
       },
       },
       onProduceDateChange: function () {
       onProduceDateChange: function () {
@@ -249,6 +297,9 @@
           this.sayPriceObj.produceDate = this.sayPriceObj.produceDate.substring(0, this.sayPriceObj.produceDate.length - 1)
           this.sayPriceObj.produceDate = this.sayPriceObj.produceDate.substring(0, this.sayPriceObj.produceDate.length - 1)
         }
         }
       },
       },
+      checkAllSayPrice: function () {
+        return this.validSayPrice.unitPrice && this.validSayPrice.minDay && this.validSayPrice.maxDay
+      },
       searchList: function () {
       searchList: function () {
         this.resetList()
         this.resetList()
       },
       },
@@ -515,7 +566,7 @@
                   }
                   }
                   color: #5392f9;
                   color: #5392f9;
                   font: small-caption;
                   font: small-caption;
-                  padding-left: 3px;
+                  padding-left: 8px;
                   & + input {
                   & + input {
                     padding-left: 34px;
                     padding-left: 34px;
                   }
                   }
@@ -547,6 +598,7 @@
                 input {
                 input {
                   width: 32px;
                   width: 32px;
                   height: 26px;
                   height: 26px;
+                  padding: 0 0 0 3px;
                 }
                 }
               }
               }
               &:nth-child(4) {
               &:nth-child(4) {

+ 3 - 1
components/applyPurchase/PublishApply.vue

@@ -32,7 +32,7 @@
               单价预算:
               单价预算:
             </span>
             </span>
             <select v-model="applyObj.currency">
             <select v-model="applyObj.currency">
-              <option value="RMB"></option>
+              <option value="RMB">¥</option>
               <option value="USD">$</option>
               <option value="USD">$</option>
             </select>
             </select>
             <input type="number" class="form-control" :class="{'error': !validObj.unitPrice}" v-model="applyObj.unitPrice" @blur="checkUnitPrice" @input="onUnitPriceInput" />
             <input type="number" class="form-control" :class="{'error': !validObj.unitPrice}" v-model="applyObj.unitPrice" @blur="checkUnitPrice" @input="onUnitPriceInput" />
@@ -321,6 +321,8 @@
               position: absolute;
               position: absolute;
               height: 20px;
               height: 20px;
               background: url('/images/applyPurchase/select.png')no-repeat right;
               background: url('/images/applyPurchase/select.png')no-repeat right;
+              background-position-x: 15px;
+              padding: 0 0 0 3px;
               & + input {
               & + input {
                 padding-left: 34px;
                 padding-left: 34px;
               }
               }

+ 1 - 1
nuxt.config.js

@@ -1,6 +1,6 @@
 const path = require('path')
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://10.10.100.107:8081/platform-b2c/' : 'http://192.168.253.158:8080/platform-b2c/')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://10.10.100.107:8081/platform-b2c/' : 'http://192.168.253.123:8080/platform-b2c/')
 
 
 module.exports = {
 module.exports = {
   router: {
   router: {

+ 3 - 0
store/applyPurchase.js

@@ -12,6 +12,9 @@ let findStoreInfoFromUuid = function ({ commit }, params = {}) {
       if (response.data.length) {
       if (response.data.length) {
         for (let j = 0; j < response.data.length; j++) {
         for (let j = 0; j < response.data.length; j++) {
           list.content[i].isOffer = list.content[i].id === response.data[j].spId
           list.content[i].isOffer = list.content[i].id === response.data[j].spId
+          if (list.content[i].isOffer) {
+            break
+          }
         }
         }
       } else {
       } else {
         list.content[i].isOffer = false
         list.content[i].isOffer = false