CRM_26-06-30#story#8858,关于“我的车辆”中行驶证主页照片识别出的“车牌号”和“车架号”的校验需求

This commit is contained in:
2026-06-23 16:44:37 +08:00
parent 68ff233674
commit 431c7ce7a2

View File

@@ -875,7 +875,7 @@ export default {
this.vehicleLicenseInfo.address = frontInfo?.address; this.vehicleLicenseInfo.address = frontInfo?.address;
this.vehicleLicenseInfo.useNature = frontInfo?.useCharacter; this.vehicleLicenseInfo.useNature = frontInfo?.useCharacter;
this.vehicleLicenseInfo.model = frontInfo?.model; this.vehicleLicenseInfo.model = frontInfo?.model;
this.vehicleLicenseInfo.vinCode = frontInfo?.vin; this.vehicleLicenseInfo.vinCode = String(frontInfo?.vin || '').toUpperCase().replace(/O/g, '0');
this.vehicleLicenseInfo.engineNumber = frontInfo?.engineNo; this.vehicleLicenseInfo.engineNumber = frontInfo?.engineNo;
this.vehicleLicenseInfo.registrationDate = frontInfo?.registerDate; this.vehicleLicenseInfo.registrationDate = frontInfo?.registerDate;
this.vehicleLicenseInfo.issueDate = frontInfo?.issueDate; this.vehicleLicenseInfo.issueDate = frontInfo?.issueDate;
@@ -1232,7 +1232,52 @@ export default {
}*/ }*/
}, },
validatePlateNumber(value) {
if (!value) {
return { valid: false, message: '请输入车牌号' }
}
const provinceList = ['京','津','冀','晋','蒙','辽','吉','黑','沪','苏','浙','皖','闽','赣','鲁','豫','鄂','湘','粤','桂','琼','渝','川','贵','云','藏','陕','甘','青','宁','新']
const firstChar = value.charAt(0)
if (!provinceList.includes(firstChar)) {
return { valid: false, message: '车牌号首位必须是省级简称(京/沪/津/渝/冀/晋/辽/吉/黑/苏/浙/皖/闽/赣/鲁/豫/鄂/湘/粤/琼/川/贵/云/陕/甘/青/蒙/桂/藏/宁/新)' }
}
if (!/^[\u4e00-\u9fa5][A-Z0-9]+$/.test(value)) {
return { valid: false, message: '车牌号只能包含汉字、字母和数字' }
}
if (![7, 8].includes(value.length)) {
return { valid: false, message: `车牌号必须为 7 位或 8 位(当前 ${value.length} 位)` }
}
return { valid: true, message: '' }
},
validateVinNo(value) {
const normalizedValue = String(value || '').toUpperCase()
if (!normalizedValue) {
return { valid: false, message: '车架号识别错误,请重新拍照上传。' }
}
if (!/^[A-NP-Z0-9]{17}$/.test(normalizedValue)) {
if (normalizedValue.includes('O')) {
return { valid: false, message: '车架号识别错误,请重新拍照上传。' }
}
if (!/^[A-NP-Z0-9]+$/.test(normalizedValue)) {
return { valid: false, message: '车架号识别错误,请重新拍照上传。' }
}
return { valid: false, message: `车架号识别错误,请重新拍照上传。` }
}
return { valid: true, message: '' }
},
async submitBtn(){ async submitBtn(){
const plateResult = this.validatePlateNumber(this.carNum)
if (!plateResult.valid) {
Dialog.alert({ message: plateResult.message })
return
}
const vinCode = String(this.vehicleLicenseInfo.vinCode || '')
const vinResult = this.validateVinNo(vinCode)
if (!vinResult.valid) {
Dialog.alert({ message: vinResult.message })
return
}
this.vehicleLicenseInfo.vinCode = vinCode
if( !this.vehicleLicenseFront ) { if( !this.vehicleLicenseFront ) {
this.$toast('行驶证主页照片不能为空') this.$toast('行驶证主页照片不能为空')
return return