修改
This commit is contained in:
parent
622a50df62
commit
8d67cac8d6
@ -281,9 +281,9 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="优惠券适用门槛" prop="couponConsumePrice">
|
<el-form-item label="优惠券适用门槛" prop="couponConsumePrice">
|
||||||
<el-input
|
<el-input
|
||||||
@keyup.native="form.couponConsumePrice =oninput(form.couponConsumePrice) "
|
:change="checkPrice()"
|
||||||
maxlength="8"
|
maxlength="8"
|
||||||
|
|
||||||
v-model="form.couponConsumePrice"
|
v-model="form.couponConsumePrice"
|
||||||
placeholder="请输入优惠券适用门槛"
|
placeholder="请输入优惠券适用门槛"
|
||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
@ -536,6 +536,28 @@ export default {
|
|||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
/**只能输入数字且有小数点最多保留两位*/
|
||||||
|
checkPrice(){
|
||||||
|
let checkPlan = '' + this.form.couponConsumePrice
|
||||||
|
checkPlan = checkPlan
|
||||||
|
.replace(/[^\d.]/g, '') // 清除“数字”和“.”以外的字符
|
||||||
|
.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
|
||||||
|
.replace(/^\./g, '') // 保证第一个为数字而不是.
|
||||||
|
.replace('.', '$#$')
|
||||||
|
.replace(/\./g, '')
|
||||||
|
.replace('$#$', '.')
|
||||||
|
if (checkPlan.indexOf('.') < 0 && checkPlan !== '') {
|
||||||
|
// 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
|
||||||
|
checkPlan = parseFloat(checkPlan) + ''
|
||||||
|
} else if (checkPlan.indexOf('.') >= 0) {
|
||||||
|
checkPlan = checkPlan
|
||||||
|
.replace(/^()*(\d+)\.(\d\d).*$/, '$1$2.$3') // 只能输入两个小数
|
||||||
|
}
|
||||||
|
this.form.couponConsumePrice = checkPlan
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
oninput(num) {
|
oninput(num) {
|
||||||
let str = num;
|
let str = num;
|
||||||
const len1 = str.substr(0, 1);
|
const len1 = str.substr(0, 1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user