registry.js
10.9 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
import { RECRUIT_MENU_ENABLED } from '../../config.js'
import { AI_ROUTES } from '../../router/routeAliases.js'
import { MENU_SECTION } from './constants.js'
import {
DYNAMIC_FORM_EQUITY_MENUS,
resolveDynamicFormMenuId
} from '../../utils/dynamicFormMenus.js'
/**
* @typedef {import('./context.js').createEquityMenuContext extends (...args: any[]) => infer R ? R : never} EquityMenuContext
* 菜单管道上下文:`userInfo`、`isStaff`、`mentorFlag`、`mode`;`ctx.policies` 见 {@link ./policies.js}
*/
/**
* 菜单跳转指令,由 {@link ./toViewModel.js} 映射为 WXML 字段,由 {@link ./jumpHandlers.js} 按 type 分发。
*
* @typedef {Object} EquityMenuAction
* @property {'router'|'navigate'|'workReport'|'salaryPerformance'|'residentTarget'|'createOrderPrompt'|'defeatOrder'} type
* 跳转类型,对应 jumpHandlers handlers 键
* @property {string} [target]
* 路由名(router)、分包 navigateToUrl(navigate)、workReport 占位路由
* @property {Object} [params]
* 传给 `wx.$router.go(target, { params })` 的参数
* @property {boolean} [usePath]
* 为 true 时 toViewModel 写 `path`(如 pending_approval)
* @property {string} [trackEventCode]
* navigate 类型点击埋点 eventCode(如 scenario_marketplace)
*/
/**
* 同步注册表条目(EQUITY_MENU_REGISTRY)。新增条目请对照本类型必填项。
*
* @typedef {Object} EquityMenuRegistryEntry
* @property {string} id
* 稳定主键:去重、`applyEquityMenuBadges`、`jumpHandlers` 按 id 分支均依赖此字段
* @property {string} label
* 展示文案;toViewModel 映射为 `menuText` 供 WXML `item.menuText`
* @property {string} icon
* CDN 图标文件名;权益 WXML 拼接 `crowdFunding/{icon}.png`
* @property {'main'|'secondary'} section
* 权益首页统一写入 `data.menuList`(见 MENU-ARCHITECTURE.md)
* @property {EquityMenuAction} action
* 跳转指令,必填
* @property {(ctx: EquityMenuContext) => boolean} visible
* 同步管道显隐;buildEquityMenusSync 过滤
* @property {number} [sortVal]
* 升序排序,越小越靠前
*
* --- 可选 UI ---
* @property {number} [tipsNum]
* 数字角标:registry 初值 + `applyEquityMenuBadges` 按 id 更新
* @property {boolean} [noRead]
* 未读气泡;residentTarget provider 注入 → WXML `bubble_icon`
* @property {boolean} [default]
* 标记默认展示类异步入口(文档用,管道不单独处理)
*
* --- 可选跳转 / 校验 ---
* @property {number} [recordId]
* 埋点 id;jumpHandlers / openWorkReportTemp 调用 pointRecord
* @property {string} [beforeClick]
* 跳转前 `wx.$globalDataFunction[beforeClick]()`,返回 true 则中断
* @property {boolean} [noCheckdailyReport]
* 为 true 时跳过日报/学习中心/异常单校验(权益 workReport 基座项)
* @property {'daily'|'weekly'|'monthly'} [reportTypeAttr]
* workReport 模版类型
* @property {string} [reportTypeVal]
* 工作报表模版 type 参数('1'/'2'/'3')
*/
/**
* 异步 provider 注入的 view model 附加字段。
*
* @typedef {Object} EquityMenuViewModelExtras
* @property {boolean} [noRead]
* 驻店目标未读气泡
* @property {number} [tipsNum]
* 角标数字;customerClue provider 可注入初值
*/
/**
* 权益首页同步菜单注册表(单一数据源)。
* 架构文档见 packageEquity/docs/MENU-ARCHITECTURE.md
* **新增菜单流程**:packageEquity/docs/ADD-MENU-GUIDE-EQUITY.md
* 跨首页 id 契约:packageDynamicForm/docs/routes-and-menus.md
* 变更记录:packageEquity/docs/DEVLOG.md
*
* @type {EquityMenuRegistryEntry[]}
*/
export const EQUITY_MENU_REGISTRY = [
// --- 工作报表基座(仅权益首页常驻)---
{
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: () => true
},
{
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: () => true
},
{
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: () => true
},
// --- 员工 / 督导同步入口 ---
{
id: 'staff_daily_report',
label: '驻店日报',
icon: 'supplementary_order',
section: MENU_SECTION.MAIN,
sortVal: 11,
recordId: 13,
action: { type: 'router', target: 'tabWorkOrder.staffDaily' },
visible: ({ policies }) => policies.staffOrMultiStoreDaily()
},
{
id: 'create_order',
label: '新建工单',
icon: 'create_order',
section: MENU_SECTION.MAIN,
sortVal: 1,
beforeClick: 'inspectionOfProhibitionBill',
action: { type: 'createOrderPrompt', target: '' },
visible: ({ isStaff }) => isStaff
},
{
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: ({ isStaff }) => isStaff
},
{
id: 'defeat_order',
label: '战败下单',
icon: 'deafeat_order',
section: MENU_SECTION.MAIN,
sortVal: 2,
action: {
type: 'defeatOrder',
target: 'packageEquity.createDeafeatOrderBefore'
},
visible: ({ isStaff, policies }) =>
isStaff && policies.hasDefeatOrderMode()
},
{
id: 'bi_report',
label: 'BI报表',
icon: 'business_data',
section: MENU_SECTION.MAIN,
sortVal: 21,
recordId: 11,
action: { type: 'router', target: 'tabOperating.index' },
visible: ({ policies }) => policies.canSelectMultiStore()
},
// --- 角色特有条件 ---
{
id: 'delivery_target',
label: '交车目标',
icon: 'delivery_target',
section: MENU_SECTION.MAIN,
sortVal: 18,
action: { type: 'router', target: 'packageEquity.deliveryTarget' },
visible: ({ policies }) => policies.isDeliveryTargetRole()
},
{
id: 'training_materials',
label: '培训资料',
icon: 'peixun_icon',
section: MENU_SECTION.MAIN,
sortVal: 15,
action: { type: 'router', target: 'packageEquity.trainingMaterials' },
visible: ({ policies }) => !policies.canSelectMultiStore()
},
{
id: 'scene_market',
label: '场景集市',
icon: 'sceneMarket',
section: MENU_SECTION.MAIN,
sortVal: 16,
action: {
type: 'navigate',
target: '/packageEquity/pages/sceneMarket/index/index',
trackEventCode: 'scenario_marketplace'
},
visible: ({ policies }) =>
policies.canViewRecruit() || policies.canViewMentorship()
},
// --- 区域运营 ---
{
id: 'recruit_manage',
label: '招聘管理',
icon: 'recruit-manage',
section: MENU_SECTION.MAIN,
sortVal: 22,
tipsNum: 0,
action: { type: 'router', target: 'packageEquity.recruitManage' },
visible: ({ policies }) =>
RECRUIT_MENU_ENABLED && policies.canViewRecruit()
},
{
id: 'pending_approval',
label: '待审批',
icon: 'refund_review_icon',
section: MENU_SECTION.MAIN,
sortVal: 23,
tipsNum: 0,
action: {
type: 'router',
target: 'tabWorkOrder.refundOperationList',
usePath: true
},
visible: ({ policies }) => policies.canViewRecruit()
},
{
id: 'study_center',
label: '学习中心',
icon: 'study-center',
section: MENU_SECTION.MAIN,
sortVal: 24,
action: { type: 'router', target: 'packageStudyCenter.studyCenter' },
visible: ({ isStaff, policies }) =>
isStaff && policies.notJiLianChannel()
}
]
/**
* 异步 provider 控制的菜单(不在同步管道默认输出)。
* 显隐由 {@link ./asyncProviders.js} 中 provider 返回值决定。
*
* @typedef {Omit<EquityMenuRegistryEntry, 'visible'> & {
* provider: string,
* visible?: (ctx: EquityMenuContext) => boolean
* }} AsyncEquityMenuRegistryEntry
*
* @type {AsyncEquityMenuRegistryEntry[]}
*/
export const ASYNC_MENU_REGISTRY = [
{
id: 'salary_appeal',
label: '工资申诉',
icon: 'salary_appeal_icon',
section: MENU_SECTION.MAIN,
sortVal: 25,
action: { type: 'router', target: 'packageEquity.salaryAppeal' },
provider: 'salaryAppeal'
},
{
id: 'missing_reception',
label: '接待缺失报备',
icon: 'missing-reception',
section: MENU_SECTION.MAIN,
sortVal: 26,
action: { type: 'router', target: 'packageEquity.missingReception' },
provider: 'missingReception'
},
{
id: 'script_extract',
label: '话术萃取',
icon: 'extract_icon',
section: MENU_SECTION.MAIN,
sortVal: 12,
default: true,
action: {
type: 'router',
target: 'packageEquity.extract',
params: { type: 1 }
},
provider: 'scriptExtract'
},
{
id: 'script_verify',
label: '话术核验',
icon: 'verification_icon',
section: MENU_SECTION.MAIN,
sortVal: 13,
default: true,
action: {
type: 'router',
target: 'packageEquity.extract',
params: { type: 2 }
},
provider: 'scriptVerify'
},
{
id: 'ai_fun_practice',
label: 'AI趣练',
icon: 'ai_chat',
section: MENU_SECTION.MAIN,
sortVal: 14,
default: true,
action: { type: 'router', target: AI_ROUTES.aiCheckStart },
provider: 'aiFunPractice'
},
{
id: 'customer_clue',
label: '客户线索',
icon: 'customer_clue',
section: MENU_SECTION.MAIN,
sortVal: 4,
default: true,
tipsNum: 0,
action: { type: 'router', target: 'packageEquity.clueList' },
provider: 'customerClue'
},
{
id: 'salary_performance_api',
label: '工资绩效',
icon: 'businessschoo',
section: MENU_SECTION.MAIN,
sortVal: 17,
action: { type: 'salaryPerformance' },
provider: 'salaryPerformance'
},
{
id: 'resident_target',
label: '驻店目标',
icon: 'resident_target',
section: MENU_SECTION.MAIN,
sortVal: 19,
action: { type: 'residentTarget', target: 'packageEquity.residentTarget' },
provider: 'residentTarget'
},
{
id: 'reception_records',
label: '接待记录',
icon: 'reception-record-icon',
section: MENU_SECTION.MAIN,
sortVal: 3,
default: true,
action: { type: 'router', target: 'packageEquity.receptionRecords' },
provider: 'receptionRecords'
},
{
id: 'illegal_recording',
label: '违规录音处理',
icon: 'illegal-recording',
section: MENU_SECTION.MAIN,
sortVal: 20,
default: true,
action: {
type: 'navigate',
target: '/packageEquity/pages/receptionRecords/receptionRecords?hideScore=1'
},
provider: 'illegalRecording'
}
]
/**
* 动态表单入口 id 按稳定路由/埋点元数据解析。
* 实际菜单项由 `dynamicForm` provider 注入,此处仅登记 id 供查找与单测。
*/
export const DYNAMIC_FORM_MENU_IDS = DYNAMIC_FORM_EQUITY_MENUS.map(item => ({
id: resolveDynamicFormMenuId(item),
label: item.menuText,
provider: 'dynamicForm',
sortVal: item.sortVal
}))