|
|
@ -57,7 +57,7 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="4"> |
|
|
|
<el-form-item> |
|
|
|
<el-radio-group v-model="formobj.isReduceFreight" @change="handleRadio"> |
|
|
|
<el-radio-group v-model="formobj.isReduceFreight"> |
|
|
|
<el-radio label="1">是</el-radio> |
|
|
|
<el-radio label="0">否</el-radio> |
|
|
|
</el-radio-group> |
|
|
@ -67,13 +67,13 @@ |
|
|
|
<span>运费</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="4"> |
|
|
|
<el-form-item><el-input v-model="formobj.freight" :disabled="formobj.isReduceFreight === '0'" class="addinputw" @keyup.native="UpNumber" placeholder="" clearable></el-input></el-form-item> |
|
|
|
<el-form-item><el-input v-model="formobj.freight" :disabled="formobj.isReduceFreight == '0'" class="addinputw" @keyup.native="formobj.freight = getNumber(formobj.freight, 2)" placeholder="" clearable></el-input></el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2" class="tleftb"> |
|
|
|
<span>计算标准(%)</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="4"> |
|
|
|
<el-form-item><el-input v-model="formobj.calculationStandard" @keyup.native="UpInput" clearable placeholder="" class="addinputw"></el-input></el-form-item> |
|
|
|
<el-form-item><el-input v-model="formobj.calculationStandard" @keyup.native="formobj.calculationStandard = getNumber(formobj.calculationStandard, 2)" clearable placeholder="" class="addinputw"></el-input></el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2" class="tleftb"> |
|
|
|
<span>预计返利</span> |
|
|
@ -142,6 +142,7 @@ export default { |
|
|
|
freight: '', |
|
|
|
manufaSaleChannel: '', |
|
|
|
manufaSaleChannelValue: '', |
|
|
|
isReduceFreight: '', |
|
|
|
remarks: '', |
|
|
|
state: '', |
|
|
|
uploadDate: '', |
|
|
@ -158,6 +159,20 @@ export default { |
|
|
|
submitdisabled: false |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
// 计算预计返利 |
|
|
|
estimateRebateSum() { |
|
|
|
let estimateRebate = '0' |
|
|
|
// 是否减运费为是时 预计返利 = (回款金额 - 运费) * 计算标准 |
|
|
|
if (this.formobj.isReduceFreight === '1') { |
|
|
|
estimateRebate = Math.round((parseFloat(estimateRebate) + (parseFloat(this.formobj.collectionMoney !== '' ? this.formobj.collectionMoney : 0) - parseFloat(this.formobj.freight !== '' ? this.formobj.freight : 0)) * (parseFloat(this.formobj.calculationStandard !== '' ? this.formobj.calculationStandard : 0) / 100)) * 100) / 100 |
|
|
|
} else { |
|
|
|
// 为否时 预计返利 = 回款金额 * 计算标准 |
|
|
|
estimateRebate = Math.round((parseFloat(estimateRebate) + parseFloat(this.formobj.collectionMoney !== '' ? this.formobj.collectionMoney : 0) * (parseFloat(this.formobj.calculationStandard !== '' ? this.formobj.calculationStandard : 0) / 100)) * 100) / 100 |
|
|
|
} |
|
|
|
return estimateRebate |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init() { |
|
|
|
fetchBySid(this.formobj.createOrgSid).then((res) => { |
|
|
@ -167,44 +182,23 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
UpNumber(e) { |
|
|
|
if (this.formobj.isReduceFreight === '') { |
|
|
|
this.formobj.calculationStandard = '' |
|
|
|
this.$message({ showClose: true, type: 'error', message: '是否减运费请选择是或否' }) |
|
|
|
return |
|
|
|
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 { |
|
|
|
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) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
UpInput(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) |
|
|
|
} |
|
|
|
}, |
|
|
|
handleRadio(value) { |
|
|
|
if (value === '1') { |
|
|
|
this.formobj.freight = '' |
|
|
|
} else { |
|
|
|
this.formobj.freight = '0' |
|
|
|
} |
|
|
|
}, |
|
|
|
estimateRebateSum() { |
|
|
|
if (this.formobj.freight !== '' && this.formobj.calculationStandard !== '') { |
|
|
|
this.formobj.estimateRebate = (parseInt(this.formobj.collectionMoney) - parseInt(this.formobj.freight)) * (parseFloat(this.formobj.calculationStandard) / 100) |
|
|
|
return this.formobj.estimateRebate |
|
|
|
// 通过正则保留小数点后指定的位数 |
|
|
|
val = val.replace(reg, '$1.$2') |
|
|
|
} |
|
|
|
return val |
|
|
|
}, |
|
|
|
showEdit(row, createOrgSid) { |
|
|
|
this.$nextTick(() => { |
|
|
@ -218,7 +212,8 @@ export default { |
|
|
|
this.formobj = resp.data |
|
|
|
if (this.formobj.scmCollectionRebateVehs.length !== 0) { |
|
|
|
for (var i = 0; i < this.formobj.scmCollectionRebateVehs.length; i++) { |
|
|
|
this.aggregate = parseInt(0) + parseInt(this.formobj.scmCollectionRebateVehs[i].costPrice) |
|
|
|
// 计算车辆回款返利列表--厂家结算价总和 |
|
|
|
this.aggregate = parseFloat(this.aggregate !== '' ? this.aggregate : 0) + parseFloat(this.formobj.scmCollectionRebateVehs[i].costPrice) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -231,21 +226,19 @@ export default { |
|
|
|
return |
|
|
|
} else { |
|
|
|
for (var i = 0; i < this.formobj.scmCollectionRebateVehs.length; i++) { |
|
|
|
this.formobj.scmCollectionRebateVehs[i].estimateRebate = parseFloat(this.formobj.estimateRebate) * (parseFloat(this.formobj.scmCollectionRebateVehs[i].costPrice / parseFloat(this.aggregate))) |
|
|
|
// 计算每台车的预计返利 = 总预计返利 * (单台结算价 / 总结算价) |
|
|
|
this.formobj.scmCollectionRebateVehs[i].estimateRebate = Math.round((parseFloat(this.estimateRebateSum) * (parseFloat(this.formobj.scmCollectionRebateVehs[i].costPrice !== '' ? this.formobj.scmCollectionRebateVehs[i].costPrice : 0) / parseFloat(this.aggregate !== '' ? this.aggregate : 0))) * 100) / 100 |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
save() { |
|
|
|
this.$refs['form_obj'].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
this.formobj.estimateRebate = this.estimateRebateSum |
|
|
|
this.submitdisabled = true |
|
|
|
req.save(this.formobj).then((resp) => { |
|
|
|
if (resp.success) { |
|
|
|
this.$message({ |
|
|
|
showClose: true, |
|
|
|
type: 'success', |
|
|
|
message: resp.msg |
|
|
|
}) |
|
|
|
this.$message({ showClose: true, type: 'success', message: resp.msg }) |
|
|
|
this.handleReturn('true') |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
@ -275,6 +268,7 @@ export default { |
|
|
|
freight: '', |
|
|
|
manufaSaleChannel: '', |
|
|
|
manufaSaleChannelValue: '', |
|
|
|
isReduceFreight: '', |
|
|
|
remarks: '', |
|
|
|
state: '', |
|
|
|
uploadDate: '', |
|
|
|