registry.js
15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
import { RECRUIT_MENU_ENABLED } from '../../config.js'
import { MENU_SECTION } from './constants.js'
import {
DYNAMIC_FORM_TAB_INDEX_MENUS,
resolveDynamicFormMenuId
} from '../../utils/dynamicFormMenus.js'
/**
* @typedef {import('./context.js').createMenuContext extends (...args: any[]) => infer R ? R : never} MenuContext
* 菜单管道上下文:`userInfo`、`isStaff`、`mentorFlag`;`ctx.policies` 见 {@link ./policies.js}
*/
/**
* 菜单跳转指令,由 {@link ./toViewModel.js} 映射为 WXML 字段,由 {@link ./jumpHandlers.js} 按 type 分发。
*
* @typedef {Object} MenuAction
* @property {'router'|'navigate'|'switchTab'|'miniProgram'|'scanCode'|'workReport'|'salaryPerformance'|'residentTarget'|'marketingMaterials'} type
* 跳转类型,对应 jumpHandlers handlers 键
* @property {string} [target]
* 路由名(router)、分包 navigateToUrl(navigate)、switchTab 路径(switchTab)
* @property {Object} [params]
* 传给 `wx.$router.go(target, { params })` 的参数
* @property {boolean} [usePath]
* 为 true 时 toViewModel 额外写 `path`(如 pending_approval)
* 另:target 为 packageEquity.extract / salaryAppeal / missingReception 时也会写 path(见 toViewModel 硬编码表)
* @property {string} [trackEventCode]
* navigate 类型点击埋点 eventCode(如 scenario_marketplace)
* @property {string} [appId]
* miniProgram:目标小程序 appId
* @property {string} [path]
* miniProgram:目标小程序页面路径
* @property {string} [envVersion]
* miniProgram:环境版本 trial / release
*/
/**
* 同步注册表条目(MENU_REGISTRY)。正文按角色/场景分组;新增条目请对照本类型必填项。
*
* @typedef {Object} MenuRegistryEntry
* @property {string} id
* 稳定主键:去重、badge 更新(`_updateMenuBadges`)、jumpHandlers 按 id 分支均依赖此字段
* @property {string} label
* 展示文案;toViewModel 映射为 `name` 供 WXML `item.name`
* @property {string} icon
* CDN 图标文件名;默认拼接 `IMG_URL + upgrade/` + icon + `.png`
* @property {'main'|'secondary'} section
* `main` → `data.menu`;`secondary` → `data.newMenu`(见 MENU_SECTION)
* @property {MenuAction} action
* 跳转指令,必填
* @property {(ctx: MenuContext) => boolean} visible
* 同步管道显隐;buildTabIndexMenusSync 过滤
* @property {number} [sortVal]
* 升序排序,越小越靠前;buildMenus 合并后 sort
*
* --- 可选 UI(注意 WXML 分块,见 MENU-ARCHITECTURE.md)---
* @property {boolean} [hot]
* 仅 `!isNoStaff` 区块(驻店员工 menu/newMenu)显示「热」角标
* @property {number} [tipsNum]
* 数字角标:registry 初值 + `_updateMenuBadges` 按 id 更新;或 provider extras 注入
* @property {string} [iconPrefix]
* 仅 `isNoStaff` 区块生效:`crowdFunding` 时图标走 `crowdFunding/`(如 recruit_manage)
*
* --- 可选跳转 / 校验(透传至 view model)---
* @property {number} [recordId]
* 埋点 id;jumpHandlers / openWorkReportTemp 调用 pointRecord
* @property {string} [beforeClick]
* 跳转前调用 `wx.$globalDataFunction[beforeClick]()`,返回 true 则中断(如禁止提单)
* @property {boolean} [noCheckdailyReport]
* 为 true 时 jumpHandlers 跳过日报/学习中心/异常单校验链
* @property {'daily'|'weekly'|'monthly'} [reportTypeAttr]
* workReport 模版类型,openWorkReportTemp 选模版
* @property {string} [reportTypeVal]
* 工作报表模版 type 参数('1'/'2'/'3')
* @property {boolean} [isRepairOrderTabFromMenu]
* switchTab 施工单时写 globalData.repairOrderOpenFromHomeMenu
*/
/**
* 异步 provider 注入的 view model 附加字段(非 registry 静态配置)。
* buildTabIndexMenusAsync 通过 registryItemToViewModel(entry, extras) 合并。
*
* @typedef {Object} MenuViewModelExtras
* @property {boolean} [noRead]
* 驻店目标未读气泡;residentTarget provider 根据 readFlag 注入 → WXML bubble_icon
* @property {number} [tipsNum]
* 角标数字;customerClue provider 可注入初值,页面 `_updateMenuBadges` 再按 id 刷新
*/
/**
* 精品首页同步菜单注册表(单一数据源)。
* 完整字段说明见上方 {@link MenuRegistryEntry};架构文档见 tabIndex/docs/MENU-ARCHITECTURE.md
* **新增菜单流程、示例与检查清单**:tabIndex/docs/ADD-MENU-GUIDE.md
*
* @type {MenuRegistryEntry[]}
*/
export const MENU_REGISTRY = [
// --- 默认驻店员工基础菜单 ---
{
id: 'create_order',
label: '新建工单',
icon: 'create_newworkorder',
section: MENU_SECTION.MAIN,
sortVal: 1,
hot: true,
recordId: 6,
beforeClick: 'inspectionOfProhibitionBill',
action: { type: 'router', target: 'tabWorkOrder.createOrder' },
visible: ({ policies }) =>
policies.notTechnician() &&
!(policies.isNoStaff() && policies.isNotMentor()) &&
!policies.canSelectMultiStore()
},
{
id: 'abnormal_flow_approval',
label: '异常流水审批',
icon: 'refund_review_icon',
section: MENU_SECTION.MAIN,
sortVal: 5,
noCheckdailyReport: true,
action: {
type: 'router',
target: 'tabWorkOrder.abnormalFlowList',
usePath: true
},
visible: ({ policies, isStaff }) =>
policies.notTechnician() && isStaff
},
{
id: 'defeat_order',
label: '战败下单',
icon: 'defeat_order',
section: MENU_SECTION.MAIN,
sortVal: 2,
hot: true,
recordId: 8,
action: { type: 'router', target: 'tabWorkOrder.defeatOrder' },
visible: ({ policies }) =>
policies.notTechnician() &&
!(policies.isNoStaff() && policies.isNotMentor()) &&
!policies.canSelectMultiStore()
},
{
id: 'create_archives',
label: '客户建档',
icon: 'customer_filing',
section: MENU_SECTION.MAIN,
sortVal: 12,
recordId: 8,
action: { type: 'router', target: 'tabWorkOrder.createArchives' },
visible: ({ policies }) =>
policies.notTechnician() &&
!(policies.isNoStaff() && policies.isNotMentor()) &&
!policies.canSelectMultiStore()
},
{
id: 'scan_code_order',
label: '扫码下单',
icon: 'scancode_verification',
section: MENU_SECTION.MAIN,
sortVal: 13,
recordId: 7,
action: { type: 'scanCode', target: 'tabWorkOrder.createOrder' },
visible: ({ policies }) =>
policies.notTechnician() &&
!(policies.isNoStaff() && policies.isNotMentor()) &&
!policies.canSelectMultiStore()
},
{
id: 'marketing_materials',
label: '营销素材',
icon: 'icon-market',
section: MENU_SECTION.MAIN,
sortVal: 14,
recordId: 9,
action: { type: 'marketingMaterials', target: '/tabWorkOrder/pages/materails/index' },
visible: ({ policies }) =>
policies.notTechnician() &&
!(policies.isNoStaff() && policies.isNotMentor()) &&
!policies.canSelectMultiStore()
},
{
id: 'business_assistant_default',
label: '生意助手',
icon: 'boutique-syzs',
section: MENU_SECTION.MAIN,
sortVal: 15,
recordId: 12,
action: {
type: 'miniProgram',
appId: 'wx2c28337db96364d2',
path: 'pages/tab/index/index',
envVersion: 'trial'
},
visible: ({ policies }) =>
policies.notTechnician() &&
!(policies.isNoStaff() && policies.isNotMentor()) &&
!policies.canSelectMultiStore()
},
{
id: 'work_daily_report',
label: '工作日报',
icon: 'supervisorDailyNew',
section: MENU_SECTION.MAIN,
sortVal: 8,
recordId: 15,
noCheckdailyReport: true,
reportTypeAttr: 'daily',
reportTypeVal: '1',
action: { type: 'workReport', target: 'tabWorkOrder.supervisorDaily' },
visible: ({ policies }) =>
policies.notTechnician() && policies.staffOrMultiStoreDaily()
},
{
id: 'work_weekly_report',
label: '工作周报',
icon: 'weeklyReport',
section: MENU_SECTION.MAIN,
sortVal: 9,
recordId: 18,
noCheckdailyReport: true,
reportTypeAttr: 'weekly',
reportTypeVal: '2',
action: { type: 'workReport', target: 'tabWorkOrder.supervisorDaily' },
visible: ({ policies }) =>
policies.notTechnician() && policies.staffOrMultiStoreDaily()
},
{
id: 'work_monthly_report',
label: '工作月报',
icon: 'monthlyReport',
section: MENU_SECTION.MAIN,
sortVal: 10,
recordId: 19,
noCheckdailyReport: true,
reportTypeAttr: 'monthly',
reportTypeVal: '3',
action: { type: 'workReport', target: 'tabWorkOrder.supervisorDaily' },
visible: ({ policies }) =>
policies.notTechnician() && policies.staffOrMultiStoreDaily()
},
// --- 非驻店非导师:仅预约管理 ---
{
id: 'appointment_manage',
label: '预约管理',
icon: 'booking_management',
section: MENU_SECTION.MAIN,
sortVal: 11,
recordId: 8,
action: { type: 'router', target: 'pages.tabDateIndex' },
visible: ({ policies }) =>
policies.notTechnician() &&
policies.isNoStaff() &&
policies.isNotMentor() &&
policies.notSpecialAccount()
},
// --- 督导/超管追加 ---
{
id: 'staff_daily_report',
label: '驻店日报',
icon: 'staffreport',
section: MENU_SECTION.MAIN,
sortVal: 16,
recordId: 13,
noCheckdailyReport: true,
action: { type: 'router', target: 'tabWorkOrder.upgradeStaffDaily' },
visible: ({ policies }) =>
policies.notTechnician() && policies.staffOrMultiStoreDaily()
},
{
id: 'bi_report',
label: 'BI报表',
icon: 'business_data',
section: MENU_SECTION.MAIN,
sortVal: 17,
recordId: 11,
action: { type: 'router', target: 'tabOperating.index' },
visible: ({ policies }) =>
policies.notTechnician() && policies.canSelectMultiStore()
},
{
id: 'business_assistant_supervisor',
label: '生意助手',
icon: 'boutique-syzs',
section: MENU_SECTION.MAIN,
sortVal: 18,
recordId: 12,
action: {
type: 'miniProgram',
appId: 'wx2c28337db96364d2',
path: 'pages/tab/index/index',
envVersion: 'trial'
},
visible: ({ policies }) =>
policies.notTechnician() &&
policies.canSelectMultiStoreForStaffDaily() &&
policies.canSelectMultiStore()
},
{
id: 'training_materials',
label: '培训资料',
icon: 'peixun_icon',
section: MENU_SECTION.SECONDARY,
sortVal: 100,
recordId: 14,
noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.trainingMaterials' },
visible: ({ policies }) => policies.notTechnician()
},
{
id: 'salary_performance_super',
label: '工资绩效',
icon: 'businessschoo',
section: MENU_SECTION.SECONDARY,
sortVal: 101,
action: { type: 'salaryPerformance' },
visible: ({ policies }) =>
policies.notTechnician() && policies.isSuper()
},
{
id: 'mentorship_manage',
label: '带教管理',
icon: 'mentorship-manage',
section: MENU_SECTION.MAIN,
sortVal: 19,
noCheckdailyReport: true,
action: { type: 'router', target: 'tabWorkOrder.mentorshipManage' },
visible: ({ policies }) =>
policies.notTechnician() && policies.canViewMentorship()
},
{
id: 'scene_market',
label: '场景集市',
icon: 'sceneMarket',
section: MENU_SECTION.MAIN,
sortVal: 20,
action: {
type: 'navigate',
target: '/packageEquity/pages/sceneMarket/index/index',
trackEventCode: 'scenario_marketplace'
},
visible: ({ policies }) =>
policies.notTechnician() &&
(policies.canViewRecruit() || policies.canViewMentorship())
},
{
id: 'script_extract',
label: '话术萃取',
icon: 'extract_icon',
section: MENU_SECTION.MAIN,
sortVal: 21,
noCheckdailyReport: true,
action: {
type: 'router',
target: 'packageEquity.extract',
params: { type: 1 }
},
visible: ({ policies }) =>
policies.notTechnician() && policies.mentorOrViolation()
},
{
id: 'pending_approval',
label: '待审批',
icon: 'refund_review_icon',
section: MENU_SECTION.MAIN,
sortVal: 26,
noCheckdailyReport: true,
action: {
type: 'router',
target: 'tabWorkOrder.refundOperationList',
usePath: true
},
visible: ({ policies }) =>
policies.notTechnician() && policies.canViewRecruit()
},
{
id: 'recruit_manage',
label: '招聘管理',
icon: 'recruit-manage',
iconPrefix: 'crowdFunding',
section: MENU_SECTION.MAIN,
sortVal: 27,
recordId: 16,
tipsNum: 0,
action: { type: 'router', target: 'packageEquity.recruitManage' },
visible: ({ policies }) =>
RECRUIT_MENU_ENABLED &&
policies.notTechnician() &&
policies.canViewRecruit()
},
{
id: 'repair_order',
label: '施工单',
icon: 'tabRepairOrder',
section: MENU_SECTION.MAIN,
sortVal: 29,
recordId: 20,
noCheckdailyReport: true,
isRepairOrderTabFromMenu: true,
action: {
type: 'switchTab',
target: '/pages/tabRepairOrder/pages/index/index'
},
visible: ({ policies }) =>
policies.notTechnician() && policies.isResidentOrStaff()
},
{
id: 'study_center',
label: '学习中心',
icon: 'study-center',
section: MENU_SECTION.MAIN,
sortVal: 30,
noCheckdailyReport: true,
action: { type: 'router', target: 'packageStudyCenter.studyCenter' },
visible: ({ policies, isStaff }) =>
policies.notTechnician() &&
policies.notJiLianChannel() &&
isStaff
}
]
/**
* 异步 provider 控制的菜单(不在同步管道默认输出)。
* 无 visible 或 visible 可省略;显隐由 {@link ./asyncProviders.js} 中 provider 返回值决定。
* provider 可返回 {@link MenuViewModelExtras} 作为 extras 合并进 view model。
*
* @typedef {Omit<MenuRegistryEntry, 'visible'> & {
* provider: string,
* visible?: (ctx: MenuContext) => boolean
* }} AsyncMenuRegistryEntry
* provider 对应 asyncProviders 返回对象的 key(如 salaryAppeal、missingReception)
*
* @type {AsyncMenuRegistryEntry[]}
*/
export const ASYNC_MENU_REGISTRY = [
{
id: 'script_verify',
label: '话术核验',
icon: 'verification_icon',
section: MENU_SECTION.MAIN,
sortVal: 22,
noCheckdailyReport: true,
action: {
type: 'router',
target: 'packageEquity.extract',
params: { type: 2 }
},
provider: 'scriptVerify'
},
{
id: 'salary_appeal',
label: '工资申诉',
icon: 'salary_appeal_icon',
section: MENU_SECTION.MAIN,
sortVal: 23,
noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.salaryAppeal' },
provider: 'salaryAppeal'
},
{
id: 'missing_reception',
label: '接待缺失报备',
icon: 'missing-reception',
section: MENU_SECTION.MAIN,
sortVal: 24,
noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.missingReception' },
provider: 'missingReception'
},
{
id: 'customer_clue',
label: '客户线索',
icon: 'customer_clue',
section: MENU_SECTION.MAIN,
sortVal: 4,
recordId: 11,
tipsNum: 0,
noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.clueList' },
provider: 'customerClue'
},
{
id: 'salary_performance_api',
label: '工资绩效',
icon: 'businessschoo',
section: MENU_SECTION.MAIN,
sortVal: 25,
action: { type: 'salaryPerformance' },
provider: 'salaryPerformance'
},
{
id: 'resident_target',
label: '驻店目标',
icon: 'resident_target',
section: MENU_SECTION.MAIN,
sortVal: 28,
action: { type: 'residentTarget', target: 'packageEquity.residentTarget' },
provider: 'residentTarget'
}
]
/**
* 动态表单入口 id 按稳定路由/埋点元数据解析。
* 实际菜单项由 {@link ../../utils/dynamicFormMenus.js} provider 注入,此处仅登记 id 供查找。
*/
export const DYNAMIC_FORM_MENU_IDS = DYNAMIC_FORM_TAB_INDEX_MENUS.map(item => ({
id: resolveDynamicFormMenuId(item),
label: item.name,
provider: 'dynamicForm',
sortVal: item.sortVal
}))