Commit 7d8e4190 by 张立顺

docs: expand low-price navigation contract

1 parent 7b4abd83
# Low-Price Order Navigation 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:** Redirect successful low-price submissions to `confirmOrder` and route pending-follow-up list items to the low-price create-order flow.
**Architecture:** Remove the low-price-only branch from `SubmitContext.doSubmit` and use the same post-submit navigation statement as the business-assistant reference project. Restore the reference list template's status-based target so `status == 1` uses the existing `jump` create-order pathway while other statuses remain on details.
**Tech Stack:** JavaScript ES modules, WeChat Mini Program page/router APIs, Node.js built-in test runner, npm work-order test scripts.
## Global Constraints
- Preserve draft-save navigation and error handling.
- Preserve `wx.$util.refreshPageData()` and the correction-order `isErrorOrder` marker.
- Pass the API response data unchanged to `confirmOrder`.
- Do not modify request payload construction, approval rules, scene defaults, or list filtering.
- Preserve the existing list `jump` access checks and pass the complete list item to the create-order route.
- Work inline because the current repository contains related uncommitted create-order changes and delegation was not requested.
---
### Task 1: Align low-price submit success navigation with the reference project
**Files:**
- Modify: `tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs`
- Modify: `tabWorkOrder/pages/createOrder/submitStrategy.js`
- Delete: `tabWorkOrder/pages/createOrder/services/lowPriceSubmitNavigation.helpers.js`
- Delete: `tabWorkOrder/pages/createOrder/tests/lowPriceSubmitNavigation.helpers.test.mjs`
**Interfaces:**
- Consumes: `SubmitContext.executeAfterApproval({ save: false })` and `api.createWithPay(submitObj)`.
- Produces: `wx.$router.redirectTo('confirmOrder', resData)` for successful low-price and ordinary non-draft submissions.
- [ ] **Step 1: Change the integration test to express the required navigation**
Replace the existing low-price pending-list test with a test that captures both router arguments:
```js
it('redirects a low-price order to confirmOrder after approval', async () => {
let apiCalls = 0
let submittedPayload
let redirectTarget = ''
let redirectData
let backCalls = 0
globalThis.__WORK_ORDER_MOCK_API__.createWithPay = payload => {
apiCalls += 1
submittedPayload = payload
return { code: 0, data: { orderCode: 'LP-1' } }
}
wx.$router.redirectTo = (route, data) => {
redirectTarget = route
redirectData = data
}
wx.$router.back = () => {
backCalls += 1
}
const { page } = createPage()
await new SubmitContext(page).executeAfterApproval({ save: false })
assert.equal(apiCalls, 1)
assert.equal(submittedPayload.baseSceneCode, '100101')
assert.equal(submittedPayload.baseSceneName, '精品升级')
assert.equal(submittedPayload.sceneType, 1)
assert.equal(redirectTarget, 'confirmOrder')
assert.deepEqual(redirectData, { orderCode: 'LP-1' })
assert.equal(backCalls, 0)
})
```
- [ ] **Step 2: Run the focused test and verify RED**
Run:
```powershell
node --test --test-name-pattern "redirects a low-price order to confirmOrder after approval" tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs
```
Expected: FAIL because `redirectTarget` is empty and the current implementation calls list back-navigation.
- [ ] **Step 3: Apply the minimal production change**
Remove the import from `./services/lowPriceSubmitNavigation.helpers.js`. Replace the low-price branch in the successful non-draft path with the shared statement:
```js
wx.$util.refreshPageData()
if (isErrorOrder) resData.isErrorOrder = true
wx.$router.redirectTo('confirmOrder', resData)
```
- [ ] **Step 4: Run the focused test and verify GREEN**
Run the command from Step 2. Expected: PASS with one selected test and no failures.
- [ ] **Step 5: Remove obsolete navigation helpers**
Delete:
```text
tabWorkOrder/pages/createOrder/services/lowPriceSubmitNavigation.helpers.js
tabWorkOrder/pages/createOrder/tests/lowPriceSubmitNavigation.helpers.test.mjs
```
Then run:
```powershell
rg -n "buildPendingLowPriceListPatch|isLowPriceListPage|isLowPriceSubmit|lowPriceSubmitNavigation" tabWorkOrder/pages/createOrder
```
Expected: no matches.
- [ ] **Step 6: Run regression verification**
Run:
```powershell
npm run test:createOrder
npm run test:workOrder
git diff --check
```
Expected: all non-live tests pass, live tests remain explicitly skipped, work-order closure reports `status: ok`, and the diff check reports no whitespace errors.
- [ ] **Step 7: Review scope without staging unrelated changes**
Run:
```powershell
git diff -- tabWorkOrder/pages/createOrder/submitStrategy.js tabWorkOrder/pages/createOrder/tests/lowPriceSubmitFlow.integration.test.mjs tabWorkOrder/pages/createOrder/services/lowPriceSubmitNavigation.helpers.js tabWorkOrder/pages/createOrder/tests/lowPriceSubmitNavigation.helpers.test.mjs
git status --short
```
Do not commit the dirty integration or production files automatically because they contain earlier confirmed create-order fixes that predate this navigation change.
---
### Task 2: Route pending-follow-up list items to create order
**Files:**
- Modify: `tests/work-order-migration/work-order-list-page.test.mjs`
- Modify: `pages/tabWorkOrder/pages/index/index.wxml`
**Interfaces:**
- Consumes: a list item `li` with numeric or string-compatible `status` and the existing `jump` event handler.
- Produces: `data-name="createOrder"` for `status == 1`; `data-name="orderDetail"` for all other statuses.
- [ ] **Step 1: Add the failing template regression assertion**
Add a test that reads the list template and asserts the card target preserves the status route:
```js
it('routes pending-follow-up cards to the low-price create-order page', async () => {
const template = await readFile(
'pages/tabWorkOrder/pages/index/index.wxml',
'utf8'
)
assert.match(
template,
/data-name="\{\{\s*li\.status\s*==\s*1\s*\?\s*'createOrder'\s*:\s*'orderDetail'\s*\}\}"/
)
})
```
- [ ] **Step 2: Run the focused test and verify RED**
Run:
```powershell
node --test --test-name-pattern "routes pending-follow-up cards to the low-price create-order page" tests/work-order-migration/work-order-list-page.test.mjs
```
Expected: FAIL because the current card target is the literal `data-name="orderDetail"`.
- [ ] **Step 3: Restore the status-based list target**
Change the low-price card element to:
```xml
data-name="{{ li.status == 1 ? 'createOrder' : 'orderDetail' }}"
```
Do not change the card's `catchtap="jump"` or `data-item="{{ li }}"` bindings.
- [ ] **Step 4: Run the focused test and verify GREEN**
Run the command from Step 2. Expected: PASS with one selected test and no failures.
- [ ] **Step 5: Include Task 2 in regression and scope review**
Run Task 1 Step 6 after both tasks are green. Include these files in the final diff review:
```text
pages/tabWorkOrder/pages/index/index.wxml
tests/work-order-migration/work-order-list-page.test.mjs
```
# Low-Price Submit Success Navigation Design
# Low-Price Order Navigation Design
## Goal
Make a successfully submitted low-price order continue to the same confirmation page as the business-assistant reference project instead of returning to the pending-order list.
Align two low-price-order navigation points with the business-assistant reference project:
- A successfully submitted order continues to the confirmation page instead of returning to the pending-order list.
- A pending-follow-up list item (`status == 1`) opens the low-price create-order flow instead of the detail page.
## Root Cause
`regional-assistant` added a low-price-only success branch in `SubmitContext.doSubmit`. That branch updates or opens the low-price list after `createWithPay` succeeds. The reference project has no such branch: every successful non-draft submission redirects to `confirmOrder` with the API response data.
The migrated low-price list also hard-codes every card's `data-name` to `orderDetail`. The reference template routes `status == 1` to `createOrder`, so the hard-coded target incorrectly sends pending-follow-up records to details.
## Design
- Preserve draft-save navigation and error handling.
......@@ -15,13 +20,17 @@ Make a successfully submitted low-price order continue to the same confirmation
- For every successful non-draft submission, including low-price orders, call `wx.$router.redirectTo('confirmOrder', resData)`.
- Remove the now-unused low-price-list navigation import, helper module, and helper tests.
- Update the low-price submit integration test to assert one API call, no list back-navigation, and a `confirmOrder` redirect carrying the returned order data.
- Change the low-price list card target to `createOrder` when `li.status == 1`; keep `orderDetail` for other states.
- Continue using the existing `jump` method so its access checks and complete list item parameters remain intact.
- Add a list-template regression assertion for the pending-follow-up route mapping.
## Verification
- First run the updated low-price submit test against the current implementation and verify it fails because the route remains empty and list back-navigation occurs.
- Apply the production change and verify the focused test passes.
- Run the list-page test before and after the template change to prove that a pending-follow-up item no longer targets `orderDetail`.
- Run the complete create-order and work-order regression suites plus `git diff --check`.
## Scope
This change does not alter request payloads, approval rules, scene defaults, list filtering, draft-save behavior, or API response handling.
This change does not alter request payloads, approval rules, scene defaults, list filtering, draft-save behavior, API response handling, or non-pending list-item routing.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!