Commit 8e53cf5f by 李伟康

```

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

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