|
|
@ -189,7 +189,7 @@ |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="payAccount" label="付款金额(元)" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input v-model="scope.row.payAccount" placeholder="" clearable @keyup.native="UpNumberOne($event, scope.row)" @keydown.native="UpNumberOne($event, scope.row)"></el-input> |
|
|
|
<el-input v-model="scope.row.payAccount" placeholder="" clearable @keyup.native="scope.row.payAccount = UpNumberOne(scope.row.payAccount, 2, scope.row)" /> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="付款备注" align="center"> |
|
|
@ -308,15 +308,24 @@ export default { |
|
|
|
} |
|
|
|
row.actualMoney = e.target.value |
|
|
|
}, |
|
|
|
UpNumberOne(e, row) { |
|
|
|
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) |
|
|
|
UpNumberOne(val, limit, row) { |
|
|
|
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') |
|
|
|
} |
|
|
|
row.payAccount = e.target.value |
|
|
|
row.payAccount = val |
|
|
|
return row.payAccount |
|
|
|
}, |
|
|
|
// 明细表添加一行数据 |
|
|
|
addCommodity() { |
|
|
@ -457,6 +466,19 @@ export default { |
|
|
|
save() { |
|
|
|
this.$refs['form_obj'].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (this.formobj.isPay === '1') { |
|
|
|
if (this.formobj.detailsPayList.length > 0) { |
|
|
|
for (var i = 0; i < this.formobj.detailsPayList.length; i++) { |
|
|
|
if (this.formobj.detailsPayList[i].payAccount === '') { |
|
|
|
this.$message({ showClose: true, type: 'error', message: '付款明细列表中付款金额不能为空' }) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.$message({ showClose: true, type: 'error', message: '付款明细列表不能为空' }) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
this.submitdisabled = true |
|
|
|
req.saveOrUpdate(this.formobj).then((resp) => { |
|
|
|
if (resp.success) { |
|
|
@ -476,6 +498,19 @@ export default { |
|
|
|
submitVehicleApply() { |
|
|
|
this.$refs['form_obj'].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (this.formobj.isPay === '1') { |
|
|
|
if (this.formobj.detailsPayList.length > 0) { |
|
|
|
for (var i = 0; i < this.formobj.detailsPayList.length; i++) { |
|
|
|
if (this.formobj.detailsPayList[i].payAccount === '') { |
|
|
|
this.$message({ showClose: true, type: 'error', message: '付款明细列表中付款金额不能为空' }) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.$message({ showClose: true, type: 'error', message: '付款明细列表不能为空' }) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
this.submitdisabled = true |
|
|
|
req.submitVehicleApply(this.formobj).then((res) => { |
|
|
|
if (res.success) { |
|
|
|