Implementation Plan: Mobile Adaptation and Import Feature
Overview
本实现计划将手机适配和导入功能分解为可执行的编码任务。首先实现手机适配(viewport和响应式布局),然后实现后端导入服务,最后实现前端导入界面。
Tasks
[x] 1. Configure viewport to disable user zoom
[x] 2. Implement mobile responsive layout
[x] 3. Checkpoint - Verify mobile adaptation
- Ensure mobile layout works correctly, ask the user if questions arise.
[x] 4. Implement backend import service
- 4.1 Create ImportService class in backend/app/services/import_service.py
- Implement
generate_template() method to create XLSX template
- Template must include headers: 人员姓名, 物品名称, 工作日期, 数量
- Include example data rows
- Requirements: 3.1, 3.2, 3.3, 3.4, 3.5
- [ ]* 4.2 Write property test for template column completeness
- Property 1: Template Column Completeness
- Validates: Requirements 3.2
- 4.3 Implement
parse_and_validate() method
- Parse XLSX file content using openpyxl
- Validate file format is XLSX
- Validate required columns exist
- Validate each row's data (person, item, date, quantity)
- Return list of valid records and list of errors
- Requirements: 4.1, 4.2, 4.3, 4.4
- [ ]* 4.4 Write property test for validation error format
- Property 4: Row Validation Error Format
- Validates: Requirements 4.4, 4.5, 5.1, 5.2, 5.3, 5.4, 5.5
- 4.5 Implement
import_records() method
- Create WorkRecord entries for each valid record
- Implement atomic operation (rollback on any failure)
- Return count of imported records
- Requirements: 4.6, 4.7, 4.8
- [ ]* 4.6 Write property test for successful import count
- Property 5: Successful Import Record Count
- Validates: Requirements 4.6, 4.7
- [ ]* 4.7 Write property test for atomic import operation
- Property 6: Atomic Import Operation
- Validates: Requirements 4.8
[x] 5. Implement backend import routes
[x] 6. Checkpoint - Verify backend import functionality
- Ensure all backend tests pass, ask the user if questions arise.
[x] 7. Implement frontend import component
[x] 8. Final checkpoint - Integration testing
- Ensure all features work together, ask the user if questions arise.
Notes
- Tasks marked with
* are optional property-based tests
- Mobile adaptation tasks (1-2) should be completed before import tasks (4-7)
- Backend import service (4) must be completed before frontend import component (7)
- Property tests use pytest + hypothesis library