|
|
@ -48,7 +48,7 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="5"> |
|
|
|
<el-form-item> |
|
|
|
<el-input v-model="formobj.shareProportion" clearable @keyup.native="UpNumber" placeholder="" class="addinputw"/> |
|
|
|
<el-input v-model="formobj.shareProportion" @input="shareProportionInput" @keyup.native="formobj.shareProportion = getNumber(formobj.shareProportion, 2)" clearable placeholder="" class="addinputw"/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="3" class="tleftb"> |
|
|
@ -56,7 +56,7 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="5"> |
|
|
|
<el-form-item> |
|
|
|
<span>{{ shareRebateTotalSummation() }}</span> |
|
|
|
<span>{{ formobj.shareRebateTotal }}</span> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="3" class="tleftb"> |
|
|
@ -64,7 +64,7 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="5"> |
|
|
|
<el-form-item> |
|
|
|
<span>{{ thisRebateBalanceSummation() }}</span> |
|
|
|
<span>{{ formobj.thisRebateBalance }}</span> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
@ -149,15 +149,23 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
UpNumber(e) { |
|
|
|
e.target.value = e.target.value.replace(/[^\d.]/g, '') // 清除“数字”和“.”"-"以外的字符 |
|
|
|
e.target.value = e.target.value.replace(/^00/, '0.') // 开头不能有两个0 |
|
|
|
e.target.value = e.target.value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的 |
|
|
|
e.target.value = e.target.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3') // 只能输入两个小数 |
|
|
|
if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') { |
|
|
|
// 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额 |
|
|
|
e.target.value = parseFloat(e.target.value) |
|
|
|
getNumber(val, limit) { |
|
|
|
val = val.replace(/[^0-9.]/g, '') // 保留数字 |
|
|
|
val = val.replace(/^00/, '0.') // 开头不能有两个0 |
|
|
|
val = val.replace(/^\./g, '0.') // 开头为小数点转换为0. |
|
|
|
val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个 |
|
|
|
val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点 |
|
|
|
/^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0 |
|
|
|
const str = '^(\\d+)\\.(\\d{' + limit + '}).*$' |
|
|
|
const reg = new RegExp(str) |
|
|
|
if (limit === 0) { |
|
|
|
// 不需要小数点 |
|
|
|
val = val.replace(reg, '$1') |
|
|
|
} else { |
|
|
|
// 通过正则保留小数点后指定的位数 |
|
|
|
val = val.replace(reg, '$1.$2') |
|
|
|
} |
|
|
|
return val |
|
|
|
}, |
|
|
|
showEdit(val) { |
|
|
|
this.$nextTick(() => { |
|
|
@ -175,24 +183,20 @@ export default { |
|
|
|
this.formobj.withholdingApply = val.withholdingApply |
|
|
|
this.formobj.distributionState = '已分配' |
|
|
|
this.formobj.scmCollectionRebateDistributionVehs = val.scmCollectionRebateDistributionVehs |
|
|
|
this.formobj.shareGinExaProportion = parseFloat(this.formobj.estimateRebate) / parseFloat(this.formobj.collectionMoney) |
|
|
|
// 计算分摊参考比例 = 预提返利 / 回款金额 |
|
|
|
this.formobj.shareGinExaProportion = Math.round((parseFloat(this.formobj.estimateRebate !== '' ? this.formobj.estimateRebate : 0) / parseFloat(this.formobj.collectionMoney !== '' ? this.formobj.collectionMoney : 0)) * 100) / 100 |
|
|
|
this.viewTitle = '回款返利分配' |
|
|
|
}, |
|
|
|
shareRebateTotalSummation() { |
|
|
|
if (this.formobj.shareProportion !== '') { |
|
|
|
this.formobj.shareRebateTotal = parseFloat(this.formobj.collectionMoney) * parseFloat(this.formobj.shareProportion) |
|
|
|
return this.formobj.shareRebateTotal |
|
|
|
} |
|
|
|
}, |
|
|
|
thisRebateBalanceSummation() { |
|
|
|
if (this.formobj.shareRebateTotal !== '') { |
|
|
|
this.formobj.thisRebateBalance = parseFloat(this.formobj.estimateRebate) - parseFloat(this.formobj.shareRebateTotal) |
|
|
|
return this.formobj.thisRebateBalance |
|
|
|
} |
|
|
|
shareProportionInput() { |
|
|
|
// 计算分摊返利总额 = 回款金额 * 分摊比例 |
|
|
|
this.formobj.shareRebateTotal = Math.round((parseFloat(this.formobj.collectionMoney !== '' ? this.formobj.collectionMoney : 0) * parseFloat(this.formobj.shareProportion !== '' ? this.formobj.shareProportion : 0)) * 100) / 100 |
|
|
|
// 计算本次返利金额 = 预提返利 - 分摊返利总额 |
|
|
|
this.formobj.thisRebateBalance = parseFloat(this.formobj.estimateRebate !== '' ? this.formobj.estimateRebate : 0) - parseFloat(this.formobj.shareRebateTotal !== '' ? this.formobj.shareRebateTotal : 0) |
|
|
|
}, |
|
|
|
handleAllocation() { |
|
|
|
for (var i = 0; i < this.formobj.scmCollectionRebateDistributionVehs.length; i++) { |
|
|
|
this.formobj.scmCollectionRebateDistributionVehs[i].distributionCollectionRebate = parseFloat(this.formobj.scmCollectionRebateDistributionVehs[i].costPrice) * parseFloat(this.formobj.shareProportion) |
|
|
|
// 计算每台车的回款返利 = 厂家结算价 * 分摊比例 |
|
|
|
this.formobj.scmCollectionRebateDistributionVehs[i].distributionCollectionRebate = Math.round((parseFloat(this.formobj.scmCollectionRebateDistributionVehs[i].costPrice !== '' ? this.formobj.scmCollectionRebateDistributionVehs[i].costPrice : 0) * (parseFloat(this.formobj.shareProportion !== '' ? this.formobj.shareProportion : 0) / 100)) * 100) / 100 |
|
|
|
} |
|
|
|
}, |
|
|
|
handleSave() { |
|
|
|