dictionaries.ts
8.82 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
import type { ChannelNode, DictOption } from '@/api';
/**
* 积分管理三个菜单用到的全部固定字典。
*
* 老系统把这些数组散落在 utils/constants.js 与各页面的 data() 里,
* 同一个状态在不同页面各抄一份(提现状态 9 项、审批状态 7 项就重复过)。
* 这里按「一个状态机一份表」收口:value 一律字符串,提交给后端的原值不变;
* label 与老系统逐字一致,改动只需要对照一张表。
*/
export interface StatusMeta {
label: string;
/** antd 徽标色名或十六进制,与设计令牌同源。 */
color: string;
}
/** 按下标取状态文案:老接口直接返回数字 status。 */
export function statusMeta(table: StatusMeta[], status: unknown): StatusMeta | undefined {
const index = Number(status);
return Number.isInteger(index) && index >= 0 && index < table.length ? table[index] : undefined;
}
export function statusOptions(table: StatusMeta[]): DictOption[] {
return table.map((item, index) => ({ value: String(index), label: item.label }));
}
/** 核销订单的结算状态(接口字段 settlementStatus,0/1)。 */
export const SETTLE_STATUS: DictOption[] = [
{ value: '0', label: '未结算' },
{ value: '1', label: '已结算' },
];
/** 提现方式(接口字段 mode,0/1)。 */
export const PAY_MODE: DictOption[] = [
{ value: '0', label: '银行卡' },
{ value: '1', label: '微信' },
];
/** 提现类型(接口字段 transferType,0/1/2)。批量与一键操作前先校验所选记录同类型。 */
export const WITHDRAWAL_TYPE: DictOption[] = [
{ value: '0', label: '积分提现' },
{ value: '1', label: '普通提现' },
{ value: '2', label: '阳光激励' },
];
/** 提现来源(接口字段 withdrawalSource,0-3)。 */
export const WITHDRAWAL_SOURCE: DictOption[] = [
{ value: '0', label: '车生活助手' },
{ value: '1', label: '系统导入' },
{ value: '2', label: '生意助手员工版' },
{ value: '3', label: '门店助手' },
];
/** 积分时段归属(接口字段 pointsPeriodType,1/2)。 */
export const POINTS_PERIOD: DictOption[] = [
{ value: '1', label: '26年9月前积分' },
{ value: '2', label: '26年9月后积分' },
];
/** 是否限制门店(提交 Y/N,接口字段 limitStoreFlag / limitStoreFlagQuery)。 */
export const LIMIT_STORE_FLAG: DictOption[] = [
{ value: 'Y', label: '是' },
{ value: 'N', label: '否' },
];
/** 服务商编码 → 展示名(接口字段 channelProvider,老列表 formatter 里就这四个值)。 */
export const CHANNEL_PROVIDER: DictOption[] = [
{ value: 'SHENBIANYUN-XH', label: '翔禾' },
{ value: 'SHENBIANYUN-YJ', label: '雅钧' },
{ value: 'SHENBIANYUN-BC', label: '博晟' },
{ value: 'SHENBIANYUN-CJ', label: '晨景' },
];
/**
* 提现单状态(0-8),对应老系统的 auditStatusStatusList。
* 颜色逐项对齐老列表的圆点数组,只有一处例外:
* 老系统把「受理失败」涂成绿色,那是抄错的一行,这里按语义给红。
*/
export const TRANSFER_STATUS: StatusMeta[] = [
{ label: '待审核', color: 'gold' },
{ label: '已审核', color: 'green' },
{ label: '第三方处理', color: 'geekblue' },
{ label: '成功', color: 'green' },
{ label: '失败', color: 'default' },
{ label: '驳回', color: 'red' },
{ label: '受理失败', color: 'red' },
{ label: '批次处理中', color: 'orange' },
{ label: '签约中', color: 'orange' },
];
/**
* 累计结算金额的统计项(老系统 constants.statisticsTypeList,逐字保留顺序与编码)。
* 提现列表顶部只展示前 4 项,「查看更多」弹窗展示全部;接口按 key 平铺回金额。
*/
export const SETTLE_STATISTICS: Array<{ key: string; label: string }> = [
{ key: 'yiXuanSettleAmount', label: '熠轩-银行卡' },
{ key: 'zxSettleAmount', label: '中雄-银行卡' },
{ key: 'yunHuoSettleAmount', label: '云获(嘀加)-银行卡' },
{ key: 'yunHuoZYSettleAmount', label: '云获(中赢)-银行卡' },
{ key: 'yunHuoWXSettleAmount', label: '云获(中赢)-微信' },
{ key: 'shenBianYunSettleAmount', label: '身边云-银行卡' },
{ key: 'birdWorkSettleAmount', label: '智鸟-银行卡' },
{ key: 'shenBianYunJXSettleAmount', label: '身边云(江西)-银行卡' },
{ key: 'xinXiangYunSettleAmount', label: '薪享云-银行卡' },
{ key: 'daXiongSettleAmount', label: '大熊-银行卡' },
];
/** 提现列表顶部统计卡固定展示前 4 项(老系统 statisticsTypeList.slice(0, 4))。 */
export const SETTLE_STATISTICS_PREVIEW = 4;
/** 审批批次状态(0-6),对应老系统 constants.statusList + approve.vue 的列渲染。 */
export const APPROVAL_STATUS: StatusMeta[] = [
{ label: '待审批', color: 'default' },
{ label: '审批中', color: 'gold' },
{ label: '审批通过', color: 'green' },
{ label: '审批驳回', color: 'red' },
{ label: '渠道到账', color: 'green' },
{ label: '用户到账', color: 'green' },
{ label: '到账异常', color: 'red' },
];
/** 审批操作记录的动作名(接口字段 operationType,从 1 开始)。 */
export const APPROVAL_OPERATION: Record<number, string> = {
1: '付款审核',
2: '批次关闭',
3: 'OA审批',
4: '渠道到账',
5: '渠道付款',
};
/** 提现详情的操作记录:type 决定动作与人称,result 决定结果文案。 */
export const TRANSFER_OPERATION_TYPES = ['审核', '付款', '受理'] as const;
export const TRANSFER_OPERATION_RESULTS = ['通过', '驳回', '失败'] as const;
/** 「审核人 / 付款人 / 受理人」这类由动作派生的标签,老系统按下标取词。 */
export function operationLabel(action: unknown, kind: 'person' | 'time' | 'name'): string {
const index = Number(action);
const name = TRANSFER_OPERATION_TYPES[index];
if (!name) return '';
return kind === 'person' ? `${name}人` : kind === 'time' ? `${name}时间` : name;
}
/** 用户积分明细三个 tab:channelSource 是接口入参,也是 tab 的 key。 */
export const SCORE_TABS = [
{ key: '2', label: '续保用户', channelSource: 2 },
{ key: '1', label: '阳光激励用户', channelSource: 1 },
{ key: '3', label: '管理层', channelSource: 3 },
] as const;
/**
* 积分流水的类型筛选,两套候选逐字来自 userDetail.vue 的 infoNameList:
* 阳光激励(channelSource=1)给全部 11 类,其余渠道只给 4 类。
* 提交值就是中文本身(老接口的 confId 与 confLabel 同值),换成编码后端不认识。
*/
const SCORE_INFO_NAMES = [
'积分收益',
'积分兑换',
'退款抵扣',
'撤单抵扣',
'错单抵扣',
'手动抵扣',
'撤销抵扣',
'售后返还',
'购物兑换',
'手动增加',
'手动扣减',
];
const SCORE_INFO_NAMES_OTHER = ['积分收益', '积分兑换', '购物兑换', '售后返还'];
export function scoreInfoNameOptions(channelSource: string | number): DictOption[] {
const names = String(channelSource) === '1' ? SCORE_INFO_NAMES : SCORE_INFO_NAMES_OTHER;
return withAll(names.map((name) => ({ value: name, label: name })));
}
/** 老系统只有阳光激励渠道允许出现「撤销」入口,且仅限无关联单号的手动抵扣流水。 */
export const MANUAL_DEDUCT_INFO_NAME = '手动抵扣';
export function canRevokeScore(
channelSource: string | number,
row: { infoName?: string; relateId?: string },
): boolean {
return String(channelSource) === '1' && row.infoName === MANUAL_DEDUCT_INFO_NAME && !row.relateId;
}
/** 付款渠道列表(老系统 constants.channelList,OA 付款审批用)。 */
export const PAYMENT_CHANNELS: DictOption[] = [
{ value: '智鸟', label: '智鸟-银行卡' },
{ value: '身边云(江西)', label: '身边云(江西)-银行卡' },
];
/**
* 渠道树按 code 递归取节点(老系统 findChannelByCode)。
* 老接口的子节点字段名是 child,不是 children。
*/
export function findChannelNode(
nodes: ChannelNode[] | undefined | null,
code: unknown,
): ChannelNode | undefined {
if (!Array.isArray(nodes) || code === undefined || code === null) return;
for (const node of nodes) {
if (node.code === code) return node;
const found = findChannelNode(node.child ?? node.children, code);
if (found) return found;
}
return undefined;
}
/** 按下标取字典文案;命中不了原样回显,避免后端加了新枚举就显示空白。 */
export function optionLabel(options: DictOption[], value: unknown): string {
if (value === null || value === undefined || value === '') return '';
const key = String(value);
return options.find((option) => option.value === key)?.label ?? key;
}
/** 老系统的下拉第一项固定是「全部」(提交空串),现系统筛选项沿用这一约定。 */
export const ALL: DictOption = { value: '', label: '全部' };
export function withAll(options: DictOption[]): DictOption[] {
return [ALL, ...options];
}