orderListRouteParams.js
1.48 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
/** 旧版 tabPane name -> 一级 + 二级;4 需保留原「不预选所属业务」 */
export const LEGACY_TAB_PANE = {
1: { category: "light", leaf: "l-1-1" },
2: { category: "light", leaf: "l-1-2" },
3: { category: "light", leaf: "l-1-3" },
4: { category: "rights", leaf: "l-2-1", legacyRightsAll: true },
5: { category: "renewal", leaf: "l-3-1" },
};
export const LEGACY_LABEL_TO_PANE = {
order: "1",
"config-upgradation": "2",
"crowd-funding": "3",
carDamage: "4",
"integral-shopping": "5",
};
/**
* 从路由 params 解析 tabPane 键
* @param {object} [params]
* @returns {string|null}
*/
export function resolveTabPaneFromParams(params) {
if (!params) {
return null;
}
let pane = params.tabPane;
const label = params.tabLabel;
if (pane == null || pane === "") {
if (
label != null
&& label !== ""
&& Object.prototype.hasOwnProperty.call(LEGACY_LABEL_TO_PANE, label)
) {
pane = LEGACY_LABEL_TO_PANE[label];
} else {
return null;
}
}
return String(pane);
}
/**
* 根据路由 params 计算 orderList 壳层应更新的状态片段
* @param {object} [params]
* @returns {object|null}
*/
export function computeRouteParamPatch(params) {
const key = resolveTabPaneFromParams(params);
if (!key) {
return null;
}
const mapping = LEGACY_TAB_PANE[key];
if (!mapping) {
return null;
}
return {
activeCategory: mapping.category,
pendingLegacyLeaf: mapping.leaf,
rightsFromLegacyTab4: !!mapping.legacyRightsAll,
isApplyingRoute: true,
};
}