# Operation Report Date Filter Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Make 05-2 工序报工 default to recent 15 days and allow user-selected report-date ranges.

**Architecture:** Backend filters miniapp report rows by `production_reports.report_date` using optional `start_date` and `end_date` parameters. Frontend initializes a 15-day range and sends it whenever 05-2 loads or refreshes.

**Tech Stack:** FastAPI, SQLAlchemy, Vue 3 SFC, Node static regression scripts, pytest.

---

### Task 1: Backend Date Filtering

**Files:**
- Modify: `backend/app/api/routes/production.py`
- Create: `backend/tests/test_miniapp_operation_report_date_filter.py`

- [ ] Add failing tests for date range filtering and invalid ranges.
- [ ] Add `start_date` and `end_date` parameters to `_miniapp_report_item_rows`.
- [ ] Add query parameters to `/production/miniapp-operation-reports`.
- [ ] Validate `start_date <= end_date`.
- [ ] Run `backend/.venv/bin/python -m pytest tests/test_miniapp_operation_report_date_filter.py -q`.

### Task 2: Frontend Date Filter

**Files:**
- Modify: `frontend/src/views/OperationReportView.vue`
- Create: `frontend/scripts/test-operation-report-date-filter.mjs`

- [ ] Add failing static regression script.
- [ ] Add default 15-day date range helpers.
- [ ] Add right-side date inputs and refresh button.
- [ ] Build request URL with `start_date` and `end_date`.
- [ ] Run `node scripts/test-operation-report-date-filter.mjs`.

### Task 3: Verification

**Files:**
- No new files.

- [ ] Run backend date-filter test.
- [ ] Run frontend date-filter script.
- [ ] Run `npm run build`.
