master
lion 7 months ago
parent 6fb402184d
commit eec33547cf

@ -859,14 +859,24 @@ export default {
idcard: { idcard: {
rules: [ rules: [
{ {
required: true, // 主访客身份证:统一改为“非必填,填了就校验格式”
errorMessage: validateFunction: (rule, value, data, callback) => {
"身份证号码不能为空 / ID card number cannot be empty", const pattern =
/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
if (!value) {
callback();
return;
}
if (!pattern.test(value)) {
callback(
new Error(
"身份证格式错误 / Invalid ID card format"
)
);
return;
}
callback();
}, },
{
pattern:
"^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]",
errorMessage: "身份证格式错误 / Invalid ID card format",
}, },
], ],
}, },
@ -961,14 +971,24 @@ export default {
idcard: { idcard: {
rules: [ rules: [
{ {
required: true, validateFunction: (rule, value, data, callback) => {
errorMessage: const pattern =
"身份证号码不能为空 / ID card number cannot be empty", /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
// 随访人身份证:非必填,填了才校验格式
if (!value) {
callback();
return;
}
if (!pattern.test(value)) {
callback(
new Error(
"身份证格式错误 / Invalid ID card format"
)
);
return;
}
callback();
}, },
{
pattern:
"^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]",
errorMessage: "身份证格式错误 / Invalid ID card format",
}, },
], ],
}, },
@ -1389,6 +1409,20 @@ export default {
if (this.follw_people_obj.credent == 2) { if (this.follw_people_obj.credent == 2) {
this.follw_people_obj.idcard = this.follw_people_obj.passcard; this.follw_people_obj.idcard = this.follw_people_obj.passcard;
} }
// 随访人员:如选择身份证(credent == 1),填写了身份证则先做准确性校验
if (
this.follw_people_obj.credent == 1 &&
this.follw_people_obj.idcard
) {
const pattern =
/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
if (!pattern.test(this.follw_people_obj.idcard)) {
this.util.alert(
"身份证格式错误 / Invalid ID card format"
);
return;
}
}
this.$refs["peopleform"] this.$refs["peopleform"]
.validate() .validate()
.then((res) => { .then((res) => {
@ -1459,6 +1493,26 @@ export default {
this.form.date = this.form.start_date; this.form.date = this.form.start_date;
} }
// 使用身份证(credent=1) 且填写了证件号时,先做一次格式校验(普通访客/施工/物流均生效)
if (this.form.credent == 1 && this.form.idcard) {
const pattern =
/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
if (!pattern.test(this.form.idcard)) {
this.util.alert(
"身份证格式错误 / Invalid ID card format"
);
return;
}
}
// 施工(type=2) / 物流(type=3) 且使用身份证(credent=1) 时,身份证必须填写
if (this.form.type != 1 && this.form.credent == 1 && !this.form.idcard) {
this.util.alert(
"身份证号码不能为空 / ID card number cannot be empty"
);
return;
}
this.$refs["formdata"] this.$refs["formdata"]
.validate() .validate()
.then(() => { .then(() => {
@ -1525,6 +1579,26 @@ export default {
this.form.date = this.form.start_date; this.form.date = this.form.start_date;
} }
// 使用身份证(credent=1) 且填写了证件号时,先做一次格式校验(普通访客/施工/物流均生效)
if (this.form.credent == 1 && this.form.idcard) {
const pattern =
/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
if (!pattern.test(this.form.idcard)) {
this.util.alert(
"身份证格式错误 / Invalid ID card format"
);
return;
}
}
// 施工(type=2) / 物流(type=3) 且使用身份证(credent=1) 时,身份证必须填写
if (this.form.type != 1 && this.form.credent == 1 && !this.form.idcard) {
this.util.alert(
"身份证号码不能为空 / ID card number cannot be empty"
);
return;
}
this.$refs["formdata"] this.$refs["formdata"]
.validate() .validate()
.then((res) => { .then((res) => {

Loading…
Cancel
Save