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
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeGridPropTypes } from '#/adapter/vxe-table';
| import type { MallDeliveryPickUpStoreApi } from '#/api/mall/trade/delivery/pickUpStore';
|
| import { markRaw } from 'vue';
|
| import { DeliveryTypeEnum, DICT_TYPE } from '..\..\..\..\packages\constants\src';
| import { getDictOptions } from '..\..\..\..\packages\effects\hooks\src';
| import { convertToInteger, formatToFraction } from '..\..\..\..\packages\utils\src';
|
| import { getSimpleDeliveryExpressList } from '#/api/mall/trade/delivery/express';
| import { getSimpleDeliveryPickUpStoreList } from '#/api/mall/trade/delivery/pickUpStore';
| import { AreaCascader } from '#/components/area';
| import { getRangePickerDefaultProps } from '#/utils';
|
| /** 关联数据 */
| let pickUpStoreList: MallDeliveryPickUpStoreApi.DeliveryPickUpStore[] = [];
| getSimpleDeliveryPickUpStoreList().then((data) => {
| pickUpStoreList = data;
| });
|
| /** 列表的搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'status',
| label: '订单状态',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.TRADE_ORDER_STATUS, 'number'),
| placeholder: '请选择订单状态',
| allowClear: true,
| },
| },
| {
| fieldName: 'payChannelCode',
| label: '支付方式',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'number'),
| placeholder: '请选择支付方式',
| allowClear: true,
| },
| },
| {
| fieldName: 'createTime',
| label: '创建时间',
| component: 'RangePicker',
| componentProps: {
| ...getRangePickerDefaultProps(),
| allowClear: true,
| },
| },
| {
| fieldName: 'terminal',
| label: '订单来源',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.TERMINAL, 'number'),
| placeholder: '请选择订单来源',
| allowClear: true,
| },
| },
| {
| fieldName: 'deliveryType',
| label: '配送方式',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.TRADE_DELIVERY_TYPE, 'number'),
| placeholder: '请选择配送方式',
| allowClear: true,
| },
| },
| {
| fieldName: 'logisticsId',
| label: '快递公司',
| component: 'ApiSelect',
| componentProps: {
| api: getSimpleDeliveryExpressList,
| labelField: 'name',
| valueField: 'id',
| placeholder: '请选择快递公司',
| allowClear: true,
| },
| dependencies: {
| triggerFields: ['deliveryType'],
| show: (values) => values.deliveryType === DeliveryTypeEnum.EXPRESS.type,
| },
| },
| {
| fieldName: 'pickUpStoreId',
| label: '自提门店',
| component: 'ApiSelect',
| componentProps: {
| api: getSimpleDeliveryPickUpStoreList,
| labelField: 'name',
| valueField: 'id',
| placeholder: '请选择自提门店',
| allowClear: true,
| },
| dependencies: {
| triggerFields: ['deliveryType'],
| show: (values) => values.deliveryType === DeliveryTypeEnum.PICK_UP.type,
| },
| },
| {
| fieldName: 'pickUpVerifyCode',
| label: '核销码',
| component: 'Input',
| componentProps: {
| placeholder: '请输入核销码',
| allowClear: true,
| },
| dependencies: {
| triggerFields: ['deliveryType'],
| show: (values) => values.deliveryType === DeliveryTypeEnum.PICK_UP.type,
| },
| },
| {
| fieldName: 'no',
| label: '订单号',
| component: 'Input',
| componentProps: {
| placeholder: '请输入订单号',
| allowClear: true,
| },
| },
| {
| fieldName: 'userId',
| label: '用户 UID',
| component: 'Input',
| componentProps: {
| placeholder: '请输入用户 UID',
| allowClear: true,
| },
| },
| {
| fieldName: 'userNickname',
| label: '用户昵称',
| component: 'Input',
| componentProps: {
| placeholder: '请输入用户昵称',
| allowClear: true,
| },
| },
| {
| fieldName: 'userMobile',
| label: '用户电话',
| component: 'Input',
| componentProps: {
| placeholder: '请输入用户电话',
| allowClear: true,
| },
| },
| ];
| }
|
| /** 表格列配置 */
| export function useGridColumns(): VxeGridPropTypes.Columns {
| return [
| {
| type: 'expand',
| width: 80,
| slots: { content: 'expand_content' },
| fixed: 'left',
| },
| {
| field: 'no',
| title: '订单号',
| fixed: 'left',
| minWidth: 180,
| },
| {
| field: 'createTime',
| title: '下单时间',
| formatter: 'formatDateTime',
| minWidth: 160,
| },
| {
| field: 'terminal',
| title: '订单来源',
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.TERMINAL },
| },
| minWidth: 120,
| },
| {
| field: 'payChannelCode',
| title: '支付方式',
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.PAY_CHANNEL_CODE },
| },
| minWidth: 120,
| },
| {
| field: 'payTime',
| title: '支付时间',
| formatter: 'formatDateTime',
| minWidth: 160,
| },
| {
| field: 'type',
| title: '订单类型',
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.TRADE_ORDER_TYPE },
| },
| minWidth: 80,
| },
| {
| field: 'payPrice',
| title: '实际支付',
| formatter: 'formatAmount2',
| minWidth: 180,
| },
| {
| field: 'user',
| title: '买家/收货人',
| formatter: ({ row }) => {
| if (row.deliveryType === DeliveryTypeEnum.EXPRESS.type) {
| return `买家:${row.user?.nickname} / 收货人: ${row.receiverName} ${row.receiverMobile}${row.receiverAreaName}${row.receiverDetailAddress}`;
| }
| if (row.deliveryType === DeliveryTypeEnum.PICK_UP.type) {
| return `门店名称:${pickUpStoreList.find((item) => item.id === row.pickUpStoreId)?.name} /
| 门店手机:${pickUpStoreList.find((item) => item.id === row.pickUpStoreId)?.phone} /
| 自提门店:${pickUpStoreList.find((item) => item.id === row.pickUpStoreId)?.detailAddress}
| `;
| }
| return '';
| },
| minWidth: 180,
| },
| {
| field: 'deliveryType',
| title: '配送方式',
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.TRADE_DELIVERY_TYPE },
| },
| minWidth: 80,
| },
| {
| field: 'status',
| title: '订单状态',
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.TRADE_ORDER_STATUS },
| },
| minWidth: 80,
| },
| {
| title: '操作',
| width: 180,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
| /** 订单备注表单配置 */
| export function useRemarkFormSchema(): VbenFormSchema[] {
| return [
| {
| component: 'Input',
| fieldName: 'id',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Input',
| componentProps: {
| type: 'textarea',
| rows: 3,
| },
| },
| ];
| }
|
| /** 订单调价表单配置 */
| export function usePriceFormSchema(): VbenFormSchema[] {
| return [
| {
| component: 'Input',
| fieldName: 'id',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'payPrice',
| label: '应付金额(总)',
| component: 'Input',
| componentProps: {
| placeholder: '请输入应付金额(总)',
| disabled: true,
| formatter: (value: string) => `${value}元`,
| },
| },
| {
| fieldName: 'adjustPrice',
| label: '订单调价',
| component: 'InputNumber',
| componentProps: {
| class: '!w-full',
| placeholder: '请输入订单调价',
| step: 0.1,
| precision: 2,
| },
| help: '订单调价。 正数,加价;负数,减价',
| rules: 'required',
| },
| {
| fieldName: 'newPayPrice',
| label: '调价后',
| component: 'Input',
| componentProps: {
| placeholder: '',
| formatter: (value: string) => `${value}元`,
| },
| dependencies: {
| triggerFields: ['payPrice', 'adjustPrice'],
| disabled: true,
| trigger(values, form) {
| const originalPrice = convertToInteger(values.payPrice);
| const adjustPrice = convertToInteger(values.adjustPrice);
| const newPrice = originalPrice + adjustPrice;
| form.setFieldValue('newPayPrice', formatToFraction(newPrice));
| },
| },
| },
| ];
| }
|
| /** 订单修改地址表单配置 */
| export function useAddressFormSchema(): VbenFormSchema[] {
| return [
| {
| component: 'Input',
| fieldName: 'id',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'receiverName',
| label: '收件人',
| component: 'Input',
| componentProps: {
| placeholder: '请输入收件人名称',
| },
| rules: 'required',
| },
| {
| fieldName: 'receiverMobile',
| label: '手机号',
| component: 'Input',
| componentProps: {
| placeholder: '请输入收件人手机号',
| },
| rules: 'required',
| },
| {
| fieldName: 'receiverAreaId',
| label: '所在地',
| component: markRaw(AreaCascader),
| componentProps: {
| allowClear: true,
| changeOnSelect: true,
| class: '!w-full',
| placeholder: '请选择收件人所在地',
| showSearch: true,
| },
| rules: 'required',
| },
| {
| fieldName: 'receiverDetailAddress',
| label: '详细地址',
| component: 'Input',
| componentProps: {
| placeholder: '请输入收件人详细地址',
| type: 'textarea',
| rows: 3,
| },
| rules: 'required',
| },
| ];
| }
|
| /** 订单发货表单配置 */
| export function useDeliveryFormSchema(): VbenFormSchema[] {
| return [
| {
| component: 'Input',
| fieldName: 'id',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'expressType',
| label: '发货方式',
| component: 'RadioGroup',
| componentProps: {
| options: [
| { label: '快递', value: 'express' },
| { label: '无需发货', value: 'none' },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| defaultValue: 'express',
| },
| {
| fieldName: 'logisticsId',
| label: '物流公司',
| component: 'ApiSelect',
| componentProps: {
| api: getSimpleDeliveryExpressList,
| labelField: 'name',
| valueField: 'id',
| placeholder: '请选择物流公司',
| },
| dependencies: {
| triggerFields: ['expressType'],
| show: (values) => values.expressType === 'express',
| },
| rules: 'required',
| },
| {
| fieldName: 'logisticsNo',
| label: '物流单号',
| component: 'Input',
| componentProps: {
| placeholder: '请输入物流单号',
| },
| dependencies: {
| triggerFields: ['expressType'],
| show: (values) => values.expressType === 'express',
| },
| rules: 'required',
| },
| ];
| }
|
|