Explorar el Código

fix(disability-person-management-ui): 修复身份证已存在错误提示显示问题

- 修改创建、更新、删除操作的错误处理逻辑
- 当后端返回400错误时,提取errorData.message作为错误消息
- 现在身份证号已存在时会显示"身份证号已存在"而不是"创建残疾人失败"
- 提升用户体验,明确错误原因

🤖 Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname hace 2 semanas
padre
commit
655eb0f231

+ 12 - 5
allin-packages/disability-person-management-ui/src/components/DisabilityPersonManagement.tsx

@@ -161,7 +161,10 @@ const DisabilityPersonManagement: React.FC = () => {
       const res = await disabilityClientManager.get().createAggregatedDisabledPerson.$post({
         json: aggregatedData
       });
-      if (res.status !== 200) throw new Error('创建残疾人失败');
+      if (res.status !== 200) {
+        const errorData = await res.json();
+        throw new Error(errorData.message || '创建残疾人失败');
+      }
       return await res.json();
     },
     onSuccess: () => {
@@ -255,7 +258,10 @@ const DisabilityPersonManagement: React.FC = () => {
         param: { id: data.id! },
         json: aggregatedData
       });
-      if (res.status !== 200) throw new Error('更新残疾人失败');
+      if (res.status !== 200) {
+        const errorData = await res.json();
+        throw new Error(errorData.message || '更新残疾人失败');
+      }
       return await res.json();
     },
     onSuccess: () => {
@@ -278,7 +284,10 @@ const DisabilityPersonManagement: React.FC = () => {
       const res = await disabilityClientManager.get().deleteDisabledPerson.$post({
         json: { id }
       });
-      if (res.status !== 200) throw new Error('删除残疾人失败');
+      if (res.status !== 200) {
+        const errorData = await res.json();
+        throw new Error(errorData.message || '删除残疾人失败');
+      }
       return await res.json();
     },
     onSuccess: () => {
@@ -846,7 +855,6 @@ const DisabilityPersonManagement: React.FC = () => {
                           label=""
                           required={true}
                           control={createForm.control}
-                          setValue={createForm.setValue}
                         />
 
                         <FormField
@@ -1211,7 +1219,6 @@ const DisabilityPersonManagement: React.FC = () => {
                         label=""
                         required={true}
                         control={updateForm.control}
-                        setValue={updateForm.setValue}
                       />
 
                       <FormField