Commit 402bc423 by 张立顺

feat 日报模板功能开发

1 parent af318235
Showing 46 changed files with 933 additions and 166 deletions
...@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false ...@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 1; let index = 2;
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
const systemInfo = getSystemInfoSync(); const systemInfo = getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion; const envName = accountInfo.miniProgram.envVersion;
......
...@@ -74,14 +74,18 @@ function mapEmployeeListToOptions(list = []) { ...@@ -74,14 +74,18 @@ function mapEmployeeListToOptions(list = []) {
* 拉取在职员工选项(onTheJob.getByMerchantId) * 拉取在职员工选项(onTheJob.getByMerchantId)
* @param {Object} [options={}] * @param {Object} [options={}]
* @param {string|number} options.merchantId 商户 ID(驻店为园区店,门店/洽谈为 4S 店) * @param {string|number} options.merchantId 商户 ID(驻店为园区店,门店/洽谈为 4S 店)
* @param {string} [options.name] 员工姓名关键词(对齐 Merchant-Seles getEmployeeList)
* @returns {Promise<{code: number, message: string, data: Array}>} * @returns {Promise<{code: number, message: string, data: Array}>}
*/ */
async function fetchStoreStaffListOptions({ merchantId } = {}) { async function fetchStoreStaffListOptions({ merchantId, name } = {}) {
if (!merchantId) { if (!merchantId) {
return { code: -1, message: '缺少门店信息', data: [] } return { code: -1, message: '缺少门店信息', data: [] }
} }
const params = { merchantId } const params = { merchantId }
if (name) {
params.name = name
}
const result = await getEmployeeListApi().getEmployeeList(params) const result = await getEmployeeListApi().getEmployeeList(params)
const code = result?.code ?? -1 const code = result?.code ?? -1
......
...@@ -66,7 +66,8 @@ async function fetchFieldOptionsAdapter(params = {}) { ...@@ -66,7 +66,8 @@ async function fetchFieldOptionsAdapter(params = {}) {
if (EMPLOYEE_LIST_OPTIONS_KEYS.has(optionsKey)) { if (EMPLOYEE_LIST_OPTIONS_KEYS.has(optionsKey)) {
return fetchStoreStaffListOptions({ return fetchStoreStaffListOptions({
merchantId: resolveEmployeeListMerchantId(optionsKey, params) merchantId: resolveEmployeeListMerchantId(optionsKey, params),
name: params.name || ''
}) })
} }
......
...@@ -17,6 +17,7 @@ function buildCacheKey(params = {}) { ...@@ -17,6 +17,7 @@ function buildCacheKey(params = {}) {
params.saleDate || '', params.saleDate || '',
params.reportType || 'store', params.reportType || 'store',
brandKey, brandKey,
params.name || '',
JSON.stringify(params.sceneList || []) JSON.stringify(params.sceneList || [])
].join('|') ].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 { BOUTIQUE_PAGE_CONTEXT } = require('../fixtures/mock-meta.js')
const schemaIndexed = require('../fixtures/schema-staff-daily-full.js') const schemaIndexed = require('../fixtures/schema-staff-daily-full.js')
const { buildMockDetailJsonContent } = require('./mockDetailJsonContent.js') const { buildMockDetailJsonContent } = require('./mockDetailJsonContent.js')
......
...@@ -38,6 +38,8 @@ Component({ ...@@ -38,6 +38,8 @@ Component({
pickerOptions: [], pickerOptions: [],
pickerValue: [], pickerValue: [],
loadingOptions: false, loadingOptions: false,
pickerSearchable: false,
searchKeyword: '',
arrowIconUrl: '' arrowIconUrl: ''
}, },
...@@ -139,6 +141,11 @@ Component({ ...@@ -139,6 +141,11 @@ Component({
return this.data.field?.options?.length ? this.data.field.options : [] return this.data.field?.options?.length ? this.data.field.options : []
}, },
/** 4sStaffList(推荐人 / 交付专员)弹框启用服务端姓名搜索 */
isStaffPickerSearchable(field = this.data.field) {
return field?.optionsKey === '4sStaffList'
},
/** 组装 optionsKey 远程拉取参数(merchantId、reportDate、saleDate 等) */ /** 组装 optionsKey 远程拉取参数(merchantId、reportDate、saleDate 等) */
buildFetchParams() { buildFetchParams() {
const ctx = this.data.requestContext || {} const ctx = this.data.requestContext || {}
...@@ -162,7 +169,8 @@ Component({ ...@@ -162,7 +169,8 @@ Component({
reportType: ctx.reportType || 'store', reportType: ctx.reportType || 'store',
sceneType: ctx.sceneType, sceneType: ctx.sceneType,
sceneList: ctx.sceneList || [], sceneList: ctx.sceneList || [],
groupBrandIds groupBrandIds,
name: this.data.searchKeyword || ''
} }
}, },
...@@ -250,6 +258,9 @@ Component({ ...@@ -250,6 +258,9 @@ Component({
return return
} }
const pickerSearchable = this.isStaffPickerSearchable(field)
this.setData({ searchKeyword: '', pickerSearchable })
let options = this.data.pickerOptions let options = this.data.pickerOptions
if (field?.optionsKey) { if (field?.optionsKey) {
// 远程 optionsKey 每次打开弹框重新拉取,避免进程内缓存展示过期数据 // 远程 optionsKey 每次打开弹框重新拉取,避免进程内缓存展示过期数据
...@@ -261,7 +272,7 @@ Component({ ...@@ -261,7 +272,7 @@ Component({
this.setData({ pickerOptions: options }) this.setData({ pickerOptions: options })
} }
if (!options.length) { if (!options.length && !pickerSearchable) {
return wx.$util?.showToast?.('暂无可选项') return wx.$util?.showToast?.('暂无可选项')
} }
...@@ -292,13 +303,20 @@ Component({ ...@@ -292,13 +303,20 @@ Component({
}) })
}, },
/** 弹框内搜索:带 name 重拉 4sStaffList(对齐 Merchant-Seles) */
async onPickerSearch(e) {
const searchKeyword = e.detail?.value || ''
this.setData({ searchKeyword })
await this.loadOptions({ useCache: false })
},
/** 弹框确认:关闭 picker 并 triggerEvent('change') 写入选中值 */ /** 弹框确认:关闭 picker 并 triggerEvent('change') 写入选中值 */
onPickerConfirm(e) { onPickerConfirm(e) {
let selected = e.detail?.value let selected = e.detail?.value
if (Array.isArray(selected)) { if (Array.isArray(selected)) {
selected = selected[0] selected = selected[0]
} }
this.setData({ showPicker: false }) this.setData({ showPicker: false, searchKeyword: '' })
const options = this.data.pickerOptions.length const options = this.data.pickerOptions.length
? this.data.pickerOptions ? this.data.pickerOptions
: this.data.field?.options || [] : this.data.field?.options || []
...@@ -315,7 +333,7 @@ Component({ ...@@ -315,7 +333,7 @@ Component({
}, },
onPickerCancel() { onPickerCancel() {
this.setData({ showPicker: false }) this.setData({ showPicker: false, searchKeyword: '' })
} }
} }
}) })
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
options="{{ pickerOptions }}" options="{{ pickerOptions }}"
value="{{ pickerValue }}" value="{{ pickerValue }}"
loading="{{ loadingOptions }}" loading="{{ loadingOptions }}"
searchable="{{ pickerSearchable }}"
search-keyword="{{ searchKeyword }}"
bind:search="onPickerSearch"
bind:confirm="onPickerConfirm" bind:confirm="onPickerConfirm"
bind:cancel="onPickerCancel" bind:cancel="onPickerCancel"
/> />
...@@ -36,13 +36,22 @@ Component({ ...@@ -36,13 +36,22 @@ Component({
mode: { mode: {
type: String, type: String,
value: 'multiple' value: 'multiple'
},
searchable: {
type: Boolean,
value: false
},
searchKeyword: {
type: String,
value: ''
} }
}, },
data: { data: {
optionRows: [], optionRows: [],
draftValues: [], draftValues: [],
isFullSucreen: false isFullSucreen: false,
emptyText: '暂无可选项'
}, },
lifetimes: { lifetimes: {
...@@ -64,6 +73,10 @@ Component({ ...@@ -64,6 +73,10 @@ Component({
if (this.properties.show && !this.properties.loading) { if (this.properties.show && !this.properties.loading) {
this.syncOptionRows() this.syncOptionRows()
} }
},
'searchable, searchKeyword': function (searchable, searchKeyword) {
if (!this.properties.show || this.properties.loading) return
this.updateEmptyText(searchable, searchKeyword)
} }
}, },
...@@ -74,12 +87,27 @@ Component({ ...@@ -74,12 +87,27 @@ Component({
syncOptionRows() { syncOptionRows() {
const draftValues = normalizePickerValues(this.properties.value) const draftValues = normalizePickerValues(this.properties.value)
const optionRows = buildPickerOptionRows(this.properties.options, this.properties.value) const optionRows = buildPickerOptionRows(this.properties.options, this.properties.value)
this.updateEmptyText(this.properties.searchable, this.properties.searchKeyword)
this.setData({ this.setData({
optionRows, optionRows,
draftValues 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 态 */ /** 点选行:single 替换 draft,multiple toggle 多选并刷新 active 态 */
onToggle(e) { onToggle(e) {
const index = e.currentTarget.dataset.index const index = e.currentTarget.dataset.index
......
{ {
"component": true, "component": true,
"usingComponents": {} "usingComponents": {
"search-input": "/components/SearchInput/SearchInput"
}
} }
...@@ -5,6 +5,14 @@ ...@@ -5,6 +5,14 @@
<block wx:if="{{ title }}"> <block wx:if="{{ title }}">
<view class="picker-popup-shell__title">{{ title }}</view> <view class="picker-popup-shell__title">{{ title }}</view>
</block> </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"> <view class="picker-popup-shell__slot">
<scroll-view scroll-y class="picker-popup__scroll"> <scroll-view scroll-y class="picker-popup__scroll">
<view wx:if="{{ loading }}" class="picker-popup__loading">加载中...</view> <view wx:if="{{ loading }}" class="picker-popup__loading">加载中...</view>
...@@ -22,7 +30,7 @@ ...@@ -22,7 +30,7 @@
<view class="picker-popup__label">{{ item.label }}</view> <view class="picker-popup__label">{{ item.label }}</view>
</view> </view>
</block> </block>
<view wx:else class="picker-popup__empty">暂无可选项</view> <view wx:else class="picker-popup__empty">{{ emptyText }}</view>
</scroll-view> </scroll-view>
</view> </view>
<view class="picker-popup-shell__footer {{ isFullSucreen ? 'is-full' : '' }}"> <view class="picker-popup-shell__footer {{ isFullSucreen ? 'is-full' : '' }}">
......
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
animation: picker-popup-show 0.5s forwards; animation: picker-popup-show 0.5s forwards;
box-sizing: border-box; box-sizing: border-box;
padding: 0 32rpx; 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 { .picker-popup-shell__title {
...@@ -45,6 +52,16 @@ ...@@ -45,6 +52,16 @@
border-bottom: 2rpx solid #ebedf0; 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 { .picker-popup-shell__slot {
flex: 1; flex: 1;
min-height: 0; min-height: 0;
......
# DEVLOG — packageDynamicForm # DEVLOG — packageDynamicForm
## 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 洽谈日期回显为空 ## 2026-06-25 — 修复保存后 F3-4-1 洽谈日期回显为空
- **根因**:运行时 `partialFromPlanImport` 包装对象经 `childrenValue` 入库;回显 `childrenValueToRowFieldsList` 读 `val.text` 为空,`rowFieldsToValueMap` 跳过空 `field.value`。 - **根因**:运行时 `partialFromPlanImport` 包装对象经 `childrenValue` 入库;回显 `childrenValueToRowFieldsList` 读 `val.text` 为空,`rowFieldsToValueMap` 跳过空 `field.value`。
......
...@@ -230,6 +230,7 @@ engine.mutateSubform(groupKey, rowIndex, childKey, 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) | 团队分享、老新对比与边界 | | [TECH-SHARE.md](./TECH-SHARE.md) | 团队分享、老新对比与边界 |
| [ARCHITECTURE.md](./ARCHITECTURE.md) | 分层、加载/保存流程 | | [ARCHITECTURE.md](./ARCHITECTURE.md) | 分层、加载/保存流程 |
| [动态表单Schema设计.md](./动态表单Schema设计.md) | 字段完整定义、TypeScript 接口 | | [动态表单Schema设计.md](./动态表单Schema设计.md) | 字段完整定义、TypeScript 接口 |
...@@ -239,4 +240,4 @@ engine.mutateSubform(groupKey, rowIndex, childKey, value) ...@@ -239,4 +240,4 @@ engine.mutateSubform(groupKey, rowIndex, childKey, value)
| [selector-modes.md](./selector-modes.md) | 选择器 mode 总览(single/multiple、日期、车型、radio) | | [selector-modes.md](./selector-modes.md) | 选择器 mode 总览(single/multiple、日期、车型、radio) |
| [field-options-api.md](./field-options-api.md) | optionsKey 接口细节 | | [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 @@ ...@@ -28,8 +28,8 @@
| subform 行数上限 | [group-repeater.md](./group-repeater.md) + daily-report-save-and-json.md §6 | | 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)(若涉及) | | 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 / 配置中心模版(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 / 配置中心模版(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-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-v2.1.1.js/json` + 三套模板单测 +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 驻店节 |
| apiSwitch 默认或联调策略 | [SESSION-HANDOFF.md](./SESSION-HANDOFF.md)(apiSwitch 速查)+ DEVLOG.md | | apiSwitch 默认或联调策略 | [SESSION-HANDOFF.md](./SESSION-HANDOFF.md)(apiSwitch 速查)+ DEVLOG.md |
| 今日计划客户 / 洽谈导入 / todayPlanStore | PAGES.md 洽谈节 + SESSION-HANDOFF + DEVLOG + integration-test-plan | | 今日计划客户 / 洽谈导入 / todayPlanStore | PAGES.md 洽谈节 + SESSION-HANDOFF + DEVLOG + integration-test-plan |
| 新单测或 TEST-ID | [integration-test-plan.md](./integration-test-plan.md) + PAGES.md「相关单测」 | | 新单测或 TEST-ID | [integration-test-plan.md](./integration-test-plan.md) + PAGES.md「相关单测」 |
...@@ -51,7 +51,9 @@ ...@@ -51,7 +51,9 @@
## Schema fixture 维护(mock) ## 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 补丁 ### 何时执行 numberInput 补丁
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- **templateType**:`1` - **templateType**:`1`
- **moduleUrl**:`staff-daily-template` - **moduleUrl**:`staff-daily-template`
- **Fixture**:`fixtures/schema-staff-daily-full.js` - **Fixture**:`fixtures/schema-staff-daily-full.js`(mock);V2.1.1 结构见 `schema-staff-daily-v2.1.1.js`
- **模版对照**:[staff-template-features.md](./staff-template-features.md)(F1-1 出勤 gate、品牌 group、F1-11) - **模版对照**:[staff-template-features.md](./staff-template-features.md)(F1-1 出勤 gate、品牌 group、F1-11)
- **特点**:含 `F1-1` 今日出勤 radio;无 subform;轻改/权益/延保字段按 `sceneType` / `baseSceneCode` / `brandId` 显隐 - **特点**:含 `F1-1` 今日出勤 radio;无 subform;轻改/权益/延保字段按 `sceneType` / `baseSceneCode` / `brandId` 显隐
...@@ -64,7 +64,8 @@ ...@@ -64,7 +64,8 @@
### 相关单测 ### 相关单测
- `IT-STAFF-TPL-001`~`005` — `staff-template-schema.test.mjs` - `IT-STAFF-TPL-001`~`008` — `staff-template-schema.test.mjs`(V2.1.1)
- `IT-V211-*` — `v211-template-visibility.test.mjs`
- `IT-LOADER-001` ~ `003` — `staffDailyFormLoader` - `IT-LOADER-001` ~ `003` — `staffDailyFormLoader`
- `IT-STAFF-API-SWITCH-*` — `staffDailyReportAdapters` - `IT-STAFF-API-SWITCH-*` — `staffDailyReportAdapters`
- `IT-ENG-001` ~ `009` — form-engine(含出勤 radio、select 单选) - `IT-ENG-001` ~ `009` — form-engine(含出勤 radio、select 单选)
...@@ -80,7 +81,7 @@ ...@@ -80,7 +81,7 @@
- **templateType**:`2` - **templateType**:`2`
- **moduleUrl**:`store-daily-template` - **moduleUrl**:`store-daily-template`
- **Fixture**:`fixtures/schema-store-daily-full.js` - **Fixture**:`fixtures/schema-store-daily-full.js`(mock);V2.1.1 结构见 `schema-store-daily-v2.1.1.js`
- **模版对照**:[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`
...@@ -110,7 +111,7 @@ ...@@ -110,7 +111,7 @@
### 保存 ### 保存
- **保存并提交**:点击后 `wx.showModal`(标题「重要提示」,文案「确认提交后将不可再编辑,确认继续?」);确定后 `dynamic.save`(先校验);成功/失败 Toast「提交成功」「提交失败」 - **保存并提交**:点击后 `wx.showModal`(标题「确定提交门店日报?」,描述提醒确认驻店日报与洽谈明细已完成、提交后将发送门店经营统计到消息群;取消「我再想想」、确定「确定提交」);确定后 `dynamic.save`(先校验);成功/失败 Toast「提交成功」「提交失败」
- **保存**:直接 `dynamic.draft.save`(跳过必填校验);成功/失败 Toast「操作成功」「操作失败」 - **保存**:直接 `dynamic.draft.save`(跳过必填校验);成功/失败 Toast「操作成功」「操作失败」
- **jsonContent 形态**:顶层 `value`(如 F2-1);subform 入库 **`childrenValue` + `origin_children`**(无 `children`);远程 select 在 `childrenValue` 行内为 `{ text, value }`;提交前 lists 仍由含 `children` 的 formList 生成。详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md) - **jsonContent 形态**:顶层 `value`(如 F2-1);subform 入库 **`childrenValue` + `origin_children`**(无 `children`);远程 select 在 `childrenValue` 行内为 `{ text, value }`;提交前 lists 仍由含 `children` 的 formList 生成。详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md)
- **reportStatus**:`0` 草稿 / `1` 已提交;当天已提交(`reportStatus=1` 或 `weeklyList` 含当日)表单只读,**无「编辑」**(不可再次提交);草稿态仍「提交」「保存」 - **reportStatus**:`0` 草稿 / `1` 已提交;当天已提交(`reportStatus=1` 或 `weeklyList` 含当日)表单只读,**无「编辑」**(不可再次提交);草稿态仍「提交」「保存」
...@@ -143,7 +144,8 @@ ...@@ -143,7 +144,8 @@
- `IT-STORE-ECHO-*` — 门店 jsonContent 回显 - `IT-STORE-ECHO-*` — 门店 jsonContent 回显
- `IT-APP-ORDER-*` / `IT-APP-CV-*` / `IT-SUBFORM-MAX-*` — 提交顺序、childrenValue、20 行上限 - `IT-APP-ORDER-*` / `IT-APP-CV-*` / `IT-SUBFORM-MAX-*` — 提交顺序、childrenValue、20 行上限
- `IT-STORE-PENDING-*` — `storeMonthlyPendingCount.test.mjs`(F2-24 待邀约数 adapter/门面/shouldFetch) - `IT-STORE-PENDING-*` — `storeMonthlyPendingCount.test.mjs`(F2-24 待邀约数 adapter/门面/shouldFetch)
- `IT-STORE-TPL-*` — `store-template-schema.test.mjs`(fixture completeFun / disabledFun) - `IT-STORE-TPL-001`~`006` — `store-template-schema.test.mjs`(V2.1.1)
- `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`
--- ---
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
- [group 子表单多行增删](./group-repeater.md) - [group 子表单多行增删](./group-repeater.md)
- [路由与菜单](./routes-and-menus.md) - [路由与菜单](./routes-and-menus.md)
- [staff / store / negotiation 模版字段对照](./staff-template-features.md)(另见 store、negotiation 同名文档) - [staff / store / negotiation 模版字段对照](./staff-template-features.md)(另见 store、negotiation 同名文档)
- [**Excel 转 JS/JSON 模板配置说明**](./excel转js模板配置说明.md)(从填写表单 xlsx 生成 schema fixture)
- [集成测试计划](./integration-test-plan.md) - [集成测试计划](./integration-test-plan.md)
- [测试环境](./test-setup.md) - [测试环境](./test-setup.md)
- [apiSwitch 速查](./SESSION-HANDOFF.md) - [apiSwitch 速查](./SESSION-HANDOFF.md)
......
...@@ -80,7 +80,7 @@ const subformDataList = buildAppSubformDataListFromJsonContent(jsonContent) ...@@ -80,7 +80,7 @@ const subformDataList = buildAppSubformDataListFromJsonContent(jsonContent)
| optionsKey | Mock | Real | | 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`,每次重新拉取** | | `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`,每次重新拉取** | | `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)) | | `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(在职员工列表) ### storeStaffList / 4sStaffList(在职员工列表)
...@@ -93,7 +93,8 @@ const subformDataList = buildAppSubformDataListFromJsonContent(jsonContent) ...@@ -93,7 +93,8 @@ const subformDataList = buildAppSubformDataListFromJsonContent(jsonContent)
- **映射**:`staffName` → `label`,`uuid` → `value` - **映射**:`staffName` → `label`,`uuid` → `value`
- **适用字段**: - **适用字段**:
- `storeStaffList`:驻店「今日驻店人员」;门店日报 `F2-1`(`multipleSelect`);洽谈明细驻店人员(`select`) - `storeStaffList`:驻店「今日驻店人员」;门店日报 `F2-1`(`multipleSelect`);洽谈明细驻店人员(`select`)
- `4sStaffList`:门店日报「交付专员」(`select`,如 `F2-9-1`);洽谈明细同类字段 - `4sStaffList`:门店日报「交付专员」(`select`,如 `F2-9-1`);洽谈明细「推荐人」等同类字段
- **搜索(仅 `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'`。 驻店/门店 [`apiSwitch.js`](../config/apiSwitch.js) 中 `STAFF_DAILY_API_SWITCH` / `STORE_DAILY_API_SWITCH` 的 `fieldOptions` 已为 `'real'`;洽谈 `NEGOTIATION_DAILY_API_SWITCH.fieldOptions` 同为 `'real'`。
......
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
完整 indexed schema 源文件在分包内维护: 完整 indexed schema 源文件在分包内维护:
- `packageDynamicForm/fixtures/schema-staff-daily-full.js`(另有 `.json` 导出) - `packageDynamicForm/fixtures/schema-staff-daily-full.js`(另有 `.json` 导出)— **V2.0 mock baseline**、Excel 转换 `keep` 行来源
- `packageDynamicForm/fixtures/schema-store-daily-full.js` - `packageDynamicForm/fixtures/schema-store-daily-full.js` — 同上
- `packageDynamicForm/fixtures/schema-negotiation-full.js` - `packageDynamicForm/fixtures/schema-negotiation-full.js`
- `packageDynamicForm/fixtures/schema-staff-daily-v2.1.1.js` / `.json` — **V2.1.1 驻店模版**(结构/显隐单测权威来源)
- `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.js` / `.json` — **V2.1.1 门店模版**
本目录仅保留体积较小的样例(`schema-staff-daily-minimal.json`、`page-context-sample.json`)。 本目录仅保留体积较小的样例(`schema-staff-daily-minimal.json`、`page-context-sample.json`)。
- 从 list 转 indexed:`node packageDynamicForm/scripts/convert-schema-to-indexed.mjs` - 从 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)
- numberInput 补 `value: 0`:`node packageDynamicForm/scripts/patch-number-input-defaults.mjs` — 见 [MAINTENANCE.md § Schema fixture](../MAINTENANCE.md#schema-fixture-维护mock) - numberInput 补 `value: 0`:`node packageDynamicForm/scripts/patch-number-input-defaults.mjs` — 见 [MAINTENANCE.md § Schema fixture](../MAINTENANCE.md#schema-fixture-维护mock)
# 驻店日报模版功能对照(staff-daily-template) # 驻店日报模版功能对照(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)
相关:[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)。
--- ---
...@@ -37,9 +40,10 @@ ...@@ -37,9 +40,10 @@
| 出勤 | F1-1 | radio:在岗 / 调休;默认在岗 | | 出勤 | F1-1 | radio:在岗 / 调休;默认在岗 |
| 延保退单 | F1-2、F1-3 | 仅延保场景 + 在岗时可见(见下) | | 延保退单 | F1-2、F1-3 | 仅延保场景 + 在岗时可见(见下) |
| 备注 | F1-4 | 始终可见(含调休) | | 备注 | F1-4 | 始终可见(含调休) |
| 品牌 group | F1-5~F1-10 | 各 `brandId` 一块,子字段按轻改/延保 `sceneType`+`baseSceneCode` | | 品牌 group | F1-5~F1-9 | 各 `brandId` 一块;V2.1.1 每块 **4** 子字段(轻改 F*-3 + 延保 F*-4~6) |
| 岚图 group | F1-10 | 5 个子字段(无「交付引荐」) | | 岚图 group | F1-10 | **3** 个子字段(仅延保售前/售后/未触客) |
| 其他品牌 | F1-11 | `filterBrandId`;8 个子字段(含权益未触客 F1-11-8) | | 其他品牌 | F1-11 | `filterBrandId`;**12** 个子字段(轻改/延保/权益) |
| 五界轻改顶层 | F1-12、F1-13 | V2.1.1 新增;五界 `brandId` + 轻改 `baseSceneCode` |
--- ---
...@@ -75,11 +79,12 @@ ...@@ -75,11 +79,12 @@
|---------|------| |---------|------|
| IT-ENG-001、IT-ENG-014 | `form-engine.test.mjs` — 出勤 gate、F1-11 filterBrandId | | IT-ENG-001、IT-ENG-014 | `form-engine.test.mjs` — 出勤 gate、F1-11 filterBrandId |
| IT-ENG-007d | `radio-value` 中文/legacy 归一 | | IT-ENG-007d | `radio-value` 中文/legacy 归一 |
| IT-STAFF-TPL-001~004 | `staff-template-schema.test.mjs` | | IT-STAFF-TPL-001~008 | `staff-template-schema.test.mjs`(V2.1.1 fixture) |
| IT-V211-* | `v211-template-visibility.test.mjs` |
| IT-LOADER-001~003 | `staffDailyFormLoader.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) # 门店日报模版功能对照(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)
相关:[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 对照)。
--- ---
...@@ -23,7 +26,7 @@ ...@@ -23,7 +26,7 @@
|------|----------|------|----------| |------|----------|------|----------|
| 驻店人员 | F2-1 / F2-2 | multipleSelect + numberInput | F2-1 仅 `brandId:[3067]` | | 驻店人员 | F2-1 / F2-2 | multipleSelect + numberInput | F2-1 仅 `brandId:[3067]` |
| 延保/权益标题 | F2-94 / F2-91 / F2-92 | divider | `isYB` / `isQY` / 双场景 → 仅 F2-94 | | 延保/权益标题 | 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-9、F2-10、F2-11 | subform | 鸿蒙 / 岚图 / 其他品牌 |
| 售后 subform | F2-12、F2-13、F2-14 | subform | 同上 | | 售后 subform | F2-12、F2-13、F2-14 | subform | 同上 |
| 轻改标题 | F2-93 | divider | `qgCode` | | 轻改标题 | F2-93 | divider | `qgCode` |
...@@ -81,7 +84,8 @@ ...@@ -81,7 +84,8 @@
|---------|------| |---------|------|
| IT-STORE-DIV-001~007 | `form-engine.test.mjs` | | IT-STORE-DIV-001~007 | `form-engine.test.mjs` |
| IT-STORE-ENG-003/005 | `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~006 | `store-template-schema.test.mjs`(V2.1.1 fixture) |
| IT-V211-* | `v211-template-visibility.test.mjs` |
| IT-STORE-STAFF-COUNT-001~005 | `store-staff-count.test.mjs` | | IT-STORE-STAFF-COUNT-001~005 | `store-staff-count.test.mjs` |
| IT-STORE-PENDING-* | `storeMonthlyPendingCount.test.mjs` | | IT-STORE-PENDING-* | `storeMonthlyPendingCount.test.mjs` |
| IT-STORE-FILTER-001/002 | `form-engine.test.mjs` | | IT-STORE-FILTER-001/002 | `form-engine.test.mjs` |
...@@ -91,4 +95,4 @@ ...@@ -91,4 +95,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 仅测试/ ...@@ -199,74 +199,64 @@ engine.init(schema, pageContext) // 页面主路径; setPageContext 仅测试/
## 6. 显隐规则引擎 ## 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 算法流程 ### 6.1 算法流程
```mermaid ```mermaid
flowchart TD flowchart TD
Start[计算字段是否可见] --> AttendanceCheck{"非 F1-1 且未选在岗?"} Start[计算字段是否可见] --> EchoCheck{detailEchoSpec}
AttendanceCheck -- 是 --> Hidden[隐藏并清值 destroy] EchoCheck -->|false| Hidden[隐藏并清值]
AttendanceCheck -- 否 --> SceneCodeCheck{field.baseSceneCode 非空?} EchoCheck -->|true| BaseOnly[仅 baseSceneSpec divider/baseSceneCode]
SceneCodeCheck -- 是 --> SceneCodeMatch{"ctx.baseSceneCode in field.baseSceneCode?"} EchoCheck -->|null 继续| ShowRule{fieldShowRuleSpec rules.keys+result}
SceneCodeCheck -- 否 --> SceneTypeCheck ShowRule -->|false| Hidden
SceneCodeMatch -- 否 --> Hidden ShowRule -->|true| BaseScene{baseSceneSpec}
SceneCodeMatch -- 是 --> SceneTypeCheck{field.sceneType 非空?} BaseScene -->|false| Hidden
SceneTypeCheck -- 是 --> SceneTypeMatch{"ctx.sceneType in field.sceneType?"} BaseScene -->|true| Brand{brandSpec brandId/filterBrandId}
SceneTypeCheck -- 否 --> BrandCheck Brand -->|false| Hidden
SceneTypeMatch -- 否 --> Hidden Brand -->|true| Visible[显示]
SceneTypeMatch -- 是 --> BrandCheck{field.brandId 非空?}
BrandCheck -- 是 --> BrandMatch{"field.brandId 与 ctx.brandIds 有交集?"}
BrandCheck -- 否 --> Visible[显示]
BrandMatch -- 否 --> Hidden
BrandMatch -- 是 --> Visible
``` ```
**divider**(`type:'divider'`)不走 `baseSceneCode`,走 [`isDividerVisible`](../form-engine/visibility.js):`isYB`/`isQY`/`ybCode`/`qyCode`/`qgCode` 与商户 `sceneList` 互斥组合(F2-91/92/93/94)。
### 6.2 规则说明 ### 6.2 规则说明
1. **出勤联动(全局)**:除 `F1-1` 外,当未选中「在岗」选项时(以 schema `options` 的 value 为准,如 `"调休"`),其余字段隐藏并清值;引擎 [`isAttendanceOnDuty`](../../form-engine/radio-value.js) 兼容 legacy `'1'`/`'2'`。 1. **详情回显(`detailEchoSpec`)**:编辑态且字段在 `echoSubformKeys`/`echoTopLevelKeys` 内时,**跳过 brand/filterBrandId**;divider 仍走场景规则;**仍校验 baseSceneCode**;出勤 gate 字段在调休时不因 echo 强制展示。
2. **baseSceneCode**:字段数组非空时,要求 `ctx.baseSceneCode` 落在字段数组内。 2. **字段联动(`fieldShowRuleSpec`)**:字段 `rules.keys` + `rules.result` 表达式为 false 时隐藏(如 `val1 == "在岗"`)。**无 keys/result 的字段不受出勤联动**——`F1-4` 备注调休仍可见。引擎 [`radio-value.js`](../form-engine/radio-value.js) 兼容 legacy `'1'`/`'2'` 与中文 `"在岗"`/`"调休"`。
3. **sceneType**:字段数组非空时,要求 `ctx.sceneType` 落在字段数组内。 3. **场景码(`baseSceneSpec`)**:非 divider 且 `baseSceneCode` 非空时,要求与商户 **`sceneList` 聚合码**(`getEffectiveSceneCodes`)有交集;**不是**单值 `ctx.baseSceneCode` 包含判断。
4. **brandId**:字段数组非空时,要求 `field.brandId` 与 `ctx.brandIds` **至少有一个交集**。 4. **品牌(`brandSpec`)**:`brandId` 非空时与 `ctx.brandIds` 有交集;`filterBrandId` 非空且商户经营品牌**全部**落在列表内时隐藏(如 F1-11、F2-11 其他品牌)。
5. **空数组 `[]`**:该维度跳过,不做限制。 5. **空数组 `[]`**:该维度跳过,不做限制。
6. **group**:group 自身先算可见性;可见才渲染 `children[0]`;子字段递归执行同一算法。 6. **group / subform**:容器自身先算可见性;可见才渲染 children;子字段/子列递归同一 spec 链。subform 行内可选 `childrenShowRules`(见 [group-repeater.md](./group-repeater.md))。
7. **重算触发**:`F1-1` 变更时全量重算;`PageContext` 变更时全量重算。 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) { ### 6.3 伪代码
return a.some(id => b.includes(id))
}
function isFieldVisible(field, ctx, values) { ```js
if (field.key !== ATTENDANCE_KEY && !isAttendanceOnDuty(list, values)) { function isFieldVisibleBySpecs(field, ctx, values, options) {
return false const echo = detailEchoSpec(field, ctx, values, options)
} if (echo === false) return false
if (field.baseSceneCode.length > 0 && !field.baseSceneCode.includes(ctx.baseSceneCode)) { if (echo === true) return baseSceneSpec(field, ctx, values, options)
return false if (!fieldShowRuleSpec(field, ctx, values, options)) return false
} if (!baseSceneSpec(field, ctx, values, options)) return false
if (field.sceneType.length > 0 && !field.sceneType.includes(ctx.sceneType)) { if (!brandSpec(field, ctx, values, options)) return false
return false
}
if (field.brandId.length > 0 && !hasIntersection(field.brandId, ctx.brandIds)) {
return false
}
return true return true
} }
/** 递归收集所有叶子字段(不含 group) */ function matchesBaseSceneCode(field, ctx) {
function flattenFields(list) { const fieldCodes = normalizeSceneCodeList(field.baseSceneCode)
const result = [] if (!fieldCodes.length) return true
for (const field of list) { const merchantCodes = getMerchantSceneCodes(ctx.sceneList)
if (field.type === 'group' && field.children?.[0]) { const effective = merchantCodes.length ? merchantCodes : normalizeSceneCodeList(ctx.baseSceneCode)
result.push(...flattenFields(field.children[0])) return fieldCodes.some(code => effective.includes(code))
} else if (field.type !== 'group') {
result.push(field)
}
}
return result
} }
``` ```
...@@ -275,11 +265,17 @@ function flattenFields(list) { ...@@ -275,11 +265,17 @@ function flattenFields(list) {
| 字段 | 可见条件(简述) | | 字段 | 可见条件(简述) |
| --- | --- | | --- | --- |
| `F1-1` 今日出勤 | 始终可见 | | `F1-1` 今日出勤 | 始终可见 |
| `F1-2` 延保退单数 | 在岗 + sceneType=0 + baseSceneCode∈{110201,110202} | | `F1-2` 延保退单数 | `rules.result` 在岗 + baseSceneCode∩sceneList 含延保码 |
| `F1-5` 问界分组 | 在岗 + brandIds 含 3454 + sceneType∈{0,1} + baseSceneCode 匹配 | | `F1-4` 备注 | 无 `rules.keys`;调休仍可见 |
| `F1-5-1` 轻改大定触客 | group 可见 + sceneType=1 + baseSceneCode∈轻改场景 | | `F1-5` 问界分组 | `rules.result` 在岗 + brandIds 含 3454 + baseSceneCode 匹配 |
| `F1-5-4` 延保售前触客 | group 可见 + sceneType=0 + baseSceneCode∈延保场景 | | `F1-5-1` 轻改大定触客 | group 可见 + baseSceneCode∈{100101,100102,100103} |
| `F1-11` 其他品牌 | 在岗 + (brandIds 无固定映射时的业务逻辑,schema 中 brandId/baseSceneCode 均为 `[]`) | | `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) { ...@@ -293,14 +289,17 @@ function flattenFields(list) {
| `integer` | boolean | `true` 时必须为整数 | | `integer` | boolean | `true` 时必须为整数 |
| `decimal` | boolean | `true` 时允许小数(金额字段) | | `decimal` | boolean | `true` 时允许小数(金额字段) |
| `maxLength` | number | 文本最大长度 | | `maxLength` | number | 文本最大长度 |
| `unit` | string | 单位展示,如 `"元"`(不参与校验,仅 UI) | | `keys` | string[] | 联动显隐依赖字段 key(如 `['F1-1']`) |
| `result` | string | 联动表达式(如 `val1 == "在岗"`),由 `fieldShowRuleSpec` eval |
`unit`(如 `"元"`)为**字段顶层属性**,不放在 `rules` 内。
### 规则组合示例 ### 规则组合示例
| 产品文案 | rules | | 产品文案 | rules |
| --- | --- | | --- | --- |
| 仅允许输入大于等于0的整数 | `{ "min": 0, "integer": true }` | | 仅允许输入大于等于0的整数 | `{ "min": 0, "integer": true }` |
| 金额,大于等于0,两位小数 | `{ "min": 0, "decimal": true, "unit": "元" }` | | 金额,大于等于0,两位小数 | 字段 `unit: "元"` + `{ "min": 0, "decimal": true }` |
| 输入不超过100字 | `{ "maxLength": 100 }` | | 输入不超过100字 | `{ "maxLength": 100 }` |
| 无额外规则 | `{}` | | 无额外规则 | `{}` |
......
...@@ -41,7 +41,7 @@ module.exports = { ...@@ -41,7 +41,7 @@ module.exports = {
} }
}, },
"2": { "2": {
"label": "延保 / 权益", "label": "延保/权益",
"sortNum": "3", "sortNum": "3",
"key": "F2-94", "key": "F2-94",
"type": "divider", "type": "divider",
...@@ -92,6 +92,10 @@ module.exports = { ...@@ -92,6 +92,10 @@ module.exports = {
0 0
], ],
"brandId": [], "brandId": [],
"ybCode": [
110201,
110202
],
"qyCode": [ "qyCode": [
110101, 110101,
110102 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"]
}
}
}
...@@ -14,6 +14,7 @@ const { parseGroupErrorKey } = require('../../form-engine/group-values.js') ...@@ -14,6 +14,7 @@ const { parseGroupErrorKey } = require('../../form-engine/group-values.js')
const negotiationApi = require('../../api/negotiationDailyReport.js') const negotiationApi = require('../../api/negotiationDailyReport.js')
const { loadNegotiationDailyForm } = require('../../services/negotiationDailyFormLoader.js') const { loadNegotiationDailyForm } = require('../../services/negotiationDailyFormLoader.js')
const { isApiSuccess } = require('../../utils/api-response.js') const { isApiSuccess } = require('../../utils/api-response.js')
const { buildDailyReportRequestContext } = require('../../utils/daily-report-request-context.js')
const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-state.js') const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-state.js')
const vinOcrBridge = require('../../services/vinOcrBridge.js') const vinOcrBridge = require('../../services/vinOcrBridge.js')
const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js') const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js')
...@@ -101,6 +102,7 @@ Page({ ...@@ -101,6 +102,7 @@ Page({
dailyReportRecordId: null, dailyReportRecordId: null,
userContext: null, userContext: null,
pageContext: null, pageContext: null,
_pageContextSnapshot: null,
loadSeq: 0, loadSeq: 0,
refreshSeq: 0, refreshSeq: 0,
engineKey: '', engineKey: '',
...@@ -455,20 +457,28 @@ Page({ ...@@ -455,20 +457,28 @@ Page({
return negotiationApi.normalizeUserInfo(userInfo) return negotiationApi.normalizeUserInfo(userInfo)
}, },
/** 解析 engine / load 快照,供 requestContext 透出场景码(AppData 可见) */
resolvePageContextForRequest() {
return (
this.engine?.getPageContext?.() ||
this._pageContextSnapshot ||
this.pageContext ||
{}
)
},
/** 透传给 select/multipleSelect 的 optionsKey 请求上下文(含 sceneType) */ /** 透传给 select/multipleSelect 的 optionsKey 请求上下文(含 sceneType) */
buildFormRequestContext() { buildFormRequestContext() {
const ctx = this.userContext || this.getRequestContext() const ctx = this.userContext || this.getRequestContext()
const userInfo = wx.$util?.getUserInfo?.() || {} const userInfo = wx.$util?.getUserInfo?.() || {}
return { return buildDailyReportRequestContext({
merchantId: ctx.merchantId || '', userContext: ctx,
yqMerchantId: ctx.yqMerchantId || '', userInfo,
staffUuid: ctx.staffUuid || '', reportDate: this.data.reportDate,
reportDate: this.data.reportDate || '',
reportType: 'negotiation', reportType: 'negotiation',
sceneType: userInfo.sceneType ?? ctx.sceneType ?? null, engineCtx: this.resolvePageContextForRequest(),
sceneList: this.pageContext?.sceneList || [], sceneTypeDefault: null
brandIds: this.pageContext?.brandIds || [] })
}
}, },
/** 主加载:Loader → engine.init → applyEngineView */ /** 主加载:Loader → engine.init → applyEngineView */
...@@ -493,6 +503,7 @@ Page({ ...@@ -493,6 +503,7 @@ Page({
} }
const { pageContext, schema, detail, initialValues } = loadRes.data const { pageContext, schema, detail, initialValues } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.pageContext = pageContext || null this.pageContext = pageContext || null
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null this.dailyReportRecordId = detail.dailyReportRecordId || null
...@@ -616,11 +627,12 @@ Page({ ...@@ -616,11 +627,12 @@ Page({
if (!isApiSuccess(loadRes.code) || !loadRes.data) return if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues, pageContext } = loadRes.data const { schema, detail, initialValues, pageContext } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.pageContext = pageContext || null
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail) this.syncReportSubmittedState(detail)
this.resetEditReport() this.resetEditReport()
if (!this.engine) return if (!this.engine) return
this.pageContext = pageContext || null
const viewState = this.reinitEngineFromLoadData({ const viewState = this.reinitEngineFromLoadData({
pageContext, pageContext,
schema, schema,
......
...@@ -20,6 +20,7 @@ const { ...@@ -20,6 +20,7 @@ const {
resolveReportSubmittedPatch resolveReportSubmittedPatch
} = require('../../utils/daily-report-edit-state.js') } = require('../../utils/daily-report-edit-state.js')
const { resolveWeekStateForReportDate } = require('../../utils/daily-report-calendar.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 dailyReportPage = require('../behaviors/dailyReportPage.js')
const dailyReportPageMethods = require('../behaviors/dailyReportPageMethods.js') const dailyReportPageMethods = require('../behaviors/dailyReportPageMethods.js')
...@@ -57,6 +58,7 @@ Page({ ...@@ -57,6 +58,7 @@ Page({
reportTemplateId: null, reportTemplateId: null,
dailyReportRecordId: null, dailyReportRecordId: null,
userContext: null, userContext: null,
_pageContextSnapshot: null,
loadSeq: 0, loadSeq: 0,
refreshSeq: 0, refreshSeq: 0,
engineKey: '', engineKey: '',
...@@ -332,17 +334,25 @@ Page({ ...@@ -332,17 +334,25 @@ Page({
return staffDailyApi.normalizeUserInfo(userInfo) return staffDailyApi.normalizeUserInfo(userInfo)
}, },
/** 解析 engine / load 快照,供 requestContext 透出场景码(AppData 可见) */
resolvePageContextForRequest() {
return (
this.engine?.getPageContext?.() ||
this._pageContextSnapshot ||
{}
)
},
/** 透传给 select/multipleSelect 的 optionsKey 请求上下文 */ /** 透传给 select/multipleSelect 的 optionsKey 请求上下文 */
buildFormRequestContext() { buildFormRequestContext() {
const ctx = this.userContext || this.getRequestContext() const ctx = this.userContext || this.getRequestContext()
return { return buildDailyReportRequestContext({
merchantId: ctx.merchantId || '', userContext: ctx,
yqMerchantId: ctx.yqMerchantId || '', reportDate: this.data.reportDate,
staffUuid: ctx.staffUuid || '',
reportDate: this.data.reportDate || '',
reportType: 'staff', reportType: 'staff',
sceneType: ctx.sceneType ?? 0 engineCtx: this.resolvePageContextForRequest(),
} sceneTypeDefault: 0
})
}, },
/** 主加载:Loader → engine.init → applyEngineView */ /** 主加载:Loader → engine.init → applyEngineView */
...@@ -368,6 +378,7 @@ Page({ ...@@ -368,6 +378,7 @@ Page({
} }
const { pageContext, schema, detail, initialValues } = loadRes.data const { pageContext, schema, detail, initialValues } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null this.dailyReportRecordId = detail.dailyReportRecordId || null
this.syncReportSubmittedState(detail) this.syncReportSubmittedState(detail)
...@@ -473,6 +484,7 @@ Page({ ...@@ -473,6 +484,7 @@ Page({
if (!isApiSuccess(loadRes.code) || !loadRes.data) return if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues, pageContext } = loadRes.data const { schema, detail, initialValues, pageContext } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail) this.syncReportSubmittedState(detail)
this.resetEditReport() this.resetEditReport()
......
...@@ -21,6 +21,10 @@ const { ...@@ -21,6 +21,10 @@ const {
shouldFetchMonthlyPendingCount shouldFetchMonthlyPendingCount
} = require('../../utils/store-monthly-pending.js') } = require('../../utils/store-monthly-pending.js')
const { isApiSuccess } = require('../../utils/api-response.js') const { isApiSuccess } = require('../../utils/api-response.js')
const { buildDailyReportRequestContext } = require('../../utils/daily-report-request-context.js')
const {
buildStoreDailySubmitConfirmModal
} = require('../../utils/store-daily-submit-confirm.js')
const { const {
STORE_STAFF_LIST_FIELD_KEY, STORE_STAFF_LIST_FIELD_KEY,
STORE_STAFF_COUNT_FIELD_KEY, STORE_STAFF_COUNT_FIELD_KEY,
...@@ -67,6 +71,7 @@ Page({ ...@@ -67,6 +71,7 @@ Page({
reportTemplateId: null, reportTemplateId: null,
dailyReportRecordId: null, dailyReportRecordId: null,
userContext: null, userContext: null,
_pageContextSnapshot: null,
loadSeq: 0, loadSeq: 0,
refreshSeq: 0, refreshSeq: 0,
engineKey: '', engineKey: '',
...@@ -353,18 +358,27 @@ Page({ ...@@ -353,18 +358,27 @@ Page({
return storeDailyApi.normalizeUserInfo(userInfo) return storeDailyApi.normalizeUserInfo(userInfo)
}, },
/** 解析 engine / load 快照,供 requestContext 透出场景码(AppData 可见) */
resolvePageContextForRequest() {
return (
this.engine?.getPageContext?.() ||
this._pageContextSnapshot ||
{}
)
},
/** 透传给 select/multipleSelect 的 optionsKey 请求上下文 */ /** 透传给 select/multipleSelect 的 optionsKey 请求上下文 */
buildFormRequestContext() { buildFormRequestContext() {
const ctx = this.userContext || this.getRequestContext() const ctx = this.userContext || this.getRequestContext()
const userInfo = wx.$util?.getUserInfo?.() || {} const userInfo = wx.$util?.getUserInfo?.() || {}
return { return buildDailyReportRequestContext({
merchantId: ctx.merchantId || '', userContext: ctx,
yqMerchantId: ctx.yqMerchantId || '', userInfo,
staffUuid: ctx.staffUuid || '', reportDate: this.data.reportDate,
reportDate: this.data.reportDate || '',
reportType: 'store', reportType: 'store',
sceneType: userInfo.sceneType ?? ctx.sceneType ?? null engineCtx: this.resolvePageContextForRequest(),
} sceneTypeDefault: null
})
}, },
/** 切日期时关闭汇总覆盖层 */ /** 切日期时关闭汇总覆盖层 */
...@@ -421,6 +435,7 @@ Page({ ...@@ -421,6 +435,7 @@ Page({
} }
const { pageContext, schema, detail, initialValues } = loadRes.data const { pageContext, schema, detail, initialValues } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null this.dailyReportRecordId = detail.dailyReportRecordId || null
this.applyReportStatusFromDetail(detail) this.applyReportStatusFromDetail(detail)
...@@ -627,14 +642,12 @@ Page({ ...@@ -627,14 +642,12 @@ Page({
} }
}, },
/** 保存并提交:二次确认后再走 submit */ /** 保存并提交:二次确认驻店/洽谈明细完成后再 dynamic.save */
onSubmitTap() { onSubmitTap() {
if (this.guardStoreDailyWriteInProgress()) return if (this.guardStoreDailyWriteInProgress()) return
const modal = buildStoreDailySubmitConfirmModal()
wx.showModal({ wx.showModal({
title: '重要提示', ...modal,
content: '确认提交后将不可再编辑,确认继续?',
cancelText: '取消',
confirmText: '确定',
success: res => { success: res => {
if (res.confirm) { if (res.confirm) {
this.submit() this.submit()
...@@ -722,6 +735,7 @@ Page({ ...@@ -722,6 +735,7 @@ Page({
if (!isApiSuccess(loadRes.code) || !loadRes.data) return if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues, pageContext } = loadRes.data const { schema, detail, initialValues, pageContext } = loadRes.data
this._pageContextSnapshot = pageContext || null
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail) this.syncReportSubmittedState(detail)
this.resetEditReport() this.resetEditReport()
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
extractSceneCodes,
resolveRequestSceneType,
buildDailyReportRequestContext
} = require('../utils/daily-report-request-context.js')
describe('daily-report-request-context', () => {
it('extractSceneCodes normalizes baseSceneCode list', () => {
assert.deepEqual(
extractSceneCodes([
{ baseSceneCode: '110201' },
{ baseSceneCode: 110101 },
{ foo: 1 }
]),
[110201, 110101]
)
})
it('resolveRequestSceneType prefers userInfo then userContext', () => {
assert.equal(
resolveRequestSceneType({ sceneType: 0 }, { sceneType: 1 }, 0),
1
)
assert.equal(resolveRequestSceneType({ sceneType: 0 }, {}, 0), 0)
assert.equal(resolveRequestSceneType({}, {}, null), null)
})
it('buildDailyReportRequestContext exposes scene flags for AppData', () => {
const ctx = buildDailyReportRequestContext({
userContext: {
merchantId: 'm4s',
yqMerchantId: 'yq',
staffUuid: 's1',
sceneType: 0
},
reportDate: '2026-07-09',
reportType: 'staff',
engineCtx: {
baseSceneCode: 110201,
sceneList: [{ baseSceneCode: 110201 }, { baseSceneCode: 110101 }],
brandIds: [3454]
}
})
assert.equal(ctx.reportType, 'staff')
assert.equal(ctx.baseSceneCode, 110201)
assert.deepEqual(ctx.sceneCodes, [110201, 110101])
assert.equal(ctx.hasWarrantyScene, true)
assert.equal(ctx.hasEquityScene, true)
assert.deepEqual(ctx.brandIds, [3454])
})
it('buildDailyReportRequestContext uses sceneTypeDefault for store when missing', () => {
const ctx = buildDailyReportRequestContext({
userContext: { merchantId: 'm1' },
userInfo: {},
reportDate: '2026-07-09',
reportType: 'store',
sceneTypeDefault: null,
engineCtx: { sceneList: [{ baseSceneCode: 110101 }] }
})
assert.equal(ctx.sceneType, null)
assert.equal(ctx.hasEquityScene, true)
assert.equal(ctx.hasWarrantyScene, false)
})
})
...@@ -186,6 +186,32 @@ describe('fieldOptionsAdapters', () => { ...@@ -186,6 +186,32 @@ describe('fieldOptionsAdapters', () => {
assert.deepEqual(res.data, [{ label: '交付专员甲', value: 'u-5', id: 'u-5', name: '交付专员甲' }]) assert.deepEqual(res.data, [{ label: '交付专员甲', value: 'u-5', id: 'u-5', name: '交付专员甲' }])
}) })
it('IT-FIELD-OPT-008: 4sStaffList passes name to getEmployeeList for popup search', async () => {
STORE_DAILY_API_SWITCH.fieldOptions = 'real'
let captured = null
__setEmployeeListApi({
getEmployeeList: async params => {
captured = params
return {
code: 0,
message: 'ok',
data: [{ staffName: '张三', uuid: 'u-8' }]
}
}
})
const res = await fetchFieldOptionsAdapter({
optionsKey: '4sStaffList',
reportType: 'negotiation',
merchantId: 'shop-3',
name: '张'
})
assert.deepEqual(captured, { merchantId: 'shop-3', name: '张' })
assert.equal(res.code, 0)
assert.deepEqual(res.data, [{ label: '张三', value: 'u-8', id: 'u-8', name: '张三' }])
})
it('IT-FIELD-OPT-007: storeStaffList uses yqMerchantId over merchantId (all pages)', async () => { it('IT-FIELD-OPT-007: storeStaffList uses yqMerchantId over merchantId (all pages)', async () => {
STAFF_DAILY_API_SWITCH.fieldOptions = 'real' STAFF_DAILY_API_SWITCH.fieldOptions = 'real'
let captured = null let captured = null
......
...@@ -104,4 +104,35 @@ describe('fieldOptionsService', () => { ...@@ -104,4 +104,35 @@ describe('fieldOptionsService', () => {
assert.equal(first.data[0].value, 'u-1') assert.equal(first.data[0].value, 'u-1')
assert.equal(second.data[0].value, 'u-2') assert.equal(second.data[0].value, 'u-2')
}) })
it('IT-FIELD-OPT-010: 4sStaffList name keyword uses separate cache key', async () => {
const { STORE_DAILY_API_SWITCH } = require('../config/apiSwitch.js')
STORE_DAILY_API_SWITCH.fieldOptions = 'real'
let callCount = 0
__setEmployeeListApi({
getEmployeeList: async params => {
callCount += 1
const label = params.name ? `员工-${params.name}` : '员工-全量'
return {
code: 0,
message: 'ok',
data: [{ staffName: label, uuid: `u-${callCount}` }]
}
}
})
const baseParams = {
optionsKey: '4sStaffList',
reportType: 'store',
merchantId: 'shop-1'
}
const full = await fetchFieldOptions(baseParams, { useCache: true })
const searched = await fetchFieldOptions({ ...baseParams, name: '张' }, { useCache: true })
const fullAgain = await fetchFieldOptions(baseParams, { useCache: true })
assert.equal(callCount, 2)
assert.equal(full.data[0].label, '员工-全量')
assert.equal(searched.data[0].label, '员工-张')
assert.equal(fullAgain.data[0].label, '员工-全量')
})
}) })
...@@ -9,6 +9,11 @@ const FIXTURE_FILES = { ...@@ -9,6 +9,11 @@ const FIXTURE_FILES = {
negotiation: '../fixtures/schema-negotiation-full.js' negotiation: '../fixtures/schema-negotiation-full.js'
} }
const V211_FIXTURE_FILES = {
staff: '../fixtures/schema-staff-daily-v2.1.1.json',
store: '../fixtures/schema-store-daily-v2.1.1.json'
}
export function loadSchemaFixture(kind = 'staff') { export function loadSchemaFixture(kind = 'staff') {
const file = FIXTURE_FILES[kind] const file = FIXTURE_FILES[kind]
if (!file) { if (!file) {
...@@ -17,3 +22,16 @@ export function loadSchemaFixture(kind = 'staff') { ...@@ -17,3 +22,16 @@ export function loadSchemaFixture(kind = 'staff') {
const indexed = require(file) const indexed = require(file)
return normalizeConfigToSchemaRoot(indexed) return normalizeConfigToSchemaRoot(indexed)
} }
/** 加载 V2.1.1 JSON fixture(list 形态,供显隐回归) */
export function loadSchemaFixtureV211(kind = 'staff') {
const file = V211_FIXTURE_FILES[kind]
if (!file) {
throw new Error(`Unknown V2.1.1 schema fixture: ${kind}`)
}
const payload = require(file)
if (!Array.isArray(payload?.list)) {
throw new Error(`V2.1.1 fixture missing list: ${kind}`)
}
return payload
}
import { describe, it } from 'node:test' import { describe, it } from 'node:test'
import assert from 'node:assert/strict' import assert from 'node:assert/strict'
import { createRequire } from 'node:module' import { loadSchemaFixtureV211 } from './schemaFixture.mjs'
import { loadSchemaFixture } from './schemaFixture.mjs'
const require = createRequire(import.meta.url) const staffSchema = loadSchemaFixtureV211('staff')
const { normalizeSchemaRoot } = require('../form-engine/schema-normalizer.js')
const { isAttendanceOnDuty } = require('../form-engine/radio-value.js')
const staffSchema = loadSchemaFixture('staff')
function findFieldByKey(list, key) { function findFieldByKey(list, key) {
return list.find(item => item.key === key) return list.find(item => item.key === key)
} }
describe('staff template schema fixture', () => { function findChildByKey(group, key) {
it('IT-STAFF-TPL-001: F1-1 uses Chinese on-duty options', () => { return (group?.children || []).find(child => child.key === key)
}
/** 递归收集 schema 内全部 key */
function collectAllKeys(list = []) {
const keys = []
function walk(field) {
if (!field?.key) return
keys.push(field.key)
const children = field.children
if (!Array.isArray(children)) return
for (const child of children) {
if (Array.isArray(child)) {
child.forEach(walk)
} else {
walk(child)
}
}
}
list.forEach(walk)
return keys
}
describe('staff daily template V2.1.1 schema', () => {
it('IT-STAFF-TPL-001: fixture metadata and F1-1 attendance radio', () => {
assert.equal(staffSchema.version, '2.1.1')
assert.equal(staffSchema.formCode, 'staff_daily_report')
assert.equal(staffSchema.list.length, 13)
const f11 = findFieldByKey(staffSchema.list, 'F1-1') const f11 = findFieldByKey(staffSchema.list, 'F1-1')
assert.equal(f11?.type, 'radio') assert.equal(f11?.type, 'radio')
assert.equal(f11?.value, '在岗') assert.equal(f11?.value, '在岗')
...@@ -24,37 +47,82 @@ describe('staff template schema fixture', () => { ...@@ -24,37 +47,82 @@ describe('staff template schema fixture', () => {
) )
}) })
it('IT-STAFF-TPL-002: legacy attendance value still counts as on duty', () => { it('IT-STAFF-TPL-002: F1-2/F1-3 on-duty show rules', () => {
assert.equal(isAttendanceOnDuty(staffSchema.list, { 'F1-1': '1' }), true) for (const key of ['F1-2', 'F1-3']) {
assert.equal(isAttendanceOnDuty(staffSchema.list, { 'F1-1': '在岗' }), true) const field = findFieldByKey(staffSchema.list, key)
assert.equal(isAttendanceOnDuty(staffSchema.list, { 'F1-1': '2' }), false) assert.equal(field?.rules?.keys?.[0], 'F1-1', key)
assert.equal(isAttendanceOnDuty(staffSchema.list, { 'F1-1': '调休' }), false) assert.match(String(field?.rules?.result), /在岗/, key)
}
}) })
it('IT-STAFF-TPL-003: F1-2 rules document on-duty show rule', () => { it('IT-STAFF-TPL-003: F1-12/F1-13 five-realm boutique top-level fields', () => {
const f12 = findFieldByKey(staffSchema.list, 'F1-2') for (const key of ['F1-12', 'F1-13']) {
assert.equal(f12?.rules?.keys?.[0], 'F1-1') const field = findFieldByKey(staffSchema.list, key)
assert.match(String(f12?.rules?.result), /在岗/) assert.equal(field?.type, 'numberInput', key)
assert.deepEqual(
field?.brandId,
[3454, 3503, 3458, 3574, 3502],
key
)
assert.deepEqual(field?.baseSceneCode, [100101, 100102, 100103], key)
}
}) })
it('IT-STAFF-TPL-004: F1-11 other-brand group has eight children including F1-11-8', () => { it('IT-STAFF-TPL-004: F1-5问界 group children after V2.1.1 trim', () => {
const group = findFieldByKey(staffSchema.list, 'F1-5')
assert.equal(group?.type, 'group')
assert.deepEqual(group?.brandId, [3454])
assert.deepEqual(group?.baseSceneCode, [100101, 100102, 100103, 110201, 110202])
const childKeys = (group?.children || []).map(c => c.key).sort()
assert.deepEqual(childKeys, ['F1-5-3', 'F1-5-4', 'F1-5-5', 'F1-5-6'])
assert.deepEqual(findChildByKey(group, 'F1-5-3')?.baseSceneCode, [
100101, 100102, 100103
])
assert.deepEqual(findChildByKey(group, 'F1-5-4')?.baseSceneCode, [
110201, 110202
])
})
it('IT-STAFF-TPL-005: removed F1-5-1/F1-5-2 not in schema', () => {
const keys = collectAllKeys(staffSchema.list)
assert.ok(!keys.includes('F1-5-1'))
assert.ok(!keys.includes('F1-5-2'))
assert.ok(!keys.includes('F1-10-1'))
assert.ok(!keys.includes('F1-10-2'))
})
it('IT-STAFF-TPL-006: F1-11 other-brand group has twelve children', () => {
const group = findFieldByKey(staffSchema.list, 'F1-11') const group = findFieldByKey(staffSchema.list, 'F1-11')
assert.equal(group?.type, 'group') assert.equal(group?.type, 'group')
assert.deepEqual(group?.filterBrandId, [ assert.deepEqual(group?.filterBrandId, [
3454, 3503, 3458, 3574, 3502, 3067 3454, 3503, 3458, 3574, 3502, 3067
]) ])
const keys = (group?.children || []).map(c => c.key)
assert.equal(keys.length, 8) const keys = (group?.children || []).map(c => c.key).sort()
assert.equal(keys.length, 12)
assert.ok(keys.includes('F1-11-8')) assert.ok(keys.includes('F1-11-8'))
assert.ok(keys.includes('F1-11-9'))
assert.ok(keys.includes('F1-11-10'))
const f118 = group.children.find(c => c.key === 'F1-11-8') const f118 = group.children.find(c => c.key === 'F1-11-8')
assert.deepEqual(f118?.baseSceneCode, [110101, 110102]) assert.deepEqual(f118?.baseSceneCode, [110101, 110102])
}) })
it('IT-STAFF-TPL-005: normalizeSchemaRoot merges F1-5 childrenRules', () => { it('IT-STAFF-TPL-007: F1-5 childrenRules cover active children', () => {
const normalized = normalizeSchemaRoot(staffSchema, {}) const group = findFieldByKey(staffSchema.list, 'F1-5')
const f15 = normalized.list.find(item => item.key === 'F1-5') const rules = group?.childrenRules || {}
const child = f15.children.find(c => c.key === 'F1-5-1') for (const key of ['F1-5-3', 'F1-5-4', 'F1-5-5', 'F1-5-6']) {
assert.equal(child.rules.integer, true) assert.equal(rules[key]?.integer, true, key)
assert.equal(child.rules.min, 0) assert.equal(rules[key]?.min, 0, key)
}
})
it('IT-STAFF-TPL-008: F1-10岚图 group is warranty-only', () => {
const group = findFieldByKey(staffSchema.list, 'F1-10')
assert.deepEqual(group?.baseSceneCode, [110201, 110202])
const childKeys = (group?.children || []).map(c => c.key)
assert.deepEqual(childKeys, ['F1-10-3', 'F1-10-4', 'F1-10-5'])
}) })
}) })
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const { buildStoreDailySubmitConfirmModal } = require('../utils/store-daily-submit-confirm.js')
describe('store-daily-submit-confirm', () => {
it('IT-STORE-SUBMIT-MODAL-001: submit modal copy matches product spec', () => {
const modal = buildStoreDailySubmitConfirmModal()
assert.equal(modal.title, '确定提交门店日报?')
assert.equal(
modal.content,
'请确认驻店人员在当前场景下已完成所有个人的驻店日报及洽谈明细。门店日报提交后,将立即发送相关门店经营统计数据到指定消息群。'
)
assert.equal(modal.cancelText, '我再想想')
assert.equal(modal.confirmText, '确定提交')
})
})
import { describe, it } from 'node:test' import { describe, it } from 'node:test'
import assert from 'node:assert/strict' import assert from 'node:assert/strict'
import { loadSchemaFixture } from './schemaFixture.mjs' import { loadSchemaFixtureV211 } from './schemaFixture.mjs'
const storeSchema = loadSchemaFixture('store') const storeSchema = loadSchemaFixtureV211('store')
function findFieldByKey(list, key) { function findFieldByKey(list, key) {
return list.find(item => item.key === key) return list.find(item => item.key === key)
} }
describe('store template schema fixture', () => { function collectAllKeys(list = []) {
it('IT-STORE-TPL-001: F2-1 completeFun targets F2-2 staff count', () => { const keys = []
function walk(field) {
if (!field?.key) return
keys.push(field.key)
const children = field.children
if (!Array.isArray(children)) return
for (const child of children) {
if (Array.isArray(child)) {
child.forEach(walk)
} else {
walk(child)
}
}
}
list.forEach(walk)
return keys
}
describe('store daily template V2.1.1 schema', () => {
it('IT-STORE-TPL-001: fixture metadata and F2-1/F2-2 staff count wiring', () => {
assert.equal(storeSchema.version, '2.1.1')
assert.equal(storeSchema.formCode, 'store_daily_report')
assert.equal(storeSchema.list.length, 55)
const f21 = findFieldByKey(storeSchema.list, 'F2-1') const f21 = findFieldByKey(storeSchema.list, 'F2-1')
assert.equal(f21?.type, 'multipleSelect') assert.equal(f21?.type, 'multipleSelect')
assert.equal(f21?.optionsKey, 'storeStaffList') assert.equal(f21?.optionsKey, 'storeStaffList')
...@@ -17,9 +40,7 @@ describe('store template schema fixture', () => { ...@@ -17,9 +40,7 @@ describe('store template schema fixture', () => {
key: 'F2-2', key: 'F2-2',
result: '(list.length)' result: '(list.length)'
}) })
})
it('IT-STORE-TPL-002: F2-2 has disabledFun keyed on F2-1', () => {
const f22 = findFieldByKey(storeSchema.list, 'F2-2') const f22 = findFieldByKey(storeSchema.list, 'F2-2')
assert.equal(f22?.type, 'numberInput') assert.equal(f22?.type, 'numberInput')
assert.equal(f22?.value, 0) assert.equal(f22?.value, 0)
...@@ -29,21 +50,63 @@ describe('store template schema fixture', () => { ...@@ -29,21 +50,63 @@ describe('store template schema fixture', () => {
}) })
}) })
it('IT-STORE-TPL-003: F2-91 isYB divider includes ybCode and qyCode', () => { it('IT-STORE-TPL-002: divider fields F2-91/F2-92/F2-94', () => {
const divider = findFieldByKey(storeSchema.list, 'F2-91') const f291 = findFieldByKey(storeSchema.list, 'F2-91')
assert.equal(divider?.type, 'divider') assert.equal(f291?.type, 'divider')
assert.equal(divider?.isYB, true) assert.equal(f291?.isYB, true)
assert.deepEqual(divider?.ybCode, [110201, 110202]) assert.deepEqual(f291?.ybCode, [110201, 110202])
assert.deepEqual(divider?.qyCode, [110101, 110102]) assert.deepEqual(f291?.qyCode, [110101, 110102])
const f292 = findFieldByKey(storeSchema.list, 'F2-92')
assert.equal(f292?.isQY, true)
const f294 = findFieldByKey(storeSchema.list, 'F2-94')
assert.equal(f294?.label, '延保/权益')
}) })
it('IT-STORE-TPL-004: F2-11 other-brand subform has filterBrandId', () => { it('IT-STORE-TPL-003: F2-11 other-brand subform has filterBrandId', () => {
const subform = findFieldByKey(storeSchema.list, 'F2-11') const subform = findFieldByKey(storeSchema.list, 'F2-11')
assert.equal(subform?.type, 'subform') assert.equal(subform?.type, 'subform')
assert.deepEqual(subform?.filterBrandId, [ assert.deepEqual(subform?.filterBrandId, [
3454, 3503, 3458, 3574, 3502, 3067 3454, 3503, 3458, 3574, 3502, 3067
]) ])
assert.deepEqual(subform?.baseSceneCode, [
110101, 110102, 110201, 110202
])
const orderChild = subform?.children?.[0]?.find(item => item.key === 'F2-11-1') const orderChild = subform?.children?.[0]?.find(item => item.key === 'F2-11-1')
assert.equal(orderChild?.optionsKey, '4sStaffList') assert.equal(orderChild?.optionsKey, '4sStaffList')
}) })
it('IT-STORE-TPL-004: removed F2-30/F2-36 not in schema', () => {
const keys = collectAllKeys(storeSchema.list)
assert.ok(!keys.includes('F2-30'))
assert.ok(!keys.includes('F2-36'))
})
it('IT-STORE-TPL-005: brand-split metrics F2-38/F2-44 exist', () => {
const f238 = findFieldByKey(storeSchema.list, 'F2-38')
assert.equal(f238?.label, '问界店总交付数')
assert.deepEqual(f238?.brandId, [3454])
assert.deepEqual(f238?.baseSceneCode, [110201, 110202])
const f244 = findFieldByKey(storeSchema.list, 'F2-44')
assert.equal(f244?.label, '其他品牌店总交付数')
assert.deepEqual(f244?.baseSceneCode, [
110101, 110102, 110201, 110202
])
assert.deepEqual(f244?.filterBrandId, [
3454, 3503, 3458, 3574, 3502, 3067
])
})
it('IT-STORE-TPL-006: F2-14 other-brand after-sales subform equity children', () => {
const subform = findFieldByKey(storeSchema.list, 'F2-14')
assert.equal(subform?.type, 'subform')
const row = subform?.children?.[0] || []
for (const key of ['F2-14-5', 'F2-14-6', 'F2-14-8']) {
const child = row.find(item => item.key === key)
assert.deepEqual(child?.baseSceneCode, [110101, 110102], key)
}
})
}) })
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { loadSchemaFixtureV211 } from './schemaFixture.mjs'
const BASE_SCENE_CODE = {
'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
}
/** 与 convert 脚本 extract_scene_codes 契约一致(边界匹配,防 2.1.1 误命中 1.1) */
function extractSceneCodes(visibility) {
const codes = []
for (const token of Object.keys(BASE_SCENE_CODE).sort((a, b) => b.length - a.length)) {
const pattern = new RegExp(`(?<![\\d.])${token.replace(/\./g, '\\.')}(?![\\d.])`)
if (pattern.test(visibility)) {
codes.push(BASE_SCENE_CODE[token])
}
}
return [...new Set(codes)].sort((a, b) => a - b)
}
function findFieldByKey(list, key) {
return list.find(item => item.key === key)
}
function findChildByKey(group, key) {
return (group?.children || []).find(child => child.key === key)
}
const staffSchema = loadSchemaFixtureV211('staff')
const storeSchema = loadSchemaFixtureV211('store')
describe('V2.1.1 scene code extraction contract', () => {
it('IT-V211-001: 2.1.1 visibility must not include boutique codes', () => {
assert.deepEqual(extractSceneCodes('[场景 包含 2.1.1 or 2.1.2] 则 [显示]'), [
110101, 110102
])
})
it('IT-V211-002: combined warranty/equity visibility excludes boutique', () => {
assert.deepEqual(
extractSceneCodes(
'[场景 包含 2.3.1 or 2.3.2 or 2.1.1 or 2.1.2] 则 [显示]'
),
[110101, 110102, 110201, 110202]
)
})
it('IT-V211-003: boutique-only visibility unchanged', () => {
assert.deepEqual(extractSceneCodes('[场景 包含 1.1 or 1.2 or 1.3] 则 [显示]'), [
100101, 100102, 100103
])
})
})
describe('V2.1.1 staff template baseSceneCode', () => {
const f111 = findFieldByKey(staffSchema.list, 'F1-11')
it('IT-V211-STAFF-001: F1-11 equity children use QY codes only', () => {
for (const key of ['F1-11-5', 'F1-11-6', 'F1-11-8']) {
const child = findChildByKey(f111, key)
assert.deepEqual(child?.baseSceneCode, [110101, 110102], key)
}
})
it('IT-V211-STAFF-002: F1-11 warranty child keeps YB codes only', () => {
const child = findChildByKey(f111, 'F1-11-7')
assert.deepEqual(child?.baseSceneCode, [110201, 110202])
})
})
describe('V2.1.1 store template baseSceneCode', () => {
it('IT-V211-STORE-001: F2-11 equity children use QY codes only', () => {
const subform = findFieldByKey(storeSchema.list, 'F2-11')
const row = subform?.children?.[0] || []
for (const key of ['F2-11-6', 'F2-11-7', 'F2-11-8']) {
const child = row.find(item => item.key === key)
assert.deepEqual(child?.baseSceneCode, [110101, 110102], key)
}
})
it('IT-V211-STORE-002: F2-14 equity children use QY codes only', () => {
const subform = findFieldByKey(storeSchema.list, 'F2-14')
const row = subform?.children?.[0] || []
for (const key of ['F2-14-5', 'F2-14-6', 'F2-14-8']) {
const child = row.find(item => item.key === key)
assert.deepEqual(child?.baseSceneCode, [110101, 110102], key)
}
})
it('IT-V211-STORE-003: other-brand combined parents exclude boutique codes', () => {
const expected = [110101, 110102, 110201, 110202]
for (const key of ['F2-44', 'F2-51', 'F2-8', 'F2-11', 'F2-14']) {
const field = findFieldByKey(storeSchema.list, key)
assert.deepEqual(field?.baseSceneCode, expected, key)
}
})
})
/** 与 form-engine matchesBaseSceneCode 契约一致,避免测试环境 ESM/CJS 混用 */
function matchesBaseSceneCode(field, ctx) {
const fieldCodes = (field?.baseSceneCode || []).map(code => Number(code))
if (!fieldCodes.length) return true
const merchantCodes = (ctx.sceneList || []).map(item => Number(item?.baseSceneCode))
return fieldCodes.some(code => merchantCodes.includes(code))
}
describe('V2.1.1 visibility contract under boutique-only scene', () => {
const boutiqueCtx = {
baseSceneCode: 100101,
brandIds: [3454, 2161],
sceneList: [{ baseSceneCode: 100101 }]
}
const equityCtx = {
baseSceneCode: 110101,
brandIds: [9999],
sceneList: [{ baseSceneCode: 110101 }]
}
const otherBrandCtx = {
baseSceneCode: 100101,
brandIds: [9999],
sceneList: [{ baseSceneCode: 100101 }]
}
it('IT-V211-STAFF-003: F1-11 equity/warranty children do not match boutique scene', () => {
const f111 = findFieldByKey(staffSchema.list, 'F1-11')
for (const key of ['F1-11-5', 'F1-11-6', 'F1-11-7', 'F1-11-8']) {
const child = findChildByKey(f111, key)
assert.equal(matchesBaseSceneCode(child, boutiqueCtx), false, key)
}
for (const key of ['F1-11-1', 'F1-11-2', 'F1-11-9']) {
const child = findChildByKey(f111, key)
assert.equal(matchesBaseSceneCode(child, boutiqueCtx), true, key)
}
})
it('IT-V211-STORE-004: other-brand warranty/equity parents do not match boutique scene', () => {
for (const key of ['F2-11', 'F2-14', 'F2-44', 'F2-51', 'F2-8']) {
const field = findFieldByKey(storeSchema.list, key)
assert.equal(matchesBaseSceneCode(field, otherBrandCtx), false, key)
}
})
it('IT-V211-STORE-005: F2-11 equity row cells do not match boutique scene', () => {
const subform = findFieldByKey(storeSchema.list, 'F2-11')
const rowTemplate = subform?.children?.[0] || []
for (const key of ['F2-11-6', 'F2-11-7', 'F2-11-8']) {
const cell = rowTemplate.find(item => item.key === key)
assert.equal(matchesBaseSceneCode(cell, otherBrandCtx), false, key)
}
})
it('IT-V211-STAFF-004: equity scene matches F1-11广联权益 children only', () => {
const f111 = findFieldByKey(staffSchema.list, 'F1-11')
for (const key of ['F1-11-5', 'F1-11-6', 'F1-11-8']) {
const child = findChildByKey(f111, key)
assert.equal(matchesBaseSceneCode(child, equityCtx), true, key)
}
for (const key of ['F1-11-1', 'F1-11-3', 'F1-11-7']) {
const child = findChildByKey(f111, key)
assert.equal(matchesBaseSceneCode(child, equityCtx), false, key)
}
})
it('IT-V211-STAFF-005: F1-12 boutique fields do not match equity-only scene', () => {
for (const key of ['F1-12', 'F1-13']) {
const field = findFieldByKey(staffSchema.list, key)
assert.equal(matchesBaseSceneCode(field, equityCtx), false, key)
}
})
})
/**
* @file 三份日报 Page 的 data.requestContext 组装(含场景调试字段)
* 纯函数:不读 wx、不调 setData;供 buildFormRequestContext 与单测使用
*/
const EQUITY_SCENE_CODES = [110101, 110102]
const WARRANTY_SCENE_CODES = [110201, 110202]
/** @param {Array} sceneList */
function extractSceneCodes(sceneList = []) {
return (Array.isArray(sceneList) ? sceneList : [])
.map(item => Number(item?.baseSceneCode))
.filter(code => !Number.isNaN(code))
}
/**
* @param {Object} [userContext={}]
* @param {Object} [userInfo={}] 门店/洽谈页优先取登录态 sceneType
* @param {number|null} [sceneTypeDefault=0]
* @returns {number|null}
*/
function resolveRequestSceneType(userContext = {}, userInfo = {}, sceneTypeDefault = 0) {
if (userInfo.sceneType != null && userInfo.sceneType !== '') {
return userInfo.sceneType
}
if (userContext.sceneType != null && userContext.sceneType !== '') {
return userContext.sceneType
}
return sceneTypeDefault
}
/**
* 组装页面 data.requestContext(AppData 可见场景码,绕过 getUserScene 缓存)
* @param {Object} [options={}]
* @param {Object} [options.userContext] normalize 后的用户上下文
* @param {Object} [options.userInfo] 原始登录态(可选,门店/洽谈优先 sceneType)
* @param {string} [options.reportDate]
* @param {string} [options.reportType] staff | store | negotiation
* @param {Object} [options.engineCtx] engine.getPageContext() 或 load 返回的 pageContext
* @param {number|null} [options.sceneTypeDefault=0]
* @returns {Object}
*/
function buildDailyReportRequestContext({
userContext = {},
userInfo = {},
reportDate = '',
reportType = 'store',
engineCtx = {},
sceneTypeDefault = 0
} = {}) {
const sceneList = Array.isArray(engineCtx.sceneList) ? engineCtx.sceneList : []
const sceneCodes = extractSceneCodes(sceneList)
return {
merchantId: userContext.merchantId || '',
yqMerchantId: userContext.yqMerchantId || '',
staffUuid: userContext.staffUuid || '',
reportDate: reportDate || '',
reportType,
sceneType: resolveRequestSceneType(userContext, userInfo, sceneTypeDefault),
baseSceneCode: engineCtx.baseSceneCode ?? null,
sceneList,
sceneCodes,
hasEquityScene: sceneCodes.some(code => EQUITY_SCENE_CODES.includes(code)),
hasWarrantyScene: sceneCodes.some(code => WARRANTY_SCENE_CODES.includes(code)),
brandIds: Array.isArray(engineCtx.brandIds) ? engineCtx.brandIds : []
}
}
module.exports = {
EQUITY_SCENE_CODES,
WARRANTY_SCENE_CODES,
extractSceneCodes,
resolveRequestSceneType,
buildDailyReportRequestContext
}
/**
* @file 门店日报「提交」二次确认弹窗文案
* 纯函数:供 storeDailyReport.onSubmitTap 与单测使用
*/
/**
* 门店日报提交前 wx.showModal 配置(提醒驻店/洽谈明细完成后再提交)
* @returns {{ title: string, content: string, cancelText: string, confirmText: string }}
*/
function buildStoreDailySubmitConfirmModal() {
return {
title: '确定提交门店日报?',
content:
'请确认驻店人员在当前场景下已完成所有个人的驻店日报及洽谈明细。门店日报提交后,将立即发送相关门店经营统计数据到指定消息群。',
cancelText: '我再想想',
confirmText: '确定提交'
}
}
module.exports = {
buildStoreDailySubmitConfirmModal
}
...@@ -11,10 +11,10 @@ function getWeekDayList(selectWeek, selectDay, customerDisabled) { ...@@ -11,10 +11,10 @@ function getWeekDayList(selectWeek, selectDay, customerDisabled) {
var mondayTime = var mondayTime =
selectWeekTime - (getWeekNumber(selectWeekTime) - 1) * 24 * 60 * 60 * 1000 selectWeekTime - (getWeekNumber(selectWeekTime) - 1) * 24 * 60 * 60 * 1000
// let testDate = new Date(mondayTime) // let testDate = new Date(mondayTime)
console.log(selectWeekTime, 'selectWeekTime') // console.log(selectWeekTime, 'selectWeekTime')
// console.log(getWeekNumber(selectWeekTime), getWeekNumber(selectWeekTime) - 1, 'getWeekNumber(selectWeekTime) - 1') // console.log(getWeekNumber(selectWeekTime), getWeekNumber(selectWeekTime) - 1, 'getWeekNumber(selectWeekTime) - 1')
// console.log(getDataFormat(selectWeekTime), 'selectWeekTime') // console.log(getDataFormat(selectWeekTime), 'selectWeekTime')
console.log(selectWeekTime, 'selectWeekTime') // console.log(selectWeekTime, 'selectWeekTime')
// console.log(getDataFormat(mondayTime), 'mondayTime') // console.log(getDataFormat(mondayTime), 'mondayTime')
var timeBean = { var timeBean = {
selectDay: 0, selectDay: 0,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!