Requirements Document
Introduction
本文档描述工作统计系统的两个新增功能需求:手机端适配(包含禁止用户缩放)和数据导入功能(支持XLSX格式模板)。这些功能将提升系统的移动端用户体验,并支持批量数据导入以提高工作效率。
Glossary
- System: 工作统计系统的整体应用
- Frontend: 前端应用,基于React和Ant Design构建
- Mobile_View: 移动端视图,针对手机屏幕优化的界面
- Viewport: 浏览器视口,控制页面显示区域和缩放行为
- Import_Service: 导入服务,负责解析和处理导入的数据文件
- Import_Template: 导入模板,预定义格式的XLSX文件
- Work_Record: 工作记录实体
- XLSX: Excel文件格式,用于数据导入导出
Requirements
Requirement 1: Mobile Responsive Design
User Story: As a mobile user, I want to use the system on my phone with a properly adapted interface, so that I can manage work records conveniently on mobile devices.
Acceptance Criteria
- THE Frontend SHALL adapt layout responsively for mobile screens (width < 768px)
- THE Frontend SHALL use single-column layout for forms and lists on mobile devices
- THE Frontend SHALL adjust navigation menu to mobile-friendly format (collapsible menu or bottom navigation)
- THE Frontend SHALL ensure all buttons and interactive elements have minimum touch target size of 44x44 pixels
- THE Frontend SHALL optimize table displays for mobile by using card-based layouts or horizontal scrolling
- THE Frontend SHALL ensure all text remains readable without horizontal scrolling on mobile devices
- WHEN displaying forms on mobile, THE Frontend SHALL stack form fields vertically
- WHEN displaying the dashboard on mobile, THE Frontend SHALL reorganize statistics cards into single-column layout
Requirement 2: Disable User Zoom
User Story: As a system administrator, I want to prevent users from zooming the page on mobile devices, so that the interface maintains consistent appearance and usability.
Acceptance Criteria
- THE Frontend SHALL set viewport meta tag to disable user scaling
- THE Viewport SHALL include
user-scalable=no attribute
- THE Viewport SHALL set
maximum-scale=1.0 to prevent zoom
- THE Viewport SHALL set
minimum-scale=1.0 to prevent zoom out
- THE Frontend SHALL maintain initial-scale at 1.0 for proper rendering
Requirement 3: Data Import Template Download
User Story: As a manager, I want to download an import template, so that I can prepare data in the correct format for batch import.
Acceptance Criteria
- THE System SHALL provide a downloadable XLSX import template
- THE Import_Template SHALL contain columns: person_name, item_name, work_date, quantity
- THE Import_Template SHALL include a header row with column names in Chinese (人员姓名, 物品名称, 工作日期, 数量)
- THE Import_Template SHALL include example data rows demonstrating correct format
- THE Import_Template SHALL specify date format as YYYY-MM-DD in the example
- WHEN a user clicks the download template button, THE System SHALL download the template file named "import_template.xlsx"
- THE Frontend SHALL display the template download button prominently in the import section
Requirement 4: Work Record Import
User Story: As a manager, I want to import work records from an XLSX file, so that I can batch create multiple records efficiently.
Acceptance Criteria
- WHEN a user uploads an XLSX file, THE Import_Service SHALL parse the file content
- THE Import_Service SHALL validate that uploaded file is in XLSX format
- THE Import_Service SHALL validate that all required columns exist in the uploaded file
- THE Import_Service SHALL validate each row's data:
- person_name must match an existing person in the system
- item_name must match an existing item in the system
- work_date must be a valid date in YYYY-MM-DD format
- quantity must be a positive number
- IF any row contains invalid data, THEN THE Import_Service SHALL return detailed error messages indicating row number and error reason
- IF all rows are valid, THEN THE Import_Service SHALL create work records for each row
- WHEN import succeeds, THE System SHALL return the count of successfully imported records
- WHEN import fails validation, THE System SHALL NOT create any records (atomic operation)
- THE Frontend SHALL display a file upload component for selecting XLSX files
- THE Frontend SHALL show import progress and results (success count or error details)
- THE Frontend SHALL limit file size to 5MB maximum
- IF file size exceeds limit, THEN THE System SHALL reject the upload with appropriate error message
Requirement 5: Import Error Handling
User Story: As a manager, I want clear error messages when import fails, so that I can correct the data and retry.
Acceptance Criteria
- WHEN person_name does not match any existing person, THE Import_Service SHALL report "第X行: 人员 'xxx' 不存在"
- WHEN item_name does not match any existing item, THE Import_Service SHALL report "第X行: 物品 'xxx' 不存在"
- WHEN work_date format is invalid, THE Import_Service SHALL report "第X行: 日期格式错误,应为 YYYY-MM-DD"
- WHEN quantity is not a positive number, THE Import_Service SHALL report "第X行: 数量必须为正数"
- WHEN required field is empty, THE Import_Service SHALL report "第X行: 'xxx' 不能为空"
- THE Frontend SHALL display all validation errors in a scrollable list
- THE Frontend SHALL highlight the first error for user attention