diff --git a/dashboard/src2/components/DomainOwnerDialog.vue b/dashboard/src2/components/DomainOwnerDialog.vue
index 7a7b2f8..b36c485 100644
--- a/dashboard/src2/components/DomainOwnerDialog.vue
+++ b/dashboard/src2/components/DomainOwnerDialog.vue
@@ -40,6 +40,7 @@
type="radio"
v-model="formData.c_regtype"
value="I"
+ @change="onRegTypeChange"
class="mr-2"
>
个人
@@ -49,6 +50,7 @@
type="radio"
v-model="formData.c_regtype"
value="E"
+ @change="onRegTypeChange"
class="mr-2"
>
企业/组织
@@ -313,7 +315,7 @@ export default {
c_ph_type: '0', // 电话类型:0-手机(固定值)
c_ph: '', // 手机号码
c_em: '', // 邮箱
- c_idtype_gswl: '', // 证件类型
+ c_idtype_gswl: 'SFZ', // 证件类型,个人默认身份证
c_idnum_gswl: '' // 证件号码
},
selectedCountry: 'CN',
@@ -339,32 +341,18 @@ export default {
}
try {
- // 准备提交数据
const submitData = { ...this.formData };
-
- // 添加国家信息
submitData.c_co = this.selectedCountry;
submitData.cocode = this.selectedCountry === 'CN' ? '+86' : '';
-
- console.log('准备提交的数据:', submitData);
-
- // 调用API创建域名所有者(包含模板创建)
- console.log('开始调用API...');
- const response = await this.$resources.createDomainOwner.submit(submitData);
-
- console.log('API调用结果:', response);
-
- if (response.success) {
- console.log('域名所有者创建成功:', response);
+ const response = await this.$resources.createDomainOwner.submit(submitData);
+ if (response.status === 'Success') {
alert('域名所有者创建成功!');
this.$emit('submit', response.data);
this.closeDialog();
} else {
- console.error('创建失败:', response);
alert(`创建失败: ${response.message}`);
}
} catch (error) {
- console.error('创建域名所有者失败:', error);
alert('创建失败,请检查网络连接或联系管理员');
}
},
@@ -434,7 +422,7 @@ export default {
c_ph_type: '0',
c_ph: '',
c_em: '',
- c_idtype_gswl: '',
+ c_idtype_gswl: 'SFZ', // 个人默认证件类型
c_idnum_gswl: ''
};
this.selectedCountry = 'CN';
@@ -472,6 +460,17 @@ export default {
this.formData.c_idnum_gswl = '';
this.idNumberError = '';
},
+ onRegTypeChange() {
+ // 根据所有者类型设置默认证件类型
+ if (this.formData.c_regtype === 'I') {
+ this.formData.c_idtype_gswl = 'SFZ'; // 个人默认身份证
+ } else {
+ this.formData.c_idtype_gswl = 'YYZZ'; // 企业默认营业执照
+ }
+ // 清空证件号码和错误信息
+ this.formData.c_idnum_gswl = '';
+ this.idNumberError = '';
+ },
getCurrentCities() {
if (!this.selectedProvince) return [];
return getCitiesByProvince(this.selectedProvince);
@@ -513,7 +512,7 @@ export default {
if (this.formData.c_idtype_gswl === 'SFZ') {
const idNum = this.formData.c_idnum_gswl;
if (idNum.length !== 18) {
- this.idNumberError = '身份证号码必须是18位';
+ this.idNumberError = `身份证号码必须是18位,当前为${idNum.length}位`;
return;
}
diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py
index 61bca50..ae5b6c1 100644
--- a/jcloud/api/domain_west.py
+++ b/jcloud/api/domain_west.py
@@ -1190,13 +1190,15 @@ def create_domain_template(**data):
'fullname': data.get('c_ln_m', '') + data.get('c_fn_m', '') # 完整姓名
}
- # 添加企业相关字段
- if data['c_regtype'] == 'E':
- if not data.get('c_org_m'):
- return {"status": "error", "message": "企业类型必须填写单位名称"}
+ # 个人类型时不传入c_org_m参数
+ if data['c_regtype'] == 'E' and data.get('c_org_m'):
template_data['c_org_m'] = data['c_org_m']
template_data['c_org'] = data.get('c_org', '') # 英文单位名称
+ # 验证企业类型必须填写单位名称
+ if data['c_regtype'] == 'E' and not data.get('c_org_m'):
+ return {"status": "error", "message": "企业类型必须填写单位名称"}
+
# 添加区县信息
if data.get('c_dt_m'):
template_data['c_dt_m'] = data['c_dt_m']