二手车交易,发布时,求购可以输入0,但不允许输入多个0

This commit is contained in:
2025-03-25 13:16:06 +08:00
parent a69d57b0fd
commit fc4cbbed7a
2 changed files with 41 additions and 6 deletions

View File

@ -105,6 +105,7 @@
style="border: none" style="border: none"
class="radioWrap" class="radioWrap"
v-model="form.minPrice" v-model="form.minPrice"
@input="validatePrice"
input-align="right" input-align="right"
> >
<template slot="right-icon" > <template slot="right-icon" >
@ -270,6 +271,12 @@ export default {
// console.log("--",this.vehicleLicensePhotoList,this.vehicleAnglePhotoList,this.otherImgSrcList) // console.log("--",this.vehicleLicensePhotoList,this.vehicleAnglePhotoList,this.otherImgSrcList)
}, },
methods:{ methods:{
validatePrice(value) {
if (/^0+$/.test(value)){
value = '0';
}
this.form.minPrice = value;
},
clearStorageFormInfo(){ clearStorageFormInfo(){
localStorage.setItem("carSourceFormInfo",'') localStorage.setItem("carSourceFormInfo",'')
}, },
@ -357,7 +364,11 @@ export default {
}else if(this.form.vehicleType !=='拖车'){ }else if(this.form.vehicleType !=='拖车'){
this.form.boardType='' this.form.boardType=''
} }
let rule=this.validationRules.find(item=>!item.value) let rule = this.validationRules.find(item =>
item.value === null ||
item.value === undefined ||
item.value === ''
)
if(rule){ if(rule){
this.$toast(rule.name) this.$toast(rule.name)
return return
@ -403,7 +414,11 @@ export default {
}else if(this.form.vehicleType !=='拖车'){ }else if(this.form.vehicleType !=='拖车'){
this.form.boardType='' this.form.boardType=''
} }
let rule=this.validationRules.find(item=>!item.value) let rule = this.validationRules.find(item =>
item.value === null ||
item.value === undefined ||
item.value === ''
)
if(rule){ if(rule){
this.$toast(rule.name) this.$toast(rule.name)
return return

View File

@ -69,12 +69,12 @@
<div class="item priceItem"> <div class="item priceItem">
<span> <span class="star">*</span>价格区间 </span> <span> <span class="star">*</span>价格区间 </span>
<div style="display: flex;align-items: center" class="price"> <div style="display: flex;align-items: center" class="price">
<el-input type="tel" v-model.number="form.minPrice" > <el-input type="tel" v-model.number="form.minPrice" @input="validatePrice">
<template slot="suffix" > <template slot="suffix" >
</template> </template>
</el-input> </el-input>
<span style="font-size: 14px;color: rgba(44, 61, 84, 0.59);margin: 0 6px">-</span> <span style="font-size: 14px;color: rgba(44, 61, 84, 0.59);margin: 0 6px">-</span>
<el-input type="tel" v-model.number="form.maxPrice" > <el-input type="tel" v-model.number="form.maxPrice" @input="validatePrice1">
<template slot="suffix" > <template slot="suffix" >
</template> </template>
</el-input> </el-input>
@ -172,6 +172,18 @@ export default {
this.ortherReason=wantBuyFormInfo.ortherReason this.ortherReason=wantBuyFormInfo.ortherReason
}, },
methods:{ methods:{
validatePrice(value) {
if (/^0+$/.test(value)){
value = '0';
}
this.form.minPrice = value;
},
validatePrice1(value) {
if (/^0+$/.test(value)){
value = '0';
}
this.form.maxPrice = value;
},
clearStorageFormInfo(){ clearStorageFormInfo(){
localStorage.setItem("wantBuyFormInfo",'') localStorage.setItem("wantBuyFormInfo",'')
}, },
@ -206,7 +218,11 @@ export default {
}else if(this.form.vehicleType !=='拖车'){ }else if(this.form.vehicleType !=='拖车'){
this.form.boardType='' this.form.boardType=''
} }
let rule=this.validationRules.find(item=>!item.value) let rule = this.validationRules.find(item =>
item.value === null ||
item.value === undefined ||
item.value === ''
)
if(rule){ if(rule){
this.$toast(rule.name) this.$toast(rule.name)
return return
@ -248,7 +264,11 @@ export default {
}else if(this.form.vehicleType !=='拖车'){ }else if(this.form.vehicleType !=='拖车'){
this.form.boardType='' this.form.boardType=''
} }
let rule=this.validationRules.find(item=>!item.value) let rule = this.validationRules.find(item =>
item.value === null ||
item.value === undefined ||
item.value === ''
)
if(rule){ if(rule){
this.$toast(rule.name) this.$toast(rule.name)
return return