# 协议编辑锁定已落库样本编码 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:** 采集协议 / 科研捐赠编辑时,已落库样本编码只读;后端拒绝改码;新增样本仍可选码。 **Architecture:** 共享校验函数比对 payload `id` 与库中 `sample_code`/`sample_code_id`;Web `SampleTransportFormSection` 与小程序 `ProtocolSampleTransportPanel` 按是否有 `id` 锁控件。 **Tech Stack:** FastAPI/SQLAlchemy、Vue 3、mobile-oa-h5、pytest **Spec:** `docs/superpowers/specs/2026-10-26-protocol-sample-code-lock-design.md` --- ### Task 1: Backend 校验 + 测试 **Files:** - Modify: `backend/app/crud/collection_protocol.py` - Modify: `backend/app/crud/research_donation.py` - Create: `backend/tests/test_protocol_sample_code_lock.py` - [x] 写失败用例 → 实现 `validate_persisted_sample_codes_immutable` → 接入两处 save → 测试通过 ### Task 2: Web UI 锁定 **Files:** - Modify: `web-admin/src/components/business/sample-transport-form-section/index.vue` - [x] 编辑且有 `id` 时编码只读 + 提示 ### Task 3: 小程序 UI 锁定 **Files:** - Modify: `mobile-oa-h5/src/market/components/ProtocolSampleTransportPanel.vue` - [x] 编辑且有 `id` 时编码只读 + 提示