新建域名所有者对话框添加身份证格式验证
This commit is contained in:
parent
8b0c05e157
commit
d497034501
@ -226,6 +226,7 @@
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">证件类型 *</label>
|
||||
<select
|
||||
v-model="formData.c_idtype_gswl"
|
||||
@change="onCertificateTypeChange"
|
||||
class="w-full border rounded px-3 py-2"
|
||||
>
|
||||
<option value="">请选择证件类型</option>
|
||||
@ -242,8 +243,12 @@
|
||||
v-model="formData.c_idnum_gswl"
|
||||
type="text"
|
||||
class="w-full border rounded px-3 py-2"
|
||||
placeholder="请输入证件号码"
|
||||
:placeholder="getCertificatePlaceholder()"
|
||||
@input="validateIdNumber"
|
||||
>
|
||||
<div v-if="idNumberError" class="text-red-500 text-xs mt-1">
|
||||
{{ idNumberError }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -316,7 +321,8 @@ export default {
|
||||
selectedCity: '',
|
||||
selectedDistrict: '',
|
||||
countryList: getCountryList(),
|
||||
chinaRegions: getChinaRegions()
|
||||
chinaRegions: getChinaRegions(),
|
||||
idNumberError: ''
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
@ -344,23 +350,11 @@ export default {
|
||||
|
||||
// 调用API创建域名所有者(包含模板创建)
|
||||
console.log('开始调用API...');
|
||||
const response = await new Promise((resolve, reject) => {
|
||||
jingrow.call({
|
||||
method: 'jcloud.api.domain_west.create_domain_owner_with_template',
|
||||
args: submitData,
|
||||
callback: (r) => {
|
||||
console.log('API调用结果:', r);
|
||||
resolve(r);
|
||||
},
|
||||
error: (r) => {
|
||||
console.error('API调用错误:', r);
|
||||
reject(r);
|
||||
}
|
||||
});
|
||||
});
|
||||
const response = await this.$resources.createDomainOwner.submit(submitData);
|
||||
|
||||
console.log('API调用结果:', response);
|
||||
|
||||
if (response.status === 'Success') {
|
||||
if (response.success) {
|
||||
console.log('域名所有者创建成功:', response);
|
||||
alert('域名所有者创建成功!');
|
||||
this.$emit('submit', response.data);
|
||||
@ -415,6 +409,13 @@ export default {
|
||||
}
|
||||
if (!this.formData.c_idnum_gswl) {
|
||||
errors.push('请输入证件号码');
|
||||
} else if (this.formData.c_idtype_gswl === 'SFZ') {
|
||||
const idNum = this.formData.c_idnum_gswl;
|
||||
if (idNum.length !== 18) {
|
||||
errors.push('身份证号码必须是18位');
|
||||
} else if (!(idNum.slice(0, 17).match(/^\d+$/) && (idNum[17].match(/^\d$/) || idNum[17].toUpperCase() === 'X'))) {
|
||||
errors.push('身份证号码格式不正确');
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
@ -440,6 +441,7 @@ export default {
|
||||
this.selectedProvince = '';
|
||||
this.selectedCity = '';
|
||||
this.selectedDistrict = '';
|
||||
this.idNumberError = '';
|
||||
},
|
||||
onCountryChange() {
|
||||
// 重置省市区选择
|
||||
@ -465,6 +467,11 @@ export default {
|
||||
onDistrictChange() {
|
||||
this.formData.c_dt_m = this.selectedDistrict;
|
||||
},
|
||||
onCertificateTypeChange() {
|
||||
// 清空证件号码和错误信息
|
||||
this.formData.c_idnum_gswl = '';
|
||||
this.idNumberError = '';
|
||||
},
|
||||
getCurrentCities() {
|
||||
if (!this.selectedProvince) return [];
|
||||
return getCitiesByProvince(this.selectedProvince);
|
||||
@ -484,7 +491,53 @@ export default {
|
||||
{ value: 'ORG', label: '组织机构代码证' }
|
||||
];
|
||||
},
|
||||
getCertificatePlaceholder() {
|
||||
if (this.formData.c_idtype_gswl === 'SFZ') {
|
||||
return '请输入18位身份证号码';
|
||||
} else if (this.formData.c_idtype_gswl === 'HZ') {
|
||||
return '请输入护照号码';
|
||||
} else if (this.formData.c_idtype_gswl === 'YYZZ') {
|
||||
return '请输入营业执照号码';
|
||||
} else if (this.formData.c_idtype_gswl === 'ORG') {
|
||||
return '请输入组织机构代码证号码';
|
||||
}
|
||||
return '请输入证件号码';
|
||||
},
|
||||
validateIdNumber() {
|
||||
this.idNumberError = '';
|
||||
|
||||
if (!this.formData.c_idnum_gswl) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.formData.c_idtype_gswl === 'SFZ') {
|
||||
const idNum = this.formData.c_idnum_gswl;
|
||||
if (idNum.length !== 18) {
|
||||
this.idNumberError = '身份证号码必须是18位';
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证格式:前17位为数字,最后一位可能是数字或X
|
||||
if (!(idNum.slice(0, 17).match(/^\d+$/) && (idNum[17].match(/^\d$/) || idNum[17].toUpperCase() === 'X'))) {
|
||||
this.idNumberError = '身份证号码格式不正确';
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
resources: {
|
||||
createDomainOwner() {
|
||||
return {
|
||||
url: 'jcloud.api.domain_west.create_domain_owner_with_template',
|
||||
onSuccess(response) {
|
||||
return response;
|
||||
},
|
||||
onError(error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@ -369,7 +369,7 @@ class WestDomain:
|
||||
}
|
||||
return self._make_request('/audit/', 'POST', body_params=body_params)
|
||||
|
||||
def create_domain_template(self, template_data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
def create_contact_template(self, template_data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
创建域名模板
|
||||
|
||||
@ -1222,7 +1222,7 @@ def create_domain_template(**data):
|
||||
|
||||
try:
|
||||
jingrow.log_error("西部模板API发送", f"模板数据: {template_data}")
|
||||
result = client.create_domain_template(template_data)
|
||||
result = client.create_contact_template(template_data)
|
||||
|
||||
if result.get('result') == 200:
|
||||
c_sysid = result.get('data', {}).get('c_sysid')
|
||||
@ -1351,9 +1351,15 @@ def create_domain_owner(**data):
|
||||
def create_domain_owner_with_template(**data):
|
||||
"""创建域名所有者(包含模板创建)"""
|
||||
try:
|
||||
# 打印接收到的参数
|
||||
jingrow.log_error("create_domain_owner_with_template 接收到的参数", f"参数: {data}")
|
||||
|
||||
# 第一步:创建域名模板
|
||||
template_result = create_domain_template(**data)
|
||||
|
||||
# 打印template_result
|
||||
jingrow.log_error("create_domain_owner_with_template template_result", f"template_result: {template_result}")
|
||||
|
||||
if template_result.get("status") != "success":
|
||||
return template_result
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user