|
|
@@ -36,14 +36,14 @@
|
|
|
</span>
|
|
|
</div>
|
|
|
<div class="form-item" v-for="(reply, index) in sayPriceObj.replies">
|
|
|
- <input type="number" placeholder="梯度" class="fl" v-model="reply.lapQty">
|
|
|
- <input type="number" placeholder="单价" class="fr" v-model="reply.price">
|
|
|
+ <input type="number" placeholder="梯度" class="fl" @blur="onReplyLapQtyBlur(index)" @input="onReplyLapQtyInput(index)" v-model="reply.lapQty">
|
|
|
+ <input type="number" placeholder="单价" class="fr" @input="onReplyPriceInput(index)" @blur="onReplyPriceBlur(index)" v-model="reply.price">
|
|
|
<i class="iconfont icon-minus" v-if="index > 0" @click="setReplies('sub', index)"></i>
|
|
|
<i class="iconfont icon-add" v-if="index == 0 && sayPriceObj.replies.length < 5" @click="setReplies('add', index)"></i>
|
|
|
</div>
|
|
|
<div class="date">
|
|
|
<span>交期(天)</span>
|
|
|
- <input type="number" placeholder="最大值" v-model="sayPriceObj.leadtime" class="fr">
|
|
|
+ <input type="number" placeholder="最大值" @input="onLeadtimeInput" @blur="onLeadtimeBlur" v-model="sayPriceObj.leadtime" class="fr">
|
|
|
</div>
|
|
|
<a class="say-price-btn" @click="commitSayPrice">确定</a>
|
|
|
</div>
|
|
|
@@ -66,6 +66,11 @@
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
+ validSayPrice: {
|
|
|
+ leadtime: false,
|
|
|
+ repliesPrice: false,
|
|
|
+ repliesLapQty: false
|
|
|
+ },
|
|
|
remindText: '',
|
|
|
timeoutCount: 0
|
|
|
}
|
|
|
@@ -123,6 +128,7 @@
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
+// window.history.back(-1)
|
|
|
},
|
|
|
setReplies: function (type, index) {
|
|
|
if (type === 'add' && this.sayPriceObj.replies.length < 5) {
|
|
|
@@ -136,7 +142,7 @@
|
|
|
},
|
|
|
commitSayPrice: function () {
|
|
|
if (this.checkValid()) {
|
|
|
- let purchaseMan = this.purchaseDetail
|
|
|
+ let purchaseMan = JSON.parse(JSON.stringify(this.purchaseDetail))
|
|
|
// this.showLoading = true
|
|
|
purchaseMan.leadtime = this.sayPriceObj.leadtime
|
|
|
purchaseMan.replies = this.sayPriceObj.replies
|
|
|
@@ -166,15 +172,99 @@
|
|
|
this.onRemind('请输入正确的报价信息')
|
|
|
}
|
|
|
},
|
|
|
+// checkValid: function () {
|
|
|
+// for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
|
|
|
+// if (!this.sayPriceObj.replies[i].lapQty || this.sayPriceObj.replies[i].lapQty <= 0 || !this.sayPriceObj.replies[i].price || this.sayPriceObj.replies[i].price <= 0) {
|
|
|
+// return false
|
|
|
+// } else if (i > 0 && ((this.sayPriceObj.replies[i].lapQty <= this.sayPriceObj.replies[i - 1].lapQty) || (this.sayPriceObj.replies[i].price <= this.sayPriceObj.replies[i - 1].price))) {
|
|
|
+// return false
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return this.sayPriceObj.leadtime && this.sayPriceObj.leadtime > 0
|
|
|
+// },
|
|
|
+ onLeadtimeInput: function () {
|
|
|
+ if (this.sayPriceObj.leadtime.length > 3) {
|
|
|
+ this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.substring(0, 3)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLeadtimeBlur: function () {
|
|
|
+ if (!this.sayPriceObj.leadtime || this.sayPriceObj.leadtime < 1 || this.sayPriceObj.leadtime >= 1000 || this.sayPriceObj.leadtime.toString().indexOf('.') !== -1) {
|
|
|
+ this.validSayPrice.leadtime = false
|
|
|
+ this.onRemind('交期请填写1-999之间的正整数')
|
|
|
+ } else {
|
|
|
+ this.validSayPrice.leadtime = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReplyPriceInput: function (index) {
|
|
|
+ let price = this.sayPriceObj.replies[index].price
|
|
|
+ if (price >= 10000) {
|
|
|
+ this.sayPriceObj.replies[index].price = price.substring(0, 4)
|
|
|
+ } else if (price.indexOf('.') > -1) {
|
|
|
+ let arr = price.split('.')
|
|
|
+ if (arr[0].length > 4) {
|
|
|
+ this.sayPriceObj.replies[index].price = Number(arr[0].substring(0, 4) + '.' + arr[1])
|
|
|
+ } else if (arr[1].length > 6) {
|
|
|
+ this.sayPriceObj.replies[index].price = Number(arr[0] + '.' + arr[1].substring(0, 6))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReplyPriceBlur: function (index) {
|
|
|
+ let price = this.sayPriceObj.replies[index].price
|
|
|
+ if (!price) {
|
|
|
+ this.sayPriceObj.replies[index].price = ''
|
|
|
+ this.onRemind('价格不能为空')
|
|
|
+ this.validSayPrice.repliesPrice = false
|
|
|
+ } else if (price <= 0) {
|
|
|
+ this.sayPriceObj.replies[index].price = ''
|
|
|
+ this.onRemind('输入值必须为正整数')
|
|
|
+ this.validSayPrice.repliesPrice = false
|
|
|
+ } else {
|
|
|
+ this.validSayPrice.repliesPrice = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReplyLapQtyBlur: function (index) {
|
|
|
+ let lapQty = this.sayPriceObj.replies[index].lapQty
|
|
|
+ let limitDownObj = this.getLimitDownQty()
|
|
|
+ if (!lapQty || lapQty < 1) {
|
|
|
+ this.sayPriceObj.replies[index].lapQty = ''
|
|
|
+ this.onRemind('输入值必须为正整数')
|
|
|
+ this.validSayPrice.repliesLapQty = false
|
|
|
+ } else if (limitDownObj.index !== index && limitDownObj.lapQty > lapQty) {
|
|
|
+ this.onRemind('输入值必须大于#该梯度的下限#')
|
|
|
+ this.sayPriceObj.replies[index].lapQty = ''
|
|
|
+ this.validSayPrice.repliesLapQty = false
|
|
|
+ } else if ((index - 1 >= 0 && this.sayPriceObj.replies[index - 1].lapQty && this.sayPriceObj.replies[index - 1].lapQty >= lapQty) || (index + 1 < this.sayPriceObj.replies.length && this.sayPriceObj.replies[index + 1].lapQty && this.sayPriceObj.replies[index + 1].lapQty <= lapQty)) {
|
|
|
+ this.onRemind('输入值会导致梯度重叠,请重新修改')
|
|
|
+ this.sayPriceObj.replies[index].lapQty = ''
|
|
|
+ this.validSayPrice.repliesLapQty = false
|
|
|
+ } else {
|
|
|
+ this.validSayPrice.repliesLapQty = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReplyLapQtyInput: function (index) {
|
|
|
+ let lapQty = this.sayPriceObj.replies[index].lapQty
|
|
|
+ if (lapQty.length > 9) {
|
|
|
+ this.sayPriceObj.replies[index].lapQty = lapQty.substring(0, 9)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getLimitDownQty: 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}
|
|
|
+ },
|
|
|
checkValid: function () {
|
|
|
for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
|
|
|
- if (!this.sayPriceObj.replies[i].lapQty || this.sayPriceObj.replies[i].lapQty <= 0 || !this.sayPriceObj.replies[i].price || this.sayPriceObj.replies[i].price <= 0) {
|
|
|
- return false
|
|
|
- } else if (i > 0 && ((this.sayPriceObj.replies[i].lapQty <= this.sayPriceObj.replies[i - 1].lapQty) || (this.sayPriceObj.replies[i].price <= this.sayPriceObj.replies[i - 1].price))) {
|
|
|
+ if (!this.sayPriceObj.replies[i].lapQty || !this.sayPriceObj.replies[i].price) {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
- return this.sayPriceObj.leadtime && this.sayPriceObj.leadtime > 0
|
|
|
+ return this.validSayPrice.leadtime && this.validSayPrice.repliesLapQty && this.validSayPrice.repliesPrice
|
|
|
},
|
|
|
onRemind: function (str) {
|
|
|
this.remindText = str
|