Commit 8e53cf5f by 李伟康

```

feat(equity): 添加车架号动态校验功能并优化提交逻辑

新增 validateState 状态控制车架号校验结果,并在输入框失焦及表单提交时触发校验。
调整代码缩进格式以提升可读性,确保 VIN 校验逻辑正确执行。
```
1 parent 375d17db
......@@ -181,8 +181,8 @@ export default {
conSecondObj: {
vin: ''
},
noticeObj: {}
noticeObj: {},
validateState: true
}
},
watch: {
......@@ -203,22 +203,22 @@ export default {
},
methods: {
// 车架号动态校验
validateVin () {
let carVinVal = this.orderObj.vin;
if (carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => {
console.log("validateVin", result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr", result);
})
}
},
// 车架号动态校验
validateVin () {
let carVinVal = this.orderObj.vin;
if (carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => {
console.log("validateVin", result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr", result);
})
}
},
// 单选框change事件
radioChange (e, val) {
this.$set(this.orderObj, val.value, e.detail.value)
......@@ -255,8 +255,8 @@ export default {
},
inputBlur (e, val) {
this.orderObj[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
if (val.value === 'vin') this.validateVin()
// VIN车架号动态校验:车架号字段,动态转换为大写
if (val.value === 'vin') this.validateVin()
},
async getServiceInfoDetail (contractNo) {
try {
......@@ -415,21 +415,21 @@ export default {
this.viewKey = Date.now()
},
async submit (operationType) {
// VIN车架号-动态校验
const carVin = this.orderObj.vin
console.log("validateState", this.orderObj);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
// VIN车架号-动态校验
const carVin = this.orderObj.vin
console.log("validateState", this.orderObj);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
uni.showLoading({
title: '提交中...',
mask: true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!