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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { PayAppApi } from '#/api/pay/app';
|
| import { h } from 'vue';
|
| import { CommonStatusEnum, DICT_TYPE } from '../../../packages/constants/src';
| import { getDictOptions } from '../../../packages/effects/hooks/src';
|
| import { z } from '#/adapter/form';
| import { InputUpload } from '#/components/upload';
| import { getRangePickerDefaultProps } from '#/utils';
|
| /** 列表的搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'name',
| label: '应用名',
| component: 'Input',
| componentProps: {
| placeholder: '请输入应用名',
| allowClear: true,
| },
| },
| {
| fieldName: 'status',
| label: '开启状态',
| component: 'Select',
| componentProps: {
| placeholder: '请选择开启状态',
| options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
| allowClear: true,
| },
| },
| {
| fieldName: 'createTime',
| label: '创建时间',
| component: 'RangePicker',
| componentProps: {
| ...getRangePickerDefaultProps(),
| clearable: true,
| },
| },
| ];
| }
|
| /** 列表的字段 */
| export function useGridColumns(
| onStatusChange?: (
| newStatus: number,
| row: PayAppApi.App,
| ) => PromiseLike<boolean | undefined>,
| ): VxeTableGridOptions['columns'] {
| return [
| {
| field: 'appKey',
| title: '应用标识',
| minWidth: 40,
| },
| {
| field: 'name',
| title: '应用名',
| minWidth: 40,
| },
| {
| field: 'status',
| title: '状态',
| align: 'center',
| minWidth: 40,
| cellRender: {
| attrs: { beforeChange: onStatusChange },
| name: 'CellSwitch',
| props: {
| checkedValue: CommonStatusEnum.ENABLE,
| unCheckedValue: CommonStatusEnum.DISABLE,
| },
| },
| },
| {
| title: '支付宝配置',
| children: [
| {
| title: 'APP',
| slots: {
| default: 'alipayAppConfig',
| },
| },
| {
| title: 'PC 网站',
| slots: {
| default: 'alipayPCConfig',
| },
| },
| {
| title: 'WAP 网站',
| slots: {
| default: 'alipayWAPConfig',
| },
| minWidth: 10,
| },
| {
| title: '扫码',
| slots: {
| default: 'alipayQrConfig',
| },
| },
| {
| title: '条码',
| slots: {
| default: 'alipayBarConfig',
| },
| },
| ],
| },
| {
| title: '微信配置',
| children: [
| {
| title: '小程序',
| slots: {
| default: 'wxLiteConfig',
| },
| },
| {
| title: 'JSAPI',
| slots: {
| default: 'wxPubConfig',
| },
| },
| {
| title: 'APP',
| slots: {
| default: 'wxAppConfig',
| },
| },
| {
| title: 'Native',
| slots: {
| default: 'wxNativeConfig',
| },
| },
| {
| title: 'WAP 网站',
| slots: {
| default: 'wxWapConfig',
| },
| minWidth: 10,
| },
| {
| title: '条码',
| slots: {
| default: 'wxBarConfig',
| },
| },
| ],
| },
| {
| title: '钱包支付配置',
| field: 'walletConfig',
| slots: {
| default: 'walletConfig',
| },
| },
| {
| title: '模拟支付配置',
| field: 'mockConfig',
| slots: {
| default: 'mockConfig',
| },
| },
| {
| title: '操作',
| width: 140,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
| /** 应用新增/修改的表单 */
| export function useAppFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'id',
| component: 'Input',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'name',
| label: '应用名',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入应用名',
| },
| },
| {
| fieldName: 'appKey',
| label: '应用标识',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入应用标识',
| },
| },
| {
| fieldName: 'status',
| label: '开启状态',
| component: 'RadioGroup',
| rules: z.number().default(CommonStatusEnum.ENABLE),
| componentProps: {
| options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
| buttonStyle: 'solid',
| optionType: 'button',
| },
| },
| {
| fieldName: 'orderNotifyUrl',
| label: '支付结果的回调地址',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入支付结果的回调地址',
| },
| },
| {
| fieldName: 'refundNotifyUrl',
| label: '退款结果的回调地址',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入退款结果的回调地址',
| },
| },
| {
| fieldName: 'transferNotifyUrl',
| label: '转账结果的回调地址',
| component: 'Input',
| componentProps: {
| placeholder: '请输入转账结果的回调地址',
| },
| },
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Textarea',
| componentProps: {
| rows: 3,
| placeholder: '请输入备注',
| },
| },
| ];
| }
|
| /** 渠道新增/修改的表单 */
| export function useChannelFormSchema(formType: string = ''): VbenFormSchema[] {
| const schema: VbenFormSchema[] = [
| {
| component: 'Input',
| fieldName: 'id',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| label: '应用编号',
| fieldName: 'appId',
| component: 'Input',
| dependencies: {
| show: () => false,
| triggerFields: [''],
| },
| },
| {
| label: '渠道编码',
| fieldName: 'code',
| component: 'Input',
| dependencies: {
| show: () => false,
| triggerFields: [''],
| },
| },
| {
| label: '渠道费率',
| fieldName: 'feeRate',
| component: 'InputNumber',
| rules: 'required',
| componentProps: {
| class: '!w-full',
| placeholder: '请输入渠道费率',
| addonAfter: '%',
| },
| defaultValue: 0,
| },
| {
| label: '渠道状态',
| fieldName: 'status',
| component: 'RadioGroup',
| rules: z.number().default(CommonStatusEnum.ENABLE),
| componentProps: {
| options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
| buttonStyle: 'solid',
| optionType: 'button',
| },
| },
| ];
| // 添加通用字段
| // 根据类型添加特定字段
| if (formType.includes('alipay_')) {
| schema.push(
| {
| label: '开放平台 APPID',
| fieldName: 'config.appId',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入开放平台 APPID',
| },
| },
| {
| label: '网关地址',
| fieldName: 'config.serverUrl',
| component: 'RadioGroup',
| rules: 'required',
| componentProps: {
| options: [
| {
| value: 'https://openapi.alipay.com/gateway.do',
| label: '线上环境',
| },
| {
| value: 'https://openapi-sandbox.dl.alipaydev.com/gateway.do',
| label: '沙箱环境',
| },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| },
| {
| label: '算法类型',
| fieldName: 'config.signType',
| component: 'RadioGroup',
| rules: 'required',
| componentProps: {
| options: [
| {
| value: 'RSA2',
| label: 'RSA2',
| },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| defaultValue: 'RSA2',
| },
| {
| label: '公钥类型',
| fieldName: 'config.mode',
| component: 'RadioGroup',
| rules: 'required',
| componentProps: {
| options: [
| {
| value: 1,
| label: '公钥模式',
| },
| {
| value: 2,
| label: '证书模式',
| },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| },
| {
| label: '应用私钥',
| fieldName: 'config.privateKey',
| component: 'Textarea',
| rules: 'required',
| componentProps: {
| placeholder: '请输入应用私钥',
| rows: 3,
| },
| },
| {
| label: '支付宝公钥',
| fieldName: 'config.alipayPublicKey',
| component: 'Textarea',
| rules: 'required',
| componentProps: {
| placeholder: '请输入支付宝公钥',
| rows: 3,
| },
| dependencies: {
| show(values: any) {
| return values?.config?.mode === 1;
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: '商户公钥应用证书',
| fieldName: 'config.appCertContent',
| component: h(InputUpload, {
| inputType: 'textarea',
| textareaProps: { rows: 3, placeholder: '请上传商户公钥应用证书' },
| fileUploadProps: {
| accept: ['crt'],
| },
| }),
| rules: 'required',
| dependencies: {
| show(values: any) {
| return values?.config?.mode === 2;
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: '支付宝公钥证书',
| fieldName: 'config.alipayPublicCertContent',
| component: h(InputUpload, {
| inputType: 'textarea',
| textareaProps: { rows: 3, placeholder: '请上传支付宝公钥证书' },
| fileUploadProps: {
| accept: ['crt'],
| },
| }),
| rules: 'required',
| dependencies: {
| show(values: any) {
| return values?.config?.mode === 2;
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: '根证书',
| fieldName: 'config.rootCertContent',
| component: h(InputUpload, {
| inputType: 'textarea',
| textareaProps: { rows: 3, placeholder: '请上传根证书' },
| fileUploadProps: {
| accept: ['crt'],
| },
| }),
| rules: 'required',
| dependencies: {
| show(values: any) {
| return values?.config?.mode === 2;
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: '接口内容加密方式',
| fieldName: 'config.encryptType',
| component: 'RadioGroup',
| rules: 'required',
| componentProps: {
| options: [
| {
| value: 'NONE',
| label: '无加密',
| },
| {
| value: 'AES',
| label: 'AES',
| },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| defaultValue: 'NONE',
| },
| {
| label: '接口内容加密密钥',
| fieldName: 'config.encryptKey',
| component: 'Input',
| rules: 'required',
| dependencies: {
| show(values: any) {
| return values?.config?.encryptType === 'AES';
| },
| triggerFields: ['config.encryptType', 'encryptType', 'config'],
| },
| },
| );
| } else if (formType.includes('wx_')) {
| schema.push(
| {
| label: '微信 APPID',
| fieldName: 'config.appId',
| help: '前往微信商户平台[https://pay.weixin.qq.com/index.php/extend/merchant_appid/mapay_platform/account_manage]查看 APPID',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入微信 APPID',
| },
| },
| {
| label: '商户号',
| fieldName: 'config.mchId',
| help: '前往微信商户平台[https://pay.weixin.qq.com/index.php/extend/pay_setting]查看商户号',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入商户号',
| },
| },
| {
| label: 'API 版本',
| fieldName: 'config.apiVersion',
| component: 'RadioGroup',
| rules: 'required',
| componentProps: {
| options: [
| {
| label: 'v2',
| value: 'v2',
| },
| {
| label: 'v3',
| value: 'v3',
| },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| },
| {
| label: '商户密钥',
| fieldName: 'config.mchKey',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入商户密钥',
| },
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v2';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: 'apiclient_cert.p12 证书',
| fieldName: 'config.keyContent',
| component: h(InputUpload, {
| inputType: 'textarea',
| textareaProps: {
| rows: 3,
| placeholder: '请上传 apiclient_cert.p12 证书',
| },
| fileUploadProps: {
| accept: ['p12'],
| },
| }),
| rules: 'required',
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v2';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: 'API V3 密钥',
| fieldName: 'config.apiV3Key',
| component: 'Input',
| rules: 'required',
| componentProps: {
| placeholder: '请输入 API V3 密钥',
| },
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v3';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: 'apiclient_key.pem 证书',
| fieldName: 'config.privateKeyContent',
| component: h(InputUpload, {
| inputType: 'textarea',
| textareaProps: {
| rows: 3,
| placeholder: '请上传 apiclient_key.pem 证书',
| },
| fileUploadProps: {
| accept: ['pem'],
| },
| }),
| rules: 'required',
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v3';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: '证书序列号',
| fieldName: 'config.certSerialNo',
| component: 'Input',
| help: '前往微信商户平台[https://pay.weixin.qq.com/index.php/core/cert/api_cert#/api-cert-manage]查看证书序列号',
| rules: 'required',
| componentProps: {
| placeholder: '请输入证书序列号',
| },
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v3';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: 'public_key.pem 证书',
| fieldName: 'config.publicKeyContent',
| component: h(InputUpload, {
| inputType: 'textarea',
| textareaProps: {
| rows: 3,
| placeholder: '请上传 public_key.pem 证书',
| },
| fileUploadProps: {
| accept: ['pem'],
| },
| }),
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v3';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| {
| label: '公钥 ID',
| fieldName: 'config.publicKeyId',
| component: 'Input',
| help: '微信支付公钥产品简介及使用说明[https://pay.weixin.qq.com/doc/v3/merchant/4012153196]',
| rules: 'required',
| componentProps: {
| placeholder: '请输入公钥 ID',
| },
| dependencies: {
| show(values: any) {
| return values?.config?.apiVersion === 'v3';
| },
| triggerFields: ['config.mode', 'mode', 'config'],
| },
| },
| );
| }
| // 添加备注字段(所有类型都有)
| schema.push({
| label: '备注',
| fieldName: 'remark',
| component: 'Input',
| componentProps: {
| placeholder: '请输入备注',
| },
| });
| return schema;
| }
|
|