Commit 7ded54f9 by 张立顺

feat 修改过滤逻辑

1 parent c19236f3
# Order Low Price Filter Parameter 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:** 让精品订单“仅查看低价订单”开关只有开启时才向列表、累计金额和导出请求传递数字 `lowPriceFlag: 1`。
**Architecture:** 保留精品订单页面现有开关值、表单结构和三个请求对 `getParams()` 的复用,只在 `getParams()` 中对 `lowPriceFlag` 做字段级规范化。单元测试直接调用真实 Vue 组件方法,验证开关值的数字/字符串形态及其他值为 `0` 的筛选字段不受影响。
**Tech Stack:** Vue 2.6、JavaScript、Jest 27、Vue CLI 5、ESLint 9
## Global Constraints
- 仅修改精品订单低价筛选参数处理,不修改权益订单。
- 数字 `1` 和字符串 `"1"` 统一输出数字 `1`。
- 数字 `0`、字符串 `"0"`、空值和其他值不输出 `lowPriceFlag` 属性。
- 不修改其他筛选字段的通用清理规则。
- 列表查询、累计金额统计和导出继续共用 `getParams()`。
- 使用 Vue 2 Options API,不引入新依赖。
- 直接在当前分支修改,不切换分支或创建 worktree。
---
## File Structure
- `tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js`:直接验证精品订单组件真实 `getParams()` 的低价筛选参数输出。
- `src/views/orderManage/order.vue`:在现有 `getParams()` 内显式保留或删除 `lowPriceFlag`。
### Task 1: 低价筛选参数规范化
**Files:**
- Create: `tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js`
- Modify: `src/views/orderManage/order.vue:1142-1198`
**Interfaces:**
- Consumes: `searchForm.lowPriceFlag`,可能是数字、字符串、空值或其他值。
- Produces: `Order.methods.getParams()` 返回的请求参数;只有开启时包含数字 `lowPriceFlag: 1`。
- [x] **Step 1: 编写失败测试**
```js
import Order from "@/views/orderManage/order.vue";
jest.mock("@/api/request", () => jest.fn());
function getParams(lowPriceFlag) {
return Order.methods.getParams.call({
baseSceneCode: "",
sceneBusinessType: undefined,
searchForm: {
lowPriceFlag,
myWaitApplySwitch: 0,
orderTime: "",
paySuccessDate: "",
sellerNameVague: "",
sourceList: "",
},
});
}
describe("orderLowPriceFilterParam", () => {
it.each([0, "0", null, undefined, "", "other"])(
"关闭或非开启值 %p 不传 lowPriceFlag",
(value) => {
const params = getParams(value);
expect(params).not.toHaveProperty("lowPriceFlag");
expect(params.myWaitApplySwitch).toBe(0);
},
);
it.each([1, "1"])("开启值 %p 固定传数字 1", (value) => {
expect(getParams(value)).toMatchObject({ lowPriceFlag: 1 });
});
});
```
- [x] **Step 2: 运行测试并确认当前关闭值仍被保留**
Run: `npm run test:unit -- tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js --runInBand`
Expected: FAIL;数字 `0` 和字符串 `"0"` 的用例收到包含 `lowPriceFlag` 的参数,字符串 `"1"` 用例收到的值不是数字 `1`。
- [x] **Step 3: 在 getParams 中实现字段级处理**
在克隆 `searchForm` 并处理 `sellerNameVague` 后加入:
```js
if (Number(params.lowPriceFlag) === 1) {
params.lowPriceFlag = 1;
} else {
delete params.lowPriceFlag;
}
```
- [x] **Step 4: 运行定向测试并确认通过**
Run: `npm run test:unit -- tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js --runInBand`
Expected: PASS;8 个参数规范化用例全部通过。
### Task 2: 回归、静态检查与提交
**Files:**
- Verify: `tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js`
- Verify: `src/views/orderManage/order.vue`
- Include: `docs/superpowers/plans/2026-08-17-order-low-price-filter-param.md`
**Interfaces:**
- Consumes: Task 1 完成的 `getParams()` 行为。
- Produces: 已验证并提交到当前分支的精品订单低价筛选参数修复。
- [x] **Step 1: 运行订单管理相关测试**
Run: `npm run test:unit -- tests/unit/views/orderManage src/views/orderManage/utils/orderListRowDisplay.spec.js --runInBand`
Expected: PASS,无订单管理回归失败。
- [x] **Step 2: 运行修改范围 ESLint 和差异检查**
```powershell
npx eslint tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js
git diff --check -- src/views/orderManage/order.vue tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js docs/superpowers/plans/2026-08-17-order-low-price-filter-param.md
```
Expected: 两个命令 exit code 均为 `0`;精品订单旧页面的历史 ESLint 诊断另行对比本次新增行,确认没有新增诊断。
- [x] **Step 3: 运行完整单元测试**
Run: `npm run test:unit -- --runInBand`
Expected: PASS,0 个失败测试。
- [x] **Step 4: 检查范围并提交**
```powershell
git status --short
git diff -- src/views/orderManage/order.vue tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js docs/superpowers/plans/2026-08-17-order-low-price-filter-param.md
git add -- docs/superpowers/plans/2026-08-17-order-low-price-filter-param.md src/views/orderManage/order.vue tests/unit/views/orderManage/orderLowPriceFilterParam.spec.js
git commit -m "fix: 调整精品订单低价筛选参数"
```
Expected: 提交只包含实施计划、精品订单页面和新增测试。
...@@ -1146,6 +1146,11 @@ export default { ...@@ -1146,6 +1146,11 @@ export default {
if (params.sellerNameVague === "全部") { if (params.sellerNameVague === "全部") {
params.sellerNameVague = ""; params.sellerNameVague = "";
} }
if (Number(params.lowPriceFlag) === 1) {
params.lowPriceFlag = 1;
} else {
delete params.lowPriceFlag;
}
if (form.orderTime && form.orderTime.length) { if (form.orderTime && form.orderTime.length) {
params.placeOrderStartDateStr = Util.dateFormate( params.placeOrderStartDateStr = Util.dateFormate(
......
import Order from "@/views/orderManage/order.vue";
jest.mock("@/api/request", () => jest.fn());
function getParams(lowPriceFlag) {
return Order.methods.getParams.call({
baseSceneCode: "",
sceneBusinessType: undefined,
searchForm: {
lowPriceFlag,
myWaitApplySwitch: 0,
orderTime: "",
paySuccessDate: "",
sellerNameVague: "",
sourceList: "",
},
});
}
describe("orderLowPriceFilterParam", () => {
it.each([0, "0", null, undefined, "", "other"])(
"关闭或非开启值 %p 不传 lowPriceFlag",
(value) => {
const params = getParams(value);
expect(params).not.toHaveProperty("lowPriceFlag");
expect(params.myWaitApplySwitch).toBe(0);
},
);
it.each([1, "1"])("开启值 %p 固定传数字 1", (value) => {
expect(getParams(value)).toMatchObject({ lowPriceFlag: 1 });
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!