6.6 KiB
Market Reference Labels 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: Ensure every Market mobile list, detail, create, and edit view displays Chinese business labels instead of internal user IDs, foreign-key IDs, or dictionary codes.
Architecture: Keep backend permission-scoped option lists unchanged, but hydrate each edit form with the current record's authoritative { value, label } snapshots so historical values remain readable. Centralize frontend display fallback rules so unresolved references render 未知人员 or —, never raw IDs/codes, and enrich sample handling responses with handler names at the backend boundary.
Tech Stack: Vue 3, Vant, JavaScript Node test runner, FastAPI, SQLAlchemy, pytest.
Task 1: Add reference-label regression coverage
Files:
-
Create:
mobile-oa-h5/src/market/reference-options.test.js -
Modify:
mobile-oa-h5/src/market/module-contracts.test.js -
Modify:
mobile-oa-h5/src/market/list-presenter.test.js -
Modify:
backend/tests/test_market_sample_api.py -
Step 1: Write failing frontend tests
Add tests proving selected user, region, hospital, sample type, sample code, and unit values are merged into scoped option sets from detail label fields. Assert protocol/sample/freight detail presenters never fall back to IDs or dictionary codes.
- Step 2: Run the focused frontend tests and verify RED
Run: node --test src/market/reference-options.test.js src/market/module-contracts.test.js src/market/list-presenter.test.js
Expected: FAIL because reference-option hydration and safe label fallbacks do not yet exist.
- Step 3: Write failing backend tests
Extend sample API tests so get_sample_detail returns handlerUserName for storage-certificate and insurance summaries and get_sample_form_options retains the currently selected handler as a readable option without widening normal region staff choices.
- Step 4: Run the focused backend tests and verify RED
Run: backend/venv/bin/pytest backend/tests/test_market_sample_api.py -q
Expected: FAIL on missing handler display names/current selected options.
Task 2: Centralize form reference-option hydration
Files:
-
Create:
mobile-oa-h5/src/market/reference-options.js -
Modify:
mobile-oa-h5/src/views/market/MarketModuleForm.vue -
Modify:
mobile-oa-h5/src/views/market/presign/PresignOrderForm.vue -
Step 1: Implement minimal hydration helpers
Create pure helpers that merge scoped options with current detail snapshots, deduplicate by normalized value, and only add entries with a real human-readable label.
- Step 2: Hydrate generic Market forms after detail/options load
For protocol fields, merge current collector, sales specialist, manager, region, hospital, sample type, sample code, and unit labels. For sample handling, merge the current handler name. Reapply hydration after region cascade option refreshes.
- Step 3: Harden the dedicated pre-sign form
Reuse the shared person-option merge behavior and render 未知人员 rather than the raw selected ID if the backend cannot resolve a name.
- Step 4: Run focused frontend tests and verify GREEN
Run: node --test src/market/reference-options.test.js src/market/module-contracts.test.js src/market/list-presenter.test.js src/market/presign/presign-form-state.test.js src/market/presign/presign-form-view.test.js
Expected: all tests pass.
Task 3: Enrich sample handler names without widening permissions
Files:
-
Modify:
backend/app/services/market_sample.py -
Modify:
backend/tests/test_market_sample_api.py -
Step 1: Resolve handler names in sample detail summaries
Batch-load tenant user display names for storage-certificate and insurance handler IDs and expose them as handlerUserName.
- Step 2: Preserve the current handler in edit options
Append only the handler already referenced by the accessible sample record when it is outside the active region-staff list; do not expose unrelated tenant users.
- Step 3: Run focused backend tests and verify GREEN
Run: backend/venv/bin/pytest backend/tests/test_market_sample_api.py -q
Expected: all tests pass.
Task 4: Remove raw ID/code display fallbacks across Market presenters
Files:
-
Modify:
mobile-oa-h5/src/market/modules/protocol.js -
Modify:
mobile-oa-h5/src/market/modules/sample.js -
Modify:
mobile-oa-h5/src/market/modules/freight.js -
Modify:
mobile-oa-h5/src/market/list-presenter.js -
Modify:
backend/app/services/market_freight.py -
Step 1: Replace person-ID fallbacks
Display authoritative name fields, 未知人员 for a non-empty unresolved person reference, and — when no reference exists.
- Step 2: Replace unresolved dictionary-code fallbacks
For status, source, payment mode, transport mode, sex, and delivery mode, use known Chinese mappings and render 未知 for an unrecognized non-empty code instead of exposing the code.
- Step 3: Keep identifiers that are business numbers
Do not alter protocol numbers, sample codes, freight batch numbers, laboratory storage codes, or other user-facing business identifiers.
- Step 4: Run presenter and contract tests
Run: node --test src/market/list-presenter.test.js src/market/module-contracts.test.js src/market/mobile-parity-ui.test.js
Expected: all tests pass.
Task 5: Full verification and browser audit
Files:
-
Modify generated graph files under
backend/graphify-out/only through the repository script. -
Step 1: Run all mobile Market tests
Run: node --test src/market/*.test.js src/market/presign/*.test.js src/utils/download-attachment.test.js src/utils/http-error.test.js
Expected: zero failures.
- Step 2: Build mobile OA H5
Run: npm run build
Expected: Vite exits with code 0.
- Step 3: Run affected backend suites
Run: backend/venv/bin/pytest backend/tests/test_market_sample_api.py backend/tests/test_market_protocol_api.py backend/tests/test_market_support_api.py backend/tests/test_market_freight_scope.py -q
Expected: zero failures.
- Step 4: Update backend code graph
Run: ./scripts/update-graph.sh backend
Expected: graph update exits with code 0.
- Step 5: Verify representative pages in the browser
Open specialist and manager protocol edit, pre-sign edit, sample handling, payment/chase detail, and freight detail. Confirm reference fields show Chinese labels, no internal UUID/user ID/dictionary code is visible, and valid business identifiers remain unchanged.