2
0

010.006.story.md 3.3 KB

Story 010.006: 修复省信息编辑功能

Status

Ready for Review

Story

As a 系统管理员 I want 能够成功编辑省信息 so that 维护地区数据

Acceptance Criteria

  1. 点击"更新"按钮后省信息能够成功更新
  2. 更新后页面显示更新后的信息
  3. 错误处理机制完善

Tasks / Subtasks

  • 修复省编辑时的层级和父级ID关系验证错误
    • 修复 AreaManagement.tsxhandleEdit 函数对 parentId 的错误转换(第363行:parentId: selectedArea.parentId || 0 应保持 null
    • 验证 updateAreaSchema 的层级和父级ID关系验证规则正确工作
  • 修复硬编码日期问题
    • 修复 handleEdit 函数中硬编码的 createdAtupdatedAt 值,使用实际值
  • 验证修复结果
    • 测试省信息编辑功能正常工作
    • 测试验证错误信息正确显示

Dev Notes

问题分析

编辑省信息时出现验证错误:"层级和父级ID关系不正确:省/直辖市(parentId=null),市/区县(parentId>0)"

根本原因

  1. AreaManagement.tsx 第363行:parentId: selectedArea.parentId || 0
    • selectedArea.parentIdnull(省级应该为 null)时,null || 0 结果为 0
    • updateAreaSchema 验证要求省级的 parentId 必须为 null
  2. handleEdit 函数中硬编码了 createdAtupdatedAt 为当前时间,而不是使用实际值

技术参考

  • 前端文件packages/area-management-ui/src/components/AreaManagement.tsx
  • Schema文件packages/geo-areas/src/modules/areas/area.schema.ts
  • 验证规则:省级(level=1)必须 parentId=null,市级/区县级必须 parentId>0

修复方案

  1. 修改 AreaManagement.tsx 第363行:parentId: selectedArea.parentId(移除 || 0
  2. 修复 handleEdit 函数中的硬编码日期值

Change Log

Date Version Description Author
2025-12-12 1.0 故事创建,基于史诗010-06需求 Bob (Scrum Master)
2025-12-12 1.1 简化故事,聚焦层级和父级ID关系验证错误修复 John (PM)
2025-12-12 1.2 开发完成:修复parentId转换和硬编码日期问题 James (Developer)

Dev Agent Record

This section will be populated by the development agent during implementation

Agent Model Used

Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)

Debug Log References

Completion Notes List

  1. 修复了 AreaManagement.tsxhandleEdit 函数对 parentId 的错误转换(第363行:移除 || 0,保持 null
  2. 验证了 updateAreaSchema 的层级和父级ID关系验证规则正确工作
  3. 修复了 handleEdit 函数中硬编码的 createdAtupdatedAt 值,使用实际值(同时修复了 handleDeletehandleToggleStatusDialog 函数)
  4. 更新了 AreaNode 类型定义,添加 createdAt?updatedAt? 字段
  5. 运行了类型检查和测试验证修复结果

File List

  1. packages/area-management-ui/src/components/AreaManagement.tsx - 修复 parentId 转换和硬编码日期
  2. packages/area-management-ui/src/types/area.ts - 更新 AreaNode 类型定义
  3. docs/stories/010.006.story.md - 更新任务状态和开发记录

QA Results

This section will be populated by the QA agent during review