Commit 74eb334b by 张立顺

docs: simplify low-price list navigation

1 parent 7d8e4190
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
**Goal:** Redirect successful low-price submissions to `confirmOrder` and route pending-follow-up list items to the low-price create-order flow. **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. **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 and reduce `jump` to a direct router dispatch with no permission or business-gate branching.
**Tech Stack:** JavaScript ES modules, WeChat Mini Program page/router APIs, Node.js built-in test runner, npm work-order test scripts. **Tech Stack:** JavaScript ES modules, WeChat Mini Program page/router APIs, Node.js built-in test runner, npm work-order test scripts.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
- Preserve `wx.$util.refreshPageData()` and the correction-order `isErrorOrder` marker. - Preserve `wx.$util.refreshPageData()` and the correction-order `isErrorOrder` marker.
- Pass the API response data unchanged to `confirmOrder`. - Pass the API response data unchanged to `confirmOrder`.
- Do not modify request payload construction, approval rules, scene defaults, or list filtering. - 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. - Remove list `jump` access checks and pass the complete list item directly to the selected route.
- Work inline because the current repository contains related uncommitted create-order changes and delegation was not requested. - Work inline because the current repository contains related uncommitted create-order changes and delegation was not requested.
--- ---
...@@ -134,31 +134,57 @@ Do not commit the dirty integration or production files automatically because th ...@@ -134,31 +134,57 @@ Do not commit the dirty integration or production files automatically because th
--- ---
### Task 2: Route pending-follow-up list items to create order ### Task 2: Route list items directly by their status target
**Files:** **Files:**
- Modify: `tests/work-order-migration/work-order-list-page.test.mjs` - Modify: `tests/work-order-migration/work-order-list-page.test.mjs`
- Modify: `pages/tabWorkOrder/pages/index/index.js`
- Modify: `pages/tabWorkOrder/pages/index/index.wxml` - Modify: `pages/tabWorkOrder/pages/index/index.wxml`
**Interfaces:** **Interfaces:**
- Consumes: a list item `li` with numeric or string-compatible `status` and the existing `jump` event handler. - Consumes: a list item `li` with numeric or string-compatible `status` and a `jump` event containing `dataset.name` and `dataset.item`.
- Produces: `data-name="createOrder"` for `status == 1`; `data-name="orderDetail"` for all other statuses. - Produces: `createOrder` for `status == 1`, `confirmOrder` for `status == 3`, and `orderDetail` for other statuses; `jump` dispatches directly to `tabWorkOrder.${name}`.
- [ ] **Step 1: Add the failing template regression assertion** - [ ] **Step 1: Add the failing navigation regression test**
Add a test that reads the list template and asserts the card target preserves the status route: Extend `loadListPage` with a router-call capture:
```js ```js
it('routes pending-follow-up cards to the low-price create-order page', async () => { const routerCalls = []
// inside wx
$router: {
go(name, params) {
routerCalls.push({ name, params })
}
}
// return value
return { pageConfig, navigateBackCalls, showTabBarCalls, routerCalls }
```
Add a test that verifies both the reference template mapping and a direct pending-follow-up dispatch:
```js
it('routes list cards directly by order status without permission gates', async () => {
const { pageConfig, routerCalls } = await loadListPage()
const template = await readFile( const template = await readFile(
'pages/tabWorkOrder/pages/index/index.wxml', 'pages/tabWorkOrder/pages/index/index.wxml',
'utf8' 'utf8'
) )
const item = { status: 1, orderCode: 'FOLLOW-1', lowPriceFlag: 1 }
const context = createPageContext(pageConfig, {})
assert.match( assert.match(
template, template,
/data-name="\{\{\s*li\.status\s*==\s*1\s*\?\s*'createOrder'\s*:\s*'orderDetail'\s*\}\}"/ /data-name="\{\{\s*li\.status\s*==\s*3\s*\?\s*'confirmOrder'\s*:\s*li\.status\s*==\s*1\s*\?\s*'createOrder'\s*:\s*'orderDetail'\s*\}\}"/
) )
pageConfig.jump.call(context, {
currentTarget: { dataset: { name: 'createOrder', item } }
})
assert.equal(routerCalls.length, 1)
assert.equal(routerCalls[0].name, 'tabWorkOrder.createOrder')
assert.equal(routerCalls[0].params, item)
}) })
``` ```
...@@ -167,20 +193,29 @@ it('routes pending-follow-up cards to the low-price create-order page', async () ...@@ -167,20 +193,29 @@ it('routes pending-follow-up cards to the low-price create-order page', async ()
Run: Run:
```powershell ```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 node --test --test-name-pattern "routes list cards directly by order status without permission gates" tests/work-order-migration/work-order-list-page.test.mjs
``` ```
Expected: FAIL because the current card target is the literal `data-name="orderDetail"`. Expected: FAIL because the current card target is the literal `data-name="orderDetail"`. The old `jump` path also cannot directly dispatch without permission state and business gates.
- [ ] **Step 3: Restore the status-based list target** - [ ] **Step 3: Restore the status-based target and simplify `jump`**
Change the low-price card element to: Change the low-price card element to:
```xml ```xml
data-name="{{ li.status == 1 ? 'createOrder' : 'orderDetail' }}" data-name="{{ li.status == 3 ? 'confirmOrder' : li.status == 1 ? 'createOrder' : 'orderDetail' }}"
```
Replace `jump` with:
```js
jump(e) {
const { item, name } = e.currentTarget.dataset
wx.$router.go('tabWorkOrder.' + name, item)
}
``` ```
Do not change the card's `catchtap="jump"` or `data-item="{{ li }}"` bindings. Do not call permission, report, task, lock, prohibition, modal, role, payment, or construction branches from `jump`.
- [ ] **Step 4: Run the focused test and verify GREEN** - [ ] **Step 4: Run the focused test and verify GREEN**
...@@ -191,6 +226,7 @@ Run the command from Step 2. Expected: PASS with one selected test and no failur ...@@ -191,6 +226,7 @@ Run the command from Step 2. Expected: PASS with one selected test and no failur
Run Task 1 Step 6 after both tasks are green. Include these files in the final diff review: Run Task 1 Step 6 after both tasks are green. Include these files in the final diff review:
```text ```text
pages/tabWorkOrder/pages/index/index.js
pages/tabWorkOrder/pages/index/index.wxml pages/tabWorkOrder/pages/index/index.wxml
tests/work-order-migration/work-order-list-page.test.mjs tests/work-order-migration/work-order-list-page.test.mjs
``` ```
...@@ -20,17 +20,18 @@ The migrated low-price list also hard-codes every card's `data-name` to `orderDe ...@@ -20,17 +20,18 @@ The migrated low-price list also hard-codes every card's `data-name` to `orderDe
- For every successful non-draft submission, including low-price orders, call `wx.$router.redirectTo('confirmOrder', resData)`. - 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. - 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. - 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. - Restore the reference card target mapping: `status == 1` uses `createOrder`, `status == 3` uses `confirmOrder`, and other states use `orderDetail`.
- Continue using the existing `jump` method so its access checks and complete list item parameters remain intact. - Simplify `jump` to dispatch directly to `tabWorkOrder.${name}` with the complete list item.
- Add a list-template regression assertion for the pending-follow-up route mapping. - Remove all permission, daily-report, study-task, lock, prohibition, role, payment-type, construction, and entry-selection branching from `jump`; the card target is the sole navigation decision.
- Add list-page regression coverage for both the target mapping and direct `jump` dispatch.
## Verification ## 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. - 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. - 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 list-page test before and after the template and `jump` changes to prove that a pending-follow-up item no longer targets `orderDetail` and dispatch does not invoke permission gates.
- Run the complete create-order and work-order regression suites plus `git diff --check`. - Run the complete create-order and work-order regression suites plus `git diff --check`.
## Scope ## Scope
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. This change does not alter request payloads, approval rules, scene defaults, list filtering, draft-save behavior, or API response handling. List item navigation is intentionally reduced to its status-derived destination without legacy permission gates.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!