|
|
@ -56,7 +56,7 @@ |
|
|
|
<span>计算标准(%)</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item><el-input v-model="formobj.calculationStandard" @keyup.native="UpNumber" 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-row> |
|
|
|
<div class="title"> |
|
|
@ -74,26 +74,10 @@ |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="车架号" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ scope.row.vinNo }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="厂家结算价" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ scope.row.manufactorSettlementPrice }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="其中运费" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ scope.row.freight }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="estimateRebate" label="预计返利" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ estimateRebate(scope.row) }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="vinNo" label="车架号" align="center" /> |
|
|
|
<el-table-column prop="manufactorSettlementPrice" label="厂家结算价" align="center" /> |
|
|
|
<el-table-column prop="freight" label="其中运费" align="center" /> |
|
|
|
<el-table-column prop="estimateRebate" label="预计返利" align="center" /> |
|
|
|
<el-table-column label="备注" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input v-model="scope.row.remarks" clearable placeholder="" class="addinputw"></el-input> |
|
|
@ -157,55 +141,23 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
UpNumber(e) { |
|
|
|
if (this.formobj.calculationModeValue === '') { |
|
|
|
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 { |
|
|
|
if (this.formobj.calculationModeKey === '001') { |
|
|
|
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) |
|
|
|
} |
|
|
|
this.formobj.calculationStandard = e.target.value |
|
|
|
} else if (this.formobj.calculationModeKey === '002') { |
|
|
|
e.target.value = e.target.value.replace(/[^\d]/g, '') // 清除“数字”和“.”"-"以外的字符 |
|
|
|
e.target.value = e.target.value.replace(/^00/, '0') // 开头不能有两个0 |
|
|
|
if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') { |
|
|
|
// 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额 |
|
|
|
console.log(e.target.value) |
|
|
|
e.target.value = parseFloat(e.target.value) |
|
|
|
} |
|
|
|
this.formobj.calculationStandard = e.target.value |
|
|
|
} |
|
|
|
// 通过正则保留小数点后指定的位数 |
|
|
|
val = val.replace(reg, '$1.$2') |
|
|
|
} |
|
|
|
}, |
|
|
|
estimateRebate(row) { |
|
|
|
if (this.formobj.calculationModeKey === '001') { |
|
|
|
var price = '' |
|
|
|
price = parseFloat(row.manufactorSettlementPrice) - parseFloat(row.freight) |
|
|
|
row.estimateRebate = this.multiplication(price, (parseFloat(this.formobj.calculationStandard) / 100)) |
|
|
|
} else if (this.formobj.calculationModeKey === '002') { |
|
|
|
row.estimateRebate = this.formobj.calculationStandard |
|
|
|
} |
|
|
|
return row.estimateRebate |
|
|
|
}, |
|
|
|
multiplication(arg1, arg2) { |
|
|
|
var m = 0 |
|
|
|
var s1 = arg1.toString() |
|
|
|
var s2 = arg2.toString() |
|
|
|
try { |
|
|
|
m += s1.split('.')[1].length |
|
|
|
} catch (e) {} |
|
|
|
try { |
|
|
|
m += s2.split('.')[1].length |
|
|
|
} catch (e) {} |
|
|
|
return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m) |
|
|
|
return val |
|
|
|
}, |
|
|
|
showAdd() { |
|
|
|
this.$nextTick(() => { |
|
|
@ -217,33 +169,29 @@ export default { |
|
|
|
this.viewTitle = '【新增】单车返利' |
|
|
|
}, |
|
|
|
changeRebateType(value) { |
|
|
|
let bb = null |
|
|
|
this.rebateType_list.forEach((e) => { |
|
|
|
if (e.dictValue === value) { |
|
|
|
bb = { |
|
|
|
key: e.dictKey, |
|
|
|
value: e.dictValue |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
this.formobj.rebateTypeKey = bb.key |
|
|
|
const choose = this.rebateType_list.filter((item) => item.dictValue === value) |
|
|
|
if (choose !== null && choose.length > 0) { |
|
|
|
this.formobj.rebateTypeKey = choose[0].dictKey |
|
|
|
} else { |
|
|
|
this.formobj.rebateTypeKey = '' |
|
|
|
} |
|
|
|
}, |
|
|
|
changeCalculationMode(value) { |
|
|
|
let bb = null |
|
|
|
this.calculationMode_list.forEach((e) => { |
|
|
|
if (e.dictValue === value) { |
|
|
|
bb = { |
|
|
|
key: e.dictKey, |
|
|
|
value: e.dictValue |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
this.formobj.calculationModeKey = bb.key |
|
|
|
const choose = this.calculationMode_list.filter((item) => item.dictValue === value) |
|
|
|
if (choose !== null && choose.length > 0) { |
|
|
|
this.formobj.calculationModeKey = choose[0].dictKey |
|
|
|
} else { |
|
|
|
this.formobj.calculationModeKey = '' |
|
|
|
} |
|
|
|
}, |
|
|
|
// 明细表添加一行数据 |
|
|
|
addjacket() { |
|
|
|
this.viewState = 2 |
|
|
|
this.$refs['divSelect'].showData(this.formobj.scmVehRebateVehs) |
|
|
|
if (this.formobj.calculationModeValue !== '' && this.formobj.calculationStandard !== '') { |
|
|
|
this.viewState = 2 |
|
|
|
this.$refs['divSelect'].showData(this.formobj.scmVehRebateVehs) |
|
|
|
} else { |
|
|
|
this.$message({ showClose: true, type: 'error', message: '请先选择计算方式及填写计算标准' }) |
|
|
|
} |
|
|
|
}, |
|
|
|
backData(value) { |
|
|
|
this.viewState = 1 |
|
|
@ -263,6 +211,15 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
this.formobj.scmVehRebateVehs.forEach((e) => { |
|
|
|
// 计算方式为比例时,预计返利 = (厂家结算价 - 运费) * (计算标准 / 100) |
|
|
|
if (this.formobj.calculationModeKey === '001') { |
|
|
|
e.estimateRebate = Math.round(((parseFloat(e.manufactorSettlementPrice !== '' ? e.manufactorSettlementPrice : 0) - parseFloat(e.freight !== '' ? e.freight : 0)) * (parseFloat(this.formobj.calculationStandard) / 100)) * 100) / 100 |
|
|
|
} else if (this.formobj.calculationModeKey === '002') { |
|
|
|
// 计算方式为固定金额时,预计返利 = 计算标准 |
|
|
|
e.estimateRebate = this.formobj.calculationStandard |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 明细表删除一行数据 |
|
|
|
dataDelete(index) { |
|
|
@ -282,11 +239,7 @@ export default { |
|
|
|
req.save(this.formobj).then((resp) => { |
|
|
|
this.submitdisabled = false |
|
|
|
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(() => { |
|
|
@ -317,7 +270,6 @@ export default { |
|
|
|
} |
|
|
|
}, 0) |
|
|
|
sums[index] += '' |
|
|
|
// this.formobj.currentAmount = sums[index] += '' |
|
|
|
} else { |
|
|
|
if (!values.every(value => isNaN(value))) { |
|
|
|
sums[index] = values.reduce((prev, curr) => { |
|
|
|