Commit 3a1df6e2 by 前端

Merge branch 'develop' into 'master'

上线合并

See merge request !544
2 parents ec24a999 2b89f32e
Showing 230 changed files with 3250 additions and 303 deletions
......@@ -18,6 +18,8 @@ alwaysApply: true
## B. 跨页影响分析(改前必查)
日常接需求用 **§F 口令**;细节检索见 [`docs/DOMAIN-INDEX.md`](../../docs/DOMAIN-INDEX.md) 与 [`docs/COMPONENT-PAGE-INDEX.md`](../../docs/COMPONENT-PAGE-INDEX.md)。
改动前检索引用,在回复中简要说明影响面:
| 改动类型 | 检索方式 | 典型共享点 |
......@@ -55,6 +57,22 @@ alwaysApply: true
- **`wx.$dateListRefresh` / `wx.$orderListRefresh` 仅在目标页 `onShow` 消费**(见 `utils/util.js` `refreshPageData`)
- 用户主动操作(筛选、下拉、切子 Tab)可直接调 `search()`,与生命周期入口分离
## F. 需求开发口令
**Agent / Plan / Ask 均识别**同一套前缀(详见 [Skill](../skills/requirement-impact-analysis/SKILL.md)):
| 口令 | Agent | Plan | Ask |
|------|-------|------|-----|
| **`做需求:<描述>`** | 简表 → 实现 → 测试 | 简表 → 实施计划 | 简表 → 思路,提示切 Agent |
| **`快改:<描述>`** | 轻量检索 → 简表 → 实现 | 轻量检索 → 简短计划 | 轻量检索 → 简表 + 改法 |
| **`只分析:<描述>`** | 仅简表 | 仅简表 | 仅简表 |
- 简表格式见 [`reference.md`](../skills/requirement-impact-analysis/reference.md);「详细分析」用 `reference-full.md`
- 未写前缀但描述新功能需求 → 按 **做需求** 处理
- Plan / Ask:**禁止改代码**;Plan 用 CreatePlan,Ask 仅回答
- 改动 `usingComponents` 后(Agent 实施时):**必须** `npm run gen:component-index` 并提交
- DOMAIN-INDEX 专章:**仅漏改复盘时补**
## 改动自检清单
- [ ] 新增/修改函数已补 JSDoc
......
---
name: requirement-impact-analysis
description: >-
Runs the simplified "做需求" workflow for WeChat mini-program development
in Agent, Plan, and Ask modes. Triggers on 做需求, 快改, 只分析, new requirements,
影响面, 改哪里, or missing related pages. Maps domains via DOMAIN-INDEX,
outputs a short impact table; then implements (Agent), plans (Plan), or advises (Ask).
---
# 做需求(简版)
一条口令完成「影响面简表 → 后续动作」。对内仍走 [DOMAIN-INDEX](../../../docs/DOMAIN-INDEX.md) + 检索;对用户默认只输出 [reference.md](./reference.md) 简表。
**Agent / Plan / Ask 均识别同一套口令**;简表之后按当前 Cursor 模式分支(见下表)。
## 口令
| 口令 | Agent | Plan | Ask |
|------|-------|------|-----|
| **`做需求:<描述>`** | 简表 → 实现 + 测试 | 简表 → **实施计划**(CreatePlan) | 简表 → 实现思路,提示切 Agent |
| **`快改:<描述>`** | 轻量检索 → 简表 → 实现 | 轻量检索 → 简表 → **简短计划** | 轻量检索 → 简表 + 改法说明 |
| **`只分析:<描述>`** | 仅简表 | 仅简表 | 仅简表 |
用户未写前缀但描述新需求时,默认按 **做需求** 处理。
## Cursor 模式分支(简表之后)
### Agent 模式
1. 执行对内流程 1~4(检索 + 简表)
2. 若非「只分析」→ 改代码 + 测试 + 自检(§A/C/D)
3. 若改了 `usingComponents` → `npm run gen:component-index`
### Plan 模式
1. 执行对内流程 1~4(检索 + 简表)
2. **禁止改代码**;用 CreatePlan 输出可执行计划,须含:
- 必改文件路径与改动要点
- 可能波及与风险
- 测试 / 回归项
- 实施顺序(单 PR 可完成的小步骤)
3. 计划末尾提示:「确认后切 Agent,说:按上述计划实现」
4. 「只分析」口令:只出简表,不 CreatePlan(除非用户明确要求出计划)
### Ask 模式
1. 执行对内流程 1~4(检索 + 简表)
2. **禁止改代码、禁止 CreatePlan**
3. 「做需求」「快改」:简表后补充实现思路(关键函数 / 注意点),末尾提示切 Agent
4. 「只分析」:仅简表即可
## 对内流程(默认不打印给用户)
1. 读 [DOMAIN-INDEX](../../../docs/DOMAIN-INDEX.md) 定域 → 读专章(见 reference.md 速查表)
2. 提取关键词 → `rg` / [COMPONENT-PAGE-INDEX](../../../docs/COMPONENT-PAGE-INDEX.md)
3. 判定快改 vs 全量(见 reference.md 模式判定表)
4. 按 [reference.md](./reference.md) **简表模板**输出
5. **按 Cursor 模式分支**(见上表 Agent / Plan / Ask)
6. Agent 且非「只分析」→ 实现 + 测试 + 自检;Agent 且改了 `usingComponents` → `npm run gen:component-index`
## 对用户输出规则
- **默认**只用简表模板(5 行左右)
- 「可能波及」为空时写「无」,不展开
- rg 命令、文档待补、自检四项:**内部执行**,除非用户说「详细分析」
- 用户说「详细分析」→ 改用 [reference-full.md](./reference-full.md) 8 段模板
## 禁止事项
- 不要仅凭单文件改动就断定无跨页影响
- 不要改全局 `Merchant-Seles` 等共享组件,除非用户明确要求跨页改造
- 不要跳过 DOMAIN-INDEX 直接全库乱搜
## 延伸阅读
- [reference.md](./reference.md) — 简表模板(默认)
- [reference-full.md](./reference-full.md) — 完整 8 段模板(详细分析时用)
- [docs/DOMAIN-INDEX.md](../../../docs/DOMAIN-INDEX.md)
- [docs/COMPONENT-PAGE-INDEX.md](../../../docs/COMPONENT-PAGE-INDEX.md)
# 需求影响面分析 — 完整版参考
> 用户说「**详细分析**」时使用本文件。日常开发默认用 [reference.md](./reference.md) 简表。
> **Agent / Plan / Ask** 均先出简表;Plan 再 CreatePlan,Ask 仅回答,Agent 再改代码(见 [SKILL.md](./SKILL.md))。
---
## 完整执行流程(6 步)
### 1. 读领域总索引
打开并阅读 [`docs/DOMAIN-INDEX.md`](../../../docs/DOMAIN-INDEX.md):
- 确定**业务域**(tabIndex / tabWorkOrder / packageEquity / packageDynamicForm / components / 横切)
- 找到该域「影响面文档」链接,优先读专章(如 `YQ-MERCHANT-ID-USAGE.md`)
- 记录「文档缺口」——无专章时需在输出中标注
### 2. 提取检索关键词
从需求中提取并分类:
| 类型 | 示例 |
|------|------|
| 页面/路由 | `createOrder`、`abnormalFlowReport` |
| 组件 | `Merchant-Seles`、`Coupon`、`Popup` |
| API/字段 | `yqMerchantId`、`getYqStoreConfig`、`orderCouponEffects` |
| 全局机制 | `wx.$orderListRefresh`、`checkServiceNotice` |
### 3. 全库检索
按检索命令模板执行 `rg`(或 Cursor Grep):
1. 关键词全库
2. `api/`、`store/` 中的封装名
3. 若涉及组件:[`docs/COMPONENT-PAGE-INDEX.md`](../../../docs/COMPONENT-PAGE-INDEX.md),或
`node scripts/gen-component-page-index.mjs --component <名称>`
4. 若涉及全局组件:`usingComponents` + 组件目录名
**共享层判定**:改动 `components/`、`api/`、`store/`、`utils/` 中逻辑 → 标记为「可能波及多分包」。
### 4. 读域专章 impact map
若 DOMAIN-INDEX 指向的专章含「功能 × 页面 × API」表,将匹配行并入「必改 / 可能波及」清单。
### 5. 输出影响面清单
使用下方 **完整输出模板**,必须包含:
- 涉及业务域(链接 DOMAIN-INDEX 对应章节)
- 必改文件(路径 + 原因)
- 可能波及(共享组件 / api / store / 其他分包)
- 建议 `rg` 命令(可复制)
- 测试与手动回归项(对齐 wechat-change-standards §C)
- 文档待补项(若发现缺口)
### 6. 结尾引用自检清单
输出末尾附上 wechat-change-standards 改动自检四项(JSDoc、ES export、跨页影响、测试)。
---
## 检索命令模板
将 `<关键词>`、`<组件名>`、`<API名>` 替换为实际值。
```bash
# 1. 关键词全库(函数名、字段名、页面名)
rg "<关键词>" --glob "!node_modules" --glob "!miniprogram_npm"
# 2. API 封装
rg "<API名>" api/
# 3. 全局状态
rg "<关键词>" store/
# 4. 组件注册名或路径
rg "<组件名>" --glob "*.json"
rg "<组件名>" components/
# 5. 单组件反向索引(CLI)
node scripts/gen-component-page-index.mjs --component <组件名>
# 6. Tab 刷新全局变量
rg "wx\.\$dateListRefresh|wx\.\$orderListRefresh"
# 7. 生命周期入口(防重复请求)
rg "onShow|loadPageData|onRoute" <目标页面目录>
```
---
## 完整输出模板(8 段)
```markdown
## 需求影响面分析
### 需求摘要
(一句话复述需求)
### 涉及业务域
- [域名](docs/DOMAIN-INDEX.md#对应锚点) — 说明
### 必改文件
| 路径 | 原因 |
|------|------|
| `path/to/file.js` | … |
### 可能波及
| 类型 | 路径/范围 | 原因 |
|------|-----------|------|
| 共享组件 | `components/...` | … |
| API | `api/...` | … |
| 其他分包页面 | `packageEquity/...` | … |
### 已有专章
- [文档标题](相对路径) — 相关章节
### 建议检索命令
\`\`\`bash
rg "..." ...
\`\`\`
### 测试 / 回归
- [ ] 单测:`npm run test:...` 或 `node --test tests/...`
- [ ] 手动:页面路径 + 操作 + 预期
### 文档待补
- (若无专章覆盖,列出建议新增的 docs 条目)
### 改动自检(wechat-change-standards)
- [ ] JSDoc
- [ ] ES export(helper)
- [ ] 跨页影响已说明
- [ ] 测试已运行或列出手动项
```
---
## 示例:改园区店 ID 传参
### 需求摘要
接口请求需统一传 `yqMerchantId`,避免误用 4S 店 `merchantId`。
### 涉及业务域
- 横切:门店 ID 语义 — [YQ-MERCHANT-ID-USAGE.md](../../../docs/YQ-MERCHANT-ID-USAGE.md)
### 必改文件
(从专章表格提取匹配行,如 equityPage、OrderScreen、createDeafeatOrder 等)
### 可能波及
- `packageDynamicForm/utils/user-merchant.js` — 下拉 vs 保存语义不同
- `store/index.js` — `get4SStoreList` 参数
### 建议检索命令
```bash
rg "yqMerchantId|sellerMerchantId|shopMerchantId" --glob "!node_modules"
```
### 测试 / 回归
- [ ] 权益开单、报价筛选、员工列表各走一遍
- [ ] 动态表单保存接口 `merchantId` 仍为 4S 店(见 user-merchant 注释)
---
## 示例:改优惠券逻辑
### 需求摘要
选券后需清空商品并重新算价。
### 涉及业务域
- tabWorkOrder — [work-order-staff-coupon.mdc](../../rules/work-order-staff-coupon.mdc)
### 必改文件
| 路径 | 原因 |
|------|------|
| `tabWorkOrder/pages/createOrder/services/orderCouponEffects.js` | 礼券副作用编排 |
| `tabWorkOrder/pages/createOrder/createOrder.js` | confirm 后触发链 |
### 可能波及
- `docs/COMPONENT-PAGE-INDEX.md` 中 Coupon 相关引用页(若 UI 层改动)
### 建议检索命令
```bash
rg "orderCouponEffects|coupon" tabWorkOrder/
node scripts/gen-component-page-index.mjs --component Coupon
```
### 测试 / 回归
- [ ] `npm run test:createOrder`
- [ ] 手动:createOrder 选券 → 商品清空 → 重新选商品算价
# 做需求 — 简版参考
> **默认输出**:下方「简表模板」。用户说「详细分析」时改用 [reference-full.md](./reference-full.md)。
---
## 简表模板(对用户默认可见)
复制以下结构,作为回复开头(「只分析」模式到此结束;「做需求」「快改」随后改代码):
```markdown
## 影响面(简版)
- **模式**:做需求 | 快改 | 只分析
- **域**:xxx([DOMAIN-INDEX](../../../docs/DOMAIN-INDEX.md))
- **必改**:`path/to/file.js` — 原因;…
- **可能波及**:无 | `components/...` / `api/...` — 原因
- **回归**:`npm run test:...` + 1 条手动路径
→ 开始改代码
```
**输出规则**:
- 「可能波及」为无时写「无」,不展开表格
- 不默认输出 rg 命令、文档待补、自检四项(内部执行即可)
- 「只分析」模式省略最后一行「→ 开始改代码」
- **Plan 模式**:简表后接 CreatePlan,最后一行改为「→ 确认后切 Agent 实现」
- **Ask 模式**:简表 + 实现思路,最后一行改为「→ 切 Agent 模式执行」
---
## Agent 内部检索(用户默认不可见)
## Cursor 模式 × 口令(简表之后)
| 口令 | Agent | Plan | Ask |
|------|-------|------|-----|
| 做需求 | 简表 → 改代码 + 测试 | 简表 → CreatePlan | 简表 → 思路,提示切 Agent |
| 快改 | 简表 → 改代码 | 简表 → 简短计划 | 简表 → 改法说明 |
| 只分析 | 仅简表 | 仅简表 | 仅简表 |
### 模式判定(检索深度,与 Cursor 模式无关)
| 条件 | 走快改 | 走做需求(全量) |
|------|--------|------------------|
| 仅单页 `services/` 或单文件 | 是 | — |
| 涉及 `components/`、`api/`、`store/`、`utils/` | — | 是 |
| 门店 ID、`wx.$xxxRefresh`、菜单/registry | — | 是 |
| 跨分包页面 | — | 是 |
### 域 → 首选专章速查
| 需求涉及 | 先读 |
|----------|------|
| 园区店 / 4S 店 ID | `docs/YQ-MERCHANT-ID-USAGE.md` |
| 精品首页菜单 | `tabIndex/docs/MENU-ARCHITECTURE.md` |
| 权益首页 | `packageEquity/docs/MENU-ARCHITECTURE.md` |
| 开单 / 员工 / 礼券 | `.cursor/rules/work-order-staff-coupon.mdc` |
| 异常流水 / 锁单 | `docs/异常流水提醒和锁单机制-前端开发清单.md` |
| 动态表单日报 | `packageDynamicForm/docs/DYNAMIC-FORM-GUIDE.md` |
| 全局 Popup / 组件合并 | `docs/components-optimization/REGRESSION.md` |
| 组件引用面 | `docs/COMPONENT-PAGE-INDEX.md` |
### 检索命令模板
```bash
rg "<关键词>" --glob "!node_modules" --glob "!miniprogram_npm"
rg "<API名>" api/
rg "<关键词>" store/
rg "<组件名>" --glob "*.json"
node scripts/gen-component-page-index.mjs --component <组件名>
rg "wx\.\$dateListRefresh|wx\.\$orderListRefresh"
```
### 简表示例:优惠券
```markdown
## 影响面(简版)
- **模式**:做需求
- **域**:tabWorkOrder / 开单礼券
- **必改**:`orderCouponEffects.js`、`createOrder.js`
- **可能波及**:无
- **回归**:`npm run test:createOrder` + 手动选券后商品清空
→ 开始改代码
```
### 简表示例:园区店 ID
```markdown
## 影响面(简版)
- **模式**:只分析
- **域**:横切 / 门店 ID
- **必改**:见 `YQ-MERCHANT-ID-USAGE.md` 匹配行
- **可能波及**:`user-merchant.js`、`store/index.js`
- **回归**:权益开单 + 动态表单保存各走一遍
```
{"timestamp":"2026-07-13T03:21:27.969+0000","status":404,"error":"Not Found","message":"Not Found","path":"/rop-dj-car-boutique/v3/api-docs"}
\ No newline at end of file
{"timestamp":"2026-07-13T03:21:45.172+0000","status":404,"error":"Not Found","message":"Not Found","path":"/rop-dj-car-boutique/swagger-resources"}
\ No newline at end of file
This diff could not be displayed because it is too large.
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
.swagger-ui .topbar .download-url-wrapper{
display: none;
}
</style>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: window.location.href.replace(/swagger-ui\/v3\/index.html/, "swagger-rop/api-docs"),
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
</script>
</body>
</html>
{"timestamp":"2026-07-13T03:21:44.945+0000","status":404,"error":"Not Found","message":"Not Found","path":"/rop-dj-car-boutique/v2/api-docs"}
\ No newline at end of file
/**
* @file 异常流水 API 纯函数:枚举与提交参数规范化(无 request 依赖,供单测与 api 层复用)
*/
/**
* 异常类型(Swagger AbnormalFlowType)
* @readonly
*/
export const ABNORMAL_FLOW_TYPE = {
PAID_NOT_RECORDED: 1,
MULTI_FLOW_ONE_ORDER: 2,
ONE_FLOW_MULTI_ORDER: 3,
PUBLIC_PAYMENT: 4,
MIXED_PAYMENT: 5,
AMOUNT_MISMATCH: 6,
OTHER: 7
}
/**
* 异常类型展示文案(Swagger 枚举描述)
* @type {Record<number, string>}
*/
export const ABNORMAL_FLOW_TYPE_LABEL = {
1: '已付款未录单',
2: '多流水对应一单',
3: '一流水对应多单',
4: '对公收款',
5: '混合支付',
6: '金额不一致',
7: '其他异常'
}
/**
* 审批状态(Swagger AbnormalFlowApprovalStatus)
* @readonly
*/
export const ABNORMAL_FLOW_APPROVAL_STATUS = {
RM_PENDING: 1,
RM_REJECTED: 2,
BG_PENDING: 3,
BG_REJECTED: 4,
APPROVED: 5
}
/**
* 流水报备标记(响应字段 declarationFlag)
* @readonly
*/
export const DECLARATION_FLAG = {
NOT_DECLARED: 0,
DECLARED: 1
}
/**
* 提交报备前规范化入参(voucherImageUrls 数组 → qs indices 序列化)
* @param {Object} data
* @param {string} data.outTradeNo 支付订单号
* @param {number|string} data.abnormalType
* @param {string} data.remark
* @param {string[]} [data.voucherImageUrls]
* @returns {Object}
*/
export function buildDeclarationSubmitParams(data = {}) {
const params = {
outTradeNo: data.outTradeNo,
abnormalType: data.abnormalType,
remark: data.remark
}
const urls = Array.isArray(data.voucherImageUrls)
? data.voucherImageUrls.filter(Boolean)
: []
if (urls.length) {
params.voucherImageUrls = urls
}
return params
}
/**
* @file 异常流水报备 / 合并待补录 — ROP API 封装(Swagger: rop-dj-car-boutique/swagger-rop/api-docs)
* 仅请求层,不调 setData;sessionId 由 request 自动注入。
*
* 临时 Mock:`ABNORMAL_FLOW_API_USE_MOCK === true` 时不打真实接口;联调/上线保持 false。
*/
import api from '~/utils/request/request.js'
import {
buildDeclarationSubmitParams
} from './abnormalFlowDeclaration.helpers.js'
import {
getMockCount,
getMockShopLock,
getMockUnionPage,
getMockDeclarationPage,
getMockDetail,
submitMock
} from './abnormalFlowDeclaration.mock.js'
export {
ABNORMAL_FLOW_TYPE,
ABNORMAL_FLOW_TYPE_LABEL,
ABNORMAL_FLOW_APPROVAL_STATUS,
DECLARATION_FLAG,
buildDeclarationSubmitParams
} from './abnormalFlowDeclaration.helpers.js'
/**
* 联调/上线为 false;本地无后端数据时可临时改 true 走 Mock
* @type {boolean}
*/
export const ABNORMAL_FLOW_API_USE_MOCK = false
/**
* 仅 checkShopLock 走 Mock(其它接口仍按 ABNORMAL_FLOW_API_USE_MOCK)
* @type {boolean}
*/
export const ABNORMAL_FLOW_CHECK_SHOP_LOCK_USE_MOCK = false
/**
* @typedef {1|2|3|4|5|6|7} AbnormalFlowTypeValue
*/
/**
* @typedef {1|2|3|4|5} AbnormalFlowApprovalStatusValue
*/
/**
* @typedef {Object} RopResponse
* @property {string|number} code 0 成功
* @property {string} [errId]
* @property {string} [message]
* @property {*} [data]
*/
/**
* @param {*} data
* @returns {Promise<RopResponse>}
*/
function mockOk(data) {
return Promise.resolve({ code: 0, message: '成功', data })
}
/**
* 异常流水统计次数(无业务入参,sessionId 自动注入)
* @param {Object} [data]
* @returns {Promise<RopResponse>}
*/
export function waitInputOrderUnionCount(data = {}) {
if (ABNORMAL_FLOW_API_USE_MOCK) {
return mockOk(getMockCount())
}
return api.post('dj.api.smartcarlife.weapp.waitinputorder.union.count', data)
}
/**
* 查询门店锁单限制
* @param {{ merchantId: number|string }} data 4S 店 merchantId
* @returns {Promise<RopResponse>}
*/
export function checkAbnormalFlowShopLock(data) {
if (ABNORMAL_FLOW_API_USE_MOCK || ABNORMAL_FLOW_CHECK_SHOP_LOCK_USE_MOCK) {
return mockOk(getMockShopLock())
}
return api.post(
'dj.api.smartcarlife.abnormalFlowDeclaration.checkShopLock',
data
)
}
/**
* 分页查询合并的待补录订单
* @param {Object} data
* @param {number} data.currentPage
* @param {number} data.pageSize
* @param {0|1} [data.declarationFlag] 流水是否报备(0 未报备 / 1 已报备)
* @returns {Promise<RopResponse>}
*/
export function waitInputOrderUnionPage(data) {
if (ABNORMAL_FLOW_API_USE_MOCK) {
return mockOk(getMockUnionPage(data))
}
return api.post('dj.api.smartcarlife.weapp.waitinputorder.union.page', data)
}
/**
* 分页查询异常流水报备列表
* @param {Object} data
* @returns {Promise<RopResponse>}
*/
export function abnormalFlowDeclarationPage(data) {
if (ABNORMAL_FLOW_API_USE_MOCK) {
return mockOk(getMockDeclarationPage(data))
}
return api.post('dj.api.smartcarlife.abnormalFlowDeclaration.page', data)
}
/**
* 提交流水报备信息
* @param {Object} data
* @returns {Promise<RopResponse>}
*/
export function abnormalFlowDeclarationSubmit(data) {
const params = buildDeclarationSubmitParams(data)
if (ABNORMAL_FLOW_API_USE_MOCK) {
return mockOk(submitMock(params))
}
return api.post(
'dj.api.smartcarlife.abnormalFlowDeclaration.submit',
params
)
}
/**
* 查询异常流水报备详情
* @param {{ id: number|string }} data
* @returns {Promise<RopResponse>}
*/
export function abnormalFlowDeclarationDetail(data) {
if (ABNORMAL_FLOW_API_USE_MOCK) {
const detail = getMockDetail(data)
if (!detail) {
return Promise.resolve({
code: 1,
message: '详情不存在',
data: null
})
}
return mockOk(detail)
}
return api.post('dj.api.smartcarlife.abnormalFlowDeclaration.detail', data)
}
/**
* @file 异常流水 API 临时 Mock(无真实后端数据时联调 UI)
* 会话内提交会从待报备挪到已报备,刷新 count/page/detail 一致。
*/
/** 改为 true 可 Mock 锁单拦截(测新建工单) */
export const MOCK_SHOP_LOCK = true
const SEED_PENDING = [
{
outTradeNo: 'MOCK_PAY_001',
tradeNo: '9891058176244388208640',
totalFee: 152052,
accountDate: '2020-06-12 15:12:52',
payType: 1,
shopMerchantName: '银基&嘀加智慧云',
yqMerchantName: '嘀加智慧云园区店',
declarationFlag: 0,
inputStatus: 0
},
{
outTradeNo: 'MOCK_PAY_002',
tradeNo: '8891058176244388208641',
totalFee: 280000,
accountDate: '2020-06-13 10:20:30',
payType: 1,
shopMerchantName: '银基&嘀加智慧云',
yqMerchantName: '嘀加智慧云园区店',
declarationFlag: 0,
inputStatus: 0
},
{
outTradeNo: 'MOCK_PAY_003',
tradeNo: '7891058176244388208642',
totalFee: 99900,
accountDate: '2020-06-14 09:05:18',
payType: 3,
shopMerchantName: '银基&嘀加智慧云',
yqMerchantName: '嘀加智慧云园区店',
declarationFlag: 0,
inputStatus: 0
},
{
outTradeNo: 'MOCK_PAY_004',
tradeNo: '6891058176244388208643',
totalFee: 368088,
accountDate: '2020-06-15 16:45:00',
payType: 4,
shopMerchantName: '银基&嘀加智慧云',
yqMerchantName: '嘀加智慧云园区店',
declarationFlag: 0,
inputStatus: 0
}
]
const SEED_REPORTED = [
{
id: 1001,
tradeNo: '2561058176244388208640',
abnormalType: 1,
submitterName: '陈小星',
totalPrice: 1520.52,
accountDate: '2020-06-11 11:30:00',
merchantName: '银基&嘀加智慧云',
approvalStatus: 1,
outTradeNo: 'MOCK_PAY_R01'
},
{
id: 1002,
tradeNo: '3561058176244388208641',
abnormalType: 2,
submitterName: '陈小星',
totalPrice: 800,
accountDate: '2020-06-10 08:15:22',
merchantName: '银基&嘀加智慧云',
approvalStatus: 2,
outTradeNo: 'MOCK_PAY_R02'
},
{
id: 1003,
tradeNo: '4561058176244388208642',
abnormalType: 3,
submitterName: '陈小星',
totalPrice: 1200,
accountDate: '2020-06-09 14:22:11',
merchantName: '银基&嘀加智慧云',
approvalStatus: 3,
outTradeNo: 'MOCK_PAY_R03'
},
{
id: 1004,
tradeNo: '5561058176244388208643',
abnormalType: 4,
submitterName: '陈小星',
totalPrice: 500,
accountDate: '2020-06-08 17:00:00',
merchantName: '银基&嘀加智慧云',
approvalStatus: 4,
outTradeNo: 'MOCK_PAY_R04'
},
{
id: 1005,
tradeNo: '6561058176244388208644',
abnormalType: 6,
submitterName: '陈小星',
totalPrice: 2100,
accountDate: '2020-06-07 12:12:12',
merchantName: '银基&嘀加智慧云',
approvalStatus: 5,
outTradeNo: 'MOCK_PAY_R05'
}
]
/** @type {typeof SEED_PENDING} */
let mockPending = clone(SEED_PENDING)
/** @type {typeof SEED_REPORTED} */
let mockReported = clone(SEED_REPORTED)
/** 详情补充信息:declarationId → detail payload */
const mockDetailExtra = {}
function clone(list) {
return list.map(item => ({ ...item }))
}
function formatNow() {
const d = new Date()
const pad = n => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(
d.getHours()
)}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
function paginate(list, currentPage = 1, pageSize = 10) {
const page = Math.max(1, Number(currentPage) || 1)
const size = Math.max(1, Number(pageSize) || 10)
const total = list.length
const pages = Math.max(1, Math.ceil(total / size) || 1)
const start = (page - 1) * size
return {
pageNum: page,
pageSize: size,
total,
pages,
list: list.slice(start, start + size)
}
}
/**
* Mock:union.count
* @returns {{ totalCount: number, notDeclaredCount: number, declaredCount: number }}
*/
export function getMockCount() {
const notDeclaredCount = mockPending.length
const declaredCount = mockReported.length
return {
totalCount: notDeclaredCount + declaredCount,
notDeclaredCount,
declaredCount
}
}
/**
* Mock:checkShopLock(true = 锁单生效)
* @returns {boolean}
*/
export function getMockShopLock() {
return true
}
/**
* Mock:union.page
* @param {Object} [params]
* @returns {Object} RpcPagination
*/
export function getMockUnionPage(params = {}) {
let list = mockPending
if (params.declarationFlag == 1) {
list = mockReported.map(item => ({
outTradeNo: item.outTradeNo || `MOCK_PAY_${item.id}`,
tradeNo: item.tradeNo,
totalFee: Math.round(Number(item.totalPrice) * 100),
accountDate: item.accountDate,
shopMerchantName: item.merchantName,
declarationFlag: 1
}))
}
return paginate(list, params.currentPage, params.pageSize)
}
/**
* Mock:declaration.page
* @param {Object} [params]
* @returns {Object} RpcPagination
*/
export function getMockDeclarationPage(params = {}) {
let list = [...mockReported]
if (params.approvalStatus != null && params.approvalStatus !== '') {
list = list.filter(
item => String(item.approvalStatus) === String(params.approvalStatus)
)
}
return paginate(list, params.currentPage, params.pageSize)
}
/**
* Mock:submit,并从待报备移到已报备
* @param {Object} data
* @returns {{ declarationId: number }}
*/
export function submitMock(data = {}) {
const outTradeNo = data.outTradeNo
const pendingIndex = mockPending.findIndex(
item => item.outTradeNo === outTradeNo
)
const pending =
pendingIndex >= 0 ? mockPending[pendingIndex] : null
if (pendingIndex >= 0) {
mockPending.splice(pendingIndex, 1)
}
const declarationId = Number(String(Date.now()).slice(-8))
const reportTime = formatNow()
const totalPrice = pending
? Number(pending.totalFee) / 100
: 0
const reported = {
id: declarationId,
tradeNo: pending?.tradeNo || outTradeNo || '',
abnormalType: data.abnormalType,
submitterName: '陈小星',
totalPrice,
accountDate: pending?.accountDate || reportTime,
merchantName: pending?.shopMerchantName || '银基&嘀加智慧云',
approvalStatus: 1,
outTradeNo: outTradeNo || pending?.outTradeNo || ''
}
mockReported.unshift(reported)
mockDetailExtra[declarationId] = {
remark: data.remark || '',
voucherImageUrls: Array.isArray(data.voucherImageUrls)
? data.voucherImageUrls
: [],
reportTime,
abnormalType: data.abnormalType
}
return { declarationId }
}
/**
* Mock:detail
* @param {{ id: number|string }} data
* @returns {Object|null}
*/
export function getMockDetail(data = {}) {
const id = Number(data.id)
const reported = mockReported.find(item => Number(item.id) === id)
if (!reported) return null
const extra = mockDetailExtra[id] || {}
const reportTime = extra.reportTime || reported.accountDate
return {
tradeInfo: {
tradeNo: reported.tradeNo,
totalPrice: reported.totalPrice,
notRefundedTotalPrice: reported.totalPrice,
payDate: reported.accountDate,
payChannel: '微信支付',
payType: 1,
merchantName: reported.merchantName,
yqMerchantName: '嘀加智慧云园区店',
declarationId: reported.id,
declarationApprovalStatus: reported.approvalStatus
},
declarationInfo: {
abnormalType: extra.abnormalType || reported.abnormalType,
remark:
extra.remark ||
'客户通过微信线上支付,信息生成系统订单未成功',
createdBy: reported.submitterName || '陈小星',
createdDate: reportTime,
delayDeadline:
extra.delayDeadline ||
(Number(reported.approvalStatus) === 5 ? '2020-06-14 18:00:00' : ''),
voucherImageUrls: extra.voucherImageUrls?.length
? extra.voucherImageUrls
: [
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/refund/refund-rule.png'
]
},
approvalLogs: buildApprovalLogs(reported.approvalStatus, reportTime)
}
}
/**
* @param {number|string} approvalStatus
* @param {string} reportTime
* @returns {Array}
*/
function buildApprovalLogs(approvalStatus, reportTime) {
const status = Number(approvalStatus)
const logs = []
if (status === 1) {
logs.push({
approvalStatus: 1,
operatorName: '何穗',
createdDate: reportTime,
remark: '',
approvalSource: 0
})
logs.push({
approvalStatus: 3,
operatorName: '',
createdDate: '',
remark: '',
approvalSource: 1
})
return logs
}
if (status === 2) {
logs.push({
approvalStatus: 2,
operatorName: '何穗',
createdDate: reportTime,
remark: '资料不齐全,请补充后重提',
approvalSource: 0
})
return logs
}
if (status === 3) {
logs.push({
approvalStatus: 3,
operatorName: '何穗',
createdDate: reportTime,
remark: '客户情况属实,建议尽快处理',
approvalSource: 0
})
logs.push({
approvalStatus: 3,
operatorName: '',
createdDate: '',
remark: '',
approvalSource: 1
})
return logs
}
if (status === 4) {
logs.push({
approvalStatus: 3,
operatorName: '何穗',
createdDate: reportTime,
remark: '同意',
approvalSource: 0
})
logs.push({
approvalStatus: 4,
operatorName: '总部运营',
createdDate: reportTime,
remark: '金额不符,驳回',
approvalSource: 1
})
return logs
}
// 5 通过
logs.push({
approvalStatus: 3,
operatorName: '何穗',
createdDate: reportTime,
remark: '同意',
approvalSource: 0
})
logs.push({
approvalStatus: 5,
operatorName: '总部运营',
createdDate: reportTime,
remark: '审批通过',
approvalSource: 1
})
return logs
}
/** 单测 / 调试复位 */
export function resetAbnormalFlowMockStore() {
mockPending = clone(SEED_PENDING)
mockReported = clone(SEED_REPORTED)
Object.keys(mockDetailExtra).forEach(key => {
delete mockDetailExtra[key]
})
}
......@@ -133,6 +133,9 @@
"pages/invoiceResult/invoiceResult",
"pages/technicianSearchList/pages/index/technicianSearchList",
"pages/refundOperationList/refundOperationList",
"pages/abnormalFlowList/abnormalFlowList",
"pages/abnormalFlowReport/abnormalFlowReport",
"pages/abnormalFlowReportDetail/abnormalFlowReportDetail",
"pages/refundDetailList/refundDetailList",
"pages/refundApply/refundApply",
"pages/createAConstructionOrder/createAConstructionOrder",
......@@ -291,6 +294,7 @@
"tab-bar": "/components/TabBar/TabBar",
"modal": "components/modal/modal",
"tips-bottom": "components/tipsBottom/index",
"abnormal-flow-tips": "components/abnormalFlowTips/index",
"gl-image": "components/GlImage/index",
"van-field": "@vant/weapp/field/index",
"van-radio-group": "@vant/weapp/radio-group/index",
......
......@@ -20,8 +20,8 @@
<text class="goods-name-text text-hide">{{filter.replaceItemText(i.goods.goodsAlias) ||filter.replaceItemText(i.goods.upgradeGoodsName) || filter.replaceItemText(i.goods.goodsInfo.goodsName)}}</text>
<image wx:if="{{ filter.isMarketingActive(i) }}" class="marketing-icon" src="/tabWorkOrder/images/activeIcon.png" mode="aspectFit" />
</view>
<text wx:if="{{ i.goods.merchantGoodsPosition && (i.goods.goodsInfo.goodsType == 1 || i.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType) }}">{{'「' + i.goods.positionStr+'」'}}</text>
<text class="warning_text" wx:if="{{ !i.goods.merchantGoodsPosition && (i.goods.goodsInfo.goodsType == 1 || i.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType) }}">无部位</text>
<text wx:if="{{ i.goods.merchantGoodsPosition || i.goods.upgradeGoodsPosition }}">{{'「' + i.goods.positionStr+'」'}}</text>
<text class="warning_text" wx:if="{{ !i.goods.merchantGoodsPosition && !i.goods.upgradeGoodsPosition && (i.goods.goodsInfo.goodsType == 1 || i.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType) }}">无部位</text>
</view>
<view class="last" wx:if="{{ !i.active }}">
<text class="price">¥{{i.goods.price}}</text>
......
......@@ -8,14 +8,8 @@ Component({
activeIndex: {
type: Number,
observer: function (n) {
console.log(this.data.tabIndex, 'activeIndex', n);
console.log(this.data.tabIndex != n);
if (this.data.tabIndex != n) {
this.setData({
tabIndex: this.data.activeIndex
})
this.setTab(this.data.tabIndex)
this.setTab(n, { suppressClick: true })
}
}
},
......@@ -63,9 +57,17 @@ Component({
tabIndex,
} = this.data
wx.$util.getViewInfo(`#tab-${tabIndex}`, old => {
if (!old) {
wx.$util.getViewInfo(`#tab-${index}`, res => {
if (!res) return
this.applyTabIndicator(index, res, suppressClick)
}, this)
return
}
let oldLeft = old.left
let oldWidth = old.width
wx.$util.getViewInfo(`#tab-${index}`, res => {
if (!res) return
let {
left,
width
......@@ -77,19 +79,28 @@ Component({
activeStyle: `width: var(--fontSize64);background-color:#347BFF;border-radius:3rpx;left:${readyLeft + readyWidth / 2}px;transition: all .1s;`
})
}
setTimeout(() => {
this.setData({
activeStyle: `width: var(--fontSize64);left:${left + (width - 32) / 2}px;background-color:#347BFF;`,
tabIndex: index,
to: `to-${index}`,
width
})
if (!suppressClick) {
this.triggerEvent('click', index)
}
}, 100)
this.applyTabIndicator(index, res, suppressClick)
}, this)
}, this)
},
/**
* @param {number} index
* @param {{ left: number, width: number }} res
* @param {boolean} suppressClick
*/
applyTabIndicator(index, res, suppressClick) {
const { left, width } = res
setTimeout(() => {
this.setData({
activeStyle: `width: var(--fontSize64);left:${left + (width - 32) / 2}px;background-color:#347BFF;`,
tabIndex: index,
to: `to-${index}`,
width
})
if (!suppressClick) {
this.triggerEvent('click', index)
}
}, 100)
}
}
})
\ No newline at end of file
......@@ -193,6 +193,7 @@ Component({
api.logout().then(_res_ => {
let { code, message } = _res_
if (code == 0) {
wx.$storage.remove('abnormalFlowPop')
app.login(false)
} else {
_this.setData({
......
// components/abnormalFlowTips/index.js
import { CLOSE_ICON_URL } from '../../utils/imageBase.js'
Component({
options: {
addGlobalClass: true,
styleIsolation: 'apply-shared'
},
externalClasses: ['custom-class'],
properties: {
show: {
type: Boolean,
value: false
},
count: {
type: Number,
value: 0
},
tipsText: {
type: String,
value: ''
}
},
data: {
IMG_URL:
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/',
closeIconUrl: CLOSE_ICON_URL
},
methods: {
onClose() {
this.triggerEvent('close')
},
onAction() {
this.triggerEvent('action')
}
}
})
{
"component": true,
"usingComponents": {}
}
<view class="abnormal-flow-tips custom-class" wx:if="{{ show }}">
<image class="tips-icon" src="{{ IMG_URL }}miniProgram/tips_icon.png" mode="aspectFit" />
<view class="content-text">{{ tipsText }}</view>
<view class="action-btn" catchtap="onAction">去处理</view>
<image
class="close-icon"
catchtap="onClose"
src="{{ closeIconUrl }}"
mode="aspectFit"
/>
</view>
.abnormal-flow-tips {
box-sizing: border-box;
display: flex;
align-items: center;
width: 100%;
padding: var(--fontSize16) var(--fontSize20);
font-size: var(--fontSize24);
font-weight: 500;
color: #f57c00;
background: #fff7ed;
border-radius: var(--fontSize12) var(--fontSize12) 0 0;
}
.tips-icon {
width: var(--fontSize28);
height: var(--fontSize28);
margin-right: var(--fontSize8);
flex-shrink: 0;
}
.content-text {
flex: 1;
line-height: var(--fontSize32);
margin-right: var(--fontSize12);
word-break: break-all;
}
.action-btn {
flex-shrink: 0;
padding: var(--fontSize6) var(--fontSize20);
margin-right: var(--fontSize12);
font-size: var(--fontSize24);
color: #347bff;
background: #ffffff;
border-radius: var(--fontSize28);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.close-icon {
width: var(--fontSize28);
height: var(--fontSize28);
flex-shrink: 0;
opacity: 0.6;
}
// components/orderPromptPop/orderPromptPop.js
const FULL_PAY_TYPE_LIST = [
{
label: '收款方为门店收款',
value: '3'
},
{
label: '收款方为嘀加且属于对公转账收款',
value: '4'
},
{
label: '收款方为嘀加二维码收款',
value: '5',
tips: '适用于已有交易收款流水需补录订单时'
},
{
label: '特殊收款',
value: '6',
tips: '仅用于无法关联流水或混合支付场景,请谨慎选择。'
}
]
const DJ_QR_ONLY_PAY_TYPE_LIST = FULL_PAY_TYPE_LIST.filter(item => item.value === '5')
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean
type: Boolean,
observer(n) {
if (n) {
this.applyDjQrOnlyPresentation(this.properties.djQrOnlyMode)
}
}
},
/** 异常流水锁单态:仅允许嘀加二维码收款 */
djQrOnlyMode: {
type: Boolean,
value: false,
observer(n) {
if (this.data.show) {
this.applyDjQrOnlyPresentation(n)
}
}
},
popupSlotStyle: {
type: String,
......@@ -23,6 +61,7 @@ Component({
type: Object,
value: {},
observer: function (v) {
if (this.properties.djQrOnlyMode) return
// 是否是扫码核销或再次下单,是的话不显示补录入口
if (Object.keys(v)?.length) {
let { payTypeList } = this.data
......@@ -47,33 +86,36 @@ Component({
*/
data: {
infoData: {},
payTypeList: [
{
label: '收款方为门店收款',
value: '3'
},
{
label: '收款方为嘀加且属于对公转账收款',
value: '4'
},
{
label: '收款方为嘀加二维码收款',
value: '5',
tips: '适用于已有交易收款流水需补录订单时'
},
{
label: '特殊收款',
value: '6',
tips: '仅用于无法关联流水或混合支付场景,请谨慎选择。'
}
]
payTypeList: FULL_PAY_TYPE_LIST.map(item => ({ ...item }))
},
/**
* 组件的方法列表
*/
methods: {
/**
* 锁单态仅展示嘀加二维码,并预选已支付 + 嘀加二维码
* @param {boolean} djQrOnlyMode
*/
applyDjQrOnlyPresentation(djQrOnlyMode) {
if (djQrOnlyMode) {
this.setData({
payTypeList: DJ_QR_ONLY_PAY_TYPE_LIST.map(item => ({ ...item })),
includesChildHeight: 'var(--fontSize870)',
infoData: { payFlag: '2', payType: '5' }
})
return
}
this.setData({
payTypeList: FULL_PAY_TYPE_LIST.map(item => ({ ...item })),
includesChildHeight: 'var(--fontSize1020)',
infoData: {}
})
},
chooseParent(e) {
if (this.properties.djQrOnlyMode) {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
let { type } = e.currentTarget.dataset
this.setData({
'infoData.payFlag': type
......@@ -81,6 +123,9 @@ Component({
},
chooseChild(e) {
let { type } = e.currentTarget.dataset
if (this.properties.djQrOnlyMode && String(type) !== '5') {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
this.setData({
'infoData.payType': type
})
......@@ -90,6 +135,10 @@ Component({
},
confirm() {
let { infoData } = this.data
const { djQrOnlyMode } = this.properties
if (djQrOnlyMode && String(infoData.payType) !== '5') {
return wx.$util.showToast('存在异常流水未处理,请选择嘀加二维码收款')
}
if (!infoData.payFlag || (infoData.payFlag == 2 && !infoData.payType)) {
return wx.$util.showToast('请选择订单收款方式')
}
......
......@@ -4,7 +4,7 @@
<view>确认订单收款方式</view>
</view>
<view class="prompt_content">
<view class="select_item">
<view class="select_item" wx:if="{{ !djQrOnlyMode }}">
<block wx:if="{{infoData.payFlag == 1}}">
<image class="radio-icon" src="/components/images/radio.png" />
</block>
......
......@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
* 4预发布
* 5cdptest
*/
let index = 1;
let index = 2;
const accountInfo = wx.getAccountInfoSync();
const systemInfo = getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion;
......
# 业务域总索引 — 需求开发第一站
> **用途**:接需求时先定业务域、查专章、再 rg 检索,减少全库盲搜与漏改。
> **维护**:做完需求若发现漏改点,在对应域补一行(5 分钟原则)。
> **关联**:[文档专题列表](./README.md) · [组件反向索引](./COMPONENT-PAGE-INDEX.md) · [改动规范](../.cursor/rules/wechat-change-standards.mdc)
---
## 使用说明
在 Cursor **任意模式**(Agent / Plan / Ask)中均可使用同一套口令:
| 口令 | Agent | Plan | Ask |
|------|-------|------|-----|
| **`做需求:<描述>`** | 简表 + 实现 + 测试 | 简表 + **实施计划** | 简表 + 实现思路 |
| **`快改:<描述>`** | 简表 + 小改 | 简表 + 简短计划 | 简表 + 改法说明 |
| **`只分析:<描述>`** | 仅简表 | 仅简表 | 仅简表 |
Plan / Ask 下不会改代码;Plan 确认后切 Agent 说「按上述计划实现」即可。
说「详细分析」可展开完整 8 段报告(见 [Skill reference-full](../.cursor/skills/requirement-impact-analysis/reference-full.md))。
---
## 业务域地图
```mermaid
flowchart TB
subgraph tabs [Tab首页]
tabIndex["tabIndex 精品首页"]
packageEquity["packageEquity 权益首页"]
end
subgraph orders [工单订单]
tabWorkOrder["tabWorkOrder 客户工单"]
tabRepairOrder["tabRepairOrder 施工单"]
tabDate["tabDate 预约管理"]
end
subgraph forms [表单学习]
packageDynamicForm["packageDynamicForm 动态表单"]
packageStudyCenter["packageStudyCenter 学习中心"]
end
subgraph cross [横切层]
components["components 全局组件"]
apiStore["api / store / utils"]
end
tabIndex --> tabWorkOrder
packageEquity --> packageDynamicForm
tabWorkOrder --> components
packageEquity --> components
tabIndex --> apiStore
```
---
## 域索引
### 精品首页 `tabIndex`
| 项 | 内容 |
|----|------|
| 关键路径 | `tabIndex/pages/index/`、`tabIndex/menu/`、`tabIndex/services/` |
| 影响面文档 | [HOMEPAGE-INDEX](../tabIndex/docs/HOMEPAGE-INDEX.md) · [MENU-ARCHITECTURE](../tabIndex/docs/MENU-ARCHITECTURE.md) · [ADD-MENU-GUIDE](../tabIndex/docs/ADD-MENU-GUIDE.md) · [TODO-SERVICE](../tabIndex/docs/TODO-SERVICE.md) · [服务中心公告](./SERVICE-CENTER-NOTICE-POPUP.md) |
| 改前检索关键词 | `rebuildMenus`、`createMenuJumpHandler`、`checkServiceNotice`、`runDailyChecks`、`wx.$dateListRefresh` |
| 文档缺口 | — |
### 权益 `packageEquity`
| 项 | 内容 |
|----|------|
| 关键路径 | `packageEquity/pages/`、`packageEquity/menu/`、`packageEquity/components/` |
| 影响面文档 | [权益首页职责地图](../packageEquity/docs/HOMEPAGE-INDEX.md) · [**权益报价开单专章**](./packageEquity/createOrderCarQuotation.md) · [下单总览](./order-creation/README.md) · [权益 Menu 架构](../packageEquity/docs/MENU-ARCHITECTURE.md) · [ADD-MENU-GUIDE-EQUITY](../packageEquity/docs/ADD-MENU-GUIDE-EQUITY.md) · [Tab 刷新变更](../packageEquity/docs/TAB-REFRESH-CHANGELOG.md) · [园区店 ID 全量](./YQ-MERCHANT-ID-USAGE.md) · [sceneType:0 专章](./EQUITY-SCENE0-YQ-MERCHANT-ID.md) · [分包分析](./packageEquity/SUBPACKAGE-ANALYSIS.md) · [P1 迁移 Checklist](./packageEquity/P1-SPLIT-MIGRATION-CHECKLIST.md) · [路由别名](./packageEquity/ROUTE-ALIAS-COMPAT-DESIGN.md) |
| 改前检索关键词 | `sceneType:0`、`yqMerchantId`、`getYqStoreConfig`、`equityPage`、`OrderNoPopup` |
| 文档缺口 | — |
### 客户工单 `tabWorkOrder`
| 项 | 内容 |
|----|------|
| 关键路径 | `tabWorkOrder/pages/createOrder/`(开单 ~3000 行)、`tabWorkOrder/pages/orderDetail/`、`tabWorkOrder/pages/abnormalFlowReport/` |
| 影响面文档 | [异常流水/锁单开发清单](./异常流水提醒和锁单机制-前端开发清单.md) · [**createOrder 开单专章**](./tabWorkOrder/createOrder.md) · [下单总览](./order-creation/README.md) · [createOrder 员工/礼券 rule](../.cursor/rules/work-order-staff-coupon.mdc) · [组件回归](./components-optimization/REGRESSION.md)(补录流水等) |
| 改前检索关键词 | `createOrder`、`orderCouponEffects`、`merchantStaffSelection`、`abnormalFlowTips`、`wx.$orderListRefresh`、`sceneType:1` |
| 文档缺口 | —(开单专章见 [createOrder.md](./tabWorkOrder/createOrder.md)) |
### 动态表单 `packageDynamicForm`
| 项 | 内容 |
|----|------|
| 关键路径 | `packageDynamicForm/pages/`、`packageDynamicForm/components/form-engine/` |
| 影响面文档 | [分包文档索引](../packageDynamicForm/docs/README.md) · [ARCHITECTURE](../packageDynamicForm/docs/ARCHITECTURE.md) · [DYNAMIC-FORM-GUIDE](../packageDynamicForm/docs/DYNAMIC-FORM-GUIDE.md) · [PAGES](../packageDynamicForm/docs/PAGES.md) · [MAINTENANCE](../packageDynamicForm/docs/MAINTENANCE.md) · [Schema 设计](../packageDynamicForm/docs/动态表单Schema设计.md) · [API 契约](../packageDynamicForm/docs/动态表单API接口契约.md) · [路由与菜单](../packageDynamicForm/docs/routes-and-menus.md) |
| 改前检索关键词 | `staffDailyReport`、`storeDailyReport`、`negotiationDetail`、`form-engine`、`jsonContent`、`user-merchant` |
| 文档缺口 | — |
### 全局组件 `components`
| 项 | 内容 |
|----|------|
| 关键路径 | `components/`(`app.json` 全局注册 16+ 项) |
| 影响面文档 | [组件治理规划](./components-optimization/README.md) · [CHANGELOG](./components-optimization/CHANGELOG.md) · [COMPATIBILITY](./components-optimization/COMPATIBILITY.md) · [REGRESSION](./components-optimization/REGRESSION.md) · [**组件反向索引**](./COMPONENT-PAGE-INDEX.md) |
| 改前检索关键词 | `usingComponents`、`Merchant-Seles`、`Coupon`、`Popup`、`CalendarMonth`、`OrderNoPopup` |
| 文档缺口 | 改全局组件前必查 [COMPONENT-PAGE-INDEX](./COMPONENT-PAGE-INDEX.md) |
### 施工单 / 预约 / 其他分包
| 域 | 关键路径 | 影响面文档 | 改前检索关键词 |
|----|----------|------------|----------------|
| `tabRepairOrder` | `tabRepairOrder/pages/` | — | 施工确认、完工、出库 |
| `tabDate` | `tabDate/pages/` | — | 预约详情、审批 |
| `tabMine` | `tabMine/pages/` | — | 技师设置、领券 |
| `tabOperating` | `tabOperating/pages/` | — | 运营看板 |
| `packageCrowdFunding` | `packageCrowdFunding/pages/` | — | 众筹活动 |
| `subvehicleConversion` | `subvehicleConversion/pages/` | — | 转车、补单 |
| `packageUsedCar` | `packageUsedCar/pages/` | — | 二手车评估 |
| `packageStudyCenter` | `packageStudyCenter/pages/` | — | 学习中心 |
| `integration` | `integration/pages/` | — | 积分、银行账户 |
### 横切:门店 ID 语义
| 项 | 内容 |
|----|------|
| 说明 | `merchantId` / `yqMerchantId` / `shopMerchantId` 混用是常见漏改源 |
| 影响面文档 | [**YQ-MERCHANT-ID-USAGE**](./YQ-MERCHANT-ID-USAGE.md)(功能×页面×API 矩阵范本) · [EQUITY-SCENE0 专章](./EQUITY-SCENE0-YQ-MERCHANT-ID.md) · [`user-merchant.js`](../packageDynamicForm/utils/user-merchant.js) |
| 改前检索关键词 | `yqMerchantId`、`sellerMerchantId`、`shopMerchantId`、`RecMerchantNo` |
### 横切:静态资源 / 编译
| 项 | 内容 |
|----|------|
| 影响面文档 | [CDN 图片迁移](./CDN-IMAGE-MIGRATION.md) · [WXS 上传修复](./WXS-UPLOAD-FIX.md) |
| 改前检索关键词 | `img02.glsx.com.cn`、`/components/images/`、`.wxs` 绝对路径 |
---
## 横切关注点速查
改以下共享点时,**必须全库检索**,不能只看当前页:
| 关注点 | 检索方式 | 说明 |
|--------|----------|------|
| 全局组件 | `rg` 组件名 / [COMPONENT-PAGE-INDEX](./COMPONENT-PAGE-INDEX.md) | `Merchant-Seles` 仍被多页引用;`createOrder` 已迁 `merchant-staff-picker` |
| `api/**` | `rg` 函数名 / `dj.api.` | 多分包共用 |
| `store/**` | `rg` action / getter 名 | 登录态、4S 店列表等 |
| Tab 列表刷新 | `wx.$dateListRefresh`、`wx.$orderListRefresh` | 仅在目标页 `onShow` 消费(见 `utils/util.js`) |
| 生命周期 | `onShow` vs `onLoad` vs `onRoute` | 列表 API 仅 `onShow` → `loadPageData` |
| 路由别名 | `ROUTE-ALIAS` 映射表 | P1 分包拆分后跳转 |
**`Merchant-Seles` 已知引用页**(改组件前必评估):
- tabWorkOrder:`defeatOrder`、`additionRecordOrder`、`createArchives`、`premiumUpgrade`、`updateOrderInfo`
- packageEquity:`createDeafeatOrder`、`createDeafeatOrderAi`、`carQuotation/updateOrderInfo`
---
## 自动化索引
| 索引 | 命令 | 说明 |
|------|------|------|
| 组件 → 页面反向索引 | `npm run gen:component-index` | 生成 [COMPONENT-PAGE-INDEX.md](./COMPONENT-PAGE-INDEX.md) |
| 组件路径断裂检测 | `node scripts/scan-component-paths.mjs` | 检测 `usingComponents` 相对路径是否存在 |
| 断裂 import 检测 | `node scripts/scan-broken-imports.mjs` | JS `require`/`import` 路径 |
组件索引变更组件引用后需重新生成:`npm run gen:component-index`。
---
## 维护约定
1. **新专章**:在对应域表「影响面文档」补链接;跨域专题同步到 [docs/README.md](./README.md)。
2. **漏改复盘**:在对应域「文档缺口」或专章末尾补一行(功能 → 文件 → 注意点)。
3. **大页面**:超过 1500 行且频繁改动时,优先补「职责地图」类文档(参考 [HOMEPAGE-INDEX](../tabIndex/docs/HOMEPAGE-INDEX.md))。
4. **组件变更**:`npm run gen:component-index` 后提交 `COMPONENT-PAGE-INDEX.md`。
---
## 后续演进(待补文档)
| 优先级 | 文档 | 说明 |
|--------|------|------|
| P1 | ~~`tabWorkOrder/docs/CREATE-ORDER-MAP.md`~~ → [tabWorkOrder/createOrder.md](./tabWorkOrder/createOrder.md) | 已补开单专章 |
| P2 | `docs/TAB-REFRESH-MAP.md` | `wx.$xxxRefresh` 全库消费点 |
| P3 | API 反向索引脚本 | 扫 `api/api.js` 生成调用方矩阵 |
# 文档说明
> **接需求第一站**:[业务域总索引 DOMAIN-INDEX.md](./DOMAIN-INDEX.md)(按域导航 + 改前必查 + 组件反向索引入口)
## 跨模块
| 文档 | 用途 |
|------|------|
| [**下单流程总览**](./order-creation/README.md) | 精品开单 vs 权益报价对比、测试矩阵、手动回归 |
| [延保 & 权益 — 园区店 ID 使用清单](./YQ-MERCHANT-ID-USAGE.md) | 延保/权益场景下哪些功能与 API 用到园区店 ID |
| [packageEquity sceneType:0 专章](./EQUITY-SCENE0-YQ-MERCHANT-ID.md) | 权益本包 + 关联分包/页面的园区店 ID 清单 |
| [服务中心公告弹窗 — 精品 vs 权益](./SERVICE-CENTER-NOTICE-POPUP.md) | 两首页 `checkServiceNotice` 行为差异与版本变更记录 |
......
# 下单流程总览
> 精品工单开单(`tabWorkOrder`)与权益车损报价(`packageEquity`)两条下单链路的对比索引、测试矩阵与手动回归入口。
| 专章 | 路径 |
|------|------|
| 精品开单 createOrder | [tabWorkOrder/createOrder.md](../tabWorkOrder/createOrder.md) |
| 权益报价 createOrderCarQuotation | [packageEquity/createOrderCarQuotation.md](../packageEquity/createOrderCarQuotation.md) |
---
## 对比摘要
| 维度 | createOrder | createOrderCarQuotation |
|------|-------------|-------------------------|
| 分包 | `tabWorkOrder` | `packageEquity` |
| 业务 | 精品工单开单(太阳膜/精品/套餐) | 车损权益升级报价 → 告知书 → 支付 |
| 入口 | Tab 工单 / 扫码 / 编辑 / 补录 | `equityPage`、`carQuotation/index`(`merchant.mode===0`) |
| 架构 | 页面 + `services/` + `routeStrategy` + `submitStrategy` | 单页 + `FirstStep`/`SecondStep` 组件 |
| 商品 | `getSelectOrderGoodsList` + 部位分桶 + 礼券 | `listByMerchantIdAndIds` + `priceCounter` |
| 提交门控 | 日报 / 学习 / 锁单 / 低价审批 | 表单 `ruleFn` + 第二步确认 |
| 单测命令 | `npm run test:createOrder` | `npm run test:quotation` |
| 代码共用 | **无直接 import 关系** | 概念相似(分元转换、VIN 校验) |
现代权益报价(`merchant.mode !== 0`)走 [`createOrderCarQuotationSimple`](../../packageEquity/pages/carQuotation/createOrderCarQuotationSimple/),本索引以标准模式页为主。
---
## 流程对照
```mermaid
flowchart LR
subgraph wo [精品开单]
WO1[onRoute 五策略] --> WO2[选品池分类]
WO2 --> WO3[goodsList 编辑]
WO3 --> WO4[SubmitContext 七步校验]
WO4 --> WO5[createWithPay 等]
end
subgraph eq [权益报价]
EQ1[FirstStep 车主] --> EQ2[SecondStep 保险+权益]
EQ2 --> EQ3[quotationAdd]
EQ3 --> EQ4[schemeConfirmation]
EQ4 --> EQ5[CarQuotationPay]
end
```
---
## 自动化测试矩阵
### 精品开单 `npm run test:createOrder`(102 用例)
| ID | 模块 | 场景 |
|----|------|------|
| IT-WO-RT-001~008 | `routeMatch.helpers` | 路由策略优先级 |
| IT-WO-SUB-001~012 | `submitPayload.helpers` | 提交清洗 / API 分支 |
| IT-WO-PS-001~010 | `productStrategy` | 三品类策略 / 折扣 / 最低价 |
| IT-WO-ECHO-001~009 | `goodsChooseEcho.helpers` | 编辑回显 subOrder 合并与营销 |
| IT-WO-PRE-001~004 | `selectOrderCatalogPreprocess` | 目录预处理 |
| — | `selectOrderCatalogClassification` | 部位分桶 / 多规格 / 套餐 |
| — | `minPriceApproval` | 低价审批列表 |
| — | `merchantStaffSelection.helpers` | 销售/转化/交付选人 |
| — | `orderCouponEffects` / `customerProfileEffects` | 礼券 / 客户档案 |
| — | `pagePopupLock` / `submitGoodsSnapshot` | 弹层锁滚动 / 提交快照 |
### 权益报价 `npm run test:quotation`(16 用例)
| ID | 模块 | 场景 |
|----|------|------|
| IT-EQ-MNY-001~005 | `quotationMoney.helpers` | 分 ↔ 元 |
| IT-EQ-PAY-001~007 | `quotationPayload.helpers` | insureList 扁平 / 回显 / 商品映射 |
| IT-EQ-RULE-001~004 | `ruleFn` | 第一步动态校验 |
全量权益:`npm run test:equity`(含上表 + 菜单/首页等)。
---
## 手动回归(无法单测覆盖)
### MR-WO-* 精品开单
| ID | 路径 |
|----|------|
| MR-WO-01 | 新建:单商品前挡分桶选品 |
| MR-WO-02 | 多规格仅出现在「其它精品」 |
| MR-WO-03 | 套餐仅在套餐弹层 |
| MR-WO-04 | 编辑/再次下单 goodsList 回显与营销价 |
| MR-WO-05 | 补录 → `supplementOrder` |
| MR-WO-06 | 错单修正 → `correctionOrder` |
| MR-WO-07 | 正常单低价审批弹层 |
| MR-WO-08 | 变更销售顾问清空礼券 |
### MR-EQ-* 权益报价
| ID | 路径 |
|----|------|
| MR-EQ-01 | 两步确认 → 方案确认页 PDF |
| MR-EQ-02 | 存草稿 → 权益 Tab 列表 |
| MR-EQ-03 | 编辑回填 insureList |
| MR-EQ-04 | `modifyEquityQuotation` 改价 |
| MR-EQ-05 | 关联 `outTradeNo` 商品可选过滤 |
| MR-EQ-06 | `priceCounter` 实时报价联动 |
---
## 改前检索
| 改动点 | 检索 |
|--------|------|
| createOrder 服务 | `rg` `tabWorkOrder/pages/createOrder/services` |
| 权益报价 helper | `packageEquity/pages/carQuotation/services` |
| 全局组件 | [COMPONENT-PAGE-INDEX](../COMPONENT-PAGE-INDEX.md) |
# createOrderCarQuotation 权益报价专章(标准模式)
路径:[`packageEquity/pages/carQuotation/createOrderCarQuotation`](../../packageEquity/pages/carQuotation/createOrderCarQuotation/)
> 总览对比见 [order-creation/README.md](../order-creation/README.md)
> **mode !== 0** 门店走 [`createOrderCarQuotationSimple`](../../packageEquity/pages/carQuotation/createOrderCarQuotationSimple/)(本专章不覆盖 Simple 业务,仅作对照)。
---
## 1. 业务定位
车损**权益升级报价**:收集车主与保险信息 → 选择权益 SKU → 后端计价 → 生成告知书 → 支付。
路由分支(全库多处):
```javascript
merchant.mode ? 'createOrderCarQuotationSimple' : 'createOrderCarQuotation'
```
---
## 2. 入口与 onRoute
| 来源 | 参数 |
|------|------|
| `equityPage` / `beforeCreate` | 新建 |
| `carQuotation/index` | `paymentMethod`、草稿 |
| 关联支付 | `outTradeNo`、`totalFee` |
| 编辑 | `id` |
| 改价回跳 | `id` + `modifyEquityQuotation` |
`onLoad` / `onShow` 为空;数据在 **`onRoute`** 与 Step 组件 `attached` 中加载。
---
## 3. 步骤与组件
```mermaid
flowchart LR
F[FirstStep mode=0] --> S[SecondStep]
S --> API[quotationAdd/update]
API --> SC[schemeConfirmation]
SC --> Pay[CarQuotationPay]
```
| 组件 | 职责 |
|------|------|
| [`FirstStep`](../../packageEquity/pages/carQuotation/components/FirstStep/FirstStep) | 场景、员工、车主表单 |
| [`SecondStep`](../../packageEquity/pages/carQuotation/components/SecondStep/SecondStep) | 保险块 + 权益单选 + `priceCounter` |
| [`VinSecDialog`](../../packageEquity/pages/carQuotation/components/VinSecDialog/VinSecDialog) | OCR 后 VIN 二次确认 |
组件通过 `wx.$router.getPageInstance()` 调用页面 `getInsurance()` / `getOwnerInfo()`。
---
## 4. 保险与权益数据
`orderInfo` 表单块 → 提交时 flatten 为 `insureList`:
| type | 表单字段 |
|------|----------|
| 0 | `business` 商业险 |
| 1 | `mutualStrength` 交强险 |
| 2 | `vehiclesAndVessels` 车船税 |
| 3 | `valueAddedVehicleLoss` 增值车损 |
| 4 | `otherInsuranceList[]` 其他 |
金额字段在 [`quotationMoney.helpers.js`](../../packageEquity/pages/carQuotation/services/quotationMoney.helpers.js) 中 **×100 / ÷100**(`needChangeList`)。
组装逻辑:[`quotationPayload.helpers.js`](../../packageEquity/pages/carQuotation/services/quotationPayload.helpers.js) — `buildInsurancePayload`、`buildOwnerPayload`、`parseInsureListToForm`。
---
## 5. 商品与计价
- `getQuotationInfo` → `listByMerchantIdAndIds` → `mapQuotationGoodsList`
- 关联支付单:`outTradeNo` 时 `isSeletct = shopMinPrice×100 >= totalFee`
- 用户选权益 → `SecondStep.onChangeInsurance` → `priceCounter` → 写 `quotedPriceUpdate`
---
## 6. 提交与后续
| 操作 | 方法 | API |
|------|------|-----|
| 第二步确认 | `handleSecondConfirmCheck(true)` | `quotationAdd` / `updateQuotation` |
| 存草稿 | `handleEditSave` | 同上 `check:false` |
| 改价 | `updateEquityPrice` | `quotationPicture` |
成功 → `schemeConfirmation` → `quotationUpgrade` → `CarQuotationPay`。
---
## 7. 已知缺口
| 项 | 说明 |
|----|------|
| `setCustomerInfo` / `resetGoods` | Simple 页有实现,标准页未定义(FirstStep 可能调用失败) |
| 隐私协议 | WXML 绑定 `agreeClick` 页面未实现 |
| 与 createOrder | **无共享业务模块**;仅 VIN、分元转换模式类似 |
---
## 8. 测试与回归
**命令:**
- `npm run test:quotation` — 报价 helper + `ruleFn`(16 用例)
- `npm run test:equity` — 全权益分包测试
**手动回归:** 见 [order-creation/README.md](../order-creation/README.md) MR-EQ-* 表。
**改前检索:** `createOrderCarQuotation` 字符串;`FirstStep`/`SecondStep` 是否共用改动。
# createOrder 精品开单专章
路径:[`tabWorkOrder/pages/createOrder`](../../tabWorkOrder/pages/createOrder/)
> 总览对比见 [order-creation/README.md](../order-creation/README.md)
---
## 1. 业务定位与入口
Tab **客户工单 → 新建工单** 主流程。根据路由参数走五种入口策略([`routeStrategy.js`](../../tabWorkOrder/pages/createOrder/routeStrategy.js) + [`routeMatch.helpers.js`](../../tabWorkOrder/pages/createOrder/services/routeMatch.helpers.js)):
| 优先级 | 条件 | 策略 | 典型场景 |
|--------|------|------|----------|
| 1 | `scene` | ScanCode | 扫码礼券核销 |
| 2 | `orderCode` + `page` | EditOrder | 编辑 / 再次下单 |
| 3 | `orderCreateType===additionRecordOrder` 或 `selectOutTradeNoArr` | AdditionRecord | 补录流水 |
| 4 | `merchantId` | Merchant | 商户入口预填 |
| 5 | 默认 | Default | 空白新建 |
`onLoad` → 若有 `orderCode` 则 `onRoute`;否则场景预填、`getUserSceneList`、销售默认人选。
---
## 2. 数据模型
| 字段 | 说明 |
|------|------|
| `orderObj` | 提交主体:客户、场景、子单、支付、礼券 |
| `goodsList` | 页面已选商品行(含 `goodsFlag` 1/2/3) |
| `subOrderList` | 提交用子单(`checkGoods` 生成) |
| 选品池桶 | `frontGearArr`…`skylightArr`、`otherProduct`、`packageList` |
`goodsFlag`:**1** 单商品(可部位分桶)、**2** 多规格(仅其它精品)、**3** 套餐。
---
## 3. 生命周期
```mermaid
flowchart TD
onLoad[onLoad] --> onRoute[onRoute]
onRoute --> RouteCtx[RouteContext]
onReady[onReady getConfig] --> PayCfg[支付方式/积分配置]
onShow[onShow 轻量] --> NoList[不拉列表 API]
```
- **onLoad**:包装 `setData`(`pagePopupLock`)、`applyOrderTypeConfig`、场景/销售预填
- **onRoute**:`RouteContext.execute` → `setOrderObj` / 补录 patch
- **onShow**:仅 `disableAlertBeforeUnload`(列表符合 Tab 规范不在此请求)
---
## 4. 选品与分类
`getSelectOrderGoodsList`:
1. `api.getSelectOrderGoodsList`
2. `normalizeMarketingMetaOnItem` + `preprocessSelectOrderCatalogItem`
3. `classifySelectOrderCatalog` → 部位桶 / `otherProduct` / `packageList`
4. `first` 时 `getChooseList` 回显 `goodsList`
相关模块:
- [`selectOrderCatalogPreprocess.js`](../../tabWorkOrder/pages/createOrder/services/selectOrderCatalogPreprocess.js)
- [`selectOrderCatalogClassification.js`](../../tabWorkOrder/pages/createOrder/services/selectOrderCatalogClassification.js)
- [`goodsPositionBucket.helpers.js`](../../tabWorkOrder/services/goodsPositionBucket.helpers.js)
`showPopup`:按 `POSITION_BUCKET_DATA_KEYS` 打开 `goodsBox` / `packageBox` / 销售选人。
---
## 5. 定价与营销
- [`productStrategy.js`](../../tabWorkOrder/pages/createOrder/productStrategy.js):`getProductStrategy` → Normal / MultiSpec / Package
- [`minPriceApproval.js`](../../tabWorkOrder/pages/createOrder/services/minPriceApproval.js):正常单低价总部审批
- `~/utils/marketingFlag`、`orderSubOrderExtras`:活动价、子单营销字段
订单类型 `djOrderType`:打折 / 买赠 / 组合等影响 `order-goods-row` 展示与 `checkGoods` 规则。
---
## 6. 人员 / 礼券 / 客户
| 能力 | 模块 / 组件 |
|------|-------------|
| 销售/转化/交付 | `merchant-staff-picker` + `merchantStaffSelection.*` |
| 礼券 | `#coupon` + `orderCouponEffects`(换人/手机号变更清空) |
| 客户档案补全 | `customerProfileEffects` + `getCustomerProfileInfo` |
精品升级(`sceneType==1`):[`orderMerchantConfig.js`](../../tabWorkOrder/pages/createOrder/services/orderMerchantConfig.js) 限制订单类型为正常单 + 内部结算。
---
## 7. 提交流程
`submit(i)` → `SubmitContext.execute`:
1. AsyncPreCheck(日报、学习、锁单)
2. StatePermission(错单/预约/补录禁建档)
3. GoodsValidation(`checkGoods`)
4. RequiredField(`checkRequired`)
5. VinValidation
6. ErrorOrderPrice(错单价差)
7. TotalPrice
通过后 [`submitPayload.helpers.js`](../../tabWorkOrder/pages/createOrder/services/submitPayload.helpers.js) 清洗并选 API:
| 条件 | API |
|------|-----|
| 建档 `save` | `createPrerecordedOrder` |
| 错单 | `correctionOrder` |
| 补录 | `supplementOrder` |
| 默认 | `createWithPay` → `confirmOrder` |
正常单可走 `buildMinPriceApprovalList` → 审批弹层。
---
## 8. 测试与回归
**命令:** `npm run test:createOrder`(102 用例)
**services 测试目录:** [`tests/`](../../tabWorkOrder/pages/createOrder/tests/)
**手动回归:** 见 [order-creation/README.md](../order-creation/README.md) MR-WO-* 表。
**改前必查:** `Merchant-Seles` 其他页、`goodsPositionBucket`(`defeatOrder` 共用)、全局 `Goods`/`SetMeal`/`Coupon` 组件。
......@@ -15,11 +15,13 @@
"postinstall": "node scripts/setup-package-used-car.mjs",
"setup": "npm install",
"verify:npm-config": "node scripts/verify-npm-config.mjs",
"test": "node --test packageDynamicForm/tests/**/*.test.mjs tabIndex/tests/**/*.test.mjs packageEquity/tests/**/*.test.mjs tabWorkOrder/pages/createOrder/tests/**/*.test.mjs tests/**/*.test.mjs",
"test": "node --experimental-detect-module --test tabWorkOrder/pages/createOrder/tests/**/*.test.mjs tests/**/*.test.mjs & node --test packageDynamicForm/tests/**/*.test.mjs tabIndex/tests/**/*.test.mjs packageEquity/tests/**/*.test.mjs",
"test:tabIndex": "node --test tabIndex/tests/**/*.test.mjs",
"test:equity": "node --test packageEquity/tests/**/*.test.mjs",
"test:equity": "node --experimental-detect-module --test packageEquity/tests/**/*.test.mjs",
"test:dynamicForm": "node --test packageDynamicForm/tests/**/*.test.mjs",
"test:createOrder": "node --test tabWorkOrder/pages/createOrder/tests/**/*.test.mjs",
"test:components": "node --test tests/popupBehavior.test.mjs tests/calendarMonthMode.test.mjs tests/componentsImageUrl.test.mjs tests/technicianSelect.helpers.test.mjs tests/sideSelectDataSource.test.mjs tests/storePickerConfirm.test.mjs"
"test:createOrder": "node --experimental-detect-module --test tabWorkOrder/pages/createOrder/tests/**/*.test.mjs",
"test:quotation": "node --experimental-detect-module --test packageEquity/tests/quotation*.test.mjs packageEquity/tests/ruleFn.test.mjs",
"test:components": "node --test tests/popupBehavior.test.mjs tests/calendarMonthMode.test.mjs tests/componentsImageUrl.test.mjs tests/technicianSelect.helpers.test.mjs tests/sideSelectDataSource.test.mjs tests/storePickerConfirm.test.mjs",
"gen:component-index": "node scripts/gen-component-page-index.mjs"
}
}
......@@ -12,6 +12,22 @@ function dynamicDailyReportDraftSave(data) {
return api.post('dj.api.smartcarlife.dailyReport.dynamic.draft.save', data, [], undefined, 'dj', false)
}
/**
* 门店日报数据上报(推送经营统计到消息群)
* @param {Object} data dailyReportRecordId
* @returns {Promise}
*/
function dynamicDailyReportDataPush(data) {
return api.post(
'dj.api.smartcarlife.dailyReport.dynamic.data.push',
data,
[],
undefined,
'dj',
false
)
}
function dailyReportDetailGet(data) {
return api.get('dj.api.smartcarlife.dailyReport.detail.get', data, [], undefined, 'dj', false)
}
......@@ -87,6 +103,7 @@ module.exports = {
dailyReportWeeklyList,
dynamicDailyReportSave,
dynamicDailyReportDraftSave,
dynamicDailyReportDataPush,
dailyReportDetailGet,
dailyReportMonthlyPendingCountGet,
getUserScene,
......
......@@ -74,14 +74,18 @@ function mapEmployeeListToOptions(list = []) {
* 拉取在职员工选项(onTheJob.getByMerchantId)
* @param {Object} [options={}]
* @param {string|number} options.merchantId 商户 ID(驻店为园区店,门店/洽谈为 4S 店)
* @param {string} [options.name] 员工姓名关键词(对齐 Merchant-Seles getEmployeeList)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchStoreStaffListOptions({ merchantId } = {}) {
async function fetchStoreStaffListOptions({ merchantId, name } = {}) {
if (!merchantId) {
return { code: -1, message: '缺少门店信息', data: [] }
}
const params = { merchantId }
if (name) {
params.name = name
}
const result = await getEmployeeListApi().getEmployeeList(params)
const code = result?.code ?? -1
......
......@@ -66,7 +66,8 @@ async function fetchFieldOptionsAdapter(params = {}) {
if (EMPLOYEE_LIST_OPTIONS_KEYS.has(optionsKey)) {
return fetchStoreStaffListOptions({
merchantId: resolveEmployeeListMerchantId(optionsKey, params)
merchantId: resolveEmployeeListMerchantId(optionsKey, params),
name: params.name || ''
})
}
......
......@@ -17,6 +17,7 @@ function buildCacheKey(params = {}) {
params.saleDate || '',
params.reportType || 'store',
brandKey,
params.name || '',
JSON.stringify(params.sceneList || [])
].join('|')
}
......
/**
* 驻店日报详情 mock(schema 来自 fixtures/schema-staff-daily-full.js)
* 样例值 F1-1 使用 legacy '1',用于验证 radio-value 与配置中心中文 value 双向兼容
*/
const { BOUTIQUE_PAGE_CONTEXT } = require('../fixtures/mock-meta.js')
const schemaIndexed = require('../fixtures/schema-staff-daily-full.js')
const { buildMockDetailJsonContent } = require('./mockDetailJsonContent.js')
......
......@@ -124,6 +124,8 @@ function buildDefaultMockDetailData(reportTemplateId) {
dailyReportRecordId: null,
baseSceneCode: WARRANTY_PAGE_CONTEXT.baseSceneCode,
reportStatus: '0',
submissionStatus: '2',
submissionDate: '',
fieldDataList: [],
subformDataList: [],
jsonContent: ''
......@@ -152,6 +154,8 @@ function fetchMockStoreDynamicDetail(params = {}) {
dailyReportRecordId: record.dailyReportRecordId || null,
baseSceneCode: record.baseSceneCode ?? WARRANTY_PAGE_CONTEXT.baseSceneCode,
reportStatus: record.reportStatus ?? '0',
submissionStatus: record.submissionStatus ?? '2',
submissionDate: record.submissionDate ?? '',
fieldDataList: record.fieldDataList || [],
subformDataList: record.subformDataList || [],
jsonContent: record.jsonContent || ''
......@@ -184,6 +188,11 @@ function saveMockStoreDynamicDetail(params = {}) {
dailyReportRecordId: dailyReportRecordId || prev.dailyReportRecordId || Date.now(),
baseSceneCode: prev.baseSceneCode ?? WARRANTY_PAGE_CONTEXT.baseSceneCode,
reportStatus: reportStatus != null ? String(reportStatus) : prev.reportStatus ?? '0',
submissionStatus:
params.submissionStatus != null
? String(params.submissionStatus)
: prev.submissionStatus ?? '2',
submissionDate: params.submissionDate ?? prev.submissionDate ?? '',
fieldDataList:
fieldDataList ??
listsFromRequestJson?.fieldDataList ??
......@@ -200,8 +209,35 @@ function saveMockStoreDynamicDetail(params = {}) {
return nextRecord
}
/**
* mock 上报:按 dailyReportRecordId 标记 submissionStatus=1
* @param {Object} [params={}]
* @param {string|number} params.dailyReportRecordId
* @returns {Object|null}
*/
function pushMockStoreDynamicDetail(params = {}) {
const { dailyReportRecordId } = params
if (dailyReportRecordId == null || dailyReportRecordId === '') {
return null
}
const targetId = String(dailyReportRecordId)
for (const [storeKey, record] of detailStore.entries()) {
if (String(record.dailyReportRecordId) === targetId) {
const nextRecord = {
...record,
submissionStatus: '1',
submissionDate: new Date().toISOString().slice(0, 19).replace('T', ' ')
}
detailStore.set(storeKey, nextRecord)
return nextRecord
}
}
return null
}
module.exports = {
fetchMockStoreDynamicDetail,
saveMockStoreDynamicDetail,
pushMockStoreDynamicDetail,
DEFAULT_REPORT_TEMPLATE_ID
}
......@@ -532,6 +532,44 @@ async function submitForm(payload = {}) {
}
}
/**
* 首屏渲染后后台刷新 brand/scene/schema 进程内缓存(不更新当前页 UI)
* @param {Object} [options={}]
* @param {Object} [options.userContext] 用户上下文(merchantId、staffUuid 等)
* @param {string} [options.baseSceneCode] 门店场景编码
* @param {number|string} [options.reportTemplateId] 模板 ID
* @returns {Promise<void>}
*/
async function revalidateCachedMetadata({
userContext = {},
baseSceneCode,
reportTemplateId
} = {}) {
if (
isNegotiationMockMode('brand') &&
isNegotiationMockMode('scene') &&
isNegotiationMockMode('schema')
) {
return
}
const { merchantId, shopMerchantId, staffUuid, phone, sceneType } = userContext
if (!merchantId) {
return
}
const refreshOptions = { skipCacheRead: true }
await Promise.allSettled([
fetchBrandAdapter({ merchantId }, refreshOptions),
fetchSceneAdapter(
{ merchantId, shopMerchantId, staffUuid, phone, sceneType },
refreshOptions
),
fetchSchemaRootAdapter(
{ reportTemplateId, baseSceneCode, merchantId },
refreshOptions
)
])
}
module.exports = {
fetchMerchantBrandIds,
fetchMerchantScene,
......@@ -545,5 +583,6 @@ module.exports = {
fetchTodayPlanStoreList,
submitForm,
buildPageContextFromSources,
normalizeUserInfo
normalizeUserInfo,
revalidateCachedMetadata
}
......@@ -108,22 +108,27 @@ async function fetchDetailAdapter(params = {}) {
/**
* 拉取洽谈 schema 根节点(mock fixture 或配置中心 negotiation-details-template + schemaCache)
* @param {Object} [params={}] reportTemplateId、baseSceneCode、merchantId
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Object}>}
*/
async function fetchSchemaRootAdapter(params = {}) {
async function fetchSchemaRootAdapter(params = {}, options = {}) {
const { reportTemplateId, baseSceneCode, merchantId } = params
const { skipCacheRead = false } = options
if (isNegotiationMockMode('schema')) {
return resolveSchemaRootResult(requireNegotiationSchemaTemplate())
}
const moduleUrl = DYNAMIC_FORM_TEMPLATE_MODULE.negotiation
const cached = getCachedSchema(moduleUrl, baseSceneCode)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedSchema(moduleUrl, baseSceneCode)
if (cached) {
return cached
}
}
const result = await fetchConfigCenterTemplate(moduleUrl)
const result = await fetchConfigCenterTemplate(moduleUrl, { useCache: !skipCacheRead })
const resolved = resolveSchemaRootResult(result.data)
setCachedSchema(moduleUrl, baseSceneCode, resolved)
return resolved
......@@ -132,11 +137,14 @@ async function fetchSchemaRootAdapter(params = {}) {
/**
* 拉取门店场景列表(mock 或 getUserScene + sceneCache)
* @param {Object} [params={}] merchantId、shopMerchantId、phone、sceneType
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchSceneAdapter(params = {}) {
async function fetchSceneAdapter(params = {}, options = {}) {
const { merchantId, shopMerchantId, staffUuid, phone, sceneType } = params
const resolvedSceneType = resolveSceneType({ sceneType })
const { skipCacheRead = false } = options
if (isNegotiationMockMode('scene')) {
return {
......@@ -146,9 +154,11 @@ async function fetchSceneAdapter(params = {}) {
}
}
const cached = getCachedScene(staffUuid, merchantId, resolvedSceneType)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedScene(staffUuid, merchantId, resolvedSceneType)
if (cached) {
return cached
}
}
const { getUserScene } = getDynamicDailyReportApi()
......@@ -168,9 +178,12 @@ async function fetchSceneAdapter(params = {}) {
/**
* 拉取门店经营品牌(mock 注入 carBrandApi 或 real + brandCache;key=merchantId,进程内复用)
* @param {Object} [params={}] merchantId
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchBrandAdapter(params = {}) {
async function fetchBrandAdapter(params = {}, options = {}) {
const { skipCacheRead = false } = options
const runFetch = async () => {
const fetcher =
fetchMerchantOperatingBrandListOverride ||
......@@ -186,9 +199,11 @@ async function fetchBrandAdapter(params = {}) {
}
const { merchantId } = params
const cached = getCachedBrand(merchantId)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedBrand(merchantId)
if (cached) {
return cached
}
}
const result = await runFetch()
setCachedBrand(merchantId, result)
......
......@@ -466,6 +466,44 @@ async function submitForm(payload = {}) {
}
}
/**
* 首屏渲染后后台刷新 brand/scene/schema 进程内缓存(不更新当前页 UI)
* @param {Object} [options={}]
* @param {Object} [options.userContext] 用户上下文(merchantId、staffUuid 等)
* @param {string} [options.baseSceneCode] 门店场景编码
* @param {number|string} [options.reportTemplateId] 模板 ID
* @returns {Promise<void>}
*/
async function revalidateCachedMetadata({
userContext = {},
baseSceneCode,
reportTemplateId
} = {}) {
if (
isStaffMockMode('brand') &&
isStaffMockMode('scene') &&
isStaffMockMode('schema')
) {
return
}
const { merchantId, shopMerchantId, staffUuid, phone, sceneType } = userContext
if (!merchantId) {
return
}
const refreshOptions = { skipCacheRead: true }
await Promise.allSettled([
fetchBrandAdapter({ merchantId }, refreshOptions),
fetchSceneAdapter(
{ merchantId, shopMerchantId, staffUuid, phone, sceneType },
refreshOptions
),
fetchSchemaRootAdapter(
{ reportTemplateId, baseSceneCode, merchantId },
refreshOptions
)
])
}
module.exports = {
fetchMerchantBrandIds,
fetchMerchantScene,
......@@ -476,5 +514,6 @@ module.exports = {
fetchWeeklyList,
submitForm,
buildPageContextFromSources,
normalizeUserInfo
normalizeUserInfo,
revalidateCachedMetadata
}
......@@ -100,22 +100,27 @@ async function fetchDetailAdapter(params = {}) {
/**
* 拉取驻店 schema 根节点(mock fixture 或配置中心 + schemaCache)
* @param {Object} [params={}] baseSceneCode 等
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Object}>}
*/
async function fetchSchemaRootAdapter(params = {}) {
async function fetchSchemaRootAdapter(params = {}, options = {}) {
const { baseSceneCode } = params
const { skipCacheRead = false } = options
if (isStaffMockMode('schema')) {
return resolveSchemaRootResult(requireStaffSchemaTemplate())
}
const moduleUrl = DYNAMIC_FORM_TEMPLATE_MODULE.staff
const cached = getCachedSchema(moduleUrl, baseSceneCode)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedSchema(moduleUrl, baseSceneCode)
if (cached) {
return cached
}
}
const result = await fetchConfigCenterTemplate(moduleUrl)
const result = await fetchConfigCenterTemplate(moduleUrl, { useCache: !skipCacheRead })
const resolved = resolveSchemaRootResult(result.data)
setCachedSchema(moduleUrl, baseSceneCode, resolved)
return resolved
......@@ -124,11 +129,14 @@ async function fetchSchemaRootAdapter(params = {}) {
/**
* 拉取门店场景列表(mock 或 getUserScene + sceneCache)
* @param {Object} [params={}] merchantId、shopMerchantId、phone、sceneType
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchSceneAdapter(params = {}) {
async function fetchSceneAdapter(params = {}, options = {}) {
const { merchantId, shopMerchantId, staffUuid, phone, sceneType } = params
const resolvedSceneType = resolveSceneType({ sceneType })
const { skipCacheRead = false } = options
if (isStaffMockMode('scene')) {
return {
......@@ -138,9 +146,11 @@ async function fetchSceneAdapter(params = {}) {
}
}
const cached = getCachedScene(staffUuid, merchantId, resolvedSceneType)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedScene(staffUuid, merchantId, resolvedSceneType)
if (cached) {
return cached
}
}
const { getUserScene } = getDynamicDailyReportApi()
......@@ -160,9 +170,12 @@ async function fetchSceneAdapter(params = {}) {
/**
* 拉取门店经营品牌(mock 或 carBrandApi + brandCache,key=merchantId,切日期复用)
* @param {Object} [params={}] merchantId
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchBrandAdapter(params = {}) {
async function fetchBrandAdapter(params = {}, options = {}) {
const { skipCacheRead = false } = options
const runFetch = async () => {
const fetcher =
fetchMerchantOperatingBrandListOverride ||
......@@ -186,9 +199,11 @@ async function fetchBrandAdapter(params = {}) {
}
const { merchantId } = params
const cached = getCachedBrand(merchantId)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedBrand(merchantId)
if (cached) {
return cached
}
}
const result = await runFetch()
setCachedBrand(merchantId, result)
......
......@@ -38,10 +38,15 @@ const {
fetchWeeklyAdapter,
saveEchoAdapter,
saveDraftAdapter,
pushReportDataAdapter,
fetchMonthlyPendingCountAdapter,
normalizeMonthlyPendingCountResponse
} = require('./storeDailyReportAdapters.js')
const { normalizeReportStatus } = require('../utils/report-status.js')
const {
normalizeSubmissionStatus,
formatSubmissionDate
} = require('../utils/submission-status.js')
const { isStoreMockMode } = require('../config/apiSwitch.js')
const { fetchDailyReportCarBrandList: fetchCarBrandListImpl } = require('./dailyReportCarBrand.js')
const { DAILY_REPORT_TEMPLATE_TYPE, DAILY_REPORT_SOURCE } = require('../config/dailyReportConstants.js')
......@@ -294,6 +299,8 @@ function buildEmptyDetail(reportTemplateId) {
reportTemplateId: reportTemplateId || STORE_DEFAULT_REPORT_TEMPLATE_ID,
dailyReportRecordId: null,
reportStatus: '0',
submissionStatus: '2',
submissionDate: '',
values: {}
}
}
......@@ -356,6 +363,8 @@ function normalizeDetailResponse(detail = {}, reportTemplateId) {
dailyReportRecordId: recordId,
baseSceneCode: detail.baseSceneCode,
reportStatus: normalizeReportStatus(detail.reportStatus),
submissionStatus: normalizeSubmissionStatus(detail.submissionStatus),
submissionDate: formatSubmissionDate(detail.submissionDate),
values: parseJsonContentDetailValues(jsonContent, []),
jsonContent,
fieldDataList: detail.fieldDataList || [],
......@@ -467,10 +476,19 @@ async function fetchWeeklyList({
* @param {number|string} payload.reportTemplateId 模板 ID
* @param {number|string|null} [payload.dailyReportRecordId] 已有记录 ID
* @param {string} payload.reportDate 报表日期
* @param {string|number} [payload.submissionStatus] 上报状态(从详情带入)
* @param {string} [payload.submissionDate] 上报时间(从详情带入)
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async function submitForm(payload = {}) {
const { engine, reportTemplateId, dailyReportRecordId, reportDate } = payload
const {
engine,
reportTemplateId,
dailyReportRecordId,
reportDate,
submissionStatus,
submissionDate
} = payload
if (!engine) {
return { code: 10002, message: '表单未初始化', data: null }
}
......@@ -492,6 +510,11 @@ async function submitForm(payload = {}) {
templateType: DAILY_REPORT_TEMPLATE_TYPE.store,
dailyReportSource: DAILY_REPORT_SOURCE.miniapp
})
saveRequest.submissionStatus = normalizeSubmissionStatus(submissionStatus)
const formattedSubmissionDate = formatSubmissionDate(submissionDate)
if (formattedSubmissionDate) {
saveRequest.submissionDate = formattedSubmissionDate
}
logStoreSaveRequestDebug('[storeDailyReport] dynamic.save 提交数据结构', saveRequest)
if (!IS_PRODUCTION) {
try {
......@@ -539,10 +562,19 @@ async function submitForm(payload = {}) {
* @param {number|string} payload.reportTemplateId 模板 ID
* @param {number|string|null} [payload.dailyReportRecordId] 已有记录 ID
* @param {string} payload.reportDate 报表日期
* @param {string|number} [payload.submissionStatus] 上报状态(从详情带入)
* @param {string} [payload.submissionDate] 上报时间(从详情带入)
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async function saveDraftForm(payload = {}) {
const { engine, reportTemplateId, dailyReportRecordId, reportDate } = payload
const {
engine,
reportTemplateId,
dailyReportRecordId,
reportDate,
submissionStatus,
submissionDate
} = payload
if (!engine) {
return { code: 10002, message: '表单未初始化', data: null }
}
......@@ -565,6 +597,11 @@ async function saveDraftForm(payload = {}) {
dailyReportSource: DAILY_REPORT_SOURCE.miniapp,
forDraft: true
})
saveRequest.submissionStatus = normalizeSubmissionStatus(submissionStatus)
const formattedSubmissionDate = formatSubmissionDate(submissionDate)
if (formattedSubmissionDate) {
saveRequest.submissionDate = formattedSubmissionDate
}
logStoreSaveRequestDebug('[storeDailyReport] dynamic.draft.save 草稿数据结构', saveRequest)
const result = await saveDraftAdapter(saveRequest)
const { code, message, data } = unwrapResponse(result)
......@@ -586,6 +623,22 @@ async function saveDraftForm(payload = {}) {
}
/**
* 门店日报数据上报(dynamic.data.push)
* @param {Object} [payload={}]
* @param {string|number} payload.dailyReportRecordId 填报记录 id
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async function pushReportData(payload = {}) {
const { dailyReportRecordId } = payload
const result = await pushReportDataAdapter({ dailyReportRecordId })
const { code, message, data } = unwrapResponse(result)
if (code == 0) {
return { code: 0, message: message || 'ok', data: data || {} }
}
return { code: code ?? -1, message, data }
}
/**
* 拉取门店本月待邀约数(仅页面在满足条件时调用)
* @param {Object} [options={}]
* @param {string|number} [options.merchantId] 4S 店 ID
......@@ -600,6 +653,44 @@ async function fetchMonthlyPendingCount({ merchantId, reportDate, sceneType } =
return normalizeMonthlyPendingCountResponse(result)
}
/**
* 首屏渲染后后台刷新 brand/scene/schema 进程内缓存(不更新当前页 UI)
* @param {Object} [options={}]
* @param {Object} [options.userContext] 用户上下文(merchantId、staffUuid 等)
* @param {string} [options.baseSceneCode] 门店场景编码
* @param {number|string} [options.reportTemplateId] 模板 ID
* @returns {Promise<void>}
*/
async function revalidateCachedMetadata({
userContext = {},
baseSceneCode,
reportTemplateId
} = {}) {
if (
isStoreMockMode('brand') &&
isStoreMockMode('scene') &&
isStoreMockMode('schema')
) {
return
}
const { merchantId, shopMerchantId, staffUuid, phone, sceneType } = userContext
if (!merchantId) {
return
}
const refreshOptions = { skipCacheRead: true }
await Promise.allSettled([
fetchBrandAdapter({ merchantId }, refreshOptions),
fetchSceneAdapter(
{ merchantId, shopMerchantId, staffUuid, phone, sceneType },
refreshOptions
),
fetchSchemaRootAdapter(
{ reportTemplateId, baseSceneCode, merchantId },
refreshOptions
)
])
}
module.exports = {
fetchMerchantBrandIds,
fetchMerchantScene,
......@@ -611,7 +702,9 @@ module.exports = {
fetchMonthlyPendingCount,
submitForm,
saveDraftForm,
pushReportData,
normalizeDetailResponse,
buildPageContextFromSources,
normalizeUserInfo
normalizeUserInfo,
revalidateCachedMetadata
}
......@@ -100,22 +100,27 @@ async function fetchDetailAdapter(params = {}) {
/**
* 拉取门店 schema 根节点(mock fixture 或配置中心 + schemaCache)
* @param {Object} [params={}] reportTemplateId、baseSceneCode、merchantId
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Object}>}
*/
async function fetchSchemaRootAdapter(params = {}) {
async function fetchSchemaRootAdapter(params = {}, options = {}) {
const { reportTemplateId, baseSceneCode, merchantId } = params
const { skipCacheRead = false } = options
if (isStoreMockMode('schema')) {
return resolveSchemaRootResult(requireStoreSchemaTemplate())
}
const moduleUrl = DYNAMIC_FORM_TEMPLATE_MODULE.store
const cached = getCachedSchema(moduleUrl, baseSceneCode)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedSchema(moduleUrl, baseSceneCode)
if (cached) {
return cached
}
}
const result = await fetchConfigCenterTemplate(moduleUrl)
const result = await fetchConfigCenterTemplate(moduleUrl, { useCache: !skipCacheRead })
const resolved = resolveSchemaRootResult(result.data)
setCachedSchema(moduleUrl, baseSceneCode, resolved)
return resolved
......@@ -124,11 +129,14 @@ async function fetchSchemaRootAdapter(params = {}) {
/**
* 拉取门店场景列表(mock 或 findByMerchantIdAndSceneType + sceneCache)
* @param {Object} [params={}] merchantId、shopMerchantId、sceneType
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchSceneAdapter(params = {}) {
async function fetchSceneAdapter(params = {}, options = {}) {
const { merchantId, shopMerchantId, staffUuid, sceneType } = params
const resolvedSceneType = resolveSceneType({ sceneType })
const { skipCacheRead = false } = options
if (isStoreMockMode('scene')) {
return {
......@@ -138,9 +146,11 @@ async function fetchSceneAdapter(params = {}) {
}
}
const cached = getCachedScene(staffUuid, merchantId, resolvedSceneType)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedScene(staffUuid, merchantId, resolvedSceneType)
if (cached) {
return cached
}
}
const { findSceneByMerchantIdAndSceneType } = getDynamicDailyReportApi()
......@@ -159,9 +169,12 @@ async function fetchSceneAdapter(params = {}) {
/**
* 拉取门店经营品牌(mock 或 carBrandApi + brandCache,key=merchantId,同门店切日期不重复请求)
* @param {Object} [params={}] merchantId
* @param {Object} [options={}]
* @param {boolean} [options.skipCacheRead=false] 为 true 时跳过读缓存但仍写回(后台 SWR 刷新)
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchBrandAdapter(params = {}) {
async function fetchBrandAdapter(params = {}, options = {}) {
const { skipCacheRead = false } = options
const runFetch = async () => {
const fetcher =
fetchMerchantOperatingBrandListOverride ||
......@@ -185,9 +198,11 @@ async function fetchBrandAdapter(params = {}) {
}
const { merchantId } = params
const cached = getCachedBrand(merchantId)
if (cached) {
return cached
if (!skipCacheRead) {
const cached = getCachedBrand(merchantId)
if (cached) {
return cached
}
}
const result = await runFetch()
setCachedBrand(merchantId, result)
......@@ -267,6 +282,34 @@ async function saveDraftAdapter(params = {}) {
return dynamicDailyReportDraftSave(params)
}
/**
* 门店日报数据上报(mock 标记已上报或 dynamic.data.push)
* @param {Object} [params={}]
* @param {string|number} params.dailyReportRecordId 填报记录 id
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async function pushReportDataAdapter(params = {}) {
const { dailyReportRecordId } = params
if (isStoreMockMode('dataPush')) {
const pushed = requireMockStoreDynamicDetail().pushMockStoreDynamicDetail({
dailyReportRecordId
})
if (!pushed) {
return { code: -1, message: '未找到填报记录', data: null }
}
return {
code: 0,
message: 'ok',
data: {
submissionStatus: pushed.submissionStatus,
submissionDate: pushed.submissionDate
}
}
}
const { dynamicDailyReportDataPush } = getDynamicDailyReportApi()
return dynamicDailyReportDataPush({ dailyReportRecordId })
}
const MOCK_MONTHLY_PENDING_COUNT = 12
/**
......@@ -351,6 +394,7 @@ module.exports = {
fetchWeeklyAdapter,
saveEchoAdapter,
saveDraftAdapter,
pushReportDataAdapter,
fetchMonthlyPendingCountAdapter,
extractPendingCountFromResponseData,
normalizeMonthlyPendingCountResponse,
......
......@@ -6,8 +6,12 @@
*/
const { fetchFieldOptions } = require('../../api/fieldOptionsService.js')
const { coerceMultipleSelectValue } = require('../../form-engine/multiple-select-value.js')
const { resolveMultipleSelectItemDisplayLabel } = require('../../form-engine/multiple-select-display.helpers.js')
const { normalizeOptionRecord } = require('../../form-engine/field-submit-value.js')
const { shouldRefreshOptionsOnPopup } = require('../../utils/field-options-popup.js')
const {
shouldRefreshOptionsOnPopup,
isEmployeeListPickerSearchable
} = require('../../utils/field-options-popup.js')
const {
buildUpgradeIconUrl,
FORM_FIELD_ARROW_ICON
......@@ -45,6 +49,8 @@ Component({
showPicker: false,
pickerOptions: [],
loadingOptions: false,
pickerSearchable: false,
searchKeyword: '',
arrowIconUrl: ''
},
......@@ -108,15 +114,16 @@ Component({
? normalizedValue.find(item => this.resolveItemKey(item) === selectedKey)
: null
labels.push(
(rawItem &&
typeof rawItem === 'object' &&
(rawItem.name || rawItem.label)) ||
matched?.label ||
selectedKey
resolveMultipleSelectItemDisplayLabel({
selectedKey,
rawItem,
matched,
hasOptionsKey: !!field?.optionsKey
})
)
})
this.setData({
displayLabel: labels.length ? labels.join('/') : '',
displayLabel: labels.filter(part => part != null && part !== '').join('/'),
pickerValueIds: selectedValues
})
},
......@@ -174,7 +181,8 @@ Component({
staffUuid: ctx.staffUuid,
reportDate: ctx.reportDate,
reportType: ctx.reportType || 'store',
sceneType: ctx.sceneType
sceneType: ctx.sceneType,
name: this.data.searchKeyword || ''
}
},
......@@ -224,17 +232,21 @@ Component({
async onTap() {
if (this.data.disabled) return
const field = this.data.field || {}
const pickerSearchable = isEmployeeListPickerSearchable(field.optionsKey)
this.setData({ searchKeyword: '', pickerSearchable })
let options = this.data.pickerOptions
if (this.data.field?.optionsKey) {
if (field?.optionsKey) {
options = await this.loadOptions({
useCache: !shouldRefreshOptionsOnPopup(this.data.field)
useCache: !shouldRefreshOptionsOnPopup(field)
})
} else {
options = this.getStaticOptions()
this.setData({ pickerOptions: options })
}
if (!options.length) {
if (!options.length && !pickerSearchable) {
return wx.$util?.showToast?.('暂无可选项')
}
......@@ -242,6 +254,13 @@ Component({
this.setData({ showPicker: true })
},
/** 弹框内搜索:带 name 重拉员工列表(对齐 Merchant-Seles) */
async onPickerSearch(e) {
const searchKeyword = e.detail?.value || ''
this.setData({ searchKeyword })
await this.loadOptions({ useCache: false })
},
buildSubmitValues(selectedValues = []) {
const options = this.data.pickerOptions.length
? this.data.pickerOptions
......@@ -264,13 +283,13 @@ Component({
onPickerConfirm(e) {
const rawValue = e.detail?.value || []
const value = this.buildSubmitValues(rawValue)
this.setData({ showPicker: false })
this.setData({ showPicker: false, searchKeyword: '' })
this.updateDisplayLabel(this.data.field, value)
this.triggerEvent('change', this.buildChangeDetail(value))
},
onPickerCancel() {
this.setData({ showPicker: false })
this.setData({ showPicker: false, searchKeyword: '' })
}
}
})
......@@ -17,6 +17,9 @@
options="{{ pickerOptions }}"
value="{{ pickerValueIds }}"
loading="{{ loadingOptions }}"
searchable="{{ pickerSearchable }}"
search-keyword="{{ searchKeyword }}"
bind:search="onPickerSearch"
bind:confirm="onPickerConfirm"
bind:cancel="onPickerCancel"
/>
......@@ -13,7 +13,10 @@ const {
isOrderListField,
resolveCarBrandTypeFlagFromField
} = require('../../utils/order-list-params.js')
const { shouldRefreshOptionsOnPopup } = require('../../utils/field-options-popup.js')
const {
shouldRefreshOptionsOnPopup,
isEmployeeListPickerSearchable
} = require('../../utils/field-options-popup.js')
const {
buildUpgradeIconUrl,
FORM_FIELD_ARROW_ICON
......@@ -38,6 +41,8 @@ Component({
pickerOptions: [],
pickerValue: [],
loadingOptions: false,
pickerSearchable: false,
searchKeyword: '',
arrowIconUrl: ''
},
......@@ -139,6 +144,11 @@ Component({
return this.data.field?.options?.length ? this.data.field.options : []
},
/** storeStaffList / 4sStaffList 弹框启用服务端姓名搜索(门店驻店人员、洽谈驻店人员、销售/交付专员) */
isStaffPickerSearchable(field = this.data.field) {
return isEmployeeListPickerSearchable(field?.optionsKey)
},
/** 组装 optionsKey 远程拉取参数(merchantId、reportDate、saleDate 等) */
buildFetchParams() {
const ctx = this.data.requestContext || {}
......@@ -162,7 +172,8 @@ Component({
reportType: ctx.reportType || 'store',
sceneType: ctx.sceneType,
sceneList: ctx.sceneList || [],
groupBrandIds
groupBrandIds,
name: this.data.searchKeyword || ''
}
},
......@@ -250,6 +261,9 @@ Component({
return
}
const pickerSearchable = this.isStaffPickerSearchable(field)
this.setData({ searchKeyword: '', pickerSearchable })
let options = this.data.pickerOptions
if (field?.optionsKey) {
// 远程 optionsKey 每次打开弹框重新拉取,避免进程内缓存展示过期数据
......@@ -261,7 +275,7 @@ Component({
this.setData({ pickerOptions: options })
}
if (!options.length) {
if (!options.length && !pickerSearchable) {
return wx.$util?.showToast?.('暂无可选项')
}
......@@ -292,13 +306,20 @@ Component({
})
},
/** 弹框内搜索:带 name 重拉员工列表(对齐 Merchant-Seles) */
async onPickerSearch(e) {
const searchKeyword = e.detail?.value || ''
this.setData({ searchKeyword })
await this.loadOptions({ useCache: false })
},
/** 弹框确认:关闭 picker 并 triggerEvent('change') 写入选中值 */
onPickerConfirm(e) {
let selected = e.detail?.value
if (Array.isArray(selected)) {
selected = selected[0]
}
this.setData({ showPicker: false })
this.setData({ showPicker: false, searchKeyword: '' })
const options = this.data.pickerOptions.length
? this.data.pickerOptions
: this.data.field?.options || []
......@@ -315,7 +336,7 @@ Component({
},
onPickerCancel() {
this.setData({ showPicker: false })
this.setData({ showPicker: false, searchKeyword: '' })
}
}
})
......@@ -17,6 +17,9 @@
options="{{ pickerOptions }}"
value="{{ pickerValue }}"
loading="{{ loadingOptions }}"
searchable="{{ pickerSearchable }}"
search-keyword="{{ searchKeyword }}"
bind:search="onPickerSearch"
bind:confirm="onPickerConfirm"
bind:cancel="onPickerCancel"
/>
......@@ -36,13 +36,22 @@ Component({
mode: {
type: String,
value: 'multiple'
},
searchable: {
type: Boolean,
value: false
},
searchKeyword: {
type: String,
value: ''
}
},
data: {
optionRows: [],
draftValues: [],
isFullSucreen: false
isFullSucreen: false,
emptyText: '暂无可选项'
},
lifetimes: {
......@@ -64,6 +73,10 @@ Component({
if (this.properties.show && !this.properties.loading) {
this.syncOptionRows()
}
},
'searchable, searchKeyword': function (searchable, searchKeyword) {
if (!this.properties.show || this.properties.loading) return
this.updateEmptyText(searchable, searchKeyword)
}
},
......@@ -74,12 +87,27 @@ Component({
syncOptionRows() {
const draftValues = normalizePickerValues(this.properties.value)
const optionRows = buildPickerOptionRows(this.properties.options, this.properties.value)
this.updateEmptyText(this.properties.searchable, this.properties.searchKeyword)
this.setData({
optionRows,
draftValues
})
},
/** 搜索态空列表文案对齐 Merchant-Seles */
updateEmptyText(searchable, searchKeyword) {
const emptyText =
searchable && searchKeyword ? '暂无数据' : '暂无可选项'
if (emptyText !== this.data.emptyText) {
this.setData({ emptyText })
}
},
/** search-input 确认搜索 → 父组件带 name 重拉员工列表 */
onSearch(e) {
this.triggerEvent('search', { value: e.detail?.value || '' })
},
/** 点选行:single 替换 draft,multiple toggle 多选并刷新 active 态 */
onToggle(e) {
const index = e.currentTarget.dataset.index
......
{
"component": true,
"usingComponents": {}
"usingComponents": {
"search-input": "/components/SearchInput/SearchInput"
}
}
......@@ -5,6 +5,14 @@
<block wx:if="{{ title }}">
<view class="picker-popup-shell__title">{{ title }}</view>
</block>
<search-input
wx:if="{{ searchable }}"
class="picker-popup-shell__search"
styleValue="border-bottom:none"
value="{{ searchKeyword }}"
bindsearch="onSearch"
placeholder="请输入名字"
/>
<view class="picker-popup-shell__slot">
<scroll-view scroll-y class="picker-popup__scroll">
<view wx:if="{{ loading }}" class="picker-popup__loading">加载中...</view>
......@@ -22,7 +30,7 @@
<view class="picker-popup__label">{{ item.label }}</view>
</view>
</block>
<view wx:else class="picker-popup__empty">暂无可选项</view>
<view wx:else class="picker-popup__empty">{{ emptyText }}</view>
</scroll-view>
</view>
<view class="picker-popup-shell__footer {{ isFullSucreen ? 'is-full' : '' }}">
......
......@@ -32,6 +32,13 @@
animation: picker-popup-show 0.5s forwards;
box-sizing: border-box;
padding: 0 32rpx;
/* root-portal 内 SearchInput 依赖的 --fontSize*(对齐 app.sass page 变量) */
--fontSize104: 104rpx;
--fontSize72: 72rpx;
--fontSize38: 38rpx;
--fontSize32: 32rpx;
--fontSize28: 28rpx;
--fontSize10: 10rpx;
}
.picker-popup-shell__title {
......@@ -45,6 +52,16 @@
border-bottom: 2rpx solid #ebedf0;
}
.picker-popup-shell__search {
flex-shrink: 0;
margin: 0 -32rpx;
padding: 0;
}
.picker-popup-shell__search search-input {
border: none;
}
.picker-popup-shell__slot {
flex: 1;
min-height: 0;
......
......@@ -18,7 +18,7 @@ const {
Component({
properties: {
/** 父页控制显隐;true 时打开弹层并重置为今天 */
/** 父页控制显隐;true 时打开弹层并重置为 anchorDate */
show: {
type: Boolean,
value: false,
......@@ -28,6 +28,11 @@ Component({
}
}
},
/** 周历选中日(弹层日期锚点,默认今天) */
anchorDate: {
type: String,
value: ''
},
/** 4S 店商户号 */
merchantId: {
type: String,
......@@ -62,27 +67,33 @@ Component({
methods: {
noScroll() {},
/** 打开弹层并重置为今天 */
/** 解析弹层日期锚点(周历选中日,缺省为今天) */
resolveAnchorDate() {
return this.properties.anchorDate || timeUtil.getTodayDateStr()
},
/** 打开弹层并重置为锚点日 */
openPopup() {
const today = timeUtil.getTodayDateStr()
const anchorDate = this.resolveAnchorDate()
this.setData({
visible: true,
currentDate: today,
currentDate: anchorDate,
customerList: [],
selectedCount: 0,
isAllSelected: false,
loadComplete: false
})
this.syncDateNavState(today)
this.loadCustomerList(today)
this.syncDateNavState(anchorDate)
this.loadCustomerList(anchorDate)
},
/** 同步日期导航按钮与文案 */
syncDateNavState(dateStr) {
const anchorDate = this.resolveAnchorDate()
this.setData({
dateLabel: formatPlanStoreDateLabel(dateStr),
canPrev: canShiftPlanStoreDate(dateStr, -1),
canNext: canShiftPlanStoreDate(dateStr, 1)
dateLabel: formatPlanStoreDateLabel(dateStr, anchorDate),
canPrev: canShiftPlanStoreDate(dateStr, -1, anchorDate),
canNext: canShiftPlanStoreDate(dateStr, 1, anchorDate)
})
},
......@@ -138,13 +149,15 @@ Component({
},
onPrevDay() {
const next = shiftPlanStoreDate(this.data.currentDate, -1)
const anchorDate = this.resolveAnchorDate()
const next = shiftPlanStoreDate(this.data.currentDate, -1, anchorDate)
if (!next) return
this.changeDate(next)
},
onNextDay() {
const next = shiftPlanStoreDate(this.data.currentDate, 1)
const anchorDate = this.resolveAnchorDate()
const next = shiftPlanStoreDate(this.data.currentDate, 1, anchorDate)
if (!next) return
this.changeDate(next)
},
......
......@@ -31,7 +31,8 @@ const STORE_DAILY_API_SWITCH = {
brand: 'real',
weekly: 'real',
fieldOptions: 'real',
monthlyPendingCount: 'real'
monthlyPendingCount: 'real',
dataPush: 'real'
}
const NEGOTIATION_DAILY_API_SWITCH = {
......
......@@ -133,6 +133,8 @@ sequenceDiagram
| schemaCache | moduleUrl + baseSceneCode | 同场景 schema 复用 |
| brandCache | merchantId | 切日期不重复打 merchant.info |
首屏仍读缓存快速展示;`applyEngineView` 后由页面 `scheduleMetadataCacheRevalidate` 空闲后台 `skipCacheRead` 刷新三缓存,**不热更新当前页 UI**(下次进页/切日期用新数据)。
三页各自 `*DailyReportCache.js`;单测 `beforeEach` 需 `clear*DailyReportCache()`。
## 相关单测模块
......
# DEVLOG — packageDynamicForm
## 2026-07-23 — 门店日报上报:save 后 detail.get 再 push
- **上报**:`dynamic.save` 成功后 `fetchReportDetail` 取 `dailyReportRecordId`,再 `dynamic.data.push`(仅 id)
- **模块**:[`storeDailyReport.js`](../pages/storeDailyReport/storeDailyReport.js) `fetchDailyReportRecordIdFromDetail`
## 2026-07-23 — 门店日报:保存/上报统一 dynamic.save + 上报 save→push
- **保存**:改 `submitForm`(`dynamic.save`),必填校验;Toast「保存成功/失败」;废弃门店页 `draft.save`
- **上报**:校验 → `dynamic.save` → `push({ dailyReportRecordId })`(id 取自 save 响应)
- **UI**:按钮区 `!isSubmissionReported`;已 save 未 push 时隐藏「保存」、保留「上报」
- **模块**:[`storeDailyReport.js`](../pages/storeDailyReport/storeDailyReport.js) `validateFormRequired` / `persistStoreDailyForm`
## 2026-07-23 — 门店日报保存/上报后刷新 submission 态
- **保存**:`saveDraftForm` 透传 `submissionStatus`/`submissionDate`;成功后 `refreshSubmissionFromDetail` 轻量 `detail.get` 刷新上报按钮
- **上报**:成功后改为 `refreshSubmissionFromDetail` + `refreshWeeklyList`(不再全量 `refreshAfterSubmit`)
- **单测**:`storeDailyReportAdapters.test.mjs` IT-STORE-DRAFT-004
## 2026-07-23 — 门店日报上报:校验后直接 push
- **调整**:上报不再要求先点「保存」;`guardStoreDailyPushInProgress` 移除「请先保存」;上报路径不调用 save/draft.save,仅必填校验 + `dynamic.data.push`
## 2026-07-23 — 门店日报数据上报(submissionStatus + data.push)
- **UI**:底部「提交」改为「上报」;`submissionStatus=1` 隐藏上报按钮
- **接口**:`detail.get` 回显 `submissionStatus`/`submissionDate`;上报调 `dynamic.data.push`;`dynamic.save` 门面可透传 submission 字段
- **模块**:[`submission-status.js`](../utils/submission-status.js)、[`storeDailyReport.js`](../api/storeDailyReport.js) `pushReportData`
- **单测**:`submission-status.test.mjs`、`store-daily-report-push.test.mjs`
## 2026-07-22 — 弹层日期 tips 相对 anchorDate
- **修复**:[`today-plan-date.js`](../services/today-plan-date.js) `getPlanStoreDateTips` / `formatPlanStoreDateLabel` 括号文案改为相对周历 `reportDate`(anchorDate),不再相对系统今天;弹层 `syncDateNavState` 传入锚点日。
## 2026-07-22 — 三页可编辑窗口 ±29 天 + 洽谈待接待客户弹层
- **可编辑窗口**:三页统一为周历选中日相对**今天 ±29 天**([`daily-report-editable-window.js`](../utils/daily-report-editable-window.js));驻店自 7 天扩展,门店/洽谈自「仅当天」扩展。
- **洽谈入口条**:可编辑日内展示;`count`/`list` 的 `inviteDate` 为周历 `reportDate`。
- **弹层**:[`today-plan-customer-popup`](../components/today-plan-customer-popup/) 默认日期 = `reportDate`;相对锚点 ±30 天切换;日期文案 `YY-MM-DD 周X (今天/…)`。
- **单测**:`daily-report-editable-window.test.mjs`;`today-plan-date.test.mjs` 边界更新。
## 2026-07-22 — F1-12/F1-13 调休隐藏
- **变更**:五界轻改顶层 F1-12/F1-13 增加 `rules.keys: ['F1-1']`、`rules.result: 'val1 == "在岗"'`,与 F1-2/F1-3、品牌 group 出勤 gate 一致;调休时不展示。
- **fixture**:`schema-staff-daily-v2.1.1.js/json` 及 `.prod.js/json`。
- **单测**:`IT-STAFF-TPL-003` 补充出勤 rules 断言。
## 2026-07-21 — V2.1.1 生产环境 brandId fixture
- **背景**:Excel 转换默认输出测试 brandId(3454/3067 等),与线上配置中心 brandIdMap(2695/2188 等)不一致。
- **新增**:`fixtures/brand-id-env-maps.mjs/json`;`schema-*-daily-v2.1.1.prod.js/json`(驻店 + 门店);`scripts/remap-schema-brand-ids.mjs`。
- **转换脚本**:`convert-excel-template-to-schema.py` 增加 `--env production`,默认输出 `.prod` 后缀。
- **单测**:`v211-template-brand-id-prod.test.mjs`;`loadSchemaFixtureV211(kind, env)` 支持 `'production'`。
- **文档**:`fixtures/README`、`excel转js模板配置说明`、`daily-report-template-config-summary`、`staff/store-template-features`。
## 2026-07-13 — 门店日报「岚图 or 其他品牌」显隐修复
- **根因**:Excel 转换 `parse_brand_restriction` 对「岚图,其他品牌」误设 `brandId: [3067]`,与 `filterBrandId` 在 `brandSpec` 中 AND 组合,导致仅其他品牌门店无法见 F2-37/F2-57/F2-58 及驻店 F1-11-1 等。
- **修复**:改为 `brandId: []` + `filterBrandId: 五界`;重生成 `schema-store-daily-v2.1.1` 与 `schema-staff-daily-v2.1.1`。
- **单测**:`IT-V211-STORE-007`~`013`、`IT-V211-STAFF-006`~`008`、`IT-STORE-TPL-008/009`、`IT-STAFF-TPL-009`。
- **文档**:`excel转js模板配置说明` §3.3 or/and 映射;`staff-template-features`、`store-template-features`。
## 2026-07-09 — 门店日报 V2.1.1 新增 F2-14-12
- **模版**:`schema-store-daily-v2.1.1.js/json` 在 F2-14 子表单新增 `F2-14-12`「今日厂家权益有效转介绍」(延保 2.3.1/2.3.2,integer ≥0,与售前 `F2-11-9` 对称)。
- **单测**:`IT-STORE-TPL-007`、`IT-V211-STORE-006`。
- **文档**:`store-template-features`、`daily-report-template-config-summary`。
## 2026-07-09 — V2.1.1 模板测试与文档同步
- **单测**:`staff-template-schema.test.mjs`、`store-template-schema.test.mjs` 切换至 `loadSchemaFixtureV211`;移除 form-engine `require`(修复 ESM 加载失败);`v211-template-visibility.test.mjs` 补充 IT-V211-STAFF-004/005 权益场景。
- **断言**:驻店 F1-12/F1-13、F1-11 十二子项、F1-5 四子项;门店移除 F2-30/F2-36、新增 F2-38/F2-44。
- **文档**:`staff-template-features`、`store-template-features`、`daily-report-template-config-summary`、`fixtures/README`、`MAINTENANCE`、`PAGES` 对齐 V2.1.1 双 fixture 职责(full.js = mock baseline,v2.1.1 = 结构/单测)。
## 2026-06-25 — 修复保存后 F3-4-1 洽谈日期回显为空
- **根因**:运行时 `partialFromPlanImport` 包装对象经 `childrenValue` 入库;回显 `childrenValueToRowFieldsList` 读 `val.text` 为空,`rowFieldsToValueMap` 跳过空 `field.value`。
......
......@@ -230,6 +230,7 @@ engine.mutateSubform(groupKey, rowIndex, childKey, value)
| 文档 | 什么时候看 |
|------|-----------|
| [daily-report-template-config-summary.md](./daily-report-template-config-summary.md) | 驻店/门店模版字段速查、替换 checklist |
| [TECH-SHARE.md](./TECH-SHARE.md) | 团队分享、老新对比与边界 |
| [ARCHITECTURE.md](./ARCHITECTURE.md) | 分层、加载/保存流程 |
| [动态表单Schema设计.md](./动态表单Schema设计.md) | 字段完整定义、TypeScript 接口 |
......@@ -239,4 +240,4 @@ engine.mutateSubform(groupKey, rowIndex, childKey, value)
| [selector-modes.md](./selector-modes.md) | 选择器 mode 总览(single/multiple、日期、车型、radio) |
| [field-options-api.md](./field-options-api.md) | optionsKey 接口细节 |
完整 JSON 示例:[动态表单Schema示例.json](./动态表单Schema示例.json)
完整 JSON 示例(驻店节选):[动态表单Schema示例.json](./动态表单Schema示例.json);完整模版见 `fixtures/schema-*-daily-full.js`
......@@ -28,8 +28,8 @@
| subform 行数上限 | [group-repeater.md](./group-repeater.md) + daily-report-save-and-json.md §6 |
| VIN / 品牌桥接(洽谈) | PAGES.md 洽谈节 + [car-brand-select.md](./car-brand-select.md)(若涉及) |
| 洽谈 schema / 配置中心模版(F3、reqParams、completeFun) | [negotiation-template-features.md](./negotiation-template-features.md) + `fixtures/schema-negotiation-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 洽谈节 |
| 门店 schema / 配置中心模版(F2、completeFun、divider) | [store-template-features.md](./store-template-features.md) + `fixtures/schema-store-daily-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 门店节 |
| 驻店 schema / 配置中心模版(F1、出勤 gate、group) | [staff-template-features.md](./staff-template-features.md) + `fixtures/schema-staff-daily-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 驻店节 |
| 门店 schema / 配置中心模版(F2、completeFun、divider) | [store-template-features.md](./store-template-features.md) + `fixtures/schema-store-daily-v2.1.1.js/json` + 三套模板单测 +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 门店节 |
| 驻店 schema / 配置中心模版(F1、出勤 gate、group) | [staff-template-features.md](./staff-template-features.md) + `fixtures/schema-staff-daily-v2.1.1.js/json` + 三套模板单测 +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 驻店节 |
| apiSwitch 默认或联调策略 | [SESSION-HANDOFF.md](./SESSION-HANDOFF.md)(apiSwitch 速查)+ DEVLOG.md |
| 今日计划客户 / 洽谈导入 / todayPlanStore | PAGES.md 洽谈节 + SESSION-HANDOFF + DEVLOG + integration-test-plan |
| 新单测或 TEST-ID | [integration-test-plan.md](./integration-test-plan.md) + PAGES.md「相关单测」 |
......@@ -51,7 +51,9 @@
## Schema fixture 维护(mock)
三份完整 indexed schema:`fixtures/schema-staff-daily-full.js`、`schema-store-daily-full.js`、`schema-negotiation-full.js`。`apiSwitch.schema = 'mock'` 与单测([`tests/schemaFixture.mjs`](../tests/schemaFixture.mjs))均依赖上述文件。
三份完整 indexed schema:`fixtures/schema-staff-daily-full.js`、`schema-store-daily-full.js`、`schema-negotiation-full.js`。`apiSwitch.schema = 'mock'` 与 [`loadSchemaFixture`](../tests/schemaFixture.mjs) 依赖上述 **full.js** 文件。
V2.1.1 模版结构/显隐单测读 `schema-*-daily-v2.1.1.json`([`loadSchemaFixtureV211`](../tests/schemaFixture.mjs)),由 Excel 转换脚本生成;`keep` 行仍从 full.js 拷贝。
### 何时执行 numberInput 补丁
......
......@@ -32,6 +32,7 @@
- [group 子表单多行增删](./group-repeater.md)
- [路由与菜单](./routes-and-menus.md)
- [staff / store / negotiation 模版字段对照](./staff-template-features.md)(另见 store、negotiation 同名文档)
- [**Excel 转 JS/JSON 模板配置说明**](./excel转js模板配置说明.md)(从填写表单 xlsx 生成 schema fixture)
- [集成测试计划](./integration-test-plan.md)
- [测试环境](./test-setup.md)
- [apiSwitch 速查](./SESSION-HANDOFF.md)
......
......@@ -79,8 +79,8 @@ const subformDataList = buildAppSubformDataListFromJsonContent(jsonContent)
| optionsKey | Mock | Real |
|------------|------|------|
| `storeStaffList` | [`mock-field-options.js`](../fixtures/mock-field-options.js) | `dj.api.smartcarlife.employee.onTheJob.getByMerchantId`([`api.getEmployeeList`](../../api/api.js))。**打开弹框时 `useCache=false`,每次重新拉取** |
| `4sStaffList` | mock fixture | 同上(对齐精品新建工单交付专员 `Merchant-Seles type=3`)。**打开弹框时 `useCache=false`,每次重新拉取** |
| `storeStaffList` | [`mock-field-options.js`](../fixtures/mock-field-options.js) | `dj.api.smartcarlife.employee.onTheJob.getByMerchantId`([`api.getEmployeeList`](../../api/api.js))。**打开弹框时 `useCache=false`,每次重新拉取**;弹框内 `search-input` 搜索时带 `name` 重拉(服务端筛选) |
| `4sStaffList` | mock fixture | 同上(对齐精品新建工单交付专员 `Merchant-Seles type=3`)。**打开弹框时 `useCache=false`,每次重新拉取**;弹框内 `search-input` 搜索时带 `name` 重拉(服务端筛选) |
| `orderList` | mock fixture(含 `raw` 供 completeFun) | `api.getGoodsOrderOutputValueList` → `dj.api.smartcarlife.goodsOrder.product.outputValue.list`(`sellerUserId`=staffUuid;**carBrandTypeFlag** 优先读 schema `field.reqParams.carBrandTypeFlag`(与 App 一致),缺失时由 subform `brandId` 推导;**saleDate** 仅行内 F3-*-12(与 App 一致,不用 reportDate);**不传** `baseGoodsCodeList`;选项 label 为 orderCode,option 含 `raw` 供 completeFun。**打开弹框时 `useCache=false`,每次重新拉取**。详见 [negotiation-template-features.md](./negotiation-template-features.md)) |
### storeStaffList / 4sStaffList(在职员工列表)
......@@ -93,7 +93,8 @@ const subformDataList = buildAppSubformDataListFromJsonContent(jsonContent)
- **映射**:`staffName` → `label`,`uuid` → `value`
- **适用字段**:
- `storeStaffList`:驻店「今日驻店人员」;门店日报 `F2-1`(`multipleSelect`);洽谈明细驻店人员(`select`)
- `4sStaffList`:门店日报「交付专员」(`select`,如 `F2-9-1`);洽谈明细同类字段
- `4sStaffList`:门店日报「交付专员」(`select`,如 `F2-9-1`);洽谈明细「推荐人」等同类字段
- **搜索(`storeStaffList` / `4sStaffList`)**:`form-picker-popup` 顶部 `search-input`,确认后 `getEmployeeList` 增加 `name` 参数(对齐 `Merchant-Seles`);无匹配显示「暂无数据」
驻店/门店 [`apiSwitch.js`](../config/apiSwitch.js) 中 `STAFF_DAILY_API_SWITCH` / `STORE_DAILY_API_SWITCH` 的 `fieldOptions` 已为 `'real'`;洽谈 `NEGOTIATION_DAILY_API_SWITCH.fieldOptions` 同为 `'real'`。
......
......@@ -2,11 +2,18 @@
完整 indexed schema 源文件在分包内维护:
- `packageDynamicForm/fixtures/schema-staff-daily-full.js`(另有 `.json` 导出)
- `packageDynamicForm/fixtures/schema-store-daily-full.js`
- `packageDynamicForm/fixtures/schema-staff-daily-full.js`(另有 `.json` 导出)— **V2.0 mock baseline**、Excel 转换 `keep` 行来源
- `packageDynamicForm/fixtures/schema-store-daily-full.js` — 同上
- `packageDynamicForm/fixtures/schema-negotiation-full.js`
- `packageDynamicForm/fixtures/schema-staff-daily-v2.1.1.js` / `.json` — **V2.1.1 驻店模版**(测试环境 brandId;结构/显隐单测权威来源)
- `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.js` / `.json` — **V2.1.1 门店模版**(测试环境 brandId)
- `packageDynamicForm/fixtures/schema-staff-daily-v2.1.1.prod.js` / `.prod.json` — **V2.1.1 驻店生产 brandId**(配置中心生产粘贴)
- `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.prod.js` / `.prod.json` — **V2.1.1 门店生产 brandId**
- `packageDynamicForm/fixtures/brand-id-env-maps.mjs` / `.json` — daily / production 双环境 brandId 映射
本目录仅保留体积较小的样例(`schema-staff-daily-minimal.json`、`page-context-sample.json`)。
- 从 list 转 indexed:`node packageDynamicForm/scripts/convert-schema-to-indexed.mjs`
- Excel 转 V2.1.x:`python packageDynamicForm/scripts/convert-excel-template-to-schema.py` — 见 [excel转js模板配置说明.md](../excel转js模板配置说明.md)
- daily → production brandId remap:`node packageDynamicForm/scripts/remap-schema-brand-ids.mjs --sheet staff|store`
- numberInput 补 `value: 0`:`node packageDynamicForm/scripts/patch-number-input-defaults.mjs` — 见 [MAINTENANCE.md § Schema fixture](../MAINTENANCE.md#schema-fixture-维护mock)
# 驻店日报模版功能对照(staff-daily-template)
配置中心模版与小程序 [`staffDailyReport`](../pages/staffDailyReport/staffDailyReport.js) 实现对照。`schema=mock` 时见 [`fixtures/schema-staff-daily-full.js`](../fixtures/schema-staff-daily-full.js)。
配置中心模版与小程序 [`staffDailyReport`](../pages/staffDailyReport/staffDailyReport.js) 实现对照。
相关:[PAGES.md § 驻店日报](./PAGES.md#驻店日报-新staffdailyreport)、[store-template-features.md](./store-template-features.md)、[negotiation-template-features.md](./negotiation-template-features.md)。
- **mock 运行时**:`schema=mock` 仍读 [`fixtures/schema-staff-daily-full.js`](../fixtures/schema-staff-daily-full.js)(V2.0 indexed baseline)
- **V2.1.1 模版结构/单测**:[`fixtures/schema-staff-daily-v2.1.1.js`](../fixtures/schema-staff-daily-v2.1.1.js) / [`.json`](../fixtures/schema-staff-daily-v2.1.1.json)(测试 brandId)
- **V2.1.1 生产 brandId**:[`fixtures/schema-staff-daily-v2.1.1.prod.js`](../fixtures/schema-staff-daily-v2.1.1.prod.js) / [`.prod.json`](../fixtures/schema-staff-daily-v2.1.1.prod.json)
相关:[daily-report-template-config-summary.md](./daily-report-template-config-summary.md)、[PAGES.md § 驻店日报](./PAGES.md#驻店日报-新staffdailyreport)、[store-template-features.md](./store-template-features.md)、[negotiation-template-features.md](./negotiation-template-features.md)。
---
......@@ -19,14 +23,16 @@
| 0 | 延保、权益 |
| 1 | 轻改 |
| 品牌 | brandId |
|------|---------|
| 问界 | 3454 |
| 享界 | 3503 |
| 智界 | 3458 |
| 尚界 | 3574 |
| 尊界 | 3502 |
| 岚图 | 3067 |
| 品牌 | brandId(测试 / daily) | brandId(生产 / production) |
|------|-------------------------|------------------------------|
| 问界 | 3454 | 2695 |
| 享界 | 3503 | 2741 |
| 智界 | 3458 | 2698 |
| 尚界 | 3574 | 2797 |
| 尊界 | 3502 | 2740 |
| 岚图 | 3067 | 2188 |
映射源:[`fixtures/brand-id-env-maps.mjs`](../fixtures/brand-id-env-maps.mjs)。生产 ID 对齐线上洽谈明细 brandIdMap。
---
......@@ -37,9 +43,10 @@
| 出勤 | F1-1 | radio:在岗 / 调休;默认在岗 |
| 延保退单 | F1-2、F1-3 | 仅延保场景 + 在岗时可见(见下) |
| 备注 | F1-4 | 始终可见(含调休) |
| 品牌 group | F1-5~F1-10 | 各 `brandId` 一块,子字段按轻改/延保 `sceneType`+`baseSceneCode` |
| 岚图 group | F1-10 | 5 个子字段(无「交付引荐」) |
| 其他品牌 | F1-11 | `filterBrandId`;8 个子字段(含权益未触客 F1-11-8) |
| 品牌 group | F1-5~F1-9 | 各 `brandId` 一块;V2.1.1 每块 **4** 子字段(轻改 F*-3 + 延保 F*-4~6) |
| 岚图 group | F1-10 | **3** 个子字段(仅延保售前/售后/未触客) |
| 其他品牌 | F1-11 | `filterBrandId`;**12** 个子字段(轻改/延保/权益) |
| 五界轻改顶层 | F1-12、F1-13 | V2.1.1 新增;五界 `brandId` + 轻改 `baseSceneCode`;**在岗**时可见(`rules.keys: F1-1`) |
---
......@@ -48,12 +55,13 @@
| Schema 能力 | 实现 | 说明 |
|-------------|------|------|
| F1-1 出勤 radio | [`radio-value.js`](../form-engine/radio-value.js) | 无 `rules.result`,始终可见 |
| F1-2/F1-3、group `rules.keys` + `result: val1 == "在岗"` | [`field-show-rule.js`](../form-engine/visibility/specs/field-show-rule.js) | eval `rules.result`;调休时隐藏;详情回显白名单不覆盖出勤 gate([`detail-echo.js`](../form-engine/visibility/specs/detail-echo.js)) |
| F1-2/F1-3、F1-12/F1-13、group `rules.keys` + `result: val1 == "在岗"` | [`field-show-rule.js`](../form-engine/visibility/specs/field-show-rule.js) | eval `rules.result`;调休时隐藏;详情回显白名单不覆盖出勤 gate([`detail-echo.js`](../form-engine/visibility/specs/detail-echo.js)) |
| F1-4 备注 | 无 `rules.result` | 调休时仍可见 |
| group `rules` / `childrenRules` | `schema-normalizer` → `normalizeStaticGroupChildren` | `childrenRules` 合并进子字段 `rules`(min/integer 等) |
| 子字段 `sceneType` / `baseSceneCode` | `isFieldVisible` → `matchesBaseSceneCode` | 轻改码 vs 延保码分行展示 |
| group `brandId` | `hasIntersection(brandId, ctx.brandIds)` | 无该品牌则不展示整块 group |
| F1-11 `filterBrandId` | `shouldHideByFilterBrandId` | 经营品牌全部在列表内时隐藏「其他品牌」 |
| F1-11 `filterBrandId` | `shouldHideByFilterBrandId` | 经营品牌全部在列表内时隐藏「其他品牌」整块 group |
| F1-11-1/9/2 等轻改子字段 | `brandId: []` + `filterBrandId: 五界` | Excel「岚图 or 其他品牌」:岚图或其它品牌任一即显示;纯五界隐藏 |
| 详情回显 | `hasDetailEcho` + `echoSubformKeys`(含 group) | 回显白名单内跳过 brand/filter 限制;**仍按** `sceneList` ↔ `baseSceneCode` 过滤;static group 不因 echo 回退全量子字段 |
| 保存 | `buildDynamicSavePayload` / App jsonContent | 顶层 value;无 subform;**lists 仅可见**;**jsonContent 含出勤等动态规则隐藏的块**;**不含**场景/brand 级隐藏块与纯模板 `0`(见 `json-content-persist.js`) |
......@@ -75,11 +83,13 @@
|---------|------|
| IT-ENG-001、IT-ENG-014 | `form-engine.test.mjs` — 出勤 gate、F1-11 filterBrandId |
| IT-ENG-007d | `radio-value` 中文/legacy 归一 |
| IT-STAFF-TPL-001~004 | `staff-template-schema.test.mjs` |
| IT-STAFF-TPL-001~009 | `staff-template-schema.test.mjs`(V2.1.1 fixture) |
| IT-V211-STAFF-006~008 | `v211-template-visibility.test.mjs`(岚图 or 其他品牌子字段) |
| IT-V211-* | `v211-template-visibility.test.mjs` |
| IT-LOADER-001~003 | `staffDailyFormLoader.test.mjs` |
---
## 维护
驻店 schema 变更时同步本文档、`schema-staff-daily-full.js`、PAGES.md 驻店节、DEVLOG.md。见 [MAINTENANCE.md](./MAINTENANCE.md)。
驻店 schema 变更时同步本文档、`schema-staff-daily-v2.1.1.js/json`、三套模板单测、PAGES.md 驻店节、DEVLOG.md。mock baseline 仍维护 `schema-staff-daily-full.js`(Excel 转换 `keep` 行来源)。见 [MAINTENANCE.md](./MAINTENANCE.md)、[excel转js模板配置说明.md](./excel转js模板配置说明.md)。
# 门店日报模版功能对照(store-daily-template)
配置中心模版与小程序 [`storeDailyReport`](../pages/storeDailyReport/storeDailyReport.js) 实现对照。`schema=mock` 时见 [`fixtures/schema-store-daily-full.js`](../fixtures/schema-store-daily-full.js)。
配置中心模版与小程序 [`storeDailyReport`](../pages/storeDailyReport/storeDailyReport.js) 实现对照。
相关:[PAGES.md § 门店日报](./PAGES.md#门店日报storedailyreport)、[field-options-api.md](./field-options-api.md)、[negotiation-template-features.md](./negotiation-template-features.md)(洽谈 F3 对照)。
- **mock 运行时**:`schema=mock` 仍读 [`fixtures/schema-store-daily-full.js`](../fixtures/schema-store-daily-full.js)(V2.0 indexed baseline)
- **V2.1.1 模版结构/单测**:[`fixtures/schema-store-daily-v2.1.1.js`](../fixtures/schema-store-daily-v2.1.1.js) / [`.json`](../fixtures/schema-store-daily-v2.1.1.json)(测试 brandId)
- **V2.1.1 生产 brandId**:[`fixtures/schema-store-daily-v2.1.1.prod.js`](../fixtures/schema-store-daily-v2.1.1.prod.js) / [`.prod.json`](../fixtures/schema-store-daily-v2.1.1.prod.json)
相关:[daily-report-template-config-summary.md](./daily-report-template-config-summary.md)、[PAGES.md § 门店日报](./PAGES.md#门店日报storedailyreport)、[field-options-api.md](./field-options-api.md)、[negotiation-template-features.md](./negotiation-template-features.md)(洽谈 F3 对照)。
---
## 场景与品牌编码(模版注释)
与洽谈共用,见 [negotiation-template-features.md § 场景与品牌编码](./negotiation-template-features.md#场景与品牌编码模版注释)。
与洽谈共用,见 [negotiation-template-features.md § 场景与品牌编码](./negotiation-template-features.md#场景与品牌编码模版注释)。brandId 双环境对照见 [`brand-id-env-maps.mjs`](../fixtures/brand-id-env-maps.mjs)(测试 daily / 生产 production)。
| sceneType | 含义 |
|-----------|------|
......@@ -23,12 +27,13 @@
|------|----------|------|----------|
| 驻店人员 | F2-1 / F2-2 | multipleSelect + numberInput | F2-1 仅 `brandId:[3067]` |
| 延保/权益标题 | F2-94 / F2-91 / F2-92 | divider | `isYB` / `isQY` / 双场景 → 仅 F2-94 |
| 店端指标 | F2-30、F2-36、F2-3~F2-8、F2-34~F2-35 | numberInput | `baseSceneCode` + `brandId` / `filterBrandId` |
| 店端指标 | F2-3~F2-8、F2-34~F2-35、F2-38~F2-51 | numberInput | V2.1.1 移除 F2-30/F2-36;新增品牌拆分交付/售后指标(F2-38/F2-44 等) |
| 售前 subform | F2-9、F2-10、F2-11 | subform | 鸿蒙 / 岚图 / 其他品牌 |
| 售后 subform | F2-12、F2-13、F2-14 | subform | 同上 |
| 售后 subform | F2-12、F2-13、F2-14 | subform | 同上;F2-14 含 `F2-14-12` 今日厂家权益有效转介绍(延保 2.3.1/2.3.2,与售前 `F2-11-9` 对称) |
| 轻改标题 | F2-93 | divider | `qgCode` |
| 轻改指标 | F2-16~F2-25 | numberInput | 五界交付数分品牌;F2-23~25 `filterBrandId` |
| 轻改 subform | F2-26、F2-27、F2-28 | subform | 销售 / 交付 / 售后 |
| 轻改指标 | F2-16~F2-25、F2-37 | numberInput | 五界交付数分品牌;F2-23~25、**F2-37** 为「岚图 or 其他品牌」:`brandId: []` + `filterBrandId: 五界` |
| 轻改 subform | F2-26、F2-27、F2-28 | subform | 五界销售 / 交付 / 售后 |
| 岚图/其他品牌轻改 subform | F2-57、F2-58 | subform | `brandId: []` + `filterBrandId: 五界`;岚图或其它品牌门店可见,纯五界隐藏 |
---
......@@ -81,7 +86,8 @@
|---------|------|
| IT-STORE-DIV-001~007 | `form-engine.test.mjs` |
| IT-STORE-ENG-003/005 | `form-engine.test.mjs` |
| IT-STORE-TPL-001/002 | `store-template-schema.test.mjs` |
| IT-STORE-TPL-001~009 | `store-template-schema.test.mjs`(V2.1.1 fixture) |
| IT-V211-STORE-007~013 | `v211-template-visibility.test.mjs`(岚图 or 其他品牌) |
| IT-STORE-STAFF-COUNT-001~005 | `store-staff-count.test.mjs` |
| IT-STORE-PENDING-* | `storeMonthlyPendingCount.test.mjs` |
| IT-STORE-FILTER-001/002 | `form-engine.test.mjs` |
......@@ -91,4 +97,4 @@
## 维护
门店 schema / 配置中心模版变更时,同步本文档、`schema-store-daily-full.js`、PAGES.md 门店节、DEVLOG.md。见 [MAINTENANCE.md](./MAINTENANCE.md)。
门店 schema / 配置中心模版变更时,同步本文档、`schema-store-daily-v2.1.1.js/json`、三套模板单测、PAGES.md 门店节、DEVLOG.md。mock baseline 仍维护 `schema-store-daily-full.js`。见 [MAINTENANCE.md](./MAINTENANCE.md)、[excel转js模板配置说明.md](./excel转js模板配置说明.md)。
......@@ -199,74 +199,64 @@ engine.init(schema, pageContext) // 页面主路径; setPageContext 仅测试/
## 6. 显隐规则引擎
实现入口:[`form-engine/visibility/specs/index.js`](../form-engine/visibility/specs/index.js) 组合 **detailEcho → fieldShowRule → baseScene → brand** 四段 spec。与 [`staff-template-features.md`](./staff-template-features.md)、[`store-template-features.md`](./store-template-features.md) 一致。
> **`field.sceneType` 说明**:schema 上的 `sceneType` 数组为配置中心/模版标注(轻改=1、延保/权益=0),便于区分子字段业务大类;**运行时显隐不读取 `ctx.sceneType`**,轻改/延保/权益分行靠 `field.baseSceneCode` 与商户 `sceneList` 交集。
### 6.1 算法流程
```mermaid
flowchart TD
Start[计算字段是否可见] --> AttendanceCheck{"非 F1-1 且未选在岗?"}
AttendanceCheck -- 是 --> Hidden[隐藏并清值 destroy]
AttendanceCheck -- 否 --> SceneCodeCheck{field.baseSceneCode 非空?}
SceneCodeCheck -- 是 --> SceneCodeMatch{"ctx.baseSceneCode in field.baseSceneCode?"}
SceneCodeCheck -- 否 --> SceneTypeCheck
SceneCodeMatch -- 否 --> Hidden
SceneCodeMatch -- 是 --> SceneTypeCheck{field.sceneType 非空?}
SceneTypeCheck -- 是 --> SceneTypeMatch{"ctx.sceneType in field.sceneType?"}
SceneTypeCheck -- 否 --> BrandCheck
SceneTypeMatch -- 否 --> Hidden
SceneTypeMatch -- 是 --> BrandCheck{field.brandId 非空?}
BrandCheck -- 是 --> BrandMatch{"field.brandId 与 ctx.brandIds 有交集?"}
BrandCheck -- 否 --> Visible[显示]
BrandMatch -- 否 --> Hidden
BrandMatch -- 是 --> Visible
Start[计算字段是否可见] --> EchoCheck{detailEchoSpec}
EchoCheck -->|false| Hidden[隐藏并清值]
EchoCheck -->|true| BaseOnly[仅 baseSceneSpec divider/baseSceneCode]
EchoCheck -->|null 继续| ShowRule{fieldShowRuleSpec rules.keys+result}
ShowRule -->|false| Hidden
ShowRule -->|true| BaseScene{baseSceneSpec}
BaseScene -->|false| Hidden
BaseScene -->|true| Brand{brandSpec brandId/filterBrandId}
Brand -->|false| Hidden
Brand -->|true| Visible[显示]
```
**divider**(`type:'divider'`)不走 `baseSceneCode`,走 [`isDividerVisible`](../form-engine/visibility.js):`isYB`/`isQY`/`ybCode`/`qyCode`/`qgCode` 与商户 `sceneList` 互斥组合(F2-91/92/93/94)。
### 6.2 规则说明
1. **出勤联动(全局)**:除 `F1-1` 外,当未选中「在岗」选项时(以 schema `options` 的 value 为准,如 `"调休"`),其余字段隐藏并清值;引擎 [`isAttendanceOnDuty`](../../form-engine/radio-value.js) 兼容 legacy `'1'`/`'2'`。
2. **baseSceneCode**:字段数组非空时,要求 `ctx.baseSceneCode` 落在字段数组内。
3. **sceneType**:字段数组非空时,要求 `ctx.sceneType` 落在字段数组内。
4. **brandId**:字段数组非空时,要求 `field.brandId` 与 `ctx.brandIds` **至少有一个交集**。
1. **详情回显(`detailEchoSpec`)**:编辑态且字段在 `echoSubformKeys`/`echoTopLevelKeys` 内时,**跳过 brand/filterBrandId**;divider 仍走场景规则;**仍校验 baseSceneCode**;出勤 gate 字段在调休时不因 echo 强制展示。
2. **字段联动(`fieldShowRuleSpec`)**:字段 `rules.keys` + `rules.result` 表达式为 false 时隐藏(如 `val1 == "在岗"`)。**无 keys/result 的字段不受出勤联动**——`F1-4` 备注调休仍可见。引擎 [`radio-value.js`](../form-engine/radio-value.js) 兼容 legacy `'1'`/`'2'` 与中文 `"在岗"`/`"调休"`。
3. **场景码(`baseSceneSpec`)**:非 divider 且 `baseSceneCode` 非空时,要求与商户 **`sceneList` 聚合码**(`getEffectiveSceneCodes`)有交集;**不是**单值 `ctx.baseSceneCode` 包含判断。
4. **品牌(`brandSpec`)**:`brandId` 非空时与 `ctx.brandIds` 有交集;`filterBrandId` 非空且商户经营品牌**全部**落在列表内时隐藏(如 F1-11、F2-11 其他品牌)。
5. **空数组 `[]`**:该维度跳过,不做限制。
6. **group**:group 自身先算可见性;可见才渲染 `children[0]`;子字段递归执行同一算法。
7. **重算触发**:`F1-1` 变更时全量重算;`PageContext` 变更时全量重算。
6. **group / subform**:容器自身先算可见性;可见才渲染 children;子字段/子列递归同一 spec 链。subform 行内可选 `childrenShowRules`(见 [group-repeater.md](./group-repeater.md))。
7. **重算触发**:`F1-1` 或任意带 `rules.keys` 的字段变更、以及 `PageContext` 变更时全量重算可见列表。
### 6.3 伪代码
**不在引擎 eval 的 schema 字段**(由页面等价实现):
```js
const ATTENDANCE_KEY = 'F1-1'
// 以 isAttendanceOnDuty(list, values) 为准,勿硬编码 '1'
| 模版字段 | 等价实现 |
| --- | --- |
| F2-1 `completeFun` → F2-2 | [`store-staff-count.js`](../utils/store-staff-count.js) |
| F2-2 `disabledFun` | F2-1 有选人时 F2-2 字段级 disabled |
function hasIntersection(a, b) {
return a.some(id => b.includes(id))
}
### 6.3 伪代码
function isFieldVisible(field, ctx, values) {
if (field.key !== ATTENDANCE_KEY && !isAttendanceOnDuty(list, values)) {
return false
}
if (field.baseSceneCode.length > 0 && !field.baseSceneCode.includes(ctx.baseSceneCode)) {
return false
}
if (field.sceneType.length > 0 && !field.sceneType.includes(ctx.sceneType)) {
return false
}
if (field.brandId.length > 0 && !hasIntersection(field.brandId, ctx.brandIds)) {
return false
}
```js
function isFieldVisibleBySpecs(field, ctx, values, options) {
const echo = detailEchoSpec(field, ctx, values, options)
if (echo === false) return false
if (echo === true) return baseSceneSpec(field, ctx, values, options)
if (!fieldShowRuleSpec(field, ctx, values, options)) return false
if (!baseSceneSpec(field, ctx, values, options)) return false
if (!brandSpec(field, ctx, values, options)) return false
return true
}
/** 递归收集所有叶子字段(不含 group) */
function flattenFields(list) {
const result = []
for (const field of list) {
if (field.type === 'group' && field.children?.[0]) {
result.push(...flattenFields(field.children[0]))
} else if (field.type !== 'group') {
result.push(field)
}
}
return result
function matchesBaseSceneCode(field, ctx) {
const fieldCodes = normalizeSceneCodeList(field.baseSceneCode)
if (!fieldCodes.length) return true
const merchantCodes = getMerchantSceneCodes(ctx.sceneList)
const effective = merchantCodes.length ? merchantCodes : normalizeSceneCodeList(ctx.baseSceneCode)
return fieldCodes.some(code => effective.includes(code))
}
```
......@@ -275,11 +265,17 @@ function flattenFields(list) {
| 字段 | 可见条件(简述) |
| --- | --- |
| `F1-1` 今日出勤 | 始终可见 |
| `F1-2` 延保退单数 | 在岗 + sceneType=0 + baseSceneCode∈{110201,110202} |
| `F1-5` 问界分组 | 在岗 + brandIds 含 3454 + sceneType∈{0,1} + baseSceneCode 匹配 |
| `F1-5-1` 轻改大定触客 | group 可见 + sceneType=1 + baseSceneCode∈轻改场景 |
| `F1-5-4` 延保售前触客 | group 可见 + sceneType=0 + baseSceneCode∈延保场景 |
| `F1-11` 其他品牌 | 在岗 + (brandIds 无固定映射时的业务逻辑,schema 中 brandId/baseSceneCode 均为 `[]`) |
| `F1-2` 延保退单数 | `rules.result` 在岗 + baseSceneCode∩sceneList 含延保码 |
| `F1-4` 备注 | 无 `rules.keys`;调休仍可见 |
| `F1-5` 问界分组 | `rules.result` 在岗 + brandIds 含 3454 + baseSceneCode 匹配 |
| `F1-5-1` 轻改大定触客 | group 可见 + baseSceneCode∈{100101,100102,100103} |
| `F1-5-4` 延保售前触客 | group 可见 + baseSceneCode∈{110201,110202} |
| `F1-11` 其他品牌 | `rules.result` 在岗 + `filterBrandId`(非六界/岚图时展示) |
| `F2-91` 延保 divider | 商户有延保码且无权益码 |
| `F2-92` 权益 divider | 商户有权益码且无延保码 |
| `F2-94` 延保/权益 divider | 商户同时有延保码与权益码 |
完整字段速查见 [daily-report-template-config-summary.md](./daily-report-template-config-summary.md)。
---
......@@ -293,14 +289,17 @@ function flattenFields(list) {
| `integer` | boolean | `true` 时必须为整数 |
| `decimal` | boolean | `true` 时允许小数(金额字段) |
| `maxLength` | number | 文本最大长度 |
| `unit` | string | 单位展示,如 `"元"`(不参与校验,仅 UI) |
| `keys` | string[] | 联动显隐依赖字段 key(如 `['F1-1']`) |
| `result` | string | 联动表达式(如 `val1 == "在岗"`),由 `fieldShowRuleSpec` eval |
`unit`(如 `"元"`)为**字段顶层属性**,不放在 `rules` 内。
### 规则组合示例
| 产品文案 | rules |
| --- | --- |
| 仅允许输入大于等于0的整数 | `{ "min": 0, "integer": true }` |
| 金额,大于等于0,两位小数 | `{ "min": 0, "decimal": true, "unit": "元" }` |
| 金额,大于等于0,两位小数 | 字段 `unit: "元"` + `{ "min": 0, "decimal": true }` |
| 输入不超过100字 | `{ "maxLength": 100 }` |
| 无额外规则 | `{}` |
......
{
"daily": {
"问界": 3454,
"享界": 3503,
"智界": 3458,
"尚界": 3574,
"尊界": 3502,
"岚图": 3067
},
"production": {
"问界": 2695,
"享界": 2741,
"智界": 2698,
"尚界": 2797,
"尊界": 2740,
"岚图": 2188
}
}
/**
* @file 日报模版 brandId 双环境映射(测试 daily / 生产 production)。
* 测试 ID 来自 Excel 转换脚本;生产 ID 对齐线上洽谈明细 brandIdMap。
* 供 remap 脚本、单测与 convert 脚本 sidecar 引用。
*/
/** @type {Record<'daily' | 'production', Record<string, number>>} */
export const BRAND_NAME_TO_ID = {
daily: {
问界: 3454,
享界: 3503,
智界: 3458,
尚界: 3574,
尊界: 3502,
岚图: 3067
},
production: {
问界: 2695,
享界: 2741,
智界: 2698,
尚界: 2797,
尊界: 2740,
岚图: 2188
}
}
/** 鸿蒙五界 brandId 列表(不含岚图) */
export const FIVE_REALM_BRAND_IDS = {
daily: [
BRAND_NAME_TO_ID.daily.问界,
BRAND_NAME_TO_ID.daily.享界,
BRAND_NAME_TO_ID.daily.智界,
BRAND_NAME_TO_ID.daily.尚界,
BRAND_NAME_TO_ID.daily.尊界
],
production: [
BRAND_NAME_TO_ID.production.问界,
BRAND_NAME_TO_ID.production.享界,
BRAND_NAME_TO_ID.production.智界,
BRAND_NAME_TO_ID.production.尚界,
BRAND_NAME_TO_ID.production.尊界
]
}
/** 五界 + 岚图,对齐 F3-3 / F1-11 / F2-11 filterBrandId */
export const FILTER_BRAND_IDS = {
daily: [...FIVE_REALM_BRAND_IDS.daily, BRAND_NAME_TO_ID.daily.岚图],
production: [...FIVE_REALM_BRAND_IDS.production, BRAND_NAME_TO_ID.production.岚图]
}
/**
* 构建 fromEnv → toEnv 的 brandId 数值替换表。
* @param {'daily' | 'production'} fromEnv
* @param {'daily' | 'production'} toEnv
* @returns {Record<number, number>}
*/
export function buildBrandIdRemap(fromEnv = 'daily', toEnv = 'production') {
const fromMap = BRAND_NAME_TO_ID[fromEnv]
const toMap = BRAND_NAME_TO_ID[toEnv]
const remap = {}
for (const name of Object.keys(fromMap)) {
remap[fromMap[name]] = toMap[name]
}
return remap
}
/**
* 替换 brandId / filterBrandId 数组中的 ID。
* @param {number[]} ids
* @param {Record<number, number>} remap
* @returns {number[]}
*/
export function remapBrandIdArray(ids, remap) {
if (!Array.isArray(ids) || ids.length === 0) return ids
return ids.map(id => {
if (id in remap) return remap[id]
return id
})
}
/**
* 深度遍历 schema list,就地替换 brandId / filterBrandId。
* @param {object[]} list
* @param {Record<number, number>} remap
*/
export function remapSchemaBrandIds(list, remap) {
function walk(field) {
if (!field || typeof field !== 'object') return
if (Array.isArray(field.brandId) && field.brandId.length) {
field.brandId = remapBrandIdArray(field.brandId, remap)
}
if (Array.isArray(field.filterBrandId) && field.filterBrandId.length) {
field.filterBrandId = remapBrandIdArray(field.filterBrandId, remap)
}
const children = field.children
if (!Array.isArray(children)) return
for (const child of children) {
if (Array.isArray(child)) {
child.forEach(walk)
} else {
walk(child)
}
}
}
for (const field of list || []) {
walk(field)
}
}
/**
* 生成 JS fixture 文件头 brandIdMap 注释块。
* @param {'daily' | 'production'} env
* @returns {string}
*/
export function buildFileHeaderComment(env = 'production') {
const map = BRAND_NAME_TO_ID[env]
const lines = [
'// const baseSceneCode = {',
"// '1.1': 100101, //精品升级",
"// '1.2': 100102, //次新车升配",
"// '1.3': 100103, //售后众筹",
"// '2.1.1': 110101, //售前会员权益升级",
"// '2.1.2': 110102, //售后会员权益升级",
"// '2.3.1': 110201, //售前延保",
"// '2.3.2': 110202, //售后延保",
'// }',
'// const sceneType = {',
"// '延保': 0,",
"// '权益': 0,",
"// '轻改': 1,",
'// }',
'// const brandIdMap = {'
]
for (const [name, id] of Object.entries(map)) {
lines.push(`// '${name}': ${id},`)
}
lines.push('// }')
return lines.join('\n')
}
......@@ -41,7 +41,7 @@ module.exports = {
}
},
"2": {
"label": "延保 / 权益",
"label": "延保/权益",
"sortNum": "3",
"key": "F2-94",
"type": "divider",
......@@ -92,6 +92,10 @@ module.exports = {
0
],
"brandId": [],
"ybCode": [
110201,
110202
],
"qyCode": [
110101,
110102
......
{
"fileHeader": "// const baseSceneCode = {\n// '1.1': 100101, //精品升级\n// '1.2': 100102, //次新车升配\n// '1.3': 100103, //售后众筹\n// '2.1.1': 110101, //售前会员权益升级\n// '2.1.2': 110102, //售后会员权益升级\n// '2.3.1': 110201, //售前延保\n// '2.3.2': 110202, //售后延保\n// }\n// const sceneType = {\n// '延保': 0,\n// '权益': 0,\n// '轻改': 1,\n// }\n// const brandIdMap = {\n// '问界': 3454,\n// '享界': 3503,\n// '智界': 3458,\n// '尚界': 3574,\n// '尊界': 3502,\n// '岚图': 3067\n// }",
"jsDoc": "/**\n * label 表单组件名称\n * key 编号\n * sortNum 排序\n * type 表单组件类型\n * required 必填\n * sceneType 业务大类 \n * brandId 门店经营品牌限制\n * baseSceneCode 显隐条件里的场景\n * options 选项数据\n * rules 其他规则\n * */",
"fields": {
"F1-11": {
"propInline": {
"filterBrandId": "//问界、尚界、尊界、智界、享界、岚图 不是其他品牌"
}
},
"F2-94": {
"propBefore": {
"ybCode": ["// baseSceneCode: [110201, 110202, 110101, 110102]"]
},
"omitProps": ["baseSceneCode"]
},
"F2-91": {
"propBefore": {
"isYB": [
"// '2.1.1': 110101, //售前会员权益升级",
"// '2.1.2': 110102, //售后会员权益升级",
"// '2.3.1': 110201, //售前延保",
"// '2.3.2': 110202, //售后延保"
]
},
"propInline": {
"ybCode": "//[场景 包含 2.3.1 or 2.3.2] 且 [场景 不包含 2.1.1 or 2.1.2] 则 [显示]"
},
"propBeforeRules": ["// baseSceneCode: [110201, 110202]"],
"omitProps": ["baseSceneCode"]
},
"F2-92": {
"propBefore": {
"isQY": [
"// '2.1.1': 110101, //售前会员权益升级",
"// '2.1.2': 110102, //售后会员权益升级",
"// '2.3.1': 110201, //售前延保",
"// '2.3.2': 110202, //售后延保"
]
},
"propInline": {
"qyCode": "//[场景 包含 2.1.1 or 2.1.2] 且 [场景 不包含 2.3.1 or 2.3.2] 则 [显示]"
},
"propBeforeRules": ["// baseSceneCode: [110101, 110102]"],
"omitProps": ["baseSceneCode"]
}
}
}
......@@ -508,7 +508,9 @@ function extractMultipleSelectIdsAndLabels(raw, field = {}) {
if (id !== '') {
ids.push(String(id))
}
names.push(name || String(id))
if (name && !isMultipleSelectIdLikeLabel(name, id)) {
names.push(name)
}
}
return
}
......@@ -518,7 +520,10 @@ function extractMultipleSelectIdsAndLabels(raw, field = {}) {
}
ids.push(str)
const matched = findStaticOption(field, str)
names.push(matched?.label ?? matched?.name ?? str)
const label = matched?.label ?? matched?.name
if (label && !isMultipleSelectIdLikeLabel(label, str)) {
names.push(label)
}
})
return { ids, displayLabel: names.filter(part => part != null && part !== '').join('/') }
}
......@@ -535,12 +540,59 @@ function splitMultipleSelectDisplayLabel(value) {
return trimmed.split('/').map(part => part.trim()).filter(part => part !== '')
}
/** 展示名是否实为 id(jsonContent 误把 uuid 当 value 时不作为 label) */
function isMultipleSelectIdLikeLabel(label, id = '') {
if (label == null || label === '') {
return true
}
return String(label) === String(id)
}
/** `/` 展示串是否含至少一段真实姓名(非 id) */
function hasRealMultipleSelectDisplayNames(ids = [], displayLabel = '') {
const names = splitMultipleSelectDisplayLabel(displayLabel)
if (!names.length) {
return false
}
return names.some((name, index) => !isMultipleSelectIdLikeLabel(name, ids[index]))
}
/** 保存前剔除与 id 相同的展示段 */
function sanitizeMultipleSelectSlashLabel(ids = [], displayLabel = '') {
if (typeof displayLabel !== 'string' || displayLabel === '') {
return ''
}
const parts = displayLabel
.trim()
.split('/')
.map(part => part.trim())
const sanitized = ids
.map((id, index) => {
const part = parts[index]
if (part == null || part === '' || isMultipleSelectIdLikeLabel(part, id)) {
return ''
}
return part
})
.filter(Boolean)
return sanitized.join('/')
}
function zipMultipleSelectIdsWithDisplayLabel(ids = [], displayLabel = '') {
const names = splitMultipleSelectDisplayLabel(displayLabel)
return ids.map((id, index) => ({
id: String(id),
name: names[index] != null && names[index] !== '' ? names[index] : String(id)
}))
return ids.map((id, index) => {
const idStr = String(id)
const namePart = names[index]
const entry = { id: idStr }
if (
namePart != null &&
namePart !== '' &&
!isMultipleSelectIdLikeLabel(namePart, idStr)
) {
entry.name = namePart
}
return entry
})
}
function resolveMultipleSelectEngineValueFromAppField(field = {}) {
......@@ -555,7 +607,7 @@ function resolveMultipleSelectEngineValueFromAppField(field = {}) {
return coerceMultipleSelectValue(meta)
}
const displayNames = splitMultipleSelectDisplayLabel(field.value)
if (displayNames.length) {
if (displayNames.length && hasRealMultipleSelectDisplayNames(meta, field.value)) {
return zipMultipleSelectIdsWithDisplayLabel(meta, field.value)
}
return meta.map(id => String(id))
......@@ -1336,7 +1388,7 @@ export function formatFieldForAppJsonContent(field = {}, options = {}) {
return next
}
next[key] = ids
next.value = displayLabel
next.value = sanitizeMultipleSelectSlashLabel(ids, displayLabel)
return next
}
......
/**
* multipleSelect 展示名解析 — 纯函数,供组件回显与 jsonContent 编解码共用
* @see packageDynamicForm/docs/field-options-api.md
*/
/**
* 展示名是否实为 id(jsonContent 误把 uuid 写入 value 时不应作为 label)
* @param {*} label 候选展示名
* @param {*} [id] 对应选项 id
* @returns {boolean}
*/
function isMultipleSelectIdLikeLabel(label, id = '') {
if (label == null || label === '') {
return true
}
return String(label) === String(id)
}
/**
* 解析 multipleSelect 单选项展示文案;optionsKey 未匹配时不回退 id
* @param {Object} [params]
* @param {string} params.selectedKey 选中 id
* @param {*} [params.rawItem] 引擎值中的原始项
* @param {Object} [params.matched] 已加载 options 中的匹配项
* @param {boolean} [params.hasOptionsKey] 是否远程 optionsKey 字段
* @returns {string}
*/
function resolveMultipleSelectItemDisplayLabel({
selectedKey,
rawItem,
matched,
hasOptionsKey = false
} = {}) {
if (rawItem != null && typeof rawItem === 'object') {
const name = rawItem.name || rawItem.label
if (name && !isMultipleSelectIdLikeLabel(name, selectedKey)) {
return String(name)
}
}
if (matched?.label) {
return String(matched.label)
}
return hasOptionsKey ? '' : String(selectedKey || '')
}
/**
* `/` 拼接展示串中剔除与 id 相同的段(保存入库前防御)
* @param {Array<string>} [ids=[]]
* @param {string} [displayLabel='']
* @returns {string}
*/
function sanitizeMultipleSelectSlashLabel(ids = [], displayLabel = '') {
if (typeof displayLabel !== 'string' || displayLabel === '') {
return ''
}
const parts = displayLabel
.trim()
.split('/')
.map(part => part.trim())
const sanitized = ids
.map((id, index) => {
const part = parts[index]
if (part == null || part === '' || isMultipleSelectIdLikeLabel(part, id)) {
return ''
}
return part
})
.filter(Boolean)
return sanitized.join('/')
}
/** App jsonContent 双 key:`value` 为 `/` 拼接展示串 */
function splitMultipleSelectDisplayLabel(value) {
if (typeof value !== 'string' || value === '') {
return []
}
const trimmed = value.trim()
if (trimmed.startsWith('[')) {
return []
}
return trimmed.split('/').map(part => part.trim()).filter(part => part !== '')
}
/** `/` 展示串是否含至少一段真实姓名(非 id) */
function hasRealMultipleSelectDisplayNames(ids = [], displayLabel = '') {
const names = splitMultipleSelectDisplayLabel(displayLabel)
if (!names.length) {
return false
}
return names.some((name, index) => !isMultipleSelectIdLikeLabel(name, ids[index]))
}
/** id 数组 + `/` 展示串 → `{ id, name? }[]`(不把 id 当 name) */
function zipMultipleSelectIdsWithDisplayLabel(ids = [], displayLabel = '') {
const names = splitMultipleSelectDisplayLabel(displayLabel)
return ids.map((id, index) => {
const idStr = String(id)
const namePart = names[index]
const entry = { id: idStr }
if (
namePart != null &&
namePart !== '' &&
!isMultipleSelectIdLikeLabel(namePart, idStr)
) {
entry.name = namePart
}
return entry
})
}
module.exports = {
isMultipleSelectIdLikeLabel,
resolveMultipleSelectItemDisplayLabel,
sanitizeMultipleSelectSlashLabel,
splitMultipleSelectDisplayLabel,
hasRealMultipleSelectDisplayNames,
zipMultipleSelectIdsWithDisplayLabel
}
......@@ -55,8 +55,10 @@ export function normalizeMultipleSelectValuesInMap(list = [], values = {}) {
}
if (typeof module !== 'undefined' && module.exports) {
const displayHelpers = require('./multiple-select-display.helpers.js')
module.exports = {
coerceMultipleSelectValue,
normalizeMultipleSelectValuesInMap
normalizeMultipleSelectValuesInMap,
...displayHelpers
}
}
......@@ -175,6 +175,38 @@ const dailyReportPageMethods = {
...pageContext,
initialValues: initialValues || {}
})
},
/**
* 首屏 applyEngineView 后,空闲时后台刷新 brand/scene/schema 缓存(不热更新 UI)
* @param {Object} api 日报 API 门面(须含 revalidateCachedMetadata)
* @param {Object} params userContext、baseSceneCode、reportTemplateId
* @param {number} loadSeq 当前 loadSeq,过期则放弃
* @returns {void}
*/
scheduleMetadataCacheRevalidate(api, params, loadSeq) {
if (this._metadataRevalidateTimer) {
clearTimeout(this._metadataRevalidateTimer)
this._metadataRevalidateTimer = null
}
const run = () => {
this._metadataRevalidateTimer = null
if (this.isStaleLoad(loadSeq)) {
return
}
if (!api || typeof api.revalidateCachedMetadata !== 'function') {
return
}
api.revalidateCachedMetadata(params).catch(() => {})
}
const schedule = () => {
this._metadataRevalidateTimer = setTimeout(run, 0)
}
if (typeof wx !== 'undefined' && typeof wx.nextTick === 'function') {
wx.nextTick(schedule)
} else {
schedule()
}
}
}
......
......@@ -14,7 +14,11 @@ const { parseGroupErrorKey } = require('../../form-engine/group-values.js')
const negotiationApi = require('../../api/negotiationDailyReport.js')
const { loadNegotiationDailyForm } = require('../../services/negotiationDailyFormLoader.js')
const { isApiSuccess } = require('../../utils/api-response.js')
const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-state.js')
const { buildDailyReportRequestContext } = require('../../utils/daily-report-request-context.js')
const { isDailyReportFormDisabled, resolveReportSubmittedPatch } = require('../../utils/daily-report-edit-state.js')
const {
isDateWithinDailyReportEditableWindow
} = require('../../utils/daily-report-editable-window.js')
const vinOcrBridge = require('../../services/vinOcrBridge.js')
const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js')
const carBrandPickerBridge = require('../../services/carBrandPickerBridge.js')
......@@ -51,6 +55,7 @@ const {
buildVinApiValidMapFromEntries
} = require('../../form-engine/vin-api-valid-tracker.js')
const dailyReportPage = require('../behaviors/dailyReportPage.js')
const dailyReportPageMethods = require('../behaviors/dailyReportPageMethods.js')
const { applyCustomersToEngine } = require('../../services/negotiationCustomerImport.js')
const { hasPlanImportDateMarker } = require('../../form-engine/plan-import-date-value.js')
const {
......@@ -69,6 +74,7 @@ Page({
reportDate: '',
weeklyList: [],
isTodayReport: true,
isDateWithinEditableWindow: false,
reportStatus: '0',
isReportSubmitted: false,
isEditReport: false,
......@@ -101,6 +107,7 @@ Page({
dailyReportRecordId: null,
userContext: null,
pageContext: null,
_pageContextSnapshot: null,
loadSeq: 0,
refreshSeq: 0,
engineKey: '',
......@@ -135,7 +142,16 @@ Page({
})
},
/** 根据 selectWeek 计算 reportDate、isTodayReport、formDisabled */
/** 按 reportDate 重算可编辑窗口(相对今天 ±29 天) */
refreshEditableWindowState(reportDate = this.data.reportDate) {
const isDateWithinEditableWindow = reportDate
? isDateWithinDailyReportEditableWindow(reportDate)
: false
Object.assign(this.data, { isDateWithinEditableWindow })
return { isDateWithinEditableWindow, formDisabled: this.getFormDisabled() }
},
/** 根据 selectWeek 计算 reportDate、isTodayReport、可编辑窗口 */
buildCalendarState(selectWeek, timeBeanInput) {
const timeBean = timeBeanInput || timeUtil.getWeekDayList(selectWeek)
const selectDay = timeBean.selectDay ?? 0
......@@ -145,12 +161,16 @@ Page({
timeBean.yearMonth = `${time.getFullYear()}-${time.getMonth() + 1}`
}
const isTodayReport = date ? timeUtil.isTodayReport(date) : true
return {
const base = {
timeBean,
selectWeek,
reportDate: date,
isTodayReport,
formDisabled: !isTodayReport
isTodayReport
}
Object.assign(this.data, base)
return {
...base,
...this.refreshEditableWindowState(date)
}
},
......@@ -175,15 +195,36 @@ Page({
return state
},
/** 非当天只读;当天已提交且未点编辑时只读 */
/** 可编辑窗外只读;已提交且未点编辑时只读 */
getFormDisabled() {
return isDailyReportFormDisabled({
isTodayReport: this.data.isTodayReport,
isDateWithinEditableWindow: this.data.isDateWithinEditableWindow,
isReportSubmitted: this.data.isReportSubmitted,
isEditReport: this.data.isEditReport
})
},
/** 从 detail + weeklyList 同步提交态,并重算可编辑窗口 */
syncReportSubmittedState(detail = {}) {
const patch = resolveReportSubmittedPatch({
detail,
reportDate: this.data.reportDate,
weeklyList: this.data.weeklyList || []
})
Object.assign(this.data, patch)
Object.assign(patch, this.refreshEditableWindowState())
this.setData(patch)
return patch.isReportSubmitted
},
/** 进入编辑态(可编辑窗外不可解锁) */
editReport() {
if (!this.data.isDateWithinEditableWindow) {
return wx.$util.showToast('已超过提交时效')
}
dailyReportPageMethods.editReport.call(this)
},
/** 复制当前 subform 各 group 的活跃行索引 */
getGroupActiveIndexMap() {
return { ...(this.data.groupActiveIndex || {}) }
......@@ -455,20 +496,28 @@ Page({
return negotiationApi.normalizeUserInfo(userInfo)
},
/** 解析 engine / load 快照,供 requestContext 透出场景码(AppData 可见) */
resolvePageContextForRequest() {
return (
this.engine?.getPageContext?.() ||
this._pageContextSnapshot ||
this.pageContext ||
{}
)
},
/** 透传给 select/multipleSelect 的 optionsKey 请求上下文(含 sceneType) */
buildFormRequestContext() {
const ctx = this.userContext || this.getRequestContext()
const userInfo = wx.$util?.getUserInfo?.() || {}
return {
merchantId: ctx.merchantId || '',
yqMerchantId: ctx.yqMerchantId || '',
staffUuid: ctx.staffUuid || '',
reportDate: this.data.reportDate || '',
return buildDailyReportRequestContext({
userContext: ctx,
userInfo,
reportDate: this.data.reportDate,
reportType: 'negotiation',
sceneType: userInfo.sceneType ?? ctx.sceneType ?? null,
sceneList: this.pageContext?.sceneList || [],
brandIds: this.pageContext?.brandIds || []
}
engineCtx: this.resolvePageContextForRequest(),
sceneTypeDefault: null
})
},
/** 主加载:Loader → engine.init → applyEngineView */
......@@ -493,6 +542,7 @@ Page({
}
const { pageContext, schema, detail, initialValues } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.pageContext = pageContext || null
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null
......@@ -511,7 +561,16 @@ Page({
loadError: ''
})
this.applyEngineView(finalViewState, { structureChanged: true })
if (this.data.isTodayReport) {
this.scheduleMetadataCacheRevalidate(
negotiationApi,
{
userContext,
baseSceneCode: pageContext.baseSceneCode,
reportTemplateId: this.reportTemplateId
},
seq
)
if (this.data.isDateWithinEditableWindow) {
this.refreshTodayPlanCustomerCount()
} else {
this.setData({ todayPlanCustomerCount: 0 })
......@@ -544,8 +603,8 @@ Page({
return wx.$util.showToast('正在提交中,请稍候')
}
if (!this.engine) return
if (!this.data.isTodayReport) {
return wx.$util.showToast('仅支持填写当天日报')
if (!this.data.isDateWithinEditableWindow) {
return wx.$util.showToast('已超过提交时效')
}
if (this.data.isReportSubmitted && !this.data.isEditReport) {
return wx.$util.showToast('日报已提交,不可再编辑')
......@@ -616,11 +675,12 @@ Page({
if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues, pageContext } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.pageContext = pageContext || null
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail)
this.resetEditReport()
if (!this.engine) return
this.pageContext = pageContext || null
const viewState = this.reinitEngineFromLoadData({
pageContext,
schema,
......@@ -937,12 +997,13 @@ Page({
},
/**
* 拉取今日待接待客户数(入口条展示)
* 由 loadFormData 在 isTodayReport 为 true 时调用
* 拉取待接待客户数(入口条展示)
* 由 loadFormData 在可编辑窗口内调用,inviteDate 为周历选中日
*/
async refreshTodayPlanCustomerCount() {
const ctx = this.userContext || this.getRequestContext()
if (!ctx.merchantId || !ctx.staffUuid) {
const inviteDate = this.data.reportDate
if (!ctx.merchantId || !ctx.staffUuid || !inviteDate) {
this.setData({ todayPlanCustomerCount: 0 })
return
}
......@@ -950,7 +1011,7 @@ Page({
const res = await negotiationApi.fetchTodayPlanStoreCount({
merchantId: ctx.merchantId,
advanceUserId: ctx.staffUuid,
inviteDate: timeUtil.getTodayDateStr()
inviteDate
})
if (res.code === 0 && Number.isFinite(res.data)) {
this.setData({ todayPlanCustomerCount: res.data })
......@@ -960,9 +1021,9 @@ Page({
}
},
/** 打开今日计划到店客户弹层 */
/** 打开计划到店客户弹层(默认可编辑日内、默认日期为周历选中日) */
openTodayPlanCustomerPopup() {
if (this.data.formDisabled || !this.data.isTodayReport) return
if (this.data.formDisabled || !this.data.isDateWithinEditableWindow) return
const ctx = this.userContext || this.getRequestContext()
this.setData({
showTodayPlanPopup: true,
......
......@@ -33,7 +33,7 @@
enhanced
show-scrollbar="{{ false }}"
>
<view wx:if="{{ isTodayReport }}" class="today-plan-banner">
<view wx:if="{{ isDateWithinEditableWindow }}" class="today-plan-banner">
<view class="today-plan-banner__left">
<image class="today-plan-banner__icon" src="{{ todayPlanClassIconUrl }}" mode="aspectFit" />
<text class="today-plan-banner__text">今日待接待客户数</text>
......@@ -72,7 +72,7 @@
bind:groupchange="onGroupChange"
></dynamic-form>
<view class="btns">
<view class="btns-con btns-con--stack" wx:if="{{ isTodayReport }}">
<view class="btns-con btns-con--stack" wx:if="{{ isDateWithinEditableWindow }}">
<block wx:if="{{ !isReportSubmitted }}">
<view class="confirm text-center" bindtap="submit">提交</view>
</block>
......@@ -89,6 +89,7 @@
<today-plan-customer-popup
show="{{ showTodayPlanPopup }}"
anchor-date="{{ reportDate }}"
merchant-id="{{ todayPlanMerchantId }}"
advance-user-id="{{ todayPlanAdvanceUserId }}"
staff-name="{{ todayPlanStaffName }}"
......
......@@ -20,8 +20,12 @@ const {
resolveReportSubmittedPatch
} = require('../../utils/daily-report-edit-state.js')
const { resolveWeekStateForReportDate } = require('../../utils/daily-report-calendar.js')
const { buildDailyReportRequestContext } = require('../../utils/daily-report-request-context.js')
const dailyReportPage = require('../behaviors/dailyReportPage.js')
const dailyReportPageMethods = require('../behaviors/dailyReportPageMethods.js')
const {
isDateWithinDailyReportEditableWindow
} = require('../../utils/daily-report-editable-window.js')
Page({
behaviors: [dailyReportPage],
......@@ -33,7 +37,7 @@ Page({
reportDate: '',
weeklyList: [],
isTodayReport: true,
isDateWithin7Days: false,
isDateWithinEditableWindow: false,
reportStatus: '0',
isReportSubmitted: false,
isEditReport: false,
......@@ -57,6 +61,7 @@ Page({
reportTemplateId: null,
dailyReportRecordId: null,
userContext: null,
_pageContextSnapshot: null,
loadSeq: 0,
refreshSeq: 0,
engineKey: '',
......@@ -90,13 +95,13 @@ Page({
})
},
/** 按 reportDate 重算严格 7 天可编辑窗口 */
/** 按 reportDate 重算可编辑窗口(相对今天 ±29 天) */
refreshEditableWindowState(reportDate = this.data.reportDate) {
const isDateWithin7Days = reportDate
? timeUtil.isDateWithin7Days(reportDate)
const isDateWithinEditableWindow = reportDate
? isDateWithinDailyReportEditableWindow(reportDate)
: false
Object.assign(this.data, { isDateWithin7Days })
return { isDateWithin7Days, formDisabled: this.getFormDisabled() }
Object.assign(this.data, { isDateWithinEditableWindow })
return { isDateWithinEditableWindow, formDisabled: this.getFormDisabled() }
},
/** 根据 selectWeek 计算 reportDate、可编辑窗口、formDisabled */
......@@ -143,10 +148,10 @@ Page({
return state
},
/** 7 天外只读;已提交且未点编辑时只读 */
/** 可编辑窗外只读;已提交且未点编辑时只读 */
getFormDisabled() {
return isDailyReportFormDisabled({
isDateWithinEditableWindow: this.data.isDateWithin7Days,
isDateWithinEditableWindow: this.data.isDateWithinEditableWindow,
isReportSubmitted: this.data.isReportSubmitted,
isEditReport: this.data.isEditReport
})
......@@ -165,9 +170,9 @@ Page({
return patch.isReportSubmitted
},
/** 进入编辑态(7 天外不可解锁) */
/** 进入编辑态(可编辑窗外不可解锁) */
editReport() {
if (!this.data.isDateWithin7Days) {
if (!this.data.isDateWithinEditableWindow) {
return wx.$util.showToast('已超过提交时效')
}
dailyReportPageMethods.editReport.call(this)
......@@ -332,17 +337,25 @@ Page({
return staffDailyApi.normalizeUserInfo(userInfo)
},
/** 解析 engine / load 快照,供 requestContext 透出场景码(AppData 可见) */
resolvePageContextForRequest() {
return (
this.engine?.getPageContext?.() ||
this._pageContextSnapshot ||
{}
)
},
/** 透传给 select/multipleSelect 的 optionsKey 请求上下文 */
buildFormRequestContext() {
const ctx = this.userContext || this.getRequestContext()
return {
merchantId: ctx.merchantId || '',
yqMerchantId: ctx.yqMerchantId || '',
staffUuid: ctx.staffUuid || '',
reportDate: this.data.reportDate || '',
return buildDailyReportRequestContext({
userContext: ctx,
reportDate: this.data.reportDate,
reportType: 'staff',
sceneType: ctx.sceneType ?? 0
}
engineCtx: this.resolvePageContextForRequest(),
sceneTypeDefault: 0
})
},
/** 主加载:Loader → engine.init → applyEngineView */
......@@ -368,6 +381,7 @@ Page({
}
const { pageContext, schema, detail, initialValues } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null
this.syncReportSubmittedState(detail)
......@@ -385,6 +399,15 @@ Page({
loadError: ''
})
this.applyEngineView(finalViewState, { structureChanged: true })
this.scheduleMetadataCacheRevalidate(
staffDailyApi,
{
userContext,
baseSceneCode: pageContext.baseSceneCode,
reportTemplateId: this.reportTemplateId
},
seq
)
} catch (error) {
if (this.isStaleLoad(seq)) return
console.error(error)
......@@ -413,7 +436,7 @@ Page({
return wx.$util.showToast('正在提交中,请稍候')
}
if (!this.engine) return
if (!this.data.isDateWithin7Days) {
if (!this.data.isDateWithinEditableWindow) {
return wx.$util.showToast('已超过提交时效')
}
if (this.data.isReportSubmitted && !this.data.isEditReport) {
......@@ -473,6 +496,7 @@ Page({
if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues, pageContext } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail)
this.resetEditReport()
......
......@@ -50,7 +50,7 @@
bind:groupnav="onGroupNav"
bind:groupchange="onGroupChange"
></dynamic-form>
<view class="btns" wx:if="{{ isDateWithin7Days }}">
<view class="btns" wx:if="{{ isDateWithinEditableWindow }}">
<view class="btns-con btns-con--stack">
<block wx:if="{{ !isReportSubmitted }}">
<view class="confirm text-center" bindtap="submit">提交</view>
......
......@@ -66,9 +66,13 @@
></dynamic-form>
<view class="btns">
<view class="btns-con btns-con--stack">
<block wx:if="{{ isTodayReport && !isReportSubmitted }}">
<view class="confirm text-center" bindtap="onSubmitTap">提交</view>
<view class="save text-center" bindtap="onSaveDraft">保存</view>
<block wx:if="{{ isDateWithinEditableWindow }}">
<view
wx:if="{{ isTodayReport && !isSubmissionReported }}"
class="confirm text-center"
bindtap="onSubmitTap"
>上报</view>
<view class="save text-center" bindtap="onSave">保存</view>
</block>
<view
wx:if="{{ isTodayReport }}"
......
#!/usr/bin/env node
/**
* @file 将 V2.1.1 daily fixture 的 brandId/filterBrandId 映射为生产环境 ID,输出 .prod.js / .prod.json。
* 结构与其余字段保持不变,供配置中心生产粘贴。
*
* 用法:
* node packageDynamicForm/scripts/remap-schema-brand-ids.mjs --sheet staff
* node packageDynamicForm/scripts/remap-schema-brand-ids.mjs --sheet store
*/
import { readFileSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import {
buildBrandIdRemap,
buildFileHeaderComment,
remapSchemaBrandIds
} from '../fixtures/brand-id-env-maps.mjs'
const __dirname = dirname(fileURLToPath(import.meta.url))
const PKG_ROOT = join(__dirname, '..')
const FIXTURES = join(PKG_ROOT, 'fixtures')
const SHEET_CONFIG = {
staff: {
dailyJson: 'schema-staff-daily-v2.1.1.json',
dailyJs: 'schema-staff-daily-v2.1.1.js',
prodJson: 'schema-staff-daily-v2.1.1.prod.json',
prodJs: 'schema-staff-daily-v2.1.1.prod.js'
},
store: {
dailyJson: 'schema-store-daily-v2.1.1.json',
dailyJs: 'schema-store-daily-v2.1.1.js',
prodJson: 'schema-store-daily-v2.1.1.prod.json',
prodJs: 'schema-store-daily-v2.1.1.prod.js'
}
}
/**
* 在 JS fixture 文本中替换 fileHeader 与数值 brandId(daily → production)。
* @param {string} jsText
* @param {Record<number, number>} remap
* @returns {string}
*/
function remapJsFixtureText(jsText, remap) {
const prodHeader = buildFileHeaderComment('production')
const headerEnd = jsText.indexOf('/**')
if (headerEnd === -1) {
throw new Error('JS fixture missing jsDoc block')
}
let out = prodHeader + '\n' + jsText.slice(headerEnd)
// 按 ID 降序替换,避免子串误伤(当前 ID 无重叠,仍做防御)
const entries = Object.entries(remap).sort((a, b) => Number(b[0]) - Number(a[0]))
for (const [from, to] of entries) {
const pattern = new RegExp(`\\b${from}\\b`, 'g')
out = out.replace(pattern, String(to))
}
return out
}
/**
* @param {'staff' | 'store'} sheet
*/
function remapSheet(sheet) {
const cfg = SHEET_CONFIG[sheet]
if (!cfg) {
throw new Error(`Unknown sheet: ${sheet}`)
}
const dailyJsonPath = join(FIXTURES, cfg.dailyJson)
const dailyJsPath = join(FIXTURES, cfg.dailyJs)
const prodJsonPath = join(FIXTURES, cfg.prodJson)
const prodJsPath = join(FIXTURES, cfg.prodJs)
const dailyPayload = JSON.parse(readFileSync(dailyJsonPath, 'utf8'))
const prodPayload = structuredClone(dailyPayload)
const remap = buildBrandIdRemap('daily', 'production')
remapSchemaBrandIds(prodPayload.list, remap)
writeFileSync(prodJsonPath, `${JSON.stringify(prodPayload, null, 2)}\n`, 'utf8')
const dailyJs = readFileSync(dailyJsPath, 'utf8')
const prodJs = remapJsFixtureText(dailyJs, remap)
writeFileSync(prodJsPath, prodJs, 'utf8')
console.log(`written ${prodJsonPath}`)
console.log(`written ${prodJsPath}`)
}
function main() {
const sheetArg = process.argv.find((_, i, arr) => arr[i - 1] === '--sheet')
const sheet = sheetArg || process.argv[2]
if (!sheet || !SHEET_CONFIG[sheet]) {
console.error('Usage: node remap-schema-brand-ids.mjs --sheet staff|store')
process.exit(1)
}
remapSheet(sheet)
}
main()
......@@ -5,7 +5,8 @@
var timeUtil = require('../../utils/timeFormat/time-utils.js')
const WEEK_CN = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const PLAN_STORE_DATE_RANGE_DAYS = 7
/** 弹层日期切换:相对锚点日过去/未来各 30 天 */
const PLAN_STORE_DATE_OFFSET_DAYS = 30
/**
* 解析 YYYY-MM-DD 为本地零点 Date
......@@ -39,12 +40,29 @@ function diffPlanStoreDaysFromToday(dateStr) {
}
/**
* 相对今天文案:今天/明天/昨天/N天前/N天后
* @param {string} dateStr
* 日期与锚点日相差天数(按本地日历,target - anchor)
* @param {string} dateStr YYYY-MM-DD
* @param {string} anchorDateStr YYYY-MM-DD
* @returns {number}
*/
function diffPlanStoreDaysFromAnchor(dateStr, anchorDateStr) {
const target = parsePlanStoreDate(dateStr)
const anchor = parsePlanStoreDate(anchorDateStr)
if (!target || !anchor) {
return 0
}
const oneDay = 24 * 60 * 60 * 1000
return Math.round((target.getTime() - anchor.getTime()) / oneDay)
}
/**
* 相对锚点日文案:今天/明天/昨天/N天前/N天后
* @param {string} dateStr 当前展示日
* @param {string} [anchorDateStr] 锚点日(周历选中日),默认今天
* @returns {string}
*/
function getPlanStoreDateTips(dateStr) {
const diff = diffPlanStoreDaysFromToday(dateStr)
function getPlanStoreDateTips(dateStr, anchorDateStr = timeUtil.getTodayDateStr()) {
const diff = diffPlanStoreDaysFromAnchor(dateStr, anchorDateStr)
if (diff === 0) return '今天'
if (diff === 1) return '明天'
if (diff === -1) return '昨天'
......@@ -56,58 +74,61 @@ function getPlanStoreDateTips(dateStr) {
}
/**
* 弹层日期展示:6月10日 周三 (今天)
* 弹层日期展示:YY-MM-DD 周X (今天);括号文案相对锚点日
* @param {string} dateStr YYYY-MM-DD
* @param {string} [anchorDateStr] 锚点日,默认今天
* @returns {string}
*/
function formatPlanStoreDateLabel(dateStr) {
function formatPlanStoreDateLabel(dateStr, anchorDateStr = timeUtil.getTodayDateStr()) {
const date = parsePlanStoreDate(dateStr)
if (!date) {
return dateStr || ''
}
const month = date.getMonth() + 1
const day = date.getDate()
const year = String(date.getFullYear()).slice(-2)
const month = `${date.getMonth() + 1}`.padStart(2, '0')
const day = `${date.getDate()}`.padStart(2, '0')
const week = WEEK_CN[date.getDay()] || ''
const tips = getPlanStoreDateTips(dateStr)
return `${month}月${day}日 ${week} (${tips})`
const tips = getPlanStoreDateTips(dateStr, anchorDateStr)
return `${year}-${month}-${day} ${week} (${tips})`
}
/**
* 是否可切换日期(前后各含今天共 7 天,偏移 ±6)
* 是否可切换日期(相对锚点日 ±PLAN_STORE_DATE_OFFSET_DAYS)
* @param {string} currentDateStr
* @param {number} offset -1 前一天 / +1 后一天
* @param {string} [anchorDateStr] 锚点日,默认今天
* @returns {boolean}
*/
function canShiftPlanStoreDate(currentDateStr, offset) {
function canShiftPlanStoreDate(currentDateStr, offset, anchorDateStr = timeUtil.getTodayDateStr()) {
const current = parsePlanStoreDate(currentDateStr)
if (!current || !offset) {
return false
}
const next = new Date(current)
next.setDate(next.getDate() + offset)
return isPlanStoreDateInRange(timeUtil.formatDateStr(next))
return isPlanStoreDateInRange(timeUtil.formatDateStr(next), anchorDateStr)
}
/**
* 判断日期是否在可选范围内(前后各含今天共 PLAN_STORE_DATE_RANGE_DAYS 天,偏移 ±(N-1))
* 判断日期是否在弹层可选范围内(相对锚点日 ±30 天)
* @param {string} dateStr
* @param {string} [anchorDateStr] 锚点日,默认今天
* @returns {boolean}
*/
function isPlanStoreDateInRange(dateStr) {
const diff = diffPlanStoreDaysFromToday(dateStr)
// 含当天共 N 天 → 前后各偏移 N-1
const maxOffset = PLAN_STORE_DATE_RANGE_DAYS - 1
return diff >= -maxOffset && diff <= maxOffset
function isPlanStoreDateInRange(dateStr, anchorDateStr = timeUtil.getTodayDateStr()) {
const diff = diffPlanStoreDaysFromAnchor(dateStr, anchorDateStr)
return diff >= -PLAN_STORE_DATE_OFFSET_DAYS && diff <= PLAN_STORE_DATE_OFFSET_DAYS
}
/**
* 切换日期
* @param {string} currentDateStr
* @param {number} offset
* @param {string} [anchorDateStr] 锚点日,默认今天
* @returns {string|null}
*/
function shiftPlanStoreDate(currentDateStr, offset) {
if (!canShiftPlanStoreDate(currentDateStr, offset)) {
function shiftPlanStoreDate(currentDateStr, offset, anchorDateStr = timeUtil.getTodayDateStr()) {
if (!canShiftPlanStoreDate(currentDateStr, offset, anchorDateStr)) {
return null
}
const current = parsePlanStoreDate(currentDateStr)
......@@ -146,9 +167,10 @@ function maskCustomerPhone(phone = '') {
}
module.exports = {
PLAN_STORE_DATE_RANGE_DAYS,
PLAN_STORE_DATE_OFFSET_DAYS,
parsePlanStoreDate,
diffPlanStoreDaysFromToday,
diffPlanStoreDaysFromAnchor,
getPlanStoreDateTips,
formatPlanStoreDateLabel,
canShiftPlanStoreDate,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!