Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2b60ea74
authored
Jun 16, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat 功能开发
1 parent
065d70ae
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
534 additions
and
140 deletions
config.js
packageDynamicForm/docs/DEVLOG.md
packageDynamicForm/docs/PAGES.md
packageDynamicForm/docs/TECH-SHARE.md
packageDynamicForm/docs/staff-template-features.md
packageDynamicForm/form-engine/json-content-persist.js
packageDynamicForm/form-engine/submit-adapter.js
packageDynamicForm/form-engine/visibility.js
packageDynamicForm/pages/behaviors/dailyReportPageMethods.js
packageDynamicForm/pages/negotiationDetail/negotiationDetail.js
packageDynamicForm/pages/staffDailyReport/staffDailyReport.js
packageDynamicForm/pages/storeDailyReport/storeDailyReport.js
packageDynamicForm/pages/storeDailyReport/storeDailyReport.wxml
packageDynamicForm/tests/json-content-persist.test.mjs
packageEquity/menu/asyncProviders.js
packageEquity/menu/badgeProviders.js
packageEquity/pages/index/index.wxml
tabIndex/docs/DEVLOG.md
tabIndex/docs/MENU-ARCHITECTURE.md
tabIndex/menu/asyncProviders.js
tabIndex/menu/badgeProviders.js
tabIndex/pages/index/index.wxml
tabIndex/tests/menu-badge-providers.test.mjs
utils/menuBadgeUtils.js
config.js
View file @
2b60ea7
...
...
@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布
* 5cdptest
*/
let
index
=
0
;
let
index
=
2
;
const
accountInfo
=
wx
.
getAccountInfoSync
();
const
systemInfo
=
wx
.
getSystemInfoSync
();
const
envName
=
accountInfo
.
miniProgram
.
envVersion
;
...
...
packageDynamicForm/docs/DEVLOG.md
View file @
2b60ea7
# DEVLOG — packageDynamicForm
## 2026-06-15 — 编辑保存后跨场景错误回显修复
-
**根因**
:
`buildJsonContentPersistList`
将场景/品牌隐藏块(含模板
`0`
)写入 jsonContent;
`getVisibleList`
static group 在 echo 下
`forceEchoBlock`
回退全量
`children`
;
`refreshAfterSubmit`
未用新
`pageContext`
-
**修复**
:
[
`json-content-persist.js`
](
../form-engine/json-content-persist.js
)
按隐藏原因过滤;static group 仅展示可见子项;三页提交后
`reinitEngineFromLoadData`
合并最新 echo 元数据
-
**单测**
:
`IT-STAFF-SAVE-SCENE-001`
、
`IT-ECHO-SCENE-001/002`
## 2026-06-15 — 门店日报已提交不显示编辑
-
**变更**
:
`storeDailyReport`
提交后永久只读,隐藏「编辑」及编辑态「保存/取消」;当天仍保留「查看洽谈明细表汇总」。驻店/洽谈仍保留编辑解锁。
## 2026-06-15 — 详情回显按 sceneList 过滤 baseSceneCode
-
**问题**
:
`detailEchoSpec`
白名单内 bypass
`baseSceneSpec`
,跨精品/权益 jsonContent 整块回显。
...
...
packageDynamicForm/docs/PAGES.md
View file @
2b60ea7
...
...
@@ -49,6 +49,7 @@
-
**jsonContent**
:顶层
`value`
;无 subform 时无
`childrenValue`
-
**草稿**
:无(仅门店有双按钮)
-
**saveEcho**
:
`off`
,回显依赖服务端 detail
-
**jsonContent 持久化**
:仅可见项 + 出勤等动态规则隐藏块;
**不**
写入
`baseSceneCode`
/
`brandId`
不匹配的 static group 或纯模板
`0`
;subform 有用户填写行时仍可跨场景入库(
`json-content-persist.js`
)
### 字段选项
...
...
@@ -102,7 +103,7 @@
| 状态 | TEST-ID |
|------|---------|
| 当天未提交:保存并提交 + 保存 + 洽谈汇总 | IT-STORE-PAGE-002 |
| 当天已提交只读 | IT-STORE-PAGE-009 |
| 当天已提交只读
(无编辑)
| IT-STORE-PAGE-009 |
| 非当天只读 | IT-STORE-PAGE-005 |
| 加载失败 | IT-STORE-PAGE-008 |
| 场景为空 | IT-STORE-LOADER-003 |
...
...
@@ -112,7 +113,7 @@
-
**保存并提交**
:点击后
`wx.showModal`
(标题「重要提示」,文案「确认提交后将不可再编辑,确认继续?」);确定后
`dynamic.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
)
-
**reportStatus**
:
`0`
草稿 /
`1`
已提交;当天已提交(
`reportStatus=1`
或
`weeklyList`
含当日)表单只读,
底部显示「编辑」;点编辑后「保存」「取消」
;草稿态仍「提交」「保存」
-
**reportStatus**
:
`0`
草稿 /
`1`
已提交;当天已提交(
`reportStatus=1`
或
`weeklyList`
含当日)表单只读,
**无「编辑」**
(不可再次提交)
;草稿态仍「提交」「保存」
### 洽谈明细表汇总
...
...
@@ -224,7 +225,7 @@
| staffDailyReport | 调休 | F1-1 选「调休」 | 仅出勤可见,其余隐藏并清值 | IT-PAGE-006 |
| staffDailyReport | 加载失败 / 场景为空 | 接口失败或 scene 空 | 「暂无数据」或空态 +「重新加载」 | IT-PAGE-008 / IT-LOADER-003 |
| storeDailyReport | 当天未提交 | 当天且 reportStatus=0 | 可编辑 +「保存并提交」「保存」「洽谈汇总」 | IT-STORE-PAGE-002 |
| storeDailyReport | 当天已提交 | 当天且已提交 | 只读 +
「编辑」;编辑态「保存」「取消」;
**仍保留**
洽谈汇总
| IT-STORE-PAGE-009 |
| storeDailyReport | 当天已提交 | 当天且已提交 | 只读 +
洽谈汇总(
**无编辑**
)
| IT-STORE-PAGE-009 |
| storeDailyReport | 非当天只读 | 选中非当天 | 只读;无底部按钮(含洽谈汇总) | IT-STORE-PAGE-005 |
| storeDailyReport | 加载失败 / 场景为空 | 同驻店 | 空态 +「重新加载」 | IT-STORE-PAGE-008 / IT-STORE-LOADER-003 |
| negotiationDetail | 当天未提交 | 周历选中当天 | 可编辑 + F3 subform + 底部「提交」 | IT-PAGE-001 |
...
...
packageDynamicForm/docs/TECH-SHARE.md
View file @
2b60ea7
...
...
@@ -42,6 +42,15 @@
当前实现是业务表单基础设施层面的方案验证,证明了 Schema + Engine + dynamic-form + Adapter 这条链路在小程序侧能走通,但不是可视化低代码平台——复杂审批流、离线冲突、多人协同等不在设计目标内。动态日报是当前验证场景;其它业务(工单、报备等)可复用 Engine 与 UI,换 schema 和 Adapter 即可。是否完全符合产品「零代码配一切」的预期,还需对齐配置天花板(预研问题第 6 条)。
**后续可扩展:**
已有 type 范围内改 schema 显隐/字段成本最低;新需求可走 registry 注册 type、扩展 optionsKey 数据源、新增 savePolicy 或显隐 Specification、新分包 Page 接入同一套 dynamic-form。form-engine 纯 JS 可与 H5 共享运行时,UI 分端实现,Schema 可同源。
细节见
[
ARCHITECTURE.md
](
./ARCHITECTURE.md
)
(分层与序列图)、
[
DYNAMIC-FORM-GUIDE.md
](
./DYNAMIC-FORM-GUIDE.md
)
(日报业务速查)。
按投入从低到高,这套能力可以持续拉长:
1.
**配置层**
— 在已有 type 内增删字段、改显隐维度与 rules;补 Specification 组合新场景(品牌/权限/行内条件),产品改配置中心即可减发版。
2.
**组件层**
— registry 注册新 form-field 组件(附件、签名、地图选点等),统一校验与 submit 值形态。
3.
**数据层**
— 扩展 optionsKey 与 mock/real Adapter,远程下拉、级联、默认值接口可插拔复用。
4.
**策略层**
— 新 savePolicy、草稿/只读/审批态策略,让不同业务 save 契约不进 Engine 硬编码。
5.
**宿主层**
— 工单、报备、建档等新分包 Page 复制「Loader + Adapter + dynamic-form」模式,换 schema 即可接入。
6.
**跨端**
— form-engine 纯 JS 与 H5 共享运行时;Schema 同源,小程序与 H5 分端 UI,App jsonContent 互显契约继续单点维护。
7.
**工程化**
— bootstrap/Adapter 模板化、pageContext 类型约束、配置 diff 与联调 fixture,降低新表单接入人力。
8.
**中长期(对齐天花板)**
— 配置预览、字段级变更审计、可视化搭表单等需单独立项,不能替代当前「Page 壳 + 集成层」边界。
日报验证的是整条组件链;后续业务只换配置与集成,不必再各写一套表单运行时。
packageDynamicForm/docs/staff-template-features.md
View file @
2b60ea7
...
...
@@ -54,8 +54,8 @@
| 子字段
`sceneType`
/
`baseSceneCode`
|
`isFieldVisible`
→
`matchesBaseSceneCode`
| 轻改码 vs 延保码分行展示 |
| group
`brandId`
|
`hasIntersection(brandId, ctx.brandIds)`
| 无该品牌则不展示整块 group |
| F1-11
`filterBrandId`
|
`shouldHideByFilterBrandId`
| 经营品牌全部在列表内时隐藏「其他品牌」 |
| 详情回显 |
`hasDetailEcho`
+
`echoSubformKeys`
(含 group) | 回显白名单内跳过 brand/filter 限制 |
| 保存 |
`buildDynamicSavePayload`
/ App jsonContent | 顶层 value;无 subform;
**lists 仅可见**
;
**jsonContent 含
可见 + 有值的隐藏块**
(调休时品牌 group 仍入库供回显
) |
| 详情回显 |
`hasDetailEcho`
+
`echoSubformKeys`
(含 group) | 回显白名单内跳过 brand/filter 限制
;
**仍按**
`sceneList`
↔
`baseSceneCode`
过滤;static group 不因 echo 回退全量子字段
|
| 保存 |
`buildDynamicSavePayload`
/ App jsonContent | 顶层 value;无 subform;
**lists 仅可见**
;
**jsonContent 含
出勤等动态规则隐藏的块**
;
**不含**
场景/brand 级隐藏块与纯模板
`0`
(见
`json-content-persist.js`
) |
---
...
...
packageDynamicForm/form-engine/json-content-persist.js
0 → 100644
View file @
2b60ea7
/**
* jsonContent 持久化范围:可见项 + 动态规则隐藏的块;排除场景/品牌级隐藏与纯模板 0
*/
import
{
hasIntersection
,
schemaHasAttendanceField
}
from
'./visibility.js'
import
{
isAttendanceOnDuty
}
from
'./radio-value.js'
import
{
getStaticGroupChildren
,
getSubformRowTemplate
}
from
'./field-types.js'
import
{
baseSceneSpec
}
from
'./visibility/specs/base-scene.js'
function
hasStoredValue
(
value
)
{
if
(
value
===
undefined
||
value
===
null
||
value
===
''
)
{
return
false
}
if
(
Array
.
isArray
(
value
)
&&
value
.
length
===
0
)
{
return
false
}
return
true
}
/** numberInput 仅为 schema 默认 0 时不计入持久化 */
export
function
isTemplateOnlyDefaultValue
(
field
=
{},
value
)
{
if
(
!
hasStoredValue
(
value
))
{
return
false
}
if
(
field
.
type
!==
'numberInput'
)
{
return
false
}
const
num
=
Number
(
value
)
if
(
Number
.
isNaN
(
num
)
||
num
!==
0
)
{
return
false
}
const
templateDefault
=
field
.
value
return
(
templateDefault
===
undefined
||
templateDefault
===
null
||
templateDefault
===
''
||
Number
(
templateDefault
)
===
0
)
}
export
function
hasMeaningfulPersistValue
(
field
=
{},
value
)
{
if
(
!
hasStoredValue
(
value
))
{
return
false
}
return
!
isTemplateOnlyDefaultValue
(
field
,
value
)
}
function
buildPersistVisibilityOptions
(
schemaList
=
[],
values
=
{},
ctx
=
{})
{
return
{
schemaList
,
hasAttendanceField
:
schemaHasAttendanceField
(
schemaList
),
attendanceOnDuty
:
isAttendanceOnDuty
(
schemaList
,
values
),
echoSubformKeys
:
ctx
.
echoSubformKeys
}
}
/** 因 baseSceneCode 或 brandId 与门店不匹配而不可持久化 */
export
function
failsStructuralPersistVisibility
(
field
=
{},
ctx
=
{},
values
=
{},
options
=
{})
{
if
(
!
baseSceneSpec
(
field
,
ctx
,
values
,
options
))
{
return
true
}
if
(
field
.
brandId
?.
length
>
0
&&
!
hasIntersection
(
field
.
brandId
,
ctx
.
brandIds
||
[]))
{
return
true
}
return
false
}
function
subformRowsHaveUserData
(
group
=
{},
rows
=
[])
{
if
(
!
Array
.
isArray
(
rows
)
||
!
rows
.
length
)
{
return
false
}
const
columnTemplate
=
getSubformRowTemplate
(
group
)
const
fieldByKey
=
new
Map
()
columnTemplate
.
forEach
(
child
=>
{
if
(
child
?.
key
)
{
fieldByKey
.
set
(
child
.
key
,
child
)
}
})
return
rows
.
some
(
rowFields
=>
{
if
(
!
Array
.
isArray
(
rowFields
))
{
return
false
}
return
rowFields
.
some
(
cell
=>
{
const
schemaField
=
fieldByKey
.
get
(
cell
.
key
)
||
cell
return
hasMeaningfulPersistValue
(
schemaField
,
cell
.
value
)
})
})
}
function
groupHasPersistableChildren
(
field
=
{},
values
=
{})
{
return
getStaticGroupChildren
(
field
).
some
(
child
=>
hasMeaningfulPersistValue
(
child
,
values
[
child
.
key
])
)
}
/**
* 隐藏块是否应写入 jsonContent
* @returns {boolean}
*/
export
function
shouldPersistHiddenBlock
(
field
=
{},
ctx
=
{},
values
=
{},
groupRowsCache
=
{},
options
=
{}
)
{
if
(
failsStructuralPersistVisibility
(
field
,
ctx
,
values
,
options
))
{
if
(
field
.
type
===
'subform'
)
{
const
rows
=
groupRowsCache
[
field
.
key
]
return
subformRowsHaveUserData
(
field
,
rows
)
}
return
false
}
if
(
field
.
type
===
'subform'
)
{
const
rows
=
groupRowsCache
[
field
.
key
]
return
Array
.
isArray
(
rows
)
&&
rows
.
length
>
0
}
if
(
field
.
type
===
'group'
)
{
return
groupHasPersistableChildren
(
field
,
values
)
}
if
(
field
.
type
===
'divider'
)
{
return
false
}
return
hasMeaningfulPersistValue
(
field
,
values
[
field
.
key
])
}
/** 按 schema 顺序:可见项 + 可持久化的隐藏项 */
export
function
buildJsonContentPersistList
(
schemaList
=
[],
visibleList
=
[],
values
=
{},
groupRowsCache
=
{},
ctx
=
{}
)
{
const
visibleKeySet
=
new
Set
((
visibleList
||
[]).
map
(
field
=>
field
.
key
))
const
options
=
buildPersistVisibilityOptions
(
schemaList
,
values
,
ctx
)
return
(
schemaList
||
[]).
filter
(
field
=>
{
if
(
!
field
?.
key
)
{
return
false
}
if
(
visibleKeySet
.
has
(
field
.
key
))
{
return
true
}
return
shouldPersistHiddenBlock
(
field
,
ctx
,
values
,
groupRowsCache
,
options
)
})
}
packageDynamicForm/form-engine/submit-adapter.js
View file @
2b60ea7
...
...
@@ -34,6 +34,15 @@ import {
serializeFormListForAppJsonStorage
,
resolveAppRowFieldEngineValue
}
from
'./app-subform-json.js'
import
{
buildJsonContentPersistList
}
from
'./json-content-persist.js'
export
{
buildJsonContentPersistList
,
hasMeaningfulPersistValue
,
isTemplateOnlyDefaultValue
,
shouldPersistHiddenBlock
,
failsStructuralPersistVisibility
}
from
'./json-content-persist.js'
export
{
buildNormalizedFieldDataList
,
...
...
@@ -130,45 +139,6 @@ function mergeStorageValues(saveValues = {}, engine, visibleList = []) {
return
{
...
saveValues
,
...
collectSubformStorageValues
(
engine
,
visibleList
)
}
}
function
hasStoredValue
(
value
)
{
if
(
value
===
undefined
||
value
===
null
||
value
===
''
)
{
return
false
}
if
(
Array
.
isArray
(
value
)
&&
value
.
length
===
0
)
{
return
false
}
return
true
}
/** 按 schema 顺序:可见项 + 仍有存储值的隐藏项(供 jsonContent 持久化) */
export
function
buildJsonContentPersistList
(
schemaList
=
[],
visibleList
=
[],
values
=
{},
groupRowsCache
=
{}
)
{
const
visibleKeySet
=
new
Set
((
visibleList
||
[]).
map
(
field
=>
field
.
key
))
return
(
schemaList
||
[]).
filter
(
field
=>
{
if
(
!
field
?.
key
)
{
return
false
}
if
(
visibleKeySet
.
has
(
field
.
key
))
{
return
true
}
if
(
field
.
type
===
'subform'
)
{
const
rows
=
groupRowsCache
[
field
.
key
]
return
Array
.
isArray
(
rows
)
&&
rows
.
length
>
0
}
if
(
field
.
type
===
'group'
)
{
return
getStaticGroupChildren
(
field
).
some
(
child
=>
hasStoredValue
(
values
[
child
.
key
]))
}
if
(
field
.
type
===
'divider'
)
{
return
false
}
return
hasStoredValue
(
values
[
field
.
key
])
})
}
function
assembleFormListForSaveListsWithValues
(
engine
,
visibleList
=
[],
saveValues
=
{})
{
const
cache
=
engine
.
getGroupRowsCache
?.()
||
{}
const
topLevel
=
buildVisibleFormList
(
...
...
@@ -191,7 +161,14 @@ export function assembleFormListForJsonContent(engine) {
const
visibleList
=
engine
.
getVisibleList
?.()
||
[]
const
values
=
engine
.
getValues
?.()
||
{}
const
cache
=
engine
.
getGroupRowsCache
?.()
||
{}
const
persistList
=
buildJsonContentPersistList
(
schemaList
,
visibleList
,
values
,
cache
)
const
ctx
=
engine
.
getPageContext
?.()
||
{}
const
persistList
=
buildJsonContentPersistList
(
schemaList
,
visibleList
,
values
,
cache
,
ctx
)
const
saveValues
=
collectSaveValues
(
engine
,
persistList
)
return
assembleFormListForSaveListsWithValues
(
engine
,
persistList
,
saveValues
)
}
...
...
packageDynamicForm/form-engine/visibility.js
View file @
2b60ea7
...
...
@@ -15,6 +15,7 @@ import {
getStaticGroupChildren
,
}
from
'./field-types.js'
import
{
isFieldVisibleBySpecs
}
from
'./visibility/specs/index.js'
import
{
baseSceneSpec
}
from
'./visibility/specs/base-scene.js'
import
{
isAttendanceOnDuty
}
from
'./radio-value.js'
export
const
ATTENDANCE_KEY
=
'F1-1'
...
...
@@ -199,12 +200,11 @@ export function getVisibleList(list = [], ctx, values) {
{
...
visibilityOptions
,
echoParentKey
:
field
.
key
},
list
)
const
rowChildren
=
visibleChildren
.
length
?
visibleChildren
:
forceEchoBlock
?
template
:
[]
if
(
rowChildren
.
length
||
forceEchoBlock
)
{
const
rowChildren
=
visibleChildren
if
(
rowChildren
.
length
||
(
forceEchoBlock
&&
baseSceneSpec
(
field
,
ctx
,
values
,
visibilityOptions
))
)
{
visible
.
push
({
...
field
,
type
:
isSubform
(
field
)
?
'subform'
:
'subform'
,
...
...
@@ -220,15 +220,10 @@ export function getVisibleList(list = [], ctx, values) {
{
...
visibilityOptions
,
echoParentKey
:
field
.
key
},
list
)
const
childrenToShow
=
visibleChildren
.
length
?
visibleChildren
:
forceEchoBlock
?
groupChildren
:
[]
if
(
childrenToShow
.
length
||
forceEchoBlock
)
{
if
(
visibleChildren
.
length
)
{
visible
.
push
({
...
field
,
children
:
childrenToShow
children
:
visibleChildren
})
}
}
else
if
(
field
.
type
!==
'group'
&&
field
.
type
!==
'subform'
)
{
...
...
packageDynamicForm/pages/behaviors/dailyReportPageMethods.js
View file @
2b60ea7
...
...
@@ -150,6 +150,21 @@ const dailyReportPageMethods = {
?
this
.
getFormDisabled
()
:
!!
this
.
data
.
formDisabled
})
},
/**
* 提交后重拉详情:用最新 pageContext(含 echo 元数据)重新 init engine
* @param {Object} loadRes.data - loadDailyForm 返回值
*/
reinitEngineFromLoadData
(
loadData
=
{})
{
if
(
!
this
.
engine
)
{
return
null
}
const
{
pageContext
,
schema
,
initialValues
}
=
loadData
return
this
.
engine
.
init
(
schema
,
{
...
pageContext
,
initialValues
:
initialValues
||
{}
})
}
}
...
...
packageDynamicForm/pages/negotiationDetail/negotiationDetail.js
View file @
2b60ea7
...
...
@@ -587,15 +587,16 @@ Page({
if
(
this
.
isStaleRefresh
(
seq
))
return
if
(
!
isApiSuccess
(
loadRes
.
code
)
||
!
loadRes
.
data
)
return
const
{
schema
,
detail
,
initialValues
}
=
loadRes
.
data
const
{
schema
,
detail
,
initialValues
,
pageContext
}
=
loadRes
.
data
this
.
dailyReportRecordId
=
detail
.
dailyReportRecordId
||
this
.
dailyReportRecordId
this
.
syncReportSubmittedState
(
detail
)
this
.
resetEditReport
()
if
(
!
this
.
engine
)
return
const
ctx
=
this
.
engine
.
getPageContext
()
const
viewState
=
this
.
engine
.
init
(
schema
,
{
...
ctx
,
initialValues
:
initialValues
||
ctx
.
initialValues
||
{}
this
.
pageContext
=
pageContext
||
null
const
viewState
=
this
.
reinitEngineFromLoadData
({
pageContext
,
schema
,
initialValues
})
if
(
this
.
isStaleRefresh
(
seq
))
return
await
this
.
refreshWeeklyList
()
...
...
packageDynamicForm/pages/staffDailyReport/staffDailyReport.js
View file @
2b60ea7
...
...
@@ -459,15 +459,15 @@ Page({
if
(
this
.
isStaleRefresh
(
seq
))
return
if
(
!
isApiSuccess
(
loadRes
.
code
)
||
!
loadRes
.
data
)
return
const
{
schema
,
detail
,
initialValues
}
=
loadRes
.
data
const
{
schema
,
detail
,
initialValues
,
pageContext
}
=
loadRes
.
data
this
.
dailyReportRecordId
=
detail
.
dailyReportRecordId
||
this
.
dailyReportRecordId
this
.
syncReportSubmittedState
(
detail
)
this
.
resetEditReport
()
if
(
!
this
.
engine
)
return
const
ctx
=
this
.
engine
.
getPageContext
()
const
viewState
=
this
.
engine
.
init
(
schema
,
{
...
ctx
,
initialValues
:
initialValues
||
ctx
.
initialValues
||
{}
const
viewState
=
this
.
reinitEngineFromLoadData
({
pageContext
,
schema
,
initialValues
})
if
(
this
.
isStaleRefresh
(
seq
))
return
await
this
.
refreshWeeklyList
()
...
...
packageDynamicForm/pages/storeDailyReport/storeDailyReport.js
View file @
2b60ea7
...
...
@@ -3,7 +3,7 @@
* @see packageDynamicForm/docs/PAGES.md#门店日报storedailyreport
* @see packageDynamicForm/docs/ARCHITECTURE.md
*
* 职责:周历选日、reportStatus 只读、保存并提交 + 保存草稿 + 洽谈明细表汇总
* 职责:周历选日、reportStatus 只读、保存并提交 + 保存草稿 + 洽谈明细表汇总
;**已提交永久只读,无编辑按钮**
* 加载:loadStoreDailyForm → brand|scene|detail 并行 → pageContext → schema → engine.init
* 写入:onFieldChange / onGroupFieldChange → engine;保存直出 Toast;保存并提交需 wx.showModal 二次确认
* 上下文:buildFormRequestContext 透传 merchantId、sceneType 给 fieldOptions
...
...
@@ -150,6 +150,13 @@ Page({
})
},
/** 门店已提交不可再编辑,不暴露编辑入口(覆盖 behavior) */
editReport
()
{
if
(
this
.
data
.
isReportSubmitted
)
{
wx
.
$util
.
showToast
(
'日报已提交,不可再编辑'
)
}
},
/** F2-1 有选人时给 F2-2 打 disabled,供 dynamic-form 字段级只读 */
patchStoreStaffCountFieldDisabled
(
viewState
=
{})
{
return
patchStoreStaffCountFieldInViewState
(
viewState
,
{
...
...
@@ -714,15 +721,15 @@ Page({
if
(
this
.
isStaleRefresh
(
seq
))
return
if
(
!
isApiSuccess
(
loadRes
.
code
)
||
!
loadRes
.
data
)
return
const
{
schema
,
detail
,
initialValues
}
=
loadRes
.
data
const
{
schema
,
detail
,
initialValues
,
pageContext
}
=
loadRes
.
data
this
.
dailyReportRecordId
=
detail
.
dailyReportRecordId
||
this
.
dailyReportRecordId
this
.
syncReportSubmittedState
(
detail
)
this
.
resetEditReport
()
if
(
!
this
.
engine
)
return
const
ctx
=
this
.
engine
.
getPageContext
()
const
viewState
=
this
.
engine
.
init
(
schema
,
{
...
ctx
,
initialValues
:
initialValues
||
ctx
.
initialValues
||
{}
const
viewState
=
this
.
reinitEngineFromLoadData
({
pageContext
,
schema
,
initialValues
})
if
(
this
.
isStaleRefresh
(
seq
))
return
await
this
.
refreshWeeklyList
()
...
...
packageDynamicForm/pages/storeDailyReport/storeDailyReport.wxml
View file @
2b60ea7
...
...
@@ -70,13 +70,6 @@
<view class="confirm text-center" bindtap="onSubmitTap">提交</view>
<view class="save text-center" bindtap="onSaveDraft">保存</view>
</block>
<block wx:elif="{{ isTodayReport && isReportSubmitted }}">
<view wx:if="{{ !isEditReport }}" class="confirm text-center" bindtap="editReport">编辑</view>
<block wx:else>
<view class="confirm text-center" bindtap="submit">保存</view>
<view class="save text-center" bindtap="cancelReport">取消</view>
</block>
</block>
<view
wx:if="{{ isTodayReport }}"
class="summary-btn text-center"
...
...
packageDynamicForm/tests/json-content-persist.test.mjs
0 → 100644
View file @
2b60ea7
/**
* jsonContent 场景持久化与回显单测
* 运行:npm run test:dynamicForm
*/
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { loadSchemaFixture } from './schemaFixture.mjs'
describe('jsonContentPersist', async () => {
const { createFormEngine } = await import('../form-engine/core.js')
const { buildDynamicSavePayload } = await import('../form-engine/submit-adapter.js')
const { getVisibleList } = await import('../form-engine/visibility.js')
const { enrichPageContextWithDetailEcho } = await import(
'../form-engine/app-subform-json.js'
)
const { mergeTemplateDefaultsIntoInitialValues } = await import(
'../form-engine/values.js'
)
const staffSchema = loadSchemaFixture('staff')
const boutiqueCtx = {
baseSceneCode: 100101,
brandIds: [3454],
merchantId: '100',
sceneList: [{ baseSceneCode: 100101 }]
}
it('IT-STAFF-SAVE-SCENE-001: boutique save excludes warranty-only fields and template-0 cross-scene groups', () => {
const initialValues = mergeTemplateDefaultsIntoInitialValues(
staffSchema.list,
{ 'F1-1': '在岗' }
)
const engine = createFormEngine(staffSchema)
engine.init(staffSchema, { ...boutiqueCtx, initialValues })
const payload = buildDynamicSavePayload({
reportTemplateId: 1001,
engine,
reportDate: '2026-06-15',
normalizedFieldDataList: true
})
const jsonKeys = JSON.parse(payload.jsonContent).map(item => item.key)
assert.ok(jsonKeys.includes('F1-1'))
assert.ok(!jsonKeys.includes('F1-2'), '延保专属 F1-2 不应入库')
const warrantyGroup = staffSchema.list.find(item => item.key === 'F1-6')
if (warrantyGroup) {
assert.ok(!jsonKeys.includes('F1-6'), '跨场景 brand group 仅模板 0 不应入库')
}
})
it('IT-ECHO-SCENE-001: wrong-scene group in jsonContent does not expand children via forceEchoBlock', () => {
const warrantyGroup = staffSchema.list.find(
item =>
item.type === 'group' &&
item.baseSceneCode?.length &&
!item.baseSceneCode.includes(100101)
)
if (!warrantyGroup) {
return
}
const jsonContent = JSON.stringify([
{ key: 'F1-1', type: 'radio', label: '出勤', value: '在岗' },
{
key: warrantyGroup.key,
type: 'group',
label: warrantyGroup.label,
children: warrantyGroup.children?.map(child => ({
...child,
value: child.type === 'numberInput' ? 0 : child.value
}))
}
])
const ctx = enrichPageContextWithDetailEcho(
{ ...boutiqueCtx },
{ jsonContent }
)
const values = { 'F1-1': '在岗' }
const visible = getVisibleList(staffSchema.list, ctx, values)
const leaked = visible.find(item => item.key === warrantyGroup.key)
assert.equal(leaked, undefined, '跨场景 group 不应出现在可见列表')
})
it('IT-ECHO-SCENE-002: off-duty brand group still persists when user entered values', () => {
const engine = createFormEngine(staffSchema)
engine.init(staffSchema, boutiqueCtx)
engine.setFieldValue('F1-1', '在岗')
engine.setFieldValue('F1-5-1', 2)
engine.setFieldValue('F1-1', '调休')
const payload = buildDynamicSavePayload({
reportTemplateId: 1001,
engine,
reportDate: '2026-06-15',
normalizedFieldDataList: true
})
const jsonContent = JSON.parse(payload.jsonContent)
const f15 = jsonContent.find(item => item.key === 'F1-5')
assert.ok(f15, '调休时应持久化已填品牌 group')
})
})
packageEquity/menu/asyncProviders.js
View file @
2b60ea7
...
...
@@ -322,6 +322,9 @@ async function resolveDynamicForm(ctx) {
trackEventCode
:
item
.
trackEventCode
}
)
}).
map
(
vm
=>
{
const
{
tipsNum
,
...
rest
}
=
vm
return
rest
})
return
{
dynamicForm
:
{
...
...
packageEquity/menu/badgeProviders.js
View file @
2b60ea7
/**
* 权益首页菜单角标拉取(
按 id 定位 menuList 下标后 setData
)
* 权益首页菜单角标拉取(
异步回写时按 id 定位,避免重排错位
)
*/
import
{
getWaitAuditCountAPI
,
waitstaffstateAPI
}
from
'~/api/api'
import
commonApi
from
'../../api/api.js'
import
{
setMenuTipsNumById
}
from
'../../utils/menuBadgeUtils.js'
const
MENU_LIST_KEY
=
'menuList'
/**
* 菜单重建后按 id 拉取角标
...
...
@@ -14,51 +17,52 @@ import commonApi from '../../api/api.js'
* @param {Array} [menuList] - 当前 menuList
*/
export
function
applyEquityMenuBadges
(
page
,
userInfo
,
menuList
=
page
.
data
.
menuList
)
{
const
approvalIndex
=
menuList
.
findIndex
(
e
=>
e
.
id
===
'pending_approval'
)
const
recruitIndex
=
menuList
.
findIndex
(
e
=>
e
.
id
===
'recruit_manage'
)
const
clueIndex
=
menuList
.
findIndex
(
e
=>
e
.
id
===
'customer_clue'
)
const
hasApproval
=
menuList
.
some
(
e
=>
e
.
id
===
'pending_approval'
)
const
hasRecruit
=
menuList
.
some
(
e
=>
e
.
id
===
'recruit_manage'
)
const
hasClue
=
menuList
.
some
(
e
=>
e
.
id
===
'customer_clue'
)
if
(
approvalIndex
>
-
1
)
{
if
(
hasApproval
)
{
getWaitAuditCountAPI
({
sceneType
:
userInfo
?.
sceneType
}).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
page
.
setData
({
[
`menuList[
${
approvalIndex
}
].tipsNum`
]:
res
.
data
.
waiteForAuditNum
})
setMenuTipsNumById
(
page
,
MENU_LIST_KEY
,
'pending_approval'
,
res
.
data
.
waiteForAuditNum
)
}
})
}
if
(
recruitIndex
>
-
1
)
{
if
(
hasRecruit
)
{
waitstaffstateAPI
().
then
(
result
=>
{
if
(
result
.
code
==
0
)
{
page
.
setData
({
[
`menuList[
${
recruitIndex
}
].tipsNum`
]:
result
.
data
.
waitProcessCount
})
setMenuTipsNumById
(
page
,
MENU_LIST_KEY
,
'recruit_manage'
,
result
.
data
.
waitProcessCount
)
}
})
}
if
(
clueIndex
>
-
1
)
{
applyCustomerClueBadge
(
page
,
clueIndex
)
if
(
hasClue
)
{
applyCustomerClueBadge
(
page
)
}
}
/**
* 客户线索角标
* @param {Object} page
* @param {number} [index] - menuList 下标,省略则按 id 查找
*/
export
async
function
applyCustomerClueBadge
(
page
,
index
)
{
const
{
sceneType
,
shopMerchantId
:
merchantId
}
=
wx
.
$util
.
getUserInfo
()
const
clueIndex
=
index
??
page
.
data
.
menuList
.
findIndex
(
e
=>
e
.
id
===
'customer_clue'
)
if
(
clueIndex
<
0
)
return
/** 客户线索角标(clue.tips.newCount) */
export
async
function
applyCustomerClueBadge
(
page
)
{
const
list
=
page
.
data
.
menuList
||
[]
if
(
!
list
.
some
(
item
=>
item
.
id
===
'customer_clue'
))
{
return
}
const
{
sceneType
,
shopMerchantId
:
merchantId
}
=
wx
.
$util
.
getUserInfo
()
const
{
data
,
code
}
=
await
commonApi
.
getCustomerClueRemind
({
sceneType
,
merchantId
:
[
merchantId
]
})
if
(
code
==
0
)
{
page
.
setData
({
[
`menuList[
${
clueIndex
}
].tipsNum`
]:
data
})
setMenuTipsNumById
(
page
,
MENU_LIST_KEY
,
'customer_clue'
,
data
)
}
}
packageEquity/pages/index/index.wxml
View file @
2b60ea7
...
...
@@ -30,7 +30,7 @@
bind:packup="onTodoPackup"
bind:missing="gotoMissingReception" />
<view class="menu_box">
<block wx:for="{{ menuList }}" wx:key="i
ndex
">
<block wx:for="{{ menuList }}" wx:key="i
d
">
<view class="menu_item"
bindtap="navGo"
data-item="{{ item }}">
...
...
tabIndex/docs/DEVLOG.md
View file @
2b60ea7
# DEVLOG — tabIndex 精品首页
## 2026-06 — 客户线索角标按 id 回写
-
`clue.tips.newCount`
仅绑定
`customer_clue`
;
`badgeProviders`
+
`utils/menuBadgeUtils.setMenuTipsNumById`
异步回写前按 id 定位,避免动态驻店日报注入重排后角标错位
-
动态三入口映射显式剥离
`tipsNum`
;首页
`menu`
/
`newMenu`
`wx:key`
改为
`id`
## 2026-06 — 服务中心公告按已读状态弹窗(V5.8.1)
-
去掉 moduleType 每日门禁;
`resolveFirstUnreadNotice`
+ 确认时
`getCompanyNoticeDetail`
标已读
...
...
tabIndex/docs/MENU-ARCHITECTURE.md
View file @
2b60ea7
...
...
@@ -140,7 +140,7 @@ flowchart TD
| 字段 | provider | 消费方 | 说明 |
|------|----------|--------|------|
|
`noRead`
|
`residentTarget`
|
`index.wxml`
`bubble_icon`
|
`readFlag === 'N'`
时显示未读气泡 |
|
`tipsNum`
|
`customerClue`
(初值) |
`index.wxml`
、
`_updateMenuBadges`
| provider 可设 0;页面再按
`customer_clue`
id 拉
接口更新
|
|
`tipsNum`
|
`customerClue`
(初值) |
`index.wxml`
、
`_updateMenuBadges`
| provider 可设 0;页面再按
`customer_clue`
id 拉
`clue.tips.newCount`
更新。
**角标必须经 `setMenuTipsNumById` 按 id 回写**
,禁止缓存数组下标(动态日报注入重排后会错位到
`staff_daily_report_new`
)。动态三入口 provider 不得携带
`tipsNum`
。
|
## 技师短路菜单
...
...
tabIndex/menu/asyncProviders.js
View file @
2b60ea7
...
...
@@ -209,6 +209,9 @@ async function resolveDynamicForm(ctx) {
trackEventCode
:
item
.
trackEventCode
}
)
}).
map
(
vm
=>
{
const
{
tipsNum
,
...
rest
}
=
vm
return
rest
})
return
{
dynamicForm
:
{
visible
:
items
.
length
>
0
,
items
,
hideLegacyStaffDaily
:
items
.
some
(
i
=>
i
.
id
===
'staff_daily_report_new'
)
}
}
}
...
...
tabIndex/menu/badgeProviders.js
View file @
2b60ea7
/**
* 菜单角标拉取(
按 id 定位 menu 下标后 setData
)
* 菜单角标拉取(
异步回写时按 menu id 定位,避免重排错位
)
*/
import
{
getWaitAuditCountAPI
,
waitstaffstateAPI
}
from
'~/api/api'
import
commonApi
from
'../../api/api.js'
import
{
setMenuTipsNumById
}
from
'../../utils/menuBadgeUtils.js'
const
MENU_LIST_KEY
=
'menu'
/**
* 菜单重建后按 id 拉取角标
...
...
@@ -14,47 +17,52 @@ import commonApi from '../../api/api.js'
* @param {Array} [menu] - 当前 menu 列表
*/
export
function
applyMenuBadges
(
page
,
userInfo
,
menu
=
page
.
data
.
menu
)
{
const
approvalIndex
=
menu
.
findIndex
(
e
=>
e
.
id
===
'pending_approval'
)
const
recruitIndex
=
menu
.
findIndex
(
e
=>
e
.
id
===
'recruit_manage'
)
const
clueIndex
=
menu
.
findIndex
(
e
=>
e
.
id
===
'customer_clue'
)
const
hasApproval
=
menu
.
some
(
e
=>
e
.
id
===
'pending_approval'
)
const
hasRecruit
=
menu
.
some
(
e
=>
e
.
id
===
'recruit_manage'
)
const
hasClue
=
menu
.
some
(
e
=>
e
.
id
===
'customer_clue'
)
if
(
approvalIndex
>
-
1
)
{
if
(
hasApproval
)
{
getWaitAuditCountAPI
({
sceneType
:
userInfo
?.
sceneType
}).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
page
.
setData
({
[
`menu[
${
approvalIndex
}
].tipsNum`
]:
res
.
data
.
waiteForAuditNum
})
setMenuTipsNumById
(
page
,
MENU_LIST_KEY
,
'pending_approval'
,
res
.
data
.
waiteForAuditNum
)
}
})
}
if
(
recruitIndex
>
-
1
)
{
if
(
hasRecruit
)
{
waitstaffstateAPI
().
then
(
result
=>
{
if
(
result
.
code
==
0
)
{
page
.
setData
({
[
`menu[
${
recruitIndex
}
].tipsNum`
]:
result
.
data
.
waitProcessCount
})
setMenuTipsNumById
(
page
,
MENU_LIST_KEY
,
'recruit_manage'
,
result
.
data
.
waitProcessCount
)
}
})
}
if
(
clueIndex
>
-
1
)
{
applyCustomerClueBadge
(
page
,
clueIndex
)
if
(
hasClue
)
{
applyCustomerClueBadge
(
page
)
}
}
/** 客户线索角标 */
export
async
function
applyCustomerClueBadge
(
page
,
index
)
{
const
{
sceneType
,
shopMerchantId
:
merchantId
}
=
wx
.
$util
.
getUserInfo
()
const
clueIndex
=
index
??
page
.
data
.
menu
.
findIndex
(
e
=>
e
.
id
===
'customer_clue'
)
if
(
clueIndex
<
0
)
return
/** 客户线索角标
(clue.tips.newCount)
*/
export
async
function
applyCustomerClueBadge
(
page
)
{
const
list
=
page
.
data
.
menu
||
[]
if
(
!
list
.
some
(
item
=>
item
.
id
===
'customer_clue'
))
{
return
}
const
{
sceneType
,
shopMerchantId
:
merchantId
}
=
wx
.
$util
.
getUserInfo
()
const
{
data
,
code
}
=
await
commonApi
.
getCustomerClueRemind
({
sceneType
,
merchantId
:
[
merchantId
]
})
if
(
code
==
0
)
{
page
.
setData
({
[
`menu[
${
clueIndex
}
].tipsNum`
]:
data
})
setMenuTipsNumById
(
page
,
MENU_LIST_KEY
,
'customer_clue'
,
data
)
}
}
tabIndex/pages/index/index.wxml
View file @
2b60ea7
...
...
@@ -177,7 +177,7 @@
</block>
<block wx:if="{{ !isNoStaff }}">
<div class="menu">
<block wx:for="{{ menu }}" wx:key="i
ndex
">
<block wx:for="{{ menu }}" wx:key="i
d
">
<view class="item" bindtap="jump" data-item="{{ item }}" data-type="{{ userInfo.userType }}">
<image src="{{ IMG_URL}}upgrade/{{item.icon }}.png" />
<view class="label">{{item.name}}</view>
...
...
@@ -190,7 +190,7 @@
</block>
<block wx:if="{{ isNoStaff }}">
<div class="menu noStaff">
<block wx:for="{{ menu }}" wx:key="i
ndex
">
<block wx:for="{{ menu }}" wx:key="i
d
">
<view class="item" bindtap="jumpThrottle" data-item="{{ item }}" data-type="{{ userInfo.userType }}">
<image wx:if="{{ item.iconPrefix != 'crowdFunding' }}" src="{{ IMG_URL}}upgrade/{{item.icon }}.png" />
<image wx:else src="{{ IMG_URL}}crowdFunding/{{item.icon }}.png" />
...
...
@@ -202,7 +202,7 @@
</block>
<block wx:if="{{ !isNoStaff }}">
<div class="menu" wx:if="{{ newMenu.length>0 }}">
<block wx:for="{{ newMenu }}" wx:key="i
ndex
">
<block wx:for="{{ newMenu }}" wx:key="i
d
">
<view class="item" bindtap="jump" data-item="{{ item }}" data-type="{{ userInfo.userType }}">
<image src="{{ IMG_URL}}upgrade/{{item.icon }}.png" />
<view class="label">{{item.name}}</view>
...
...
tabIndex/tests/menu-badge-providers.test.mjs
0 → 100644
View file @
2b60ea7
/**
* 菜单角标按 id 回写单测
*
* 运行:npm run test:tabIndex
* 用例前缀:IT-MENU-BADGE-*
*/
import { describe, it, beforeEach, afterEach } from 'node:test'
import assert from 'node:assert/strict'
import { setupWxMock } from './menuTestHelpers.mjs'
import { setMenuTipsNumById } from '../../utils/menuBadgeUtils.js'
const globalRef = globalThis
function createMockPage(listKey, items) {
const data = { [listKey]: items.map(item => ({ ...item })) }
return {
data,
setData(patch) {
for (const [key, value] of Object.entries(patch)) {
const match = key.match(new RegExp(`^${listKey}\\[(\\d+)\\]\\.tipsNum$`))
if (match) {
data[listKey][Number(match[1])].tipsNum = value
}
}
}
}
}
describe('menuBadgeProviders', () => {
let originalWx
beforeEach(() => {
originalWx = globalRef.wx
setupWxMock(globalRef)
globalRef.wx.$util = {
getUserInfo: () => ({
sceneType: 1,
shopMerchantId: 'm1'
})
}
})
afterEach(() => {
globalRef.wx = originalWx
})
it('IT-MENU-BADGE-001: setMenuTipsNumById writes to id after menu reorder', () => {
const page = createMockPage('menu', [
{ id: 'customer_clue', label: '客户线索' },
{ id: 'staff_daily_report_new', label: '驻店日报' }
])
page.data.menu = [
{ id: 'staff_daily_report_new', label: '驻店日报' },
{ id: 'customer_clue', label: '客户线索' }
]
const ok = setMenuTipsNumById(page, 'menu', 'customer_clue', 5)
assert.equal(ok, true)
assert.equal(page.data.menu[0].tipsNum, undefined)
assert.equal(page.data.menu[1].tipsNum, 5)
})
it('IT-MENU-BADGE-002: setMenuTipsNumById no-ops when menu id missing', () => {
const page = createMockPage('menu', [
{ id: 'staff_daily_report_new', label: '驻店日报' }
])
const ok = setMenuTipsNumById(page, 'menu', 'customer_clue', 5)
assert.equal(ok, false)
assert.equal(page.data.menu[0].tipsNum, undefined)
})
it('IT-MENU-BADGE-003: stale clue index must not badge staff_daily_report_new after reorder', () => {
const staleClueIndex = 0
const page = createMockPage('menu', [
{ id: 'customer_clue', label: '客户线索' },
{ id: 'staff_daily_report_new', label: '驻店日报' }
])
page.data.menu = [
{ id: 'staff_daily_report_new', label: '驻店日报' },
{ id: 'customer_clue', label: '客户线索' }
]
page.setData({ [`menu[${staleClueIndex}].tipsNum`]: 5 })
assert.equal(page.data.menu[0].id, 'staff_daily_report_new')
assert.equal(page.data.menu[0].tipsNum, 5)
delete page.data.menu[0].tipsNum
setMenuTipsNumById(page, 'menu', 'customer_clue', 5)
assert.equal(page.data.menu[0].tipsNum, undefined)
assert.equal(page.data.menu[1].tipsNum, 5)
})
})
utils/menuBadgeUtils.js
0 → 100644
View file @
2b60ea7
/**
* 菜单角标 setData:异步回写前按 id 定位,避免菜单重排后错位
* @param {Object} page - Page / Component 实例
* @param {string} listKey - data 字段名,如 menu / menuList
* @param {string} menuId - registry id
* @param {number|string} tipsNum
*/
export
function
setMenuTipsNumById
(
page
,
listKey
,
menuId
,
tipsNum
)
{
const
list
=
page
.
data
[
listKey
]
||
[]
const
index
=
list
.
findIndex
(
item
=>
item
.
id
===
menuId
)
if
(
index
<
0
||
list
[
index
]?.
id
!==
menuId
)
{
return
false
}
page
.
setData
({
[
`
${
listKey
}
[
${
index
}
].tipsNum`
]:
tipsNum
})
return
true
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment