Browse Source

处理验证信息和币种问题

wangcz 7 years ago
parent
commit
495d010be6

+ 79 - 14
components/mobile/center/outOfStorage/otherStorage.vue

@@ -24,9 +24,11 @@
         <div class="linetext width50 fl">物料名称: <span v-text="item.pcmpcode">21324</span></div>
         <div class="linetext width50 fl">规格: <span v-text="item.spec">21324</span></div>
         <div class="linetext width50 fl"><em>*</em>{{switchType === 'INBOUND' ? '入库数' : '出库数'}}(PCS): <span>
-          <input type="text" style="width:1rem;" v-model.number="item.qty">
+          <input type="text" style="width:1rem;" v-model="item.qty" @input="onAmountInput(item, index)">
+        </span></div>
+        <div class="linetext width50 fl">单价({{currency === 'RMB' ? '¥': '$'}}):<span>
+          <input type="text" style="width:2rem;" v-model="item.price" @blur="rMBPriceBlur(item, index)">
         </span></div>
-        <div class="linetext width50 fl">单价(¥):<span><input type="text" style="width:2rem;" v-model.number="item.price"></span></div>
         <div class="content-line" v-show="item.showSimilarCodeList && item.cmpCode">
           <ul class="similar">
             <li v-for="sCode in similarCode" @click.stop="setCode(sCode, index)">
@@ -79,6 +81,16 @@
       this.allObj.push(this.storageObj)
       document.body.onclick = function() {
         _this.allObj.forEach(val => {
+          if(!val.productId) {
+            val = {
+              cmpCode: '',
+              brand: '',
+              pcmpcode: '',
+              spec: '',
+              qty: '',
+              price: ''
+            }
+          }
           val.showSimilarCodeList = false
         })
       }
@@ -106,7 +118,15 @@
       initData () {
         this.enName = ''
         this.allObj = []
-        this.allObj.push(this.storageObj)
+        this.allObj.push({
+          cmpCode: '',
+          brand: '',
+          pcmpcode: '',
+          spec: '',
+          qty: '',
+          price: '',
+          showSimilarCodeList: false,
+        })
       },
       onCodeChange (type) {
         this.allObj[type].showSimilarCodeList = true
@@ -117,14 +137,13 @@
         if (this.allObj[type].cmpCode) {
           this.$http.get('/trade/products/code/keyword', {params: {keyword: this.allObj[type].cmpCode}})
             .then(response => {
-              if(response.data){
-                this.similarCode = response.data || []
+              if(response.data.length > 0){
+                this.similarCode = response.data
               } else {
                 this.onRemind('没有找到产品信息')
               }
               this.allObj[type].showSimilarCodeList = response.data.length > 0
             }).catch((err) => {
-              this.allObj[type].showSimilarCodeList = false
               this.similarCode = []
               this.onRemind('没有找到产品信息')
             })
@@ -156,21 +175,67 @@
           this.allObj.push(_item)
         }
       },
+      onAmountInput: function (item, index) {
+        if (!(/^[0-9]*$/).test(item.qty)) {
+          let chineseIndex = -1
+          for (let i = 0; i < item.qty.length; i++) {
+            if (!(/^[0-9]*$/).test(item.qty.charAt(i))) {
+              chineseIndex = i
+              break
+            }
+          }
+          this.allObj[index].qty = this.baseUtils.cutOutString(item.qty, chineseIndex)
+        } else if (item.qty.length > 9) {
+          this.onRemind ('数量不能高于1亿')
+          this.allObj[index].qty = this.baseUtils.cutOutString(item.qty, 9)
+        }
+      },
+      rMBPriceBlur(item) {
+        if (item.price === '' || !item.price) { return false }
+        if (!/^[0-9]+([.]{1}[0-9]{1,6})?$/.test(item.price)) {
+          this.onRemind('单价只能输入数字带6位小数')
+        } else if (Math.abs(item.price) === 0) {
+          return false
+        } else if (Math.abs(item.price) >= 10000) {
+          item.price = 9999
+          this.onRemind ('单价不能高于10000')
+          return false
+        }
+        item.price = item.price.toString()
+        let splits = item.price.split('.')
+        if (splits[0].length >= 4) {
+          splits[0] = splits[0].substr(0, 4)
+          item.price = splits[0]
+        }
+        if (splits[1]) {
+          item.price = splits[0] + '.' + splits[1]
+        }
+        if (splits[1] && splits[1].length > 6) {
+          splits[1] = splits[1].substr(0, 7)
+          let str = splits[1].substr(0, 6)
+          if (splits[1][splits[1].length - 1] >= 5) {
+            str = splits[1].substr(0, 6)
+            str = Math.abs(str) + 1
+          }
+          item.price = splits[0] + '.' + Math.ceil(str)
+        }
+      },
       saveClick (type) {
         if(type === 'clear') {
           this.initData()
         }else {
-          if(!this.enName) {
-            this.onRemind('请输入' + this.switchType === 'INBOUND' ? '请输入卖家名称' : '请输入买家名称')
-          } else {
-            let arr = []
-            this.allObj.forEach(val => {
-              if(!val.price && !val.qty && !val.productId) {
+          let arr = []
+          let falg = false;
+          this.allObj.forEach(val => {
+            if(val.productId) {
+              if(!val.price && !val.qty) {
                 this.onRemind('请将数据补充完整')
-                return
               }
+              falg = true;
               arr.push({price: val.price, productId: val.productId, qty:val.qty})
-            })
+            }
+          })
+          if(falg) {
             this.$http.post(`/CommodityInOutbound/${this.switchType === 'INBOUND'? 'inBound': 'outBound'}/other?enName=${this.enName}`, arr)
               .then(response => {
                 if(response.data.code === 1){

+ 1 - 1
pages/mobile/center/vendor/outOfStorage/_id.vue

@@ -25,7 +25,7 @@
             <div class="linetext width50 fl">物料名称: <span v-text="item.kindName || '-'">21324</span></div>
             <div class="linetext width50 fl">规格: <span v-text="item.spec || '-'">21324</span></div>
             <div class="linetext width50 fl">{{storageList.type === 'INBOUND' ? '入库数' : '出库数'}}(PCS): <span v-text="item.qty || '-'">21324</span></div>
-            <div class="linetext width50 fl">单价(¥): <span class="base-color" v-text="item.price || '-'">21324</span></div>
+            <div class="linetext width50 fl">单价({{currency === 'RMB' ? '¥': '$'}}): <span class="base-color" v-text="item.price || '-'">21324</span></div>
           </li>
         </ul>
       </div>

+ 1 - 1
pages/mobile/center/vendor/outOfStorage/index.vue

@@ -14,7 +14,7 @@
         <div class="storage-record">
           <div class="search-content clearfix">
             <div class="search">
-              <input type="text" v-model="filterParams.keyword" :placeholder="switchType ==='OUTBOUND' ? '发货单/卖家' : '订单号/买家'" class="staff-search" @keyup.13="filterRecord">
+              <input type="text" v-model="filterParams.keyword" :placeholder="switchType ==='OUTBOUND' ? '订单号/买家名称' : (handleItem === 0 ? '入库订单/卖家名称':'发货单/卖家名称')" class="staff-search" @keyup.13="filterRecord">
               <span @click="filterRecord"><i class="iconfont icon-sousuo"></i></span>
             </div>
           </div>

+ 1 - 1
pages/mobile/center/vendor/outOfStorage/purchase/_storeid.vue

@@ -28,7 +28,7 @@
             <div class="linetext width50 fl">物料名称: <span v-text="item.kiName || '-'">21324</span></div>
             <div class="linetext width50 fl">规格: <span v-text="item.spec || '-'">21324</span></div>
             <div class="linetext width50 fl">入库数(PCS):<span v-text="item.qty || '-'">-</span></div>
-            <div class="linetext width50 fl">单价(¥): <span class="base-color" v-text="item.price || '-'">21324</span></div>
+            <div class="linetext width50 fl">单价({{currency === 'RMB' ? '¥': '$'}}): <span class="base-color" v-text="item.price || '-'">21324</span></div>
           </li>
         </ul>
       </div>

+ 3 - 0
plugins/mixin.js

@@ -18,6 +18,9 @@ Vue.mixin({
     user() {
       return this.$store.state.option.user
     },
+    currency() {
+      return this.$store.state.option.currency
+    },
     isAdmin () {
       let isAdmin = null
       if (this.user.data.enterprise) {

+ 9 - 1
store/index.js

@@ -61,7 +61,8 @@ export const actions = {
       // 全局数据
       store.dispatch('loadUserInfo'),
       store.dispatch('loadHotSearchDevice'),
-      store.dispatch('loadHotSearchBrand')
+      store.dispatch('loadHotSearchBrand'),
+      store.dispatch('loadCurrencyData')
     ])
   },
   // 获取用户信息
@@ -108,6 +109,13 @@ export const actions = {
         commit('option/REQUEST_COUNTER_FAILURE')
       })
   },
+  // 获取币别信息
+  loadCurrencyData ({commit}) {
+    return axios.get('basic/enterprise/currency')
+      .then(res => {
+        commit('option/SET_CURRENCY', res.data)
+      })
+  },
   // 获取楼层配置
   loadFloors({ commit }) {
     commit('floor/REQUEST_LIST')

+ 5 - 0
store/option.js

@@ -41,6 +41,8 @@ export const state = () => ({
     fetching: false,
     data: {}
   },
+  //币别
+  currency: '',
   messageType: '',
   showMobileFooter: true
 })
@@ -134,6 +136,9 @@ export const mutations = {
   REQUEST_WECHATINFO_STATUS_FAILURE (state) {
     state.wechatInfo.fetching = false
   },
+  SET_CURRENCY (state, result) {
+    state.currency = result.data ? result.data.data : 'RMB'
+  },
   GET_MESSAGETYPE (state, result) {
     state.messageType = result || ''
   },