|
|
@@ -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)">
|
|
|
@@ -53,6 +55,11 @@
|
|
|
default: 'INBOUND'
|
|
|
}
|
|
|
},
|
|
|
+ fetch({route, store}) {
|
|
|
+ return Promise.all([
|
|
|
+ store.dispatch('loadCurrencyData')
|
|
|
+ ])
|
|
|
+ },
|
|
|
data () {
|
|
|
return {
|
|
|
remindText: '',
|
|
|
@@ -79,6 +86,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 +123,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 +142,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 +180,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){
|