gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
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
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallBrokerageUserApi } from '#/api/mall/trade/brokerage/user';
 
import { DICT_TYPE } from '..\..\..\..\..\packages\constants\src';
import { getDictOptions } from '..\..\..\..\..\packages\effects\hooks\src';
import { fenToYuan } from '..\..\..\..\..\packages\utils\src';
 
import { getRangePickerDefaultProps } from '#/utils';
 
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'bindUserId',
      label: '推广员编号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入推广员编号',
        allowClear: true,
      },
    },
    {
      fieldName: 'brokerageEnabled',
      label: '推广资格',
      component: 'RadioGroup',
      componentProps: {
        placeholder: '请选择推广资格',
        allowClear: true,
        options: [
          { label: '有', value: true },
          { label: '无', value: false },
        ],
      },
      defaultValue: true,
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}
 
/** 列表的字段 */
export function useGridColumns(
  onBrokerageEnabledChange?: (
    newEnabled: boolean,
    row: MallBrokerageUserApi.BrokerageUser,
  ) => PromiseLike<boolean | undefined>,
): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'id',
      title: '用户编号',
      minWidth: 80,
    },
    {
      field: 'avatar',
      title: '头像',
      minWidth: 70,
      cellRender: {
        name: 'CellImage',
      },
    },
    {
      field: 'nickname',
      title: '昵称',
      minWidth: 80,
    },
    {
      field: 'brokerageUserCount',
      title: '推广人数',
      minWidth: 80,
    },
    {
      field: 'brokerageOrderCount',
      title: '推广订单数量',
      minWidth: 110,
    },
    {
      field: 'brokerageOrderPrice',
      title: '推广订单金额',
      minWidth: 110,
      formatter: ({ row }) => `¥${fenToYuan(row.brokerageOrderPrice)}`,
    },
    {
      field: 'withdrawPrice',
      title: '已提现金额',
      minWidth: 100,
      formatter: ({ row }) => `¥${fenToYuan(row.withdrawPrice)}`,
    },
    {
      field: 'withdrawCount',
      title: '已提现次数',
      minWidth: 100,
    },
    {
      field: 'price',
      title: '未提现金额',
      minWidth: 100,
      formatter: ({ row }) => `¥${fenToYuan(row.price)}`,
    },
    {
      field: 'frozenPrice',
      title: '冻结中佣金',
      minWidth: 100,
      formatter: ({ row }) => `¥${fenToYuan(row.frozenPrice)}`,
    },
    {
      field: 'brokerageEnabled',
      title: '推广资格',
      minWidth: 80,
      align: 'center',
      cellRender: {
        attrs: { beforeChange: onBrokerageEnabledChange },
        name: 'CellSwitch',
        props: {
          checkedValue: true,
          uncheckedValue: false,
          checkedChildren: '有',
          unCheckedChildren: '无',
        },
      },
    },
    {
      field: 'brokerageTime',
      title: '成为推广员时间',
      minWidth: 180,
      formatter: 'formatDateTime',
    },
    {
      field: 'bindUserId',
      title: '上级推广员编号',
      minWidth: 150,
    },
    {
      field: 'bindUserTime',
      title: '推广员绑定时间',
      minWidth: 180,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 150,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
 
/** 创建分销员表单配置 */
export function useCreateFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'userId',
      label: '分销员编号',
      component: 'InputSearch',
      componentProps: {
        placeholder: '请输入分销员编号',
      },
      rules: 'required',
    },
    {
      fieldName: 'bindUserId',
      label: '上级推广员编号',
      component: 'InputSearch',
      componentProps: {
        placeholder: '请输入上级推广员编号',
      },
      rules: 'required',
    },
  ];
}
 
/** 修改分销用户表单配置 */
export function useUpdateFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'bindUserId',
      label: '上级推广员编号',
      component: 'InputSearch',
      componentProps: {
        placeholder: '请输入上级推广员编号',
      },
      rules: 'required',
    },
  ];
}
 
/** 用户列表弹窗搜索表单配置 */
export function useUserListFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'level',
      label: '用户类型',
      component: 'Select',
      componentProps: {
        options: [
          { label: '全部', value: undefined },
          { label: '一级推广人', value: '1' },
          { label: '二级推广人', value: '2' },
        ],
        allowClear: true,
      },
    },
    {
      fieldName: 'bindUserTime',
      label: '绑定时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}
 
/** 用户列表弹窗表格列配置 */
export function useUserListColumns(): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'id',
      title: '用户编号',
      minWidth: 80,
    },
    {
      field: 'avatar',
      title: '头像',
      minWidth: 70,
      cellRender: {
        name: 'CellImage',
        props: {
          width: 24,
          height: 24,
          shape: 'circle',
        },
      },
    },
    {
      field: 'nickname',
      title: '昵称',
      minWidth: 80,
    },
    {
      field: 'brokerageUserCount',
      title: '推广人数',
      minWidth: 80,
    },
    {
      field: 'brokerageOrderCount',
      title: '推广订单数量',
      minWidth: 110,
    },
    {
      field: 'brokerageEnabled',
      title: '推广资格',
      minWidth: 80,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
      },
    },
    {
      field: 'bindUserTime',
      title: '绑定时间',
      width: 180,
      formatter: 'formatDateTime',
    },
  ];
}
 
/** 推广订单列表弹窗搜索表单配置 */
export function useOrderListFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'sourceUserLevel',
      label: '用户类型',
      component: 'Select',
      componentProps: {
        options: [
          { label: '全部', value: 0 },
          { label: '一级推广人', value: 1 },
          { label: '二级推广人', value: 2 },
        ],
      },
      defaultValue: 0,
    },
    {
      fieldName: 'status',
      label: '状态',
      component: 'Select',
      componentProps: {
        placeholder: '请选择状态',
        allowClear: true,
        options: getDictOptions(DICT_TYPE.BROKERAGE_RECORD_STATUS, 'number'),
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}
 
/** 推广订单列表弹窗表格列配置 */
export function useOrderListColumns(): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'bizId',
      title: '订单编号',
      minWidth: 80,
    },
    {
      field: 'sourceUserId',
      title: '用户编号',
      minWidth: 80,
    },
    {
      field: 'sourceUserAvatar',
      title: '头像',
      minWidth: 70,
      cellRender: {
        name: 'CellImage',
        props: {
          width: 24,
          height: 24,
        },
      },
    },
    {
      field: 'sourceUserNickname',
      title: '昵称',
      minWidth: 80,
    },
    {
      field: 'price',
      title: '佣金',
      minWidth: 100,
      formatter: ({ row }) => `¥${fenToYuan(row.price)}`,
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 85,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.BROKERAGE_RECORD_STATUS },
      },
    },
    {
      field: 'createTime',
      title: '创建时间',
      width: 180,
      formatter: 'formatDateTime',
    },
  ];
}