feat(gerp/form): CompanyInfo 同一租户仅一条,防重复提交(epcreate 打通)

This commit is contained in:
TermiNexus committed 2026-08-13 02:39:42 +08:00
1 parent 1504c86bce
commit 0d019c1c8e
1 file changed
+5
+5
View File
@@ -1247,6 +1247,11 @@ class FormService(FormServiceBase):
dup_qs = dup_qs.filter(CompanyUUID=urw_company)
if dup_qs.exists():
return {'error': f'该用户-角色对已在此{target_label}中', 'field': 'UserRoleUUID'}
# CompanyInfo 唯一性:同一租户仅一条企业信息(epcreate 是"完善本企业"向导,
# 防重复提交产生多条;修改走租户详情编辑)
if table_name == 'CompanyInfo' and self.current_tenant_uuid:
if CompanyInfo.objects.filter(TenantUUID_id=self.current_tenant_uuid).exists():
return {'error': '该租户已存在企业信息,如需修改请在租户详情中编辑', 'field': 'Table'}
pk_field_name = model._meta.pk.name if model._meta.pk else None
# 关联表主键由后端强制生成(UserRole/UserRoleWorkgroup/UserRoleDepartment/WorkgroupRole 等):
# 前端新增时若携带主键(如编辑表单回填),直接覆盖,避免撞主键报 1062 Duplicate