|
@@ -82,16 +82,28 @@ export default {
|
|
},
|
|
},
|
|
mounted() {},
|
|
mounted() {},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ //校验车牌号
|
|
|
|
+ isVehicleNumber(vehicleNumber) {
|
|
|
|
+ // console.log(vehicleNumber);
|
|
|
|
+ var result = false;
|
|
|
|
+ if (vehicleNumber.length == 7) {
|
|
|
|
+ var express = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使场领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
|
|
|
|
+ result = express.test(vehicleNumber);
|
|
|
|
+ }else if(vehicleNumber.length == 8){
|
|
|
|
+ var express = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{1}[A-HJ-NP-Z]{1}(([A-HJ-NP-Z0-9]{5})|([0-9]{6}|[A-HJ-NP-Z]{1}[0-9]{5}|[0-9]{5}[A-HJ-NP-Z]{1}|[A-HJ-NP-Z]{2}[0-9]{4}))$/;
|
|
|
|
+ result = express.test(vehicleNumber);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ },
|
|
//初始化数据
|
|
//初始化数据
|
|
initData() {
|
|
initData() {
|
|
let that = this;
|
|
let that = this;
|
|
- let regExp = /(^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$)/;
|
|
|
|
if (that.carNumber == "") {
|
|
if (that.carNumber == "") {
|
|
this.$message.error("车牌号不能为空!");
|
|
this.$message.error("车牌号不能为空!");
|
|
//清除旧的定时器
|
|
//清除旧的定时器
|
|
clearTimeout(this.timer);
|
|
clearTimeout(this.timer);
|
|
return;
|
|
return;
|
|
- } else if (!regExp.test(that.carNumber)) {
|
|
|
|
|
|
+ } else if (!that.isVehicleNumber(that.carNumber)) {
|
|
this.$message.error("请输入正确的车牌号!");
|
|
this.$message.error("请输入正确的车牌号!");
|
|
//清除旧的定时器
|
|
//清除旧的定时器
|
|
clearTimeout(this.timer);
|
|
clearTimeout(this.timer);
|