You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.1 KiB
89 lines
3.1 KiB
// pages/message/index.js
|
|
const util = require('../../../utils/util')
|
|
const math = require('../../../utils/math')
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
form: { type: Object, value: null },
|
|
item: { type: Object, value: null },
|
|
index: { type: Number, value: 0 },
|
|
list: { type: Array, value: [] },
|
|
status: { type: Number, value: 0 }
|
|
},
|
|
data: {
|
|
visible: false,
|
|
focus: 0
|
|
},
|
|
methods: {
|
|
showCategory: function(){
|
|
this.setData({ visible: true })
|
|
},
|
|
onSelect: function({detail}){
|
|
if(this.data.item.productId == detail.id){
|
|
return
|
|
}
|
|
for (var i = 0; i < this.data.form.productCategoryInfos.length; i++) {
|
|
if (this.data.form.productCategoryInfos[i].productId == detail.id){
|
|
util.showToast('纸品已经存在,请不要重复添加')
|
|
return
|
|
}
|
|
}
|
|
this.data.item.productId = detail.id
|
|
this.data.item.settleUnitPrice = ''
|
|
this.data.item.konePrice = '指导价格:' + detail.defaultUnitPrice
|
|
this.data.item.highestUnitPrice = detail.highestUnitPrice
|
|
this.data.item.lowestUnitPrice = detail.lowestUnitPrice
|
|
this.data.item.productCategoryName = detail.name
|
|
this.statAmount()
|
|
wx.nextTick(() => {
|
|
this.triggerEvent('change', {index: this.data.index, item: this.data.item });
|
|
})
|
|
},
|
|
bindInput: function (e) {
|
|
this.data.item[e.currentTarget.id] = e.detail
|
|
if(e.currentTarget.id == 'deductPercent'){
|
|
if(util.isEmpty(e.detail)){
|
|
this.data.item.deductWeight = null
|
|
this.data.item.deductPercent = null
|
|
} else {
|
|
this.data.item.deductWeight = math.divide(math.times(this.data.item.netWeight, Number(e.detail)), 100).toFixed(2)
|
|
}
|
|
this.statAmount()
|
|
} else if(e.currentTarget.id == 'deductWeight'){
|
|
if(util.isEmpty(e.detail)){
|
|
this.data.item.deductWeight = null
|
|
this.data.item.deductPercent = null
|
|
} else {
|
|
this.data.item.deductPercent = math.times(math.divide(Number(e.detail), this.data.item.netWeight), 100).toFixed(2)
|
|
}
|
|
this.statAmount()
|
|
} else if(e.currentTarget.id == 'settleUnitPrice'){
|
|
this.statAmount()
|
|
}
|
|
wx.nextTick(() => {
|
|
this.triggerEvent('change', {index: this.data.index, item: this.data.item});
|
|
})
|
|
},
|
|
statAmount: function(){
|
|
this.data.item.settleWeight = this.data.item.netWeight
|
|
if(!util.isEmpty(this.data.item.deductWeight)){
|
|
this.data.item.settleWeight = math.minus(this.data.item.netWeight, this.data.item.deductWeight)
|
|
}
|
|
if(!util.isEmpty(this.data.item.settleUnitPrice) && Number(this.data.item.settleUnitPrice) > 0){
|
|
this.data.item.settlePrice = math.times(this.data.item.settleWeight, this.data.item.settleUnitPrice)
|
|
} else {
|
|
this.data.item.settlePrice = null
|
|
}
|
|
this.setData({ item: this.data.item, cIndex: this.data.cIndex })
|
|
},
|
|
changeDeductType: function(e){
|
|
var type = Number(e.currentTarget.dataset.type)
|
|
this.setData({ ['item.deductType']: type, focus: type })
|
|
}
|
|
}
|
|
|
|
})
|