Commit cd550b02 by 张立顺

fix bug

1 parent 96155887
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
| `packageDynamicForm/api/fieldOptionsAdapters.js#resolveMockMode` | — | — | | `packageDynamicForm/api/fieldOptionsAdapters.js#resolveMockMode` | — | — |
| `packageDynamicForm/api/fieldOptionsService.js#buildCacheKey` | — | — | | `packageDynamicForm/api/fieldOptionsService.js#buildCacheKey` | — | — |
| `packageDynamicForm/api/fieldOptionsService.js#clearFieldOptionsCache` | — | — | | `packageDynamicForm/api/fieldOptionsService.js#clearFieldOptionsCache` | — | — |
| `packageDynamicForm/api/fieldOptionsService.js#fetchFieldOptions` | `packageDynamicForm/components/form-field-multipleSelect/form-field-multipleSelect.js`<br>`packageDynamicForm/components/form-field-select/form-field-select.js` | — | | `packageDynamicForm/api/fieldOptionsService.js#fetchFieldOptions` | `packageDynamicForm/api/storeDailyReport.js`<br>`packageDynamicForm/components/form-field-multipleSelect/form-field-multipleSelect.js`<br>`packageDynamicForm/components/form-field-select/form-field-select.js` | — |
| `packageDynamicForm/api/mockDetailJsonContent.js#buildMockDetailJsonContent` | `packageDynamicForm/api/mockDynamicDetail.js`<br>`packageDynamicForm/api/mockStoreDynamicDetail.js` | — | | `packageDynamicForm/api/mockDetailJsonContent.js#buildMockDetailJsonContent` | `packageDynamicForm/api/mockDynamicDetail.js`<br>`packageDynamicForm/api/mockStoreDynamicDetail.js` | — |
| `packageDynamicForm/api/mockDynamicDetail.js#buildStaffSampleDetail` | — | — | | `packageDynamicForm/api/mockDynamicDetail.js#buildStaffSampleDetail` | — | — |
| `packageDynamicForm/api/mockDynamicDetail.js#delay` | — | — | | `packageDynamicForm/api/mockDynamicDetail.js#delay` | — | — |
...@@ -322,6 +322,7 @@ ...@@ -322,6 +322,7 @@
| `packageDynamicForm/api/staffDailyReportCache.js#setCachedSchema` | `packageDynamicForm/api/staffDailyReportAdapters.js` | — | | `packageDynamicForm/api/staffDailyReportCache.js#setCachedSchema` | `packageDynamicForm/api/staffDailyReportAdapters.js` | — |
| `packageDynamicForm/api/storeDailyReport.js#buildEmptyDetail` | — | — | | `packageDynamicForm/api/storeDailyReport.js#buildEmptyDetail` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#buildPageContextFromSources` | — | — | | `packageDynamicForm/api/storeDailyReport.js#buildPageContextFromSources` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#buildStoreStaffHydrationFailure` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#fetchDailyReportCarBrandList` | — | — | | `packageDynamicForm/api/storeDailyReport.js#fetchDailyReportCarBrandList` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#fetchMerchantBrandIds` | — | — | | `packageDynamicForm/api/storeDailyReport.js#fetchMerchantBrandIds` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#fetchMerchantScene` | — | — | | `packageDynamicForm/api/storeDailyReport.js#fetchMerchantScene` | — | — |
...@@ -331,14 +332,19 @@ ...@@ -331,14 +332,19 @@
| `packageDynamicForm/api/storeDailyReport.js#fetchSchema` | — | — | | `packageDynamicForm/api/storeDailyReport.js#fetchSchema` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#fetchWeeklyList` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — | | `packageDynamicForm/api/storeDailyReport.js#fetchWeeklyList` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — |
| `packageDynamicForm/api/storeDailyReport.js#hasValidDetailSchemaSnapshot` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — | | `packageDynamicForm/api/storeDailyReport.js#hasValidDetailSchemaSnapshot` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — |
| `packageDynamicForm/api/storeDailyReport.js#hydrateStoreStaffSelectionValue` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#hydrateStoreStaffSelectionsBeforeSave` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySchemaList` | — | — | | `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySchemaList` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySnapshotField` | — | — | | `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySnapshotField` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#logStoreSaveRequestDebug` | — | — | | `packageDynamicForm/api/storeDailyReport.js#logStoreSaveRequestDebug` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#needsStoreStaffNameHydration` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#normalizeDetailJsonContent` | — | — | | `packageDynamicForm/api/storeDailyReport.js#normalizeDetailJsonContent` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#normalizeDetailResponse` | — | — | | `packageDynamicForm/api/storeDailyReport.js#normalizeDetailResponse` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#normalizeUserInfo` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — | | `packageDynamicForm/api/storeDailyReport.js#normalizeUserInfo` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — |
| `packageDynamicForm/api/storeDailyReport.js#pushReportData` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — | | `packageDynamicForm/api/storeDailyReport.js#pushReportData` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — |
| `packageDynamicForm/api/storeDailyReport.js#resolveSchemaDetailValues` | — | — | | `packageDynamicForm/api/storeDailyReport.js#resolveSchemaDetailValues` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#resolveStoreStaffSelectionId` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#resolveStoreStaffSelectionName` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#revalidateCachedMetadata` | — | — | | `packageDynamicForm/api/storeDailyReport.js#revalidateCachedMetadata` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#saveDraftForm` | — | — | | `packageDynamicForm/api/storeDailyReport.js#saveDraftForm` | — | — |
| `packageDynamicForm/api/storeDailyReport.js#submitForm` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — | | `packageDynamicForm/api/storeDailyReport.js#submitForm` | `packageDynamicForm/pages/storeDailyReport/storeDailyReport.js` | — |
......
...@@ -4,24 +4,24 @@ ...@@ -4,24 +4,24 @@
## 规模 ## 规模
- 节点:9958 - 节点:9966
- 关系:22821 - 关系:22834
- 未解析:152 - 未解析:153
## 节点类型 ## 节点类型
| 类型 | 数量 | | 类型 | 数量 |
| --- | --- | | --- | --- |
| apiOperation | 715 | | apiOperation | 721 |
| component | 266 | | component | 266 |
| document | 134 | | document | 134 |
| domain | 15 | | domain | 15 |
| endpoint | 399 | | endpoint | 399 |
| globalState | 39 | | globalState | 39 |
| method | 7152 | | method | 7153 |
| module | 869 | | module | 869 |
| page | 165 | | page | 165 |
| test | 204 | | test | 205 |
## 关系类型 ## 关系类型
...@@ -29,14 +29,14 @@ ...@@ -29,14 +29,14 @@
| --- | --- | | --- | --- |
| bindsEvent | 2463 | | bindsEvent | 2463 |
| calls | 2511 | | calls | 2511 |
| callsApi | 775 | | callsApi | 776 |
| callsEndpoint | 491 | | callsEndpoint | 491 |
| contains | 1869 | | contains | 1870 |
| coveredBy | 417 | | coveredBy | 417 |
| declares | 7162 | | declares | 7163 |
| definesApi | 715 | | definesApi | 721 |
| documentedBy | 530 | | documentedBy | 530 |
| imports | 1991 | | imports | 1995 |
| navigatesTo | 240 | | navigatesTo | 240 |
| readsState | 2718 | | readsState | 2718 |
| usesComponent | 866 | | usesComponent | 866 |
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
| --- | --- | | --- | --- |
| page | 5 | | page | 5 |
| component | 18 | | component | 18 |
| apiOperation | 218 | | apiOperation | 224 |
| globalState | 1 | | globalState | 1 |
| test | 88 | | test | 88 |
| document | 25 | | document | 25 |
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
| apiOperation | `packageDynamicForm/api/staffDailyReportCache.js#setCachedSchema` | | apiOperation | `packageDynamicForm/api/staffDailyReportCache.js#setCachedSchema` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#buildEmptyDetail` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#buildEmptyDetail` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#buildPageContextFromSources` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#buildPageContextFromSources` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#buildStoreStaffHydrationFailure` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchDailyReportCarBrandList` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchDailyReportCarBrandList` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchMerchantBrandIds` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchMerchantBrandIds` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchMerchantScene` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchMerchantScene` |
...@@ -206,14 +207,19 @@ ...@@ -206,14 +207,19 @@
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchSchema` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchSchema` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchWeeklyList` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#fetchWeeklyList` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#hasValidDetailSchemaSnapshot` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#hasValidDetailSchemaSnapshot` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#hydrateStoreStaffSelectionValue` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#hydrateStoreStaffSelectionsBeforeSave` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySchemaList` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySchemaList` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySnapshotField` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#isValidStoreDailySnapshotField` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#logStoreSaveRequestDebug` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#logStoreSaveRequestDebug` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#needsStoreStaffNameHydration` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#normalizeDetailJsonContent` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#normalizeDetailJsonContent` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#normalizeDetailResponse` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#normalizeDetailResponse` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#normalizeUserInfo` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#normalizeUserInfo` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#pushReportData` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#pushReportData` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#resolveSchemaDetailValues` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#resolveSchemaDetailValues` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#resolveStoreStaffSelectionId` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#resolveStoreStaffSelectionName` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#revalidateCachedMetadata` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#revalidateCachedMetadata` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#saveDraftForm` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#saveDraftForm` |
| apiOperation | `packageDynamicForm/api/storeDailyReport.js#submitForm` | | apiOperation | `packageDynamicForm/api/storeDailyReport.js#submitForm` |
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
| component | 46 | | component | 46 |
| apiOperation | 106 | | apiOperation | 106 |
| globalState | 2 | | globalState | 2 |
| test | 26 | | test | 27 |
| document | 4 | | document | 4 |
## 可定位实体 ## 可定位实体
...@@ -222,6 +222,7 @@ ...@@ -222,6 +222,7 @@
| page | `tabWorkOrder/pages/updateOrderInfo/updateOrderInfo` | | page | `tabWorkOrder/pages/updateOrderInfo/updateOrderInfo` |
| page | `tabWorkOrder/pages/upgradeStaffDaily/upgradeStaffDaily` | | page | `tabWorkOrder/pages/upgradeStaffDaily/upgradeStaffDaily` |
| test | `tabWorkOrder/pages/createOrder/tests/customerDailyFields.helpers.test.mjs` | | test | `tabWorkOrder/pages/createOrder/tests/customerDailyFields.helpers.test.mjs` |
| test | `tabWorkOrder/pages/createOrder/tests/customerDailyFields.integration.test.mjs` |
| test | `tabWorkOrder/pages/createOrder/tests/customerDailyFields.ui.test.mjs` | | test | `tabWorkOrder/pages/createOrder/tests/customerDailyFields.ui.test.mjs` |
| test | `tabWorkOrder/pages/createOrder/tests/customerProfileEffects.test.mjs` | | test | `tabWorkOrder/pages/createOrder/tests/customerProfileEffects.test.mjs` |
| test | `tabWorkOrder/pages/createOrder/tests/goodsChooseEcho.helpers.test.mjs` | | test | `tabWorkOrder/pages/createOrder/tests/goodsChooseEcho.helpers.test.mjs` |
......
This diff could not be displayed because it is too large.
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
*/ */
const { buildPageContext, SCHEMA_OPTIONS_MAP } = require('../fixtures/mock-meta.js') const { buildPageContext, SCHEMA_OPTIONS_MAP } = require('../fixtures/mock-meta.js')
const { dynamicDailyReportSave } = require('./dynamicDailyReport.js') const { dynamicDailyReportSave } = require('./dynamicDailyReport.js')
const { fetchFieldOptions } = require('./fieldOptionsService.js')
const { const {
DEFAULT_REPORT_TEMPLATE_ID: { store: STORE_DEFAULT_REPORT_TEMPLATE_ID } DEFAULT_REPORT_TEMPLATE_ID: { store: STORE_DEFAULT_REPORT_TEMPLATE_ID }
} = require('../config/dailyReportConstants.js') } = require('../config/dailyReportConstants.js')
...@@ -70,8 +71,130 @@ const { ...@@ -70,8 +71,130 @@ const {
isApiSuccess, isApiSuccess,
isEmptyDetailPayload isEmptyDetailPayload
} = require('../utils/api-response.js') } = require('../utils/api-response.js')
const {
isMultipleSelectIdLikeLabel
} = require('../form-engine/multiple-select-display.helpers.js')
const { normalizeOptionRecord } = require('../form-engine/field-submit-value.js')
const IS_PRODUCTION = envIndex === 3 const IS_PRODUCTION = envIndex === 3
const STORE_STAFF_OPTIONS_KEY = 'storeStaffList'
function resolveStoreStaffSelectionId(item) {
if (item != null && typeof item === 'object') {
return item.id ?? item.value ?? ''
}
return item ?? ''
}
function resolveStoreStaffSelectionName(item) {
if (item == null || typeof item !== 'object') {
return ''
}
return item.name ?? item.label ?? ''
}
function needsStoreStaffNameHydration(item) {
const id = resolveStoreStaffSelectionId(item)
const name = resolveStoreStaffSelectionName(item)
return id !== '' && isMultipleSelectIdLikeLabel(name, id)
}
function hydrateStoreStaffSelectionValue(rawValue = [], options = []) {
const optionMap = new Map()
;(options || []).forEach(option => {
const normalized = normalizeOptionRecord(option)
if (normalized?.id) {
optionMap.set(String(normalized.id), normalized)
}
})
const unresolvedIds = []
const value = (Array.isArray(rawValue) ? rawValue : []).map(item => {
if (!needsStoreStaffNameHydration(item)) {
return item
}
const id = String(resolveStoreStaffSelectionId(item))
const matched = optionMap.get(id)
if (!matched || isMultipleSelectIdLikeLabel(matched.name, id)) {
unresolvedIds.push(id)
return item
}
return matched
})
return { value, unresolvedIds }
}
function buildStoreStaffHydrationFailure(code = -1, message = '') {
const reason = typeof message === 'string' && message.trim() && message !== 'ok'
? message.trim()
: '获取驻店人员失败'
return {
code: code ?? -1,
message: reason.includes('重新选择') ? reason : `${reason},请重新选择`
}
}
/**
* 保存前将 storeStaffList 的 UUID-only 回显补全为完整人员对象,避免 requestJson 生成 name=UUID。
* @param {Object} options
* @param {Object} options.engine 表单引擎
* @param {Object} [options.pageContext] 页面上下文
* @param {Object} [options.userContext] 当前用户上下文
* @param {string} [options.reportDate] 日报日期
* @returns {Promise<{code: number, message: string}>}
*/
async function hydrateStoreStaffSelectionsBeforeSave({
engine,
pageContext = {},
userContext = {},
reportDate = ''
} = {}) {
const schemaList = engine?.getSchemaList?.() || []
const values = engine?.getValues?.() || {}
const fields = schemaList.filter(field => (
field?.type === 'multipleSelect' &&
field.optionsKey === STORE_STAFF_OPTIONS_KEY &&
Array.isArray(values[field.key]) &&
values[field.key].some(needsStoreStaffNameHydration)
))
if (!fields.length) {
return { code: 0, message: 'ok' }
}
let result
try {
result = await fetchFieldOptions({
optionsKey: STORE_STAFF_OPTIONS_KEY,
merchantId: pageContext.merchantId || userContext.merchantId,
yqMerchantId: pageContext.yqMerchantId || userContext.yqMerchantId,
staffUuid: userContext.staffUuid,
reportDate,
reportType: 'store'
}, { useCache: false })
} catch (error) {
return buildStoreStaffHydrationFailure()
}
if (result?.code != 0) {
return buildStoreStaffHydrationFailure(result?.code, result?.message)
}
if (!Array.isArray(result.data)) {
return buildStoreStaffHydrationFailure()
}
const hydratedFields = []
for (const field of fields) {
const hydrated = hydrateStoreStaffSelectionValue(values[field.key], result.data)
if (hydrated.unresolvedIds.length) {
return {
code: 10002,
message: `${field.label || '今日驻店人员'}信息已失效,请重新选择`
}
}
hydratedFields.push({ key: field.key, value: hydrated.value })
}
hydratedFields.forEach(field => engine.setFieldValue(field.key, field.value))
return { code: 0, message: 'ok' }
}
/** 非生产环境:打印 save 请求体并校验 requestJson */ /** 非生产环境:打印 save 请求体并校验 requestJson */
function logStoreSaveRequestDebug(label, saveRequest = {}) { function logStoreSaveRequestDebug(label, saveRequest = {}) {
...@@ -589,6 +712,15 @@ async function submitForm(payload = {}) { ...@@ -589,6 +712,15 @@ async function submitForm(payload = {}) {
} }
const pageContext = engine.getPageContext() || {} const pageContext = engine.getPageContext() || {}
const userContext = normalizeUserInfo(wx.$util?.getUserInfo?.() || {}) const userContext = normalizeUserInfo(wx.$util?.getUserInfo?.() || {})
const hydrationResult = await hydrateStoreStaffSelectionsBeforeSave({
engine,
pageContext,
userContext,
reportDate
})
if (hydrationResult.code != 0) {
return { ...hydrationResult, data: null }
}
const { request: saveRequest, fieldDataList, subformDataList } = buildDailyReportSaveRequest({ const { request: saveRequest, fieldDataList, subformDataList } = buildDailyReportSaveRequest({
reportDate, reportDate,
userContext, userContext,
......
# DEVLOG — packageDynamicForm # DEVLOG — packageDynamicForm
## 2026-08-26 — 门店日报编辑态隐藏上报按钮
- **问题**:已保存的门店日报进入编辑后,页面仍可能显示「上报数据」,与编辑态只允许保存的交互约束不符。
- **根因**:操作区状态更新只把派生的 `showReport` 写入视图,`isEditReport` 仅直接修改 `data`;模板又只依赖 `showReport`,没有以响应式编辑标记做最终门禁。
- **修复**:`applyStoreDailyViewState` 在同一次 `setData` 中同步 `isEditReport` 与按钮状态;上报按钮改为 `showReport && !isEditReport` 才渲染。
- **验证**:`IT-STORE-DAILY-PAGE-001e/001f` 覆盖编辑态渲染门禁和单次视图状态同步。
## 2026-08-26 — 门店日报二次保存旧值修复
- **问题**:F2-101「今日驻店人员」保存后再次编辑时,`requestJson.fieldDataList[].fieldValue` 会把人员 UUID 同时写入 `id` 和 `name`;驻店人员、备注及 F2-107-18「未成交原因」还可能继续提交详情快照中的旧值。
- **根因**:UUID-only 的远程多选回显只在组件内通过选项接口补展示名;顶层字段的保存组装又保留了详情快照的 App 双键 `field[fieldKey]`。子表单则在已生成 engine 当前 `children` 后,仍保留上次保存的 `childrenValue`;lists 生成优先解码 `childrenValue`,因而覆盖了本次编辑的行数据。
- **修复**:门店日报保存前按 UUID 补全缺失的驻店人员姓名;生成保存 formList 时用 engine 当前值覆盖顶层详情双键,并在子表单写入当前 `children` 时删除继承的旧 `childrenValue`。无法补全人员姓名时阻止保存并提示重新选择。
- **验证**:`IT-STORE-SAVE-STAFF-001/002/003` 覆盖 UUID-only 回显与异常阻断;`IT-STORE-SAVE-LATEST-001/002/003` 覆盖驻店人员、备注和未成交原因的修改与清空;`IT-APP-LISTS-CURRENT-SUBFORM-001/002` 覆盖子表单清空值和删行不回灌旧 `childrenValue`。
## 2026-08-26 — 门店日报保存与编辑按钮改为蓝色
- **变更**:门店日报底部「保存」和「编辑」按钮统一使用页面主蓝色背景与白色文字。
- **边界**:仅调整门店日报页面本地样式,不影响「上报数据」按钮、其他日报页面或共享组件。
- **验证**:`IT-STORE-DAILY-PAGE-001d` 覆盖两种操作共用蓝色主按钮样式。
## 2026-08-24 — 门店日报移除洽谈明细表汇总入口 ## 2026-08-24 — 门店日报移除洽谈明细表汇总入口
- **变更**:移除门店日报底部「查看洽谈明细表汇总」按钮,并清理该页的汇总覆盖层、状态、事件、组件注册和专属样式。 - **变更**:移除门店日报底部「查看洽谈明细表汇总」按钮,并清理该页的汇总覆盖层、状态、事件、组件注册和专属样式。
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
| 今天或前 29 天无记录:可编辑,仅「保存」 | IT-STORE-STATE-001 | | 今天或前 29 天无记录:可编辑,仅「保存」 | IT-STORE-STATE-001 |
| 已保存记录:默认只读;可编辑日期显示「编辑」 | IT-STORE-STATE-002 | | 已保存记录:默认只读;可编辑日期显示「编辑」 | IT-STORE-STATE-002 |
| 今天已保存且未上报:只读,显示「编辑」及可用「上报数据」 | IT-STORE-STATE-002 | | 今天已保存且未上报:只读,显示「编辑」及可用「上报数据」 | IT-STORE-STATE-002 |
| 已保存记录进入编辑:只显示「保存」,隐藏「上报数据」 | IT-STORE-DAILY-PAGE-001e/001f |
| 已保存过去日期:只读,显示「编辑」;「上报数据」禁用 | IT-STORE-STATE-003 | | 已保存过去日期:只读,显示「编辑」;「上报数据」禁用 | IT-STORE-STATE-003 |
| 早于前 29 天:只读,显示禁用的「上报数据」 | IT-STORE-STATE-003 | | 早于前 29 天:只读,显示禁用的「上报数据」 | IT-STORE-STATE-003 |
| 未来:周历禁用,不能进入可编辑表单 | IT-STORE-STATE-003 | | 未来:周历禁用,不能进入可编辑表单 | IT-STORE-STATE-003 |
...@@ -124,9 +125,10 @@ ...@@ -124,9 +125,10 @@
### 保存与上报 ### 保存与上报
- **保存**:点击「保存」才调用 `dynamic.save`,并做必填校验。保存成功后回到默认只读态;已有记录须先点「编辑」才能再保存。 - **保存**:点击「保存」才调用 `dynamic.save`,并做必填校验。保存成功后回到默认只读态;已有记录须先点「编辑」才能再保存。
- **编辑值权威源**:二次保存以当前 engine values 及子表单行缓存为准;详情 `jsonContent` 快照保留的远程多选双键和子表单 `childrenValue` 仅用于初次回显,不得覆盖本次修改、清空或删行后的驻店人员、备注、未成交原因等当前值。
- **上报**:点击「上报数据」先二次确认,然后只执行 **`detail.get` → `dynamic.data.push({ dailyReportRecordId })`**。此路径绝不隐式保存,也不以当前未保存的表单值替换服务端记录;缺记录 id 或读取失败时不 push。 - **上报**:点击「上报数据」先二次确认,然后只执行 **`detail.get` → `dynamic.data.push({ dailyReportRecordId })`**。此路径绝不隐式保存,也不以当前未保存的表单值替换服务端记录;缺记录 id 或读取失败时不 push。
- **上报确认弹窗**:`title: "确定上报数据?"`;`content: "请确认已记录今日所有非成交客户信息,并确保成交客户已完成录单。门店日报上报后,将立即发送相关门店经营统计数据到指定消息群。"`;`cancelText: "我再想想"`;`confirmText: "确定"`。 - **上报确认弹窗**:`title: "确定上报数据?"`;`content: "请确认已记录今日所有非成交客户信息,并确保成交客户已完成录单。门店日报上报后,将立即发送相关门店经营统计数据到指定消息群。"`;`cancelText: "我再想想"`;`confirmText: "确定"`。
- **上报按钮**:只有「今天 + 已保存 + 未上报 + 非编辑态」可用;过去日期显示为禁用,已上报时不可再次上报。 - **上报按钮**:只有「今天 + 已保存 + 未上报 + 非编辑态」可用;进入编辑态后直接隐藏,过去日期显示为禁用,已上报时不可再次上报。
- **保存防护**:同一门店、日报日期和员工保存成功后 60 秒内再次保存提示「操作过于频繁,请稍后再试」;子表单按模板 `validateDuplicates` 声明的字段检查重复,空值忽略、字符串去除首尾空格,命中时阻止保存并列出全部重复行号。V2.3 `F2-107` 声明 `['F2-107-2']`,提示如「第1,3行客户手机号重复」。 - **保存防护**:同一门店、日报日期和员工保存成功后 60 秒内再次保存提示「操作过于频繁,请稍后再试」;子表单按模板 `validateDuplicates` 声明的字段检查重复,空值忽略、字符串去除首尾空格,命中时阻止保存并列出全部重复行号。V2.3 `F2-107` 声明 `['F2-107-2']`,提示如「第1,3行客户手机号重复」。
- **客户车架号**:V2.3.0 `F2-107-9` 为可选字段,只执行模板声明的 `maxLength: 20`;不执行固定 17 位格式或 VIN 接口校验。扫码/OCR 能力保留,识别结果只写回发起识别的子表行。 - **客户车架号**:V2.3.0 `F2-107-9` 为可选字段,只执行模板声明的 `maxLength: 20`;不执行固定 17 位格式或 VIN 接口校验。扫码/OCR 能力保留,识别结果只写回发起识别的子表行。
- **并发冲突弹窗**:进入编辑时记录详情接口返回的记录 ID;保存前重新 `detail.get`,仅当两次 ID 不一致(包括初始无 ID、最新有 ID)时提示覆盖。两次均无 ID 或 ID 相同均直接保存;ID 相同但内容变化不提示。 - **并发冲突弹窗**:进入编辑时记录详情接口返回的记录 ID;保存前重新 `detail.get`,仅当两次 ID 不一致(包括初始无 ID、最新有 ID)时提示覆盖。两次均无 ID 或 ID 相同均直接保存;ID 相同但内容变化不提示。
......
...@@ -62,11 +62,13 @@ App 草稿 `saveReport` 仅做 childrenValue 序列化、**不产** fieldDataLis ...@@ -62,11 +62,13 @@ App 草稿 `saveReport` 仅做 childrenValue 序列化、**不产** fieldDataLis
### 2.1 顶层字段 ### 2.1 顶层字段
- 普通字段:`type` 非 `subform`,保留 **`value`**(`select` / 远程 select 可有双 key `field[field.key]`)。远程 **单选** 入库 jsonContent:`value` 为回显名,`field[field.key]` 为 **id 字符串**(非 `{ id, name }` 对象)。 - 普通字段:`type` 非 `subform`,保留 **`value`**(`select` / 远程 select 可有双 key `field[field.key]`)。远程 **单选** 入库 jsonContent:`value` 为回显名,`field[field.key]` 为 **id 字符串**(非 `{ id, name }` 对象)。
- 远程 **`multipleSelect`**(`optionsKey` 为 `storeStaffList` 等,见 `REMOTE_SELECT_OPTIONS_KEYS`):双 key 与 App 一致——**`value`** 为选中项名称 `/` 拼接展示串,**`field[field.key]`** 为 id 字符串数组(如 F2-1 今日驻店人员);引擎回显优先读 `field[field.key]`。`fieldDataList` 仍为 `[{ id, name, ... }, ...]` JSON,与 jsonContent 形态独立。**从 jsonContent 单独生成 lists**(`buildAppNormalizedListsFromJsonContent`)时,会将 id 数组与 `value` 展示串按序 zip 为 `{ id, name }`(App / 小程序共用,见 `resolveMultipleSelectEngineValueFromAppField`)。 - 远程 **`multipleSelect`**(`optionsKey` 为 `storeStaffList` 等,见 `REMOTE_SELECT_OPTIONS_KEYS`):双 key 与 App 一致——**`value`** 为选中项名称 `/` 拼接展示串,**`field[field.key]`** 为 id 字符串数组(如 F2-1 今日驻店人员);引擎回显优先读 `field[field.key]`。编辑保存组装 formList 时,必须先用 engine 当前选择同时覆盖 `value` 与该双键;当前选择已清空时同步删除二者,详情快照中的旧 id 数组不得覆盖本次编辑。`fieldDataList` 仍为 `[{ id, name, ... }, ...]` JSON,与 jsonContent 形态独立。**从 jsonContent 单独生成 lists**(`buildAppNormalizedListsFromJsonContent`)时,会将 id 数组与 `value` 展示串按序 zip 为 `{ id, name }`(App / 小程序共用,见 `resolveMultipleSelectEngineValueFromAppField`)。
- 静态 `type: 'group'`:保留 **`children`**(扁平子字段列表 + 各字段 `value`),**不**转为 `childrenValue`。 - 静态 `type: 'group'`:保留 **`children`**(扁平子字段列表 + 各字段 `value`),**不**转为 `childrenValue`。
### 2.2 subform(入库形态) ### 2.2 subform(入库形态)
保存组装时,`buildAppJsonContent` 以 engine 当前行缓存生成 `children`,并必须删除详情 schema 快照继承的旧 `childrenValue`。否则 lists 解析会按回显协议优先读取 `childrenValue`,把本次修改、清空或删行恢复成上次保存数据。旧 `childrenValue` 仅在详情回显阶段作为数据源;进入提交组装后,当前 `children` 是行数据的唯一权威源。
```js ```js
{ {
key: 'F2-9', key: 'F2-9',
......
...@@ -2079,6 +2079,8 @@ export function buildAppJsonContent(visibleList = [], groupRowsCache = {}, pageC ...@@ -2079,6 +2079,8 @@ export function buildAppJsonContent(visibleList = [], groupRowsCache = {}, pageC
const rowFieldsList = groupRowsCache[field.key] || [] const rowFieldsList = groupRowsCache[field.key] || []
const section = cloneJson(field) const section = cloneJson(field)
delete section.value delete section.value
// 详情 schema 会携带上次保存的 childrenValue;本次 engine 行缓存才是提交权威源。
delete section.childrenValue
const children = cloneRowFieldsList(rowFieldsList).map(row => { const children = cloneRowFieldsList(rowFieldsList).map(row => {
const structurallyVisibleRow = row.filter(cell => const structurallyVisibleRow = row.filter(cell =>
......
...@@ -29,6 +29,7 @@ import { ...@@ -29,6 +29,7 @@ import {
buildNormalizedSubformDataList, buildNormalizedSubformDataList,
mapSchemaFieldToStorageType, mapSchemaFieldToStorageType,
serializeFieldValueForStorage, serializeFieldValueForStorage,
REMOTE_SELECT_OPTIONS_KEYS,
buildAppNormalizedListsFromJsonContent, buildAppNormalizedListsFromJsonContent,
buildAppJsonContent, buildAppJsonContent,
serializeFormListForAppJsonStorage, serializeFormListForAppJsonStorage,
...@@ -72,7 +73,13 @@ function applyStaticGroupValues(field = {}, values = {}, ctx = {}, schemaList = ...@@ -72,7 +73,13 @@ function applyStaticGroupValues(field = {}, values = {}, ctx = {}, schemaList =
return { ...next, children } return { ...next, children }
} }
function applyValuesToFormList(list = [], values = {}, ctx = {}, schemaList = []) { function applyValuesToFormList(
list = [],
values = {},
ctx = {},
schemaList = [],
{ clearMissing = false } = {}
) {
return (list || []).map(field => { return (list || []).map(field => {
if (field.type === 'subform') { if (field.type === 'subform') {
const nextGroup = { ...field } const nextGroup = { ...field }
...@@ -89,8 +96,23 @@ function applyValuesToFormList(list = [], values = {}, ctx = {}, schemaList = [] ...@@ -89,8 +96,23 @@ function applyValuesToFormList(list = [], values = {}, ctx = {}, schemaList = []
return applyStaticGroupValues(field, values, ctx, schemaList) return applyStaticGroupValues(field, values, ctx, schemaList)
} }
const nextField = { ...field } const nextField = { ...field }
const isRemoteMultipleSelect = Boolean(
field.key &&
REMOTE_SELECT_OPTIONS_KEYS.has(field.optionsKey) &&
field.type === 'multipleSelect'
)
if (values[field.key] !== undefined) { if (values[field.key] !== undefined) {
nextField.value = values[field.key] nextField.value = values[field.key]
// 详情快照保留远程多选 App 双键;编辑保存时必须让 engine 当前值覆盖旧 meta。
if (isRemoteMultipleSelect) {
nextField[field.key] = values[field.key]
}
} else if (clearMissing) {
// engine 会移除已清空字段;保存快照也必须删掉详情旧值,避免二次编辑回滚。
delete nextField.value
if (isRemoteMultipleSelect) {
delete nextField[field.key]
}
} }
return nextField return nextField
}) })
...@@ -148,11 +170,12 @@ function assembleFormListForSaveListsWithValues(engine, visibleList = [], saveVa ...@@ -148,11 +170,12 @@ function assembleFormListForSaveListsWithValues(engine, visibleList = [], saveVa
const cache = engine.getGroupRowsCache?.() || {} const cache = engine.getGroupRowsCache?.() || {}
const ctx = engine.getPageContext?.() || {} const ctx = engine.getPageContext?.() || {}
const schemaList = engine.getSchemaList?.() || [] const schemaList = engine.getSchemaList?.() || []
const topLevel = buildVisibleFormList( const topLevel = applyValuesToFormList(
visibleList.filter(field => field.type !== 'subform'), cloneJson(visibleList.filter(field => field.type !== 'subform')),
saveValues, saveValues,
ctx, ctx,
schemaList schemaList,
{ clearMissing: true }
) )
const subformSections = buildAppJsonContent(visibleList, cache, ctx) const subformSections = buildAppJsonContent(visibleList, cache, ctx)
return [...topLevel, ...subformSections] return [...topLevel, ...subformSections]
......
...@@ -261,6 +261,11 @@ Page({ ...@@ -261,6 +261,11 @@ Page({
return this.applyStoreDailyViewState({ isEditing: isEditReport }) return this.applyStoreDailyViewState({ isEditing: isEditReport })
}, },
/**
* 统一发布门店日报操作区状态,确保编辑标记与按钮在同一次 setData 中同步。
* @param {Object} [overrides] 本次状态重算的覆盖项
* @returns {Object} 已同步到页面的视图状态
*/
applyStoreDailyViewState(overrides = {}) { applyStoreDailyViewState(overrides = {}) {
const patch = resolveStoreDailyViewState({ const patch = resolveStoreDailyViewState({
isDateEditable: this.data.isDateWithinEditableWindow, isDateEditable: this.data.isDateWithinEditableWindow,
...@@ -271,7 +276,8 @@ Page({ ...@@ -271,7 +276,8 @@ Page({
loading: this.data.loading, loading: this.data.loading,
...overrides ...overrides
}) })
Object.assign(this.data, patch, { isEditReport: patch.isEditing }) patch.isEditReport = patch.isEditing
Object.assign(this.data, patch)
this.setData(patch) this.setData(patch)
return patch return patch
}, },
......
...@@ -81,8 +81,8 @@ page { ...@@ -81,8 +81,8 @@ page {
} }
.btns .save { .btns .save {
background: #fff; background: #347bff;
color: #292d33; color: #fff;
border: none; border: none;
} }
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<view wx:if="{{ showSave }}" class="save text-center" bindtap="onSave">保存</view> <view wx:if="{{ showSave }}" class="save text-center" bindtap="onSave">保存</view>
<view wx:if="{{ showEdit }}" class="save text-center" bindtap="editReport">编辑</view> <view wx:if="{{ showEdit }}" class="save text-center" bindtap="editReport">编辑</view>
<view <view
wx:if="{{ showReport }}" wx:if="{{ showReport && !isEditReport }}"
class="confirm text-center {{ reportDisabled ? 'is-disabled' : '' }}" class="confirm text-center {{ reportDisabled ? 'is-disabled' : '' }}"
bindtap="onSubmitTap" bindtap="onSubmitTap"
aria-disabled="{{ reportDisabled }}" aria-disabled="{{ reportDisabled }}"
......
...@@ -48,6 +48,35 @@ const subformJsonContent = JSON.stringify([ ...@@ -48,6 +48,35 @@ const subformJsonContent = JSON.stringify([
} }
]) ])
function buildStaleCustomerReasonSection() {
return {
key: 'F2-107',
label: '今日非成交客户',
type: 'subform',
childrenShowRules: {
'F2-107-18': {
keys: ['F2-107-7'],
result: "val1 && Array.isArray(val1) && val1.includes('1')"
}
},
origin_children: [
{
key: 'F2-107-7',
label: '客户标签',
type: 'multipleSelect',
options: [{ label: '已触客', value: '1' }]
},
{ key: 'F2-107-18', label: '未成交原因', type: 'input' }
],
childrenValue: [{
'F2-107': {
'F2-107-7': { text: '已触客', value: ['1'] },
'F2-107-18': '保存前的旧原因'
}
}]
}
}
const fullJsonContent = JSON.stringify([ const fullJsonContent = JSON.stringify([
{ {
key: 'F2-1', key: 'F2-1',
...@@ -465,4 +494,43 @@ describe('App save lists from jsonContent', () => { ...@@ -465,4 +494,43 @@ describe('App save lists from jsonContent', () => {
assert.equal(row['F2-107-18'], '价格原因') assert.equal(row['F2-107-18'], '价格原因')
}) })
it('IT-APP-LISTS-CURRENT-SUBFORM-001: clearing a reason does not reuse stale childrenValue', () => {
const formList = buildAppJsonContent(
[buildStaleCustomerReasonSection()],
{
'F2-107': [[
{
key: 'F2-107-7',
label: '客户标签',
type: 'multipleSelect',
options: [{ label: '已触客', value: '1' }],
value: ['1']
},
{ key: 'F2-107-18', label: '未成交原因', type: 'input' }
]]
}
)
const payload = buildAppDailyReportSubmitPayload(formList)
assert.ok(!payload.subformDataList.some(item => (
item.parentFieldKey === 'F2-107' &&
item.columnFieldKey === 'F2-107-18'
)))
const savedRow = JSON.parse(payload.jsonContent)[0]
.childrenValue[0]['F2-107']
assert.equal(savedRow['F2-107-18'], '')
assert.notEqual(savedRow['F2-107-18'], '保存前的旧原因')
})
it('IT-APP-LISTS-CURRENT-SUBFORM-002: deleting the current row removes stale childrenValue rows', () => {
const formList = buildAppJsonContent(
[buildStaleCustomerReasonSection()],
{ 'F2-107': [] }
)
const payload = buildAppDailyReportSubmitPayload(formList)
assert.ok(!payload.subformDataList.some(item => item.parentFieldKey === 'F2-107'))
assert.deepEqual(JSON.parse(payload.jsonContent)[0].childrenValue, [])
})
}) })
...@@ -8,6 +8,7 @@ const require = createRequire(import.meta.url) ...@@ -8,6 +8,7 @@ const require = createRequire(import.meta.url)
const pageRoot = new URL('../pages/storeDailyReport/', import.meta.url) const pageRoot = new URL('../pages/storeDailyReport/', import.meta.url)
const js = readFileSync(new URL('storeDailyReport.js', pageRoot), 'utf8') const js = readFileSync(new URL('storeDailyReport.js', pageRoot), 'utf8')
const wxml = readFileSync(new URL('storeDailyReport.wxml', pageRoot), 'utf8') const wxml = readFileSync(new URL('storeDailyReport.wxml', pageRoot), 'utf8')
const sass = readFileSync(new URL('storeDailyReport.sass', pageRoot), 'utf8')
const pageConfig = JSON.parse(readFileSync(new URL('storeDailyReport.json', pageRoot), 'utf8')) const pageConfig = JSON.parse(readFileSync(new URL('storeDailyReport.json', pageRoot), 'utf8'))
const calendarWxml = readFileSync(new URL('../components/weekCalendar/weekCalendar.wxml', import.meta.url), 'utf8') const calendarWxml = readFileSync(new URL('../components/weekCalendar/weekCalendar.wxml', import.meta.url), 'utf8')
...@@ -163,11 +164,56 @@ describe('storeDailyReport page contract', () => { ...@@ -163,11 +164,56 @@ describe('storeDailyReport page contract', () => {
it('IT-STORE-DAILY-PAGE-001b: edit and report render independently from showEdit and showReport', () => { it('IT-STORE-DAILY-PAGE-001b: edit and report render independently from showEdit and showReport', () => {
assert.match(wxml, /wx:if="\{\{ showEdit \}\}"[^>]*[\s\S]*?bindtap="editReport"/) assert.match(wxml, /wx:if="\{\{ showEdit \}\}"[^>]*[\s\S]*?bindtap="editReport"/)
assert.match(wxml, /wx:if="\{\{ showReport \}\}"[^>]*[\s\S]*?bindtap="onSubmitTap"/) assert.match(wxml, /wx:if="\{\{ showReport && !isEditReport \}\}"[^>]*[\s\S]*?bindtap="onSubmitTap"/)
assert.doesNotMatch(wxml, /wx:elif="\{\{ showEdit \}\}"/) assert.doesNotMatch(wxml, /wx:elif="\{\{ showEdit \}\}"/)
assert.doesNotMatch(wxml, /showReport\s*&&\s*hasSavedRecord/) assert.doesNotMatch(wxml, /showReport\s*&&\s*hasSavedRecord/)
}) })
it('IT-STORE-DAILY-PAGE-001e: report action is gated by the reactive edit flag', () => {
assert.match(
wxml,
/wx:if="\{\{ showReport && !isEditReport \}\}"[^>]*[\s\S]*?bindtap="onSubmitTap"/
)
})
it('IT-STORE-DAILY-PAGE-001f: entering edit publishes the edit flag and hides report in one view patch', () => {
const { page } = createStorePageHarness({
modules: {
'../../utils/store-daily-report-state.js': require('../utils/store-daily-report-state.js')
}
})
const viewPatches = []
Object.assign(page.data, {
isDateWithinEditableWindow: true,
isTodayReport: true,
hasSavedRecord: true,
isSubmissionReported: false,
isEditReport: false,
showReport: true,
loading: false
})
page.setData = patch => {
viewPatches.push(structuredClone(patch))
Object.assign(page.data, patch)
}
page.editReport()
const actionPatch = viewPatches[0]
assert.equal(actionPatch.isEditReport, true)
assert.equal(actionPatch.showReport, false)
assert.equal(actionPatch.showSave, true)
})
it('IT-STORE-DAILY-PAGE-001d: save and edit actions use the primary blue button style', () => {
assert.match(wxml, /class="save text-center"[^>]*bindtap="onSave"/)
assert.match(wxml, /class="save text-center"[^>]*bindtap="editReport"/)
assert.match(
sass,
/\.btns \.save \{[^}]*background:\s*#347bff;[^}]*color:\s*#fff;/
)
})
it('IT-STORE-DAILY-PAGE-001c: omits the negotiation summary entry and page integration', () => { it('IT-STORE-DAILY-PAGE-001c: omits the negotiation summary entry and page integration', () => {
const { page } = createStorePageHarness() const { page } = createStorePageHarness()
......
...@@ -232,8 +232,10 @@ Page({ ...@@ -232,8 +232,10 @@ Page({
packageList: [], packageList: [],
baseConfigData: {}, baseConfigData: {},
showSource: false, showSource: false,
customerSourcePickerIndex: 0,
customerTagOptions: getBoutiqueCustomerTagOptions(), customerTagOptions: getBoutiqueCustomerTagOptions(),
customerDailyFieldMerchantBrands: [], customerDailyFieldMerchantBrands: [],
customerDailyFieldBrandMerchantId: '',
customerTagDraftOptions: [], customerTagDraftOptions: [],
customerTagsPopup: false, customerTagsPopup: false,
customerTagsText: '', customerTagsText: '',
...@@ -1660,7 +1662,10 @@ Page({ ...@@ -1660,7 +1662,10 @@ Page({
/** /**
* 路由/接口回显写入 orderObj(编辑、再次下单、扫码礼券等)。 * 路由/接口回显写入 orderObj(编辑、再次下单、扫码礼券等)。
* 含礼券字段从 customerCoupon 回显的逻辑。 * 含礼券字段从 customerCoupon 回显的逻辑。
* 同门店客户档案回填时复用已加载的经营品牌立即同步日报字段显隐;
* 跨门店仍等待新经营品牌结果,避免沿用旧门店规则。
* @param {Object} options 订单详情或路由入参 * @param {Object} options 订单详情或路由入参
* @returns {void}
*/ */
setOrderObj(options) { setOrderObj(options) {
this._setOrderObjInvoked = true this._setOrderObjInvoked = true
...@@ -1814,6 +1819,21 @@ Page({ ...@@ -1814,6 +1819,21 @@ Page({
phase: 'pending', phase: 'pending',
customer: orderObj.customer customer: orderObj.customer
}) })
// 切店后的品牌请求存在等待窗口,必须同时核对缓存归属门店,避免串用旧品牌规则。
const canReuseMerchantBrandContext =
orderObj.merchantId !== undefined &&
orderObj.merchantId !== null &&
orderObj.merchantId !== '' &&
String(orderObj.merchantId) === String(prevOrderObj.merchantId || '') &&
String(orderObj.merchantId) ===
String(this.data.customerDailyFieldBrandMerchantId || '')
const pendingVisibilityContext = {
baseSceneName: orderObj.baseSceneName,
baseSceneCode: orderObj.baseSceneCode,
merchantBrands: canReuseMerchantBrandContext
? this.data.customerDailyFieldMerchantBrands || []
: []
}
// 回显订单类型名称 // 回显订单类型名称
let { orderTypeName, orderTypeList } = this.data let { orderTypeName, orderTypeList } = this.data
if (orderObj.djOrderType !== undefined && orderObj.djOrderType !== null) { if (orderObj.djOrderType !== undefined && orderObj.djOrderType !== null) {
...@@ -1830,6 +1850,14 @@ Page({ ...@@ -1830,6 +1850,14 @@ Page({
currentWordNumber: orderObj?.remark?.length || 0, currentWordNumber: orderObj?.remark?.length || 0,
orderObj, orderObj,
orderTypeName, orderTypeName,
customerTagsText: formatCustomerTags(orderObj.customer.customerTags),
showCustomerTags: isBoutiqueCustomerTagsVisible(
orderObj.customer.salesType
),
showActualDeliveryDate: isBoutiqueActualDeliveryDateVisible({
...pendingVisibilityContext,
salesType: orderObj.customer.salesType
}),
first: true, first: true,
flag: true, flag: true,
isErrorOrder, isErrorOrder,
...@@ -3069,7 +3097,8 @@ Page({ ...@@ -3069,7 +3097,8 @@ Page({
this.setData( this.setData(
{ {
customerTagOptions, customerTagOptions,
customerDailyFieldMerchantBrands: merchantBrands customerDailyFieldMerchantBrands: merchantBrands,
customerDailyFieldBrandMerchantId: requestMerchantId
}, },
() => { () => {
const resolvedCustomer = coordinateBoutiqueCustomerDailyFieldsEcho({ const resolvedCustomer = coordinateBoutiqueCustomerDailyFieldsEcho({
...@@ -3137,8 +3166,18 @@ Page({ ...@@ -3137,8 +3166,18 @@ Page({
'orderObj.customer.actualDeliveryDate': e.detail.value || '' 'orderObj.customer.actualDeliveryDate': e.detail.value || ''
}) })
}, },
/**
* 打开客户来源选择器,并按当前业务值定位选项。
* 客户档案可能直接回填 salesType,不能沿用 Picker 上一次保留的内部索引。
* @returns {void}
*/
toSelectCustomerSource() { toSelectCustomerSource() {
const salesType = this.data.orderObj?.customer?.salesType
const selectedIndex = (this.data.Sourcecolumns || []).findIndex(
item => String(item.type) === String(salesType)
)
this.setData({ this.setData({
customerSourcePickerIndex: selectedIndex >= 0 ? selectedIndex : 0,
showSource: true showSource: true
}) })
}, },
......
...@@ -914,10 +914,12 @@ value="{{ orderObj.remark }}" ...@@ -914,10 +914,12 @@ value="{{ orderObj.remark }}"
/> />
<van-popup show="{{ showSource }}" position="bottom" bind:close="onCloseSource"> <van-popup show="{{ showSource }}" position="bottom" bind:close="onCloseSource">
<van-picker <van-picker
wx:if="{{ showSource }}"
show-toolbar show-toolbar
title="客户来源" title="客户来源"
bind:cancel="onCloseSource" bind:cancel="onCloseSource"
columns="{{ Sourcecolumns }}" columns="{{ Sourcecolumns }}"
default-index="{{ customerSourcePickerIndex }}"
value-key="name" value-key="name"
bind:confirm="onChangeSource" bind:confirm="onChangeSource"
/> />
......
import assert from 'node:assert/strict'
import { register } from 'node:module'
import test from 'node:test'
register(
'../../../../tests/work-order-migration/shims/create-order-context-loader.mjs',
import.meta.url
)
let pageConfig
globalThis.getApp = () => ({ globalData: {} })
globalThis.Page = config => {
pageConfig = config
}
globalThis.require = specifier => {
if (specifier === '~/utils/timeFormat/time-utils.js') {
return { getTodayDateStr: () => '2026-08-26' }
}
throw new Error(`Unexpected CommonJS dependency in page test: ${specifier}`)
}
globalThis.wx = {
getAccountInfoSync: () => ({
miniProgram: { appId: 'test-app-id', envVersion: 'develop' }
}),
getDeviceInfo: () => ({ platform: 'devtools' }),
getWindowInfo: () => ({ screenWidth: 375, windowWidth: 375 }),
getAppBaseInfo: () => ({ host: { env: '' }, SDKVersion: 'test' }),
getSystemInfoSync: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
$util: {
getUserInfo: () => ({}),
showLoading() {}
}
}
await import(`../createOrder.js?customer-daily-fields=${Date.now()}`)
function createPage(currentMerchantId, cachedBrandMerchantId = currentMerchantId) {
return {
...pageConfig,
data: {
...structuredClone(pageConfig.data),
orderObj: {
merchantId: currentMerchantId,
baseSceneCode: 100101,
baseSceneName: '1.1 轻改场景',
customer: {
customerSex: 1,
experienceFlag: 'N',
salesType: 0
}
},
customerDailyFieldMerchantBrands: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: 3454, name: 'AITO 问界' }]
}
],
customerDailyFieldBrandMerchantId: cachedBrandMerchantId,
showActualDeliveryDate: false
},
setData(patch, callback) {
Object.assign(this.data, patch)
callback?.()
},
loadBoutiqueCustomerTagOptions() {},
echoCustomerProfileIfNeeded: async () => {},
getSelectOrderGoodsList() {}
}
}
function createSelectedCustomer(merchantId) {
return {
merchantId,
merchantName: `门店-${merchantId}`,
remark: '已有备注',
customer: {
customerSex: 1,
experienceFlag: 'N',
salesType: 3,
standNo: 'LSVAA4182E2123456',
carSeriesName: '问界M5',
actualDeliveryDate: ''
}
}
}
test('IT-WO-DAILY-020: customer profile immediately reuses brands only for the same merchant', () => {
const sameMerchantPage = createPage(10001)
pageConfig.setOrderObj.call(sameMerchantPage, createSelectedCustomer(10001))
assert.equal(sameMerchantPage.data.orderObj.customer.salesType, 3)
assert.equal(sameMerchantPage.data.showActualDeliveryDate, true)
const changedMerchantPage = createPage(10001)
pageConfig.setOrderObj.call(
changedMerchantPage,
createSelectedCustomer(20002)
)
assert.equal(changedMerchantPage.data.orderObj.customer.salesType, 3)
assert.equal(changedMerchantPage.data.showActualDeliveryDate, false)
const pendingBrandPage = createPage(20002, 10001)
pageConfig.setOrderObj.call(
pendingBrandPage,
createSelectedCustomer(20002)
)
assert.equal(pendingBrandPage.data.orderObj.customer.salesType, 3)
assert.equal(pendingBrandPage.data.showActualDeliveryDate, false)
})
test('IT-WO-DAILY-021: resolved brand context records its merchant provenance', async () => {
globalThis.__WORK_ORDER_MOCK_API__ = {
getMerchantCarBrandList: () => ({
code: 0,
data: {
data: [
{
carBrandList: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: 3454, name: 'AITO 问界' }]
}
]
}
]
}
})
}
const page = createPage(10001, '')
page.loadBoutiqueCustomerTagOptions =
pageConfig.loadBoutiqueCustomerTagOptions
try {
await page.loadBoutiqueCustomerTagOptions(10001)
assert.equal(page.data.customerDailyFieldBrandMerchantId, 10001)
} finally {
delete globalThis.__WORK_ORDER_MOCK_API__
}
})
test('IT-WO-DAILY-022: opening customer source picker selects the current source', () => {
const page = createPage(10001)
page.data.orderObj.customer.salesType = 3
pageConfig.toSelectCustomerSource.call(page)
assert.equal(page.data.showSource, true)
assert.equal(page.data.customerSourcePickerIndex, 1)
pageConfig.onCloseSource.call(page)
page.data.orderObj.customer.salesType = '1'
pageConfig.toSelectCustomerSource.call(page)
assert.equal(page.data.customerSourcePickerIndex, 2)
pageConfig.onCloseSource.call(page)
page.data.orderObj.customer.salesType = 99
pageConfig.toSelectCustomerSource.call(page)
assert.equal(page.data.customerSourcePickerIndex, 0)
})
...@@ -218,4 +218,18 @@ describe('boutique customer daily field UI contract', () => { ...@@ -218,4 +218,18 @@ describe('boutique customer daily field UI contract', () => {
orderListStart < deliveryDateStart && deliveryDateStart < orderPayTypeStart orderListStart < deliveryDateStart && deliveryDateStart < orderPayTypeStart
) )
}) })
it('IT-WO-DAILY-UI-015: customer source picker remounts with the current source index', () => {
const wxml = read('../createOrder.wxml')
const sourcePopup = wxml.match(
/<van-popup show="\{\{ showSource \}\}"[\s\S]*?<\/van-popup>/
)?.[0]
assert.ok(sourcePopup, 'customer source popup must exist')
assert.match(sourcePopup, /<van-picker[\s\S]*?wx:if="\{\{ showSource \}\}"/)
assert.match(
sourcePopup,
/default-index="\{\{ customerSourcePickerIndex \}\}"/
)
})
}) })
...@@ -67,6 +67,12 @@ export default { ...@@ -67,6 +67,12 @@ export default {
data: null data: null
}) })
}, },
getMerchantCarBrandList(data) {
return configuredResponse('getMerchantCarBrandList', data, {
code: 0,
data: { data: [] }
})
},
createWithPay(data) { createWithPay(data) {
return configuredResponse('createWithPay', data, { return configuredResponse('createWithPay', data, {
code: 0, code: 0,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!