Commit 83f2939e by 张立顺

feat 日报功能

1 parent 82f7121e
# Fix Daily Report Calendar Anchor Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Make `resolveWeekStateForReportDate(reportDate, now)` generate its week list from the same injected clock used to calculate the week offset.
**Architecture:** Reuse the existing `getWeekDayList(selectWeek, selectDay)` anchor parameter by passing the resolver's normalized `todayStr`. Keep all public signatures and production defaults unchanged, and use the existing calendar test as the regression test.
**Tech Stack:** Node.js 20 built-in test runner, CommonJS JavaScript, npm scripts, WeChat mini-program date utilities.
## Global Constraints
- Work on the current branch because the user explicitly requested a direct repair.
- Do not change `utils/timeFormat/time-utils.js` or its public signature.
- Do not freeze or mock global `Date`.
- Preserve production behavior when `now` is omitted.
- This small repair does not require a migration manifest.
---
### Task 1: Propagate the report calendar clock anchor
**Files:**
- Modify: `packageDynamicForm/utils/daily-report-calendar.js:36`
- Test: `packageDynamicForm/tests/daily-report-calendar.test.mjs`
**Interfaces:**
- Consumes: `resolveWeekStateForReportDate(reportDate: string, now?: Date)` and `timeUtil.getWeekDayList(selectWeek: number, selectDay?: string)`.
- Produces: unchanged `{ selectWeek, timeBean }`, with `timeBean.weekDayList[timeBean.selectDay].date` equal to the requested report date for the injected clock.
- [ ] **Step 1: Run the existing regression test and verify red**
Run: `node --test packageDynamicForm/tests/daily-report-calendar.test.mjs`
Expected: FAIL with actual system-clock-derived date `2026-08-05` instead of the injected-clock result `2026-06-10`.
- [ ] **Step 2: Implement the minimal anchor propagation**
Change the week-list construction to:
```js
const timeBean = timeUtil.getWeekDayList(selectWeek, todayStr)
```
Do not change offset or selected-day calculations.
- [ ] **Step 3: Verify the focused test is green**
Run: `node --test packageDynamicForm/tests/daily-report-calendar.test.mjs`
Expected: PASS with the selected date `2026-06-10`.
- [ ] **Step 4: Verify the dynamic-form suite**
Run: `npm run test:dynamicForm`
Expected: PASS with all currently discovered dynamic-form tests and zero failures.
- [ ] **Step 5: Verify the root test chain**
Run: `npm test`
Expected: the calendar blocker is absent. If a later independent suite fails, record that exact failure without attributing it to this repair.
- [ ] **Step 6: Inspect the patch**
Run: `git diff --check`, `git diff -- packageDynamicForm/utils/daily-report-calendar.js`, and `git status --short`.
Expected: one production-line change plus this plan document, with no whitespace errors.
# DEVLOG — packageDynamicForm # DEVLOG — packageDynamicForm
## 2026-08-13 — V2.3 客户编码与 VIN 历史链路恢复
- **模板编码**:`F2-107-3` 客户来源移除 `id`,数字编码写入 `value`;轻改使用销售端 `0` / 交付端 `3`,延保权益使用门店售前 `0` / 门店售后 `1`,忽略自然到店。客户标签继续使用 `1`~`5` 数字 `value`,相关行内显隐规则同步按数字判断。
- **车架号**:V2.3 `F2-107-9` 恢复历史 VIN 能力;非空值必须满足 17 位格式,失焦及 OCR 回填触发接口校验,保存前立即复验全部可见子表行,失败时按行阻止保存并展示具体原因。
- **OCR**:复用 VIN OCR bridge,并携带 `groupKey + rowIndex + childKey` 上下文,确保识别结果精确回填原子表行;卸载时清理待回填状态。
- **生成与验证**:转换器覆盖 daily / production 四份 V2.3 JS/JSON;新增模板编码、17 位格式、门店页接口校验与 OCR 回填回归。
## 2026-08-12 — 客户标签按业务场景和主营品牌动态显示 ## 2026-08-12 — 客户标签按业务场景和主营品牌动态显示
- **模板协议**:静态选项直接使用声明式 `baseSceneCode`、`brandId`、`filterBrandId`;`matchEffect` 缺省或为 `include` 时命中条件显示,为 `exclude` 时命中条件隐藏。五界 ID 直接按 daily/production 环境写入选项,不再生成嵌套显隐对象、选项表达式或额外上下文变量。 - **模板协议**:静态选项直接使用声明式 `baseSceneCode`、`brandId`、`filterBrandId`;`matchEffect` 缺省或为 `include` 时命中条件显示,为 `exclude` 时命中条件隐藏。五界 ID 直接按 daily/production 环境写入选项,不再生成嵌套显隐对象、选项表达式或额外上下文变量。
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
- **templateType**:`2` - **templateType**:`2`
- **moduleUrl**:`store-daily-template` - **moduleUrl**:`store-daily-template`
- **Fixture**:`fixtures/schema-store-daily-full.js`(mock);V2.1.1 结构见 `schema-store-daily-v2.1.1.js` - **Fixture**:`fixtures/schema-store-daily-full.js`(mock);V2.1.1 结构见 `schema-store-daily-v2.1.1.js`;V2.3.0 生成物见 `schema-store-daily-v2.3.0.js/json` 及对应 `.prod` 文件
- **模版对照**:[store-template-features.md](./store-template-features.md)(F2-1/F2-2 联动、divider、subform、F2-24) - **模版对照**:[store-template-features.md](./store-template-features.md)(F2-1/F2-2 联动、divider、subform、F2-24)
- **特点**:F2 固定字段 + 多品牌 subform(问界/享界等);divider 区分延保/权益/轻改;`F2-1` 驻店人员 `multipleSelect` - **特点**:F2 固定字段 + 多品牌 subform(问界/享界等);divider 区分延保/权益/轻改;`F2-1` 驻店人员 `multipleSelect`
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
- **上报确认弹窗**:`title: "确定上报数据?"`;`content: "请确认已记录今日所有非成交客户信息,并确保成交客户已完成录单。门店日报上报后,将立即发送相关门店经营统计数据到指定消息群。"`;`cancelText: "我再想想"`;`confirmText: "确定"`。 - **上报确认弹窗**:`title: "确定上报数据?"`;`content: "请确认已记录今日所有非成交客户信息,并确保成交客户已完成录单。门店日报上报后,将立即发送相关门店经营统计数据到指定消息群。"`;`cancelText: "我再想想"`;`confirmText: "确定"`。
- **上报按钮**:只有「今天 + 已保存 + 未上报 + 非编辑态」可用;过去日期显示为禁用,已上报时不可再次上报。 - **上报按钮**:只有「今天 + 已保存 + 未上报 + 非编辑态」可用;过去日期显示为禁用,已上报时不可再次上报。
- **保存防护**:同一门店、日报日期和员工保存成功后 60 秒内再次保存提示「操作过于频繁,请稍后再试」;F2-107 中重复客户手机号会阻止保存并列出重复行号。 - **保存防护**:同一门店、日报日期和员工保存成功后 60 秒内再次保存提示「操作过于频繁,请稍后再试」;F2-107 中重复客户手机号会阻止保存并列出重复行号。
- **客户车架号**:V2.3.0 `F2-107-9` 为可选字段;一旦填写必须通过 17 位 VIN 格式校验。失焦、OCR 回填及保存前均调用 VIN 校验接口,失败时当前子表行标红并阻止保存;OCR 结果只写回发起识别的行。
- **并发冲突弹窗**:进入编辑时记录详情接口返回的记录 ID;保存前重新 `detail.get`,仅当两次 ID 不一致(包括初始无 ID、最新有 ID)时提示覆盖。两次均无 ID 或 ID 相同均直接保存;ID 相同但内容变化不提示。 - **并发冲突弹窗**:进入编辑时记录详情接口返回的记录 ID;保存前重新 `detail.get`,仅当两次 ID 不一致(包括初始无 ID、最新有 ID)时提示覆盖。两次均无 ID 或 ID 相同均直接保存;ID 相同但内容变化不提示。
- **离开编辑态弹窗**:换日、切周和返回均使用 `title: "重要提示"`、`content: "内容尚未提交,是否退出编辑?"`、`cancelText: "继续编辑"`、`confirmText: "确定退出"`。取消留在原页并保留填写值,确认才离开。 - **离开编辑态弹窗**:换日、切周和返回均使用 `title: "重要提示"`、`content: "内容尚未提交,是否退出编辑?"`、`cancelText: "继续编辑"`、`confirmText: "确定退出"`。取消留在原页并保留填写值,确认才离开。
- **detail.get** 回显:`submissionStatus`(1 已上报 / 2 未上报)、`submissionDate`(`yyyy-MM-dd HH:mm:ss`) - **detail.get** 回显:`submissionStatus`(1 已上报 / 2 未上报)、`submissionDate`(`yyyy-MM-dd HH:mm:ss`)
...@@ -161,6 +162,7 @@ ...@@ -161,6 +162,7 @@
- `IT-V211-STORE-007`~`013` — `v211-template-visibility.test.mjs`(岚图 or 其他品牌) - `IT-V211-STORE-007`~`013` — `v211-template-visibility.test.mjs`(岚图 or 其他品牌)
- `IT-V211-*` — `v211-template-visibility.test.mjs` - `IT-V211-*` — `v211-template-visibility.test.mjs`
- `IT-STORE-STAFF-COUNT-*` — `store-staff-count.test.mjs` - `IT-STORE-STAFF-COUNT-*` — `store-staff-count.test.mjs`
- `IT-STORE-DAILY-PAGE-VIN-*` / `IT-VIN-SYNC-*` — 门店页 VIN 失焦、提交、OCR 与 17 位格式
--- ---
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
- **mock 运行时**:`schema=mock` 仍读 [`fixtures/schema-store-daily-full.js`](../fixtures/schema-store-daily-full.js)(V2.0 indexed baseline) - **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 模版结构/单测**:[`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) - **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)
- **V2.3.0 daily / production**:[`fixtures/schema-store-daily-v2.3.0.js`](../fixtures/schema-store-daily-v2.3.0.js) / [`.json`](../fixtures/schema-store-daily-v2.3.0.json);[`fixtures/schema-store-daily-v2.3.0.prod.js`](../fixtures/schema-store-daily-v2.3.0.prod.js) / [`.prod.json`](../fixtures/schema-store-daily-v2.3.0.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 对照)。 相关:[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 对照)。
...@@ -53,6 +54,12 @@ ...@@ -53,6 +54,12 @@
| subform 最多 20 行 | `subform-limits.js` | `rules.maxLength` | | subform 最多 20 行 | `subform-limits.js` | `rules.maxLength` |
| 保存 jsonContent | `app-subform-json.js` | F2-1 双 key;subform `childrenValue` | | 保存 jsonContent | `app-subform-json.js` | F2-1 双 key;subform `childrenValue` |
| 洽谈汇总 | `negotiation-summary` + `discussion.staff.list` | 非本模版字段,门店页能力 | | 洽谈汇总 | `negotiation-summary` + `discussion.staff.list` | 非本模版字段,门店页能力 |
| V2.3.0 F2-107-9 客户车架号 | `prefixComponent:'scan'` + `field-format-rules.js` + `vinVaildate.js` + `vinOcrBridge.js` | 非空时须为 17 位 VIN;失焦/OCR/保存前走接口校验,OCR 按 subform 行上下文回填 |
### V2.3.0 客户来源与客户标签值协议
- `F2-107-3` 客户来源只输出 `label + value`,不输出 `id`:轻改场景为销售端 `0`、交付端 `3`;延保/权益场景为门店售前 `0`、门店售后 `1`。自然到店 `2` 不进入模板。
- `F2-107-7` 客户标签只输出数字 `value`:已触客 `1`、已拉群 `2`、已交付引荐 `3`、首保维保客户 `4`、事故车客户 `5`;行内显隐规则同步按数字值判断。
--- ---
......
...@@ -251,23 +251,23 @@ ...@@ -251,23 +251,23 @@
options: [ options: [
{ {
label: '销售端引流-售前', label: '销售端引流-售前',
value: '0', value: '0',
baseSceneCode: [100101, 100102, 100103] baseSceneCode: [100101, 100102, 100103]
}, },
{ {
label: '交付端引流-售前', label: '交付端引流-售前',
value: '3', value: '3',
baseSceneCode: [100101, 100102, 100103] baseSceneCode: [100101, 100102, 100103]
}, },
{ {
label: '门店引流-售前', label: '门店引流-售前',
value: '0', value: '0',
baseSceneCode: [110101, 110102, 110201, 110202] baseSceneCode: [110101, 110102, 110201, 110202]
}, },
{ {
label: '门店引流-售后', label: '门店引流-售后',
value: '1', value: '1',
baseSceneCode: [110101, 110102, 110201, 110202] baseSceneCode: [110101, 110102, 110201, 110202]
} }
], ],
rules: {}, rules: {},
......
...@@ -187,23 +187,41 @@ ...@@ -187,23 +187,41 @@
"options": [ "options": [
{ {
"label": "销售端引流-售前", "label": "销售端引流-售前",
"value": "0", "value": "0",
"baseSceneCode": [100101, 100102, 100103] "baseSceneCode": [
100101,
100102,
100103
]
}, },
{ {
"label": "交付端引流-售前", "label": "交付端引流-售前",
"value": "3", "value": "3",
"baseSceneCode": [100101, 100102, 100103] "baseSceneCode": [
100101,
100102,
100103
]
}, },
{ {
"label": "门店引流-售前", "label": "门店引流-售前",
"value": "0", "value": "0",
"baseSceneCode": [110101, 110102, 110201, 110202] "baseSceneCode": [
110101,
110102,
110201,
110202
]
}, },
{ {
"label": "门店引流-售后", "label": "门店引流-售后",
"value": "1", "value": "1",
"baseSceneCode": [110101, 110102, 110201, 110202] "baseSceneCode": [
110101,
110102,
110201,
110202
]
} }
] ]
}, },
......
...@@ -251,23 +251,23 @@ ...@@ -251,23 +251,23 @@
options: [ options: [
{ {
label: '销售端引流-售前', label: '销售端引流-售前',
value: '0', value: '0',
baseSceneCode: [100101, 100102, 100103] baseSceneCode: [100101, 100102, 100103]
}, },
{ {
label: '交付端引流-售前', label: '交付端引流-售前',
value: '3', value: '3',
baseSceneCode: [100101, 100102, 100103] baseSceneCode: [100101, 100102, 100103]
}, },
{ {
label: '门店引流-售前', label: '门店引流-售前',
value: '0', value: '0',
baseSceneCode: [110101, 110102, 110201, 110202] baseSceneCode: [110101, 110102, 110201, 110202]
}, },
{ {
label: '门店引流-售后', label: '门店引流-售后',
value: '1', value: '1',
baseSceneCode: [110101, 110102, 110201, 110202] baseSceneCode: [110101, 110102, 110201, 110202]
} }
], ],
rules: {}, rules: {},
......
...@@ -187,23 +187,41 @@ ...@@ -187,23 +187,41 @@
"options": [ "options": [
{ {
"label": "销售端引流-售前", "label": "销售端引流-售前",
"value": "0", "value": "0",
"baseSceneCode": [100101, 100102, 100103] "baseSceneCode": [
100101,
100102,
100103
]
}, },
{ {
"label": "交付端引流-售前", "label": "交付端引流-售前",
"value": "3", "value": "3",
"baseSceneCode": [100101, 100102, 100103] "baseSceneCode": [
100101,
100102,
100103
]
}, },
{ {
"label": "门店引流-售前", "label": "门店引流-售前",
"value": "0", "value": "0",
"baseSceneCode": [110101, 110102, 110201, 110202] "baseSceneCode": [
110101,
110102,
110201,
110202
]
}, },
{ {
"label": "门店引流-售后", "label": "门店引流-售后",
"value": "1", "value": "1",
"baseSceneCode": [110101, 110102, 110201, 110202] "baseSceneCode": [
110101,
110102,
110201,
110202
]
} }
] ]
}, },
......
...@@ -17,7 +17,7 @@ export const VIN_FORMAT_REGEX_17 = /^[A-HJ-NPR-Z0-9]{17}$/i ...@@ -17,7 +17,7 @@ export const VIN_FORMAT_REGEX_17 = /^[A-HJ-NPR-Z0-9]{17}$/i
export const VIN_FORMAT_REGEX = VIN_FORMAT_REGEX_17 export const VIN_FORMAT_REGEX = VIN_FORMAT_REGEX_17
export const VIN_FORMAT_MSG = export const VIN_FORMAT_MSG =
'请输入最多 20 位有效字符(支持大写 A-H/J-N/P-Z、0-9)' '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)'
export const VIN_MAX_LENGTH_MSG = len => export const VIN_MAX_LENGTH_MSG = len =>
`${len}`.length ? `车架号不能超过${len}位` : VIN_FORMAT_MSG `${len}`.length ? `车架号不能超过${len}位` : VIN_FORMAT_MSG
...@@ -61,7 +61,7 @@ export function validateVinSyncFormat(value, maxLength = VIN_MAX_LENGTH) { ...@@ -61,7 +61,7 @@ export function validateVinSyncFormat(value, maxLength = VIN_MAX_LENGTH) {
if (str.length > limit) { if (str.length > limit) {
return VIN_MAX_LENGTH_MSG(limit) return VIN_MAX_LENGTH_MSG(limit)
} }
if (!buildVinFormatRegex(limit).test(str)) { if (str.length !== 17 || !VIN_FORMAT_REGEX_17.test(str)) {
return VIN_FORMAT_MSG return VIN_FORMAT_MSG
} }
return null return null
......
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
group-row-visible-map="{{ groupRowVisibleMap }}" group-row-visible-map="{{ groupRowVisibleMap }}"
group-row-total-map="{{ groupRowTotalMap }}" group-row-total-map="{{ groupRowTotalMap }}"
bind:change="onFieldChange" bind:change="onFieldChange"
bind:blur="onFieldBlur"
bind:groupblur="onGroupFieldBlur"
bind:groupadd="onGroupAdd" bind:groupadd="onGroupAdd"
bind:groupremove="onGroupRemove" bind:groupremove="onGroupRemove"
bind:groupnav="onGroupNav" bind:groupnav="onGroupNav"
......
...@@ -661,11 +661,11 @@ def build_children_rules(children: list[dict]) -> dict: ...@@ -661,11 +661,11 @@ def build_children_rules(children: list[dict]) -> dict:
V230_STORE_CHILD_SHOW_RULES = { V230_STORE_CHILD_SHOW_RULES = {
'F2-107-12': { 'F2-107-12': {
'keys': ['F2-107-7'], 'keys': ['F2-107-7'],
'result': "val1 && Array.isArray(val1) && (val1.includes('已触客') || val1.includes('已交付引荐'))", 'result': "val1 && Array.isArray(val1) && (val1.includes('1') || val1.includes('3'))",
}, },
'F2-107-13': { 'F2-107-13': {
'keys': ['F2-107-7'], 'keys': ['F2-107-7'],
'result': "val1 && Array.isArray(val1) && val1.includes('已交付引荐')", 'result': "val1 && Array.isArray(val1) && val1.includes('3')",
}, },
'F2-107-14': { 'F2-107-14': {
'keys': ['F2-107-13'], 'keys': ['F2-107-13'],
...@@ -673,7 +673,7 @@ V230_STORE_CHILD_SHOW_RULES = { ...@@ -673,7 +673,7 @@ V230_STORE_CHILD_SHOW_RULES = {
}, },
'F2-107-15': { 'F2-107-15': {
'keys': ['F2-107-7'], 'keys': ['F2-107-7'],
'result': "val1 && Array.isArray(val1) && val1.includes('已触客')", 'result': "val1 && Array.isArray(val1) && val1.includes('1')",
}, },
'F2-107-16': { 'F2-107-16': {
'keys': ['F2-107-15'], 'keys': ['F2-107-15'],
...@@ -681,16 +681,29 @@ V230_STORE_CHILD_SHOW_RULES = { ...@@ -681,16 +681,29 @@ V230_STORE_CHILD_SHOW_RULES = {
}, },
'F2-107-17': { 'F2-107-17': {
'keys': ['F2-107-7'], 'keys': ['F2-107-7'],
'result': "!Array.isArray(val1) || (val1 && !val1.includes('已触客'))", 'result': "!Array.isArray(val1) || (val1 && !val1.includes('1'))",
}, },
'F2-107-18': { 'F2-107-18': {
'keys': ['F2-107-7'], 'keys': ['F2-107-7'],
'result': "val1 && Array.isArray(val1) && val1.includes('已触客')", 'result': "val1 && Array.isArray(val1) && val1.includes('1')",
}, },
} }
V230_SHOW_RULE_CONTEXT_KEYS = {'$sceneCodes', '$brandIds'} V230_SHOW_RULE_CONTEXT_KEYS = {'$sceneCodes', '$brandIds'}
OPTION_VISIBILITY_KEYS = {'baseSceneCode', 'brandId', 'filterBrandId'} OPTION_VISIBILITY_KEYS = {'baseSceneCode', 'brandId', 'filterBrandId'}
V230_CUSTOMER_SOURCE_VALUE_BY_LABEL = {
'销售端引流-售前': '0',
'交付端引流-售前': '3',
'门店引流-售前': '0',
'门店引流-售后': '1',
}
V230_CUSTOMER_TAG_VALUE_BY_LABEL = {
'已触客': '1',
'已拉群': '2',
'已交付引荐': '3',
'首保维保客户': '4',
'事故车客户': '5',
}
def _includes_any(value_name: str, values: list[int]) -> str: def _includes_any(value_name: str, values: list[int]) -> str:
...@@ -710,10 +723,10 @@ def build_v230_delivery_date_show_rule() -> dict: ...@@ -710,10 +723,10 @@ def build_v230_delivery_date_show_rule() -> dict:
result = ( result = (
"val1 && Array.isArray(val1) && val2 && Array.isArray(val2) && " "val1 && Array.isArray(val1) && val2 && Array.isArray(val2) && "
f"(({boutique_expr} && {five_realm_expr} && " f"(({boutique_expr} && {five_realm_expr} && "
"val3 == '交付端引流-售前') || " "val3 == '3') || "
f"({boutique_expr} && !{five_realm_expr} && " f"({boutique_expr} && !{five_realm_expr} && "
"(val3 == '销售端引流-售前' || val3 == '交付端引流-售前')) || " "(val3 == '0' || val3 == '3')) || "
f"({warranty_equity_expr} && val3 == '门店引流-售前'))" f"({warranty_equity_expr} && val3 == '0'))"
) )
return { return {
'keys': ['$sceneCodes', '$brandIds', 'F2-107-3'], 'keys': ['$sceneCodes', '$brandIds', 'F2-107-3'],
...@@ -732,18 +745,37 @@ def build_v230_store_child_show_rules() -> dict: ...@@ -732,18 +745,37 @@ def build_v230_store_child_show_rules() -> dict:
def apply_v230_customer_tag_option_visibility(options: list[dict]) -> None: def apply_v230_customer_tag_option_visibility(options: list[dict]) -> None:
"""给 F2-107-7 选项写入声明式场景×主营品牌显隐配置。""" """给 F2-107-7 选项写入声明式场景×主营品牌显隐配置。"""
light_scenes = [100101, 100102, 100103] light_scenes = [100101, 100102, 100103]
five_realm_values = {'已拉群', '首保维保客户', '事故车客户'} five_realm_labels = {'已拉群', '首保维保客户', '事故车客户'}
for option in options: for option in options:
value = option.get('value') label = option.get('label')
if value in five_realm_values: mapped_value = V230_CUSTOMER_TAG_VALUE_BY_LABEL.get(label)
if mapped_value is not None:
option.pop('id', None)
option['value'] = mapped_value
if label in five_realm_labels:
option['baseSceneCode'] = light_scenes.copy() option['baseSceneCode'] = light_scenes.copy()
option['brandId'] = FIVE_REALM_IDS.copy() option['brandId'] = FIVE_REALM_IDS.copy()
elif value == '已交付引荐': elif label == '已交付引荐':
option['baseSceneCode'] = light_scenes.copy() option['baseSceneCode'] = light_scenes.copy()
option['filterBrandId'] = FIVE_REALM_IDS.copy() option['filterBrandId'] = FIVE_REALM_IDS.copy()
option['matchEffect'] = 'exclude' option['matchEffect'] = 'exclude'
def apply_v230_customer_source_values(options: list[dict]) -> None:
"""客户来源按 App 协议保存数字 value,不输出 id。"""
for option in options:
label = option.get('label')
mapped_value = V230_CUSTOMER_SOURCE_VALUE_BY_LABEL.get(label)
if mapped_value is None:
continue
option.pop('id', None)
option['value'] = mapped_value
if label in {'销售端引流-售前', '交付端引流-售前'}:
option['baseSceneCode'] = [100101, 100102, 100103]
elif label in {'门店引流-售前', '门店引流-售后'}:
option['baseSceneCode'] = [110101, 110102, 110201, 110202]
def build_v230_children_rules(children: list[dict]) -> dict: def build_v230_children_rules(children: list[dict]) -> dict:
"""为 subform 生成引擎现有的父级子字段校验索引。""" """为 subform 生成引擎现有的父级子字段校验索引。"""
allowed = {'min', 'integer', 'decimal', 'maxLength', 'maxDate', 'format', 'level'} allowed = {'min', 'integer', 'decimal', 'maxLength', 'maxDate', 'format', 'level'}
...@@ -831,6 +863,12 @@ def assemble_v230_list(records: list[dict], sheet_cfg: dict) -> list[dict]: ...@@ -831,6 +863,12 @@ def assemble_v230_list(records: list[dict], sheet_cfg: dict) -> list[dict]:
if customer_tags is not None: if customer_tags is not None:
customer_tags['optionsKey'] = 'options' customer_tags['optionsKey'] = 'options'
apply_v230_customer_tag_option_visibility(customer_tags.get('options') or []) apply_v230_customer_tag_option_visibility(customer_tags.get('options') or [])
customer_source = next(
(child for child in children if child.get('key') == 'F2-107-3'),
None,
)
if customer_source is not None:
apply_v230_customer_source_values(customer_source.get('options') or [])
product_categories = next( product_categories = next(
(child for child in children if child.get('key') == 'F2-107-12'), (child for child in children if child.get('key') == 'F2-107-12'),
None, None,
......
...@@ -20,18 +20,21 @@ describe('field-format-rules', async () => { ...@@ -20,18 +20,21 @@ describe('field-format-rules', async () => {
it('IT-VIN-SYNC-001: vin sync format validation', () => { it('IT-VIN-SYNC-001: vin sync format validation', () => {
assert.equal(validateVinSyncFormat('LSGGF53W8CH045613'), null) assert.equal(validateVinSyncFormat('LSGGF53W8CH045613'), null)
assert.equal(validateVinSyncFormat('LSGGF53W8CH04561'), null) assert.equal(
validateVinSyncFormat('LSGGF53W8CH04561'),
'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)'
)
assert.equal(validateVinSyncFormat('LSGGF53W8CH04561!'), '请输入正确的VIN码') assert.equal(validateVinSyncFormat('LSGGF53W8CH04561!'), '请输入正确的VIN码')
}) })
it('IT-VIN-SYNC-002: vin excludes I O Q', () => { it('IT-VIN-SYNC-002: vin excludes I O Q', () => {
assert.equal( assert.equal(
validateVinSyncFormat('LSGGF53W8CH04561I'), validateVinSyncFormat('LSGGF53W8CH04561I'),
'请输入最多 20 位有效字符(支持大写 A-H/J-N/P-Z、0-9)' '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)'
) )
assert.equal( assert.equal(
validateVinSyncFormat('LSGGF53W8CH04561O'), validateVinSyncFormat('LSGGF53W8CH04561O'),
'请输入最多 20 位有效字符(支持大写 A-H/J-N/P-Z、0-9)' '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)'
) )
}) })
...@@ -43,10 +46,13 @@ describe('field-format-rules', async () => { ...@@ -43,10 +46,13 @@ describe('field-format-rules', async () => {
assert.equal(shouldCheckVinApi('LSGGF53W8CH04561'), false) assert.equal(shouldCheckVinApi('LSGGF53W8CH04561'), false)
}) })
it('IT-VIN-SYNC-004: vin max length 20 and resolveVinInputMaxLength', () => { it('IT-VIN-SYNC-004: vin must be exactly 17 chars while input max length stays configurable', () => {
const twenty = 'A'.repeat(20) const twenty = 'A'.repeat(20)
const twentyOne = 'A'.repeat(21) const twentyOne = 'A'.repeat(21)
assert.equal(validateVinSyncFormat(twenty), null) assert.equal(
validateVinSyncFormat(twenty),
'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)'
)
assert.match(validateVinSyncFormat(twentyOne), /不能超过20位/) assert.match(validateVinSyncFormat(twentyOne), /不能超过20位/)
assert.equal( assert.equal(
resolveVinInputMaxLength({ resolveVinInputMaxLength({
......
...@@ -22,6 +22,7 @@ function createFallbackModule(overrides = {}) { ...@@ -22,6 +22,7 @@ function createFallbackModule(overrides = {}) {
function createStorePageHarness(overrides = {}) { function createStorePageHarness(overrides = {}) {
let definition let definition
let clearPendingCalls = 0 let clearPendingCalls = 0
let clearVinPendingCalls = 0
const carBrandPickerBridge = { const carBrandPickerBridge = {
clearPending() { clearPending() {
clearPendingCalls += 1 clearPendingCalls += 1
...@@ -31,6 +32,43 @@ function createStorePageHarness(overrides = {}) { ...@@ -31,6 +32,43 @@ function createStorePageHarness(overrides = {}) {
} }
const modules = { const modules = {
'../../services/carBrandPickerBridge.js': carBrandPickerBridge, '../../services/carBrandPickerBridge.js': carBrandPickerBridge,
'../../services/vinOcrBridge.js': {
clearPending() {
clearVinPendingCalls += 1
},
handleReWrite: () => false,
normalizeVin: value => String(value || '').trim().toUpperCase(),
openVinOcr() {}
},
'../../services/vin-ocr-context.js': {
resolveVinFieldContext: context => ({
...context,
isGroupField: !!context.groupKey
})
},
'~/utils/vinVaildate.js': {
validateVin: async () => ({ data: { data: { valid: true } } }),
validateVinImmediate: async () => ({ data: { data: { valid: true } } }),
cancelPendingVinDebounce() {}
},
'../../form-engine/field-types.js': {
getSubformRowTemplateForAdd: group => group?.origin_children || []
},
'../../form-engine/field-format-rules.js': {
isVinScanField: field => field?.prefixComponent === 'scan',
validateVinSyncFormat: () => null,
resolveVinInputMaxLength: () => 20,
VIN_API_FAIL_MSG: '车架号校验不匹配,请核对后重新输入'
},
'../../form-engine/vin-api-valid-tracker.js': {
buildVinErrorKey: ({ groupKey, rowIndex, childKey }) =>
groupKey ? `${groupKey}__${rowIndex}__${childKey}` : childKey,
shouldRunVinApiValidate: value => String(value || '').length === 17,
runVinApiValidate: async () => ({ ok: true, valid: true }),
runVinApiValidateImmediate: async () => ({ ok: true, valid: true }),
listVinScanCellsFromCache: () => [],
buildVinApiValidMapFromEntries: async () => ({})
},
'../../form-engine/car-brand-value.js': { '../../form-engine/car-brand-value.js': {
resolveCarBrandValueForValidation: (field, childKey, value) => field?.[childKey] || value resolveCarBrandValueForValidation: (field, childKey, value) => field?.[childKey] || value
}, },
...@@ -58,7 +96,11 @@ function createStorePageHarness(overrides = {}) { ...@@ -58,7 +96,11 @@ function createStorePageHarness(overrides = {}) {
page.setData = function (patch) { page.setData = function (patch) {
Object.assign(this.data, patch) Object.assign(this.data, patch)
} }
return { page, getClearPendingCalls: () => clearPendingCalls } return {
page,
getClearPendingCalls: () => clearPendingCalls,
getClearVinPendingCalls: () => clearVinPendingCalls
}
} }
function createDeterministicWeekTimeUtil(today = '2026-08-10') { function createDeterministicWeekTimeUtil(today = '2026-08-10') {
...@@ -285,9 +327,143 @@ describe('storeDailyReport page contract', () => { ...@@ -285,9 +327,143 @@ describe('storeDailyReport page contract', () => {
}) })
it('IT-STORE-DAILY-PAGE-014: unloading clears the pending vehicle picker once', () => { it('IT-STORE-DAILY-PAGE-014: unloading clears the pending vehicle picker once', () => {
const { page, getClearPendingCalls } = createStorePageHarness() const { page, getClearPendingCalls, getClearVinPendingCalls } = createStorePageHarness()
page.onUnload() page.onUnload()
assert.equal(getClearPendingCalls(), 1) assert.equal(getClearPendingCalls(), 1)
assert.equal(getClearVinPendingCalls(), 1)
})
it('IT-STORE-DAILY-PAGE-015: wires VIN blur events and validates with the API result map', () => {
assert.match(wxml, /bind:blur="onFieldBlur"/)
assert.match(wxml, /bind:groupblur="onGroupFieldBlur"/)
const { page } = createStorePageHarness()
let validateOptions
page.engine = {
validate(options) {
validateOptions = options
return { ok: true, errorMap: {} }
},
getViewState: () => ({ values: {}, groupRowsCache: {} })
}
assert.equal(page.validateFormRequired({ vin: true }), true)
assert.deepEqual(validateOptions, { vinApiValidMap: { vin: true } })
})
it('IT-STORE-DAILY-PAGE-016: exposes the historical VIN OCR write-back bridge', () => {
const { page } = createStorePageHarness()
assert.equal(typeof page.openVinOcrForField, 'function')
assert.equal(typeof page.applyVinOcrResult, 'function')
assert.equal(typeof page.reWrite, 'function')
assert.match(js, /flushAllVinApiValidation/)
assert.match(js, /validateVinImmediate/)
})
it('IT-STORE-DAILY-PAGE-VIN-017: reports the concrete VIN validation message', () => {
let toastMessage = ''
const { page } = createStorePageHarness({
wx: {
$util: {
showToast(message) {
toastMessage = message
}
}
}
})
page.applyEngineView = () => {}
page.engine = {
validate: () => ({
ok: false,
errorMap: { 'F2-107__0__F2-107-9': '请输入 17 位有效字符' },
errors: [{ message: '请输入 17 位有效字符' }]
}),
getViewState: () => ({ values: {}, groupRowsCache: {} })
}
assert.equal(page.validateFormRequired(), false)
assert.equal(toastMessage, '请输入 17 位有效字符')
})
it('IT-STORE-DAILY-PAGE-VIN-018: writes OCR VIN into the addressed subform row', () => {
const { page } = createStorePageHarness()
let mutation
let appliedExtra
page.data.errors = {
'F2-107__2__F2-107-9': '请输入 17 位有效字符',
other: 'keep'
}
page.engine = {
mutateSubform(groupKey, rowIndex, childKey, value) {
mutation = { groupKey, rowIndex, childKey, value }
return { values: {}, groupRowsCache: {} }
}
}
page.applyEngineView = (viewState, extra) => {
appliedExtra = extra
}
page.applyVinOcrResult({
groupKey: 'F2-107',
rowIndex: 2,
childKey: 'F2-107-9',
vin: 'LHGCM82633A123456'
})
assert.deepEqual(mutation, {
groupKey: 'F2-107',
rowIndex: 2,
childKey: 'F2-107-9',
value: 'LHGCM82633A123456'
})
assert.equal(appliedExtra.changedGroupKey, 'F2-107')
assert.deepEqual(appliedExtra.errors, { other: 'keep' })
})
it('IT-STORE-DAILY-PAGE-VIN-019: save-time flush immediately validates every VIN through the API', async () => {
let immediateCall
const errorKey = 'F2-107__0__F2-107-9'
const { page } = createStorePageHarness({
modules: {
'~/utils/vinVaildate.js': {
validateVin: async () => ({ data: { data: { valid: true } } }),
async validateVinImmediate(vin, options) {
immediateCall = { vin, options }
return { data: { data: { valid: false } } }
},
cancelPendingVinDebounce() {}
},
'../../form-engine/vin-api-valid-tracker.js': {
buildVinErrorKey: ({ groupKey, rowIndex, childKey }) =>
groupKey ? `${groupKey}__${rowIndex}__${childKey}` : childKey,
shouldRunVinApiValidate: value => String(value || '').length === 17,
runVinApiValidate: async () => ({ ok: true, valid: true }),
async runVinApiValidateImmediate(vin, validateFn, options) {
const result = await validateFn(vin, options)
return { ok: true, valid: result?.data?.data?.valid !== false }
},
listVinScanCellsFromCache: () => [{
errorKey,
vin: 'LHGCM82633A123456'
}],
async buildVinApiValidMapFromEntries(entries, runOne) {
const result = await runOne(entries[0].vin)
return { [entries[0].errorKey]: result.ok && result.valid }
}
}
}
})
page.engine = {
getViewState: () => ({ groupRowsCache: { 'F2-107': [] } })
}
const result = await page.flushAllVinApiValidation()
assert.deepEqual(immediateCall, {
vin: 'LHGCM82633A123456',
options: { silent: true }
})
assert.equal(result.vinApiValidMap[errorKey], false)
assert.equal(page.data.errors[errorKey], '车架号校验不匹配,请核对后重新输入')
}) })
async function runSaveConflictScenario({ baseId, latestDetail, confirm = true }) { async function runSaveConflictScenario({ baseId, latestDetail, confirm = true }) {
......
...@@ -303,9 +303,9 @@ class StoreV230ConverterTest(unittest.TestCase): ...@@ -303,9 +303,9 @@ class StoreV230ConverterTest(unittest.TestCase):
self.assertIn(f"val1.includes('{scene_code}')", delivery_rule) self.assertIn(f"val1.includes('{scene_code}')", delivery_rule)
for brand_id in converter.FIVE_REALM_IDS: for brand_id in converter.FIVE_REALM_IDS:
self.assertIn(f"val2.includes('{brand_id}')", delivery_rule) self.assertIn(f"val2.includes('{brand_id}')", delivery_rule)
self.assertIn("val3 == '销售端引流-售前'", delivery_rule) self.assertIn("val3 == '0'", delivery_rule)
self.assertIn("val3 == '交付端引流-售前'", delivery_rule) self.assertIn("val3 == '3'", delivery_rule)
self.assertIn("val3 == '门店引流-售前'", delivery_rule) self.assertNotIn("val3 == '销售端引流-售前'", delivery_rule)
self.assertEqual( self.assertEqual(
subform['childrenRules'].get('F2-107-4'), subform['childrenRules'].get('F2-107-4'),
{'maxDate': 'new Date()', 'format': 'date'}, {'maxDate': 'new Date()', 'format': 'date'},
...@@ -360,6 +360,56 @@ class StoreV230ConverterTest(unittest.TestCase): ...@@ -360,6 +360,56 @@ class StoreV230ConverterTest(unittest.TestCase):
self.assertEqual(children['F2-107-7']['optionsKey'], 'options') self.assertEqual(children['F2-107-7']['optionsKey'], 'options')
self.assertEqual(children['F2-107-12']['optionsKey'], 'options') self.assertEqual(children['F2-107-12']['optionsKey'], 'options')
def test_customer_source_uses_numeric_value_without_id(self):
rows = [
record('F2-107', '今日非成交客户', '子表单', 142),
record(
'F2-107-3',
'客户来源',
'选择器',
3,
options=(
'固定值\n'
'- 选项1: 销售端引流-售前\n'
'- 选项2: 交付端引流-售前\n'
'- 选项3: 门店引流-售前\n'
'- 选项4: 门店引流-售后'
),
other_rules='单选',
),
]
fields = converter.assemble_v230_list(
rows,
converter.resolve_sheet_config('store', '2.3.0'),
)
source = fields[0]['children'][0][0]
self.assertEqual(
source['options'],
[
{
'label': '销售端引流-售前',
'value': '0',
'baseSceneCode': [100101, 100102, 100103],
},
{
'label': '交付端引流-售前',
'value': '3',
'baseSceneCode': [100101, 100102, 100103],
},
{
'label': '门店引流-售前',
'value': '0',
'baseSceneCode': [110101, 110102, 110201, 110202],
},
{
'label': '门店引流-售后',
'value': '1',
'baseSceneCode': [110101, 110102, 110201, 110202],
},
],
)
self.assertTrue(all('id' not in option for option in source['options']))
def test_builds_declarative_customer_tag_option_visibility(self): def test_builds_declarative_customer_tag_option_visibility(self):
rows = [ rows = [
record('F2-107', '今日非成交客户', '子表单', 142), record('F2-107', '今日非成交客户', '子表单', 142),
...@@ -378,14 +428,15 @@ class StoreV230ConverterTest(unittest.TestCase): ...@@ -378,14 +428,15 @@ class StoreV230ConverterTest(unittest.TestCase):
) )
tags = fields[0]['children'][0][0] tags = fields[0]['children'][0][0]
self.assertEqual(tags['optionsKey'], 'options') self.assertEqual(tags['optionsKey'], 'options')
options = {option['value']: option for option in tags['options']} options = {option['label']: option for option in tags['options']}
self.assertEqual(options['已触客'], {'label': '已触客', 'value': '已触客'}) self.assertEqual(options['已触客'], {'label': '已触客', 'value': '1'})
for value in ['已拉群', '首保维保客户', '事故车客户']: mapped_values = {'已拉群': '2', '首保维保客户': '4', '事故车客户': '5'}
for label, mapped_value in mapped_values.items():
self.assertEqual( self.assertEqual(
options[value], options[label],
{ {
'label': value, 'label': label,
'value': value, 'value': mapped_value,
'baseSceneCode': [100101, 100102, 100103], 'baseSceneCode': [100101, 100102, 100103],
'brandId': converter.FIVE_REALM_IDS, 'brandId': converter.FIVE_REALM_IDS,
}, },
...@@ -394,7 +445,7 @@ class StoreV230ConverterTest(unittest.TestCase): ...@@ -394,7 +445,7 @@ class StoreV230ConverterTest(unittest.TestCase):
options['已交付引荐'], options['已交付引荐'],
{ {
'label': '已交付引荐', 'label': '已交付引荐',
'value': '已交付引荐', 'value': '3',
'baseSceneCode': [100101, 100102, 100103], 'baseSceneCode': [100101, 100102, 100103],
'filterBrandId': converter.FIVE_REALM_IDS, 'filterBrandId': converter.FIVE_REALM_IDS,
'matchEffect': 'exclude', 'matchEffect': 'exclude',
......
...@@ -33,7 +33,7 @@ function resolveWeekStateForReportDate(reportDate, now = new Date()) { ...@@ -33,7 +33,7 @@ function resolveWeekStateForReportDate(reportDate, now = new Date()) {
countSundays -= 1 countSundays -= 1
} }
const selectWeek = 0 - countSundays const selectWeek = 0 - countSundays
const timeBean = timeUtil.getWeekDayList(selectWeek) const timeBean = timeUtil.getWeekDayList(selectWeek, todayStr)
timeBean.selectDay = target.getDay() === 0 ? 6 : target.getDay() - 1 timeBean.selectDay = target.getDay() === 0 ? 6 : target.getDay() - 1
return { selectWeek, timeBean } return { selectWeek, timeBean }
} }
......
...@@ -24,13 +24,20 @@ ...@@ -24,13 +24,20 @@
"miniprogram": { "miniprogram": {
"list": [ "list": [
{ {
"name": "tabOperating/pages/operatingShow/operatingShow", "name": "packageDynamicForm/pages/storeDailyReport/storeDailyReport",
"pathName": "tabOperating/pages/operatingShow/operatingShow", "pathName": "packageDynamicForm/pages/storeDailyReport/storeDailyReport",
"query": "", "query": "",
"scene": null, "scene": null,
"launchMode": "default" "launchMode": "default"
}, },
{ {
"name": "tabOperating/pages/operatingShow/operatingShow",
"pathName": "tabOperating/pages/operatingShow/operatingShow",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "tabWorkOrder/pages/staffDaily/staffDaily", "name": "tabWorkOrder/pages/staffDaily/staffDaily",
"pathName": "tabWorkOrder/pages/staffDaily/staffDaily", "pathName": "tabWorkOrder/pages/staffDaily/staffDaily",
"query": "", "query": "",
...@@ -82,4 +89,4 @@ ...@@ -82,4 +89,4 @@
] ]
} }
} }
}
\ No newline at end of file \ No newline at end of file
}
...@@ -448,7 +448,8 @@ Page({ ...@@ -448,7 +448,8 @@ Page({
val.errorZero = false; val.errorZero = false;
} }
if (!((val.refundPrice ?? "") === "") && val.refundPrice > val.finalPrice) { if (!((val.refundPrice ?? "") === "") && val.refundPrice > val.finalPrice) {
val.errorTarget = true; // val.errorTarget = true;
val.errorTarget = false;
} else { } else {
val.errorTarget = false; val.errorTarget = false;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!