Commit 4f31d228 by cen

fix: 客户信息车架号判断

1 parent bd87d02f
......@@ -39,7 +39,7 @@ import GlCell from '../../../../components/Form/GlCell.vue'
import { UpdateOrderInfo, popupTypeEnum, payTypeList, titleList } from '../contant'
import { interceptionMixin } from '@/mixin/index'
import NoticePopup from '@/components/NoticePopup.vue'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default {
name: 'CreateOrder',
mixins: [interceptionMixin],
......@@ -65,7 +65,8 @@ export default {
externalData: [],
popupType: 0,
baseConfigData: {},
requiredList: [], // 录单设置的必填项
requiredList: [],
validateState: true, // 录单设置的必填项
orderObj: {
owner: '',
phone: '',
......@@ -123,8 +124,19 @@ export default {
},
// 输入框失去焦点事件
inputBlur(e, val) {
console.log(e, val)
this.orderObj[val.value] = this.orderObj[val.value]
console.log(e, val, val.value === 'carVin')
if (val.value === 'carVin') {
validateVin(this.orderObj.carVin).then(result => {
console.log('validateVin', result)
let { valid } = result.data
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
this.orderObj.carVin = formatVinInput(this.orderObj.carVin)
})
} else {
this.orderObj[val.value] = this.orderObj[val.value]
}
},
// 校验必填等规则
checkRequired() {
......@@ -151,10 +163,10 @@ export default {
// 如果是customerPhone,添加phoneRex校验
if (item.value === 'phone' && !phoneRex.test(value)) throw `请输入正确的${item.label}`
}
if (orderObj.carVin) {
const vinRex = /^(?=.*[A-Za-z])[A-Za-z0-9]{17}$/
if (!vinRex.test(orderObj.carVin)) throw '请输入正确的车架号'
}
// if (orderObj.carVin) {
// const vinRex = /^(?=.*[A-Za-z])[A-Za-z0-9]{17}$/
// if (!vinRex.test(orderObj.carVin)) throw '请输入正确的车架号'
// }
if (orderObj.certificateNo && orderObj.certificateNo.length != 18) throw '请输入正确的18位证件号'
return true
} catch (error) {
......@@ -169,6 +181,18 @@ export default {
// 提交
async submit() {
if (!this.checkRequired() || (await this.checkDailyReport())) return
if (this.orderObj.carVin) {
// 前置判断
if (this.orderObj.carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (this.orderObj.carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
let params = {
id: this.orderObj.id,
notes: this.orderObj.notes || '',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!