From a602decde99dc3f8c195b85504af1012689c1bcd Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Mon, 26 May 2025 16:52:11 +0800 Subject: [PATCH] refactor: pay app --- apps/web-antd/package.json | 1 - apps/web-antd/src/views/pay/app/data.ts | 425 +++---- apps/web-antd/src/views/pay/app/index.vue | 1006 ++++++++++------- .../src/views/pay/app/modules/app-form.vue | 115 +- ...ipay-channel-form.vue => channel-form.vue} | 136 ++- .../src/views/pay/app/modules/channel/data.ts | 456 -------- .../app/modules/channel/mock-channel-form.vue | 105 -- .../modules/channel/wallet-channel-form.vue | 105 -- .../modules/channel/weixin-channel-form.vue | 148 --- .../src/views/pay/app/modules/data.ts | 530 +++++++++ 10 files changed, 1444 insertions(+), 1583 deletions(-) rename apps/web-antd/src/views/pay/app/modules/{channel/alipay-channel-form.vue => channel-form.vue} (58%) delete mode 100644 apps/web-antd/src/views/pay/app/modules/channel/data.ts delete mode 100644 apps/web-antd/src/views/pay/app/modules/channel/mock-channel-form.vue delete mode 100644 apps/web-antd/src/views/pay/app/modules/channel/wallet-channel-form.vue delete mode 100644 apps/web-antd/src/views/pay/app/modules/channel/weixin-channel-form.vue create mode 100644 apps/web-antd/src/views/pay/app/modules/data.ts diff --git a/apps/web-antd/package.json b/apps/web-antd/package.json index b779d03a..f9a0862e 100644 --- a/apps/web-antd/package.json +++ b/apps/web-antd/package.json @@ -26,7 +26,6 @@ "#/*": "./src/*" }, "dependencies": { - "@ant-design/icons-vue": "catalog:", "@form-create/ant-design-vue": "catalog:", "@form-create/antd-designer": "catalog:", "@tinymce/tinymce-vue": "catalog:", diff --git a/apps/web-antd/src/views/pay/app/data.ts b/apps/web-antd/src/views/pay/app/data.ts index dcc83ba0..5063e408 100644 --- a/apps/web-antd/src/views/pay/app/data.ts +++ b/apps/web-antd/src/views/pay/app/data.ts @@ -1,223 +1,242 @@ -import type { FormSchemaGetter } from '#/adapter/form'; -import type { VxeGridProps } from '#/adapter/vxe-table'; +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { PayAppApi } from '#/api/pay/app'; +import { CommonStatusEnum } from '#/utils/constants'; import { DICT_TYPE, getDictOptions } from '#/utils/dict'; -export const querySchema: FormSchemaGetter = () => [ - { - component: 'Input', - fieldName: 'name', - label: '应用名', - componentProps: { - placeholder: '请输入应用名', +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'name', + label: '应用名', + componentProps: { + placeholder: '请输入应用名', + }, }, - }, - { - component: 'Select', - fieldName: 'status', - label: '开启状态', - componentProps: { - placeholder: '请选择开启状态', - options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + { + component: 'Select', + fieldName: 'status', + label: '开启状态', + componentProps: { + placeholder: '请选择开启状态', + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, }, - }, - { - component: 'RangePicker', - fieldName: 'createTime', - label: '创建时间', - componentProps: { - placeholder: ['开始日期', '结束日期'], + { + component: 'RangePicker', + fieldName: 'createTime', + label: '创建时间', + componentProps: { + placeholder: ['开始日期', '结束日期'], + }, }, - }, -]; + ]; +} -export const columns: VxeGridProps['columns'] = [ - { type: 'checkbox', width: 60 }, - { - title: '应用标识', - field: 'appKey', - }, - { - title: '应用名', - field: 'name', - }, - { - title: '开启状态', - field: 'status', - slots: { - default: 'status', +export function useGridColumns( + onStatusChange?: ( + newStatus: number, + row: T, + ) => PromiseLike, +): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 60 }, + { + title: '应用标识', + field: 'appKey', }, - }, - { - title: '支付宝配置', - children: [ - { - title: 'APP 支付', - slots: { - default: 'alipayAppConfig', + { + title: '应用名', + field: 'name', + }, + { + field: 'status', + title: '状态', + minWidth: 100, + align: 'center', + cellRender: { + attrs: { beforeChange: onStatusChange }, + name: 'CellSwitch', + props: { + checkedValue: CommonStatusEnum.ENABLE, + unCheckedValue: CommonStatusEnum.DISABLE, }, }, - { - title: 'PC 网站支付', - slots: { - default: 'alipayPCConfig', - }, - }, - { - title: 'WAP 网站支付', - slots: { - default: 'alipayWAPConfig', - }, - }, - { - 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', - }, - }, - { - title: '条码支付', - slots: { - default: 'wxBarConfig', - }, - }, - ], - }, - { - title: '钱包支付配置', - field: 'walletConfig', - slots: { - default: 'walletConfig', }, - }, - { - title: '模拟支付配置', - field: 'mockConfig', - slots: { - default: 'mockConfig', + { + title: '支付宝配置', + children: [ + { + title: 'APP 支付', + slots: { + default: 'alipayAppConfig', + }, + }, + { + title: 'PC 网站支付', + slots: { + default: 'alipayPCConfig', + }, + }, + { + title: 'WAP 网站支付', + slots: { + default: 'alipayWAPConfig', + }, + }, + { + title: '扫码支付', + slots: { + default: 'alipayQrConfig', + }, + }, + { + title: '条码支付', + slots: { + default: 'alipayBarConfig', + }, + }, + ], }, - }, - { - field: 'action', - fixed: 'right', - slots: { default: 'action' }, - title: '操作', - minWidth: 160, - }, -]; - -export const modalSchema: FormSchemaGetter = () => [ - { - label: '应用编号', - fieldName: 'id', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], + { + 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', + }, + }, + { + title: '条码支付', + slots: { + default: 'wxBarConfig', + }, + }, + ], }, - }, - { - label: '应用名', - fieldName: 'name', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入应用名', + { + title: '钱包支付配置', + field: 'walletConfig', + slots: { + default: 'walletConfig', + }, }, - }, - { - label: '应用标识', - fieldName: 'appKey', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入应用标识', + { + title: '模拟支付配置', + field: 'mockConfig', + slots: { + default: 'mockConfig', + }, }, - }, - { - label: '开启状态', - fieldName: 'status', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + { + title: '操作', + width: 130, + fixed: 'right', + slots: { default: 'actions' }, }, - }, - { - label: '支付结果的回调地址', - fieldName: 'orderNotifyUrl', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入支付结果的回调地址', + ]; +} +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + label: '应用编号', + fieldName: 'id', + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, }, - }, - { - label: '退款结果的回调地址', - fieldName: 'refundNotifyUrl', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入支付结果的回调地址', + { + label: '应用名', + fieldName: 'name', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入应用名', + }, }, - }, - { - label: '转账结果的回调地址', - fieldName: 'transferNotifyUrl', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入转账结果的回调地址', + { + label: '应用标识', + fieldName: 'appKey', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入应用标识', + }, }, - }, - { - label: '备注', - fieldName: 'remark', - component: 'Textarea', - componentProps: { - rows: 3, - placeholder: '请输入备注', + { + label: '开启状态', + fieldName: 'status', + component: 'RadioGroup', + rules: 'required', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, }, - }, -]; + { + label: '支付结果的回调地址', + fieldName: 'orderNotifyUrl', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入支付结果的回调地址', + }, + }, + { + label: '退款结果的回调地址', + fieldName: 'refundNotifyUrl', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入支付结果的回调地址', + }, + }, + { + label: '转账结果的回调地址', + fieldName: 'transferNotifyUrl', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入转账结果的回调地址', + }, + }, + { + label: '备注', + fieldName: 'remark', + component: 'Textarea', + componentProps: { + rows: 3, + placeholder: '请输入备注', + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/pay/app/index.vue b/apps/web-antd/src/views/pay/app/index.vue index 08cfc1b3..df349c1b 100644 --- a/apps/web-antd/src/views/pay/app/index.vue +++ b/apps/web-antd/src/views/pay/app/index.vue @@ -1,118 +1,90 @@ diff --git a/apps/web-antd/src/views/pay/app/modules/app-form.vue b/apps/web-antd/src/views/pay/app/modules/app-form.vue index 3791d15a..9f34bc7a 100644 --- a/apps/web-antd/src/views/pay/app/modules/app-form.vue +++ b/apps/web-antd/src/views/pay/app/modules/app-form.vue @@ -1,90 +1,83 @@ diff --git a/apps/web-antd/src/views/pay/app/modules/channel/alipay-channel-form.vue b/apps/web-antd/src/views/pay/app/modules/channel-form.vue similarity index 58% rename from apps/web-antd/src/views/pay/app/modules/channel/alipay-channel-form.vue rename to apps/web-antd/src/views/pay/app/modules/channel-form.vue index a188ce67..87177087 100644 --- a/apps/web-antd/src/views/pay/app/modules/channel/alipay-channel-form.vue +++ b/apps/web-antd/src/views/pay/app/modules/channel-form.vue @@ -1,104 +1,96 @@ diff --git a/apps/web-antd/src/views/pay/app/modules/channel/data.ts b/apps/web-antd/src/views/pay/app/modules/channel/data.ts deleted file mode 100644 index db6c66bf..00000000 --- a/apps/web-antd/src/views/pay/app/modules/channel/data.ts +++ /dev/null @@ -1,456 +0,0 @@ -import type { FormSchemaGetter } from '#/adapter/form'; - -import { DICT_TYPE, getDictOptions } from '#/utils/dict'; - -export const modalAliPaySchema: FormSchemaGetter = () => [ - { - label: '商户编号', - fieldName: 'id', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '应用编号', - fieldName: 'appId', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '渠道编码', - fieldName: 'code', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '渠道费率', - fieldName: 'feeRate', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入渠道费率', - }, - }, - { - label: '开放平台 APPID', - fieldName: 'config.appId', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入开放平台 APPID', - }, - }, - { - label: '渠道状态', - fieldName: 'status', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), - }, - defaultValue: 1, - }, - { - 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: '沙箱环境', - }, - ], - }, - }, - { - label: '算法类型', - fieldName: 'config.signType', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: [ - { - value: 'RSA2', - label: 'RSA2', - }, - ], - }, - defaultValue: 'RSA2', - }, - { - label: '公钥类型', - fieldName: 'config.mode', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: [ - { - value: 0, - label: '公钥模式', - }, - { - value: 1, - label: '证书模式', - }, - ], - }, - }, - { - label: '应用私钥', - fieldName: 'config.privateKey', - component: 'Textarea', - rules: 'required', - componentProps: { - placeholder: '请输入应用私钥', - rows: 8, - }, - dependencies: { - show(values) { - return values.config.mode !== undefined; - }, - triggerFields: ['config'], - }, - }, - { - label: '支付宝公钥', - fieldName: 'config.alipayPublicKey', - component: 'Textarea', - rules: 'required', - componentProps: { - placeholder: '请输入支付宝公钥', - rows: 8, - }, - dependencies: { - show(values) { - return values?.config?.mode === 0; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: '商户公钥应用证书', - fieldName: 'config.appCertContent', - slotName: 'appCertContent', - component: 'Textarea', - rules: 'required', - componentProps: { - placeholder: '请上传商户公钥应用证书', - rows: 8, - }, - dependencies: { - show(values) { - return values?.config?.mode === 1; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: '支付宝公钥证书', - fieldName: 'config.alipayPublicCertContent', - slotName: 'alipayPublicCertContent', - component: 'Textarea', - rules: 'required', - componentProps: { - placeholder: '请上传支付宝公钥证书', - rows: 8, - }, - dependencies: { - show(values) { - return values?.config?.mode === 1; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: '根证书', - fieldName: 'config.rootCertContent', - slotName: 'rootCertContent', - component: 'Textarea', - rules: 'required', - componentProps: { - placeholder: '请上传根证书', - rows: 8, - }, - dependencies: { - show(values) { - return values?.config?.mode === 1; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: '接口内容加密方式', - fieldName: 'config.encryptType', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: [ - { - value: 'NONE', - label: '无加密', - }, - { - value: 'AES', - label: 'AES', - }, - ], - }, - defaultValue: 'NONE', - }, - { - label: '备注', - fieldName: 'remark', - component: 'Textarea', - componentProps: { - rows: 3, - placeholder: '请输入备注', - }, - }, -]; - -export const modalMockSchema: FormSchemaGetter = () => [ - { - label: '商户编号', - fieldName: 'id', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '应用编号', - fieldName: 'appId', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '渠道状态', - fieldName: 'status', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), - }, - defaultValue: 1, - }, - { - label: '渠道编码', - fieldName: 'code', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '渠道费率', - fieldName: 'feeRate', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入渠道费率', - }, - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '备注', - fieldName: 'remark', - component: 'Textarea', - componentProps: { - rows: 3, - placeholder: '请输入备注', - }, - }, -]; - -export const modalWeixinSchema: FormSchemaGetter = () => [ - { - label: '商户编号', - fieldName: 'id', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '应用编号', - fieldName: 'appId', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '渠道编码', - fieldName: 'code', - component: 'Input', - dependencies: { - show: () => false, - triggerFields: [''], - }, - }, - { - label: '渠道费率', - fieldName: 'feeRate', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入渠道费率', - }, - }, - { - label: '微信 APPID', - fieldName: 'config.appId', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入微信 APPID', - }, - }, - { - label: '商户号', - fieldName: 'config.mchId', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入商户号', - }, - }, - { - label: '渠道状态', - fieldName: 'status', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), - }, - defaultValue: 1, - }, - { - label: 'API 版本', - fieldName: 'config.apiVersion', - component: 'RadioGroup', - rules: 'required', - componentProps: { - options: [ - { - label: 'v2', - value: 'v2', - }, - { - label: 'v3', - value: 'v3', - }, - ], - }, - }, - { - label: '商户密钥', - fieldName: 'config.mchKey', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入商户密钥', - }, - dependencies: { - show(values) { - return values?.config?.apiVersion === 'v2'; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: 'apiclient_cert.p12 证书', - fieldName: 'config.keyContent', - slotName: 'keyContent', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请上传 apiclient_cert.p12 证书', - }, - dependencies: { - show(values) { - 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) { - return values?.config?.apiVersion === 'v3'; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: 'apiclient_key.pem 证书', - fieldName: 'config.privateKeyContent', - slotName: 'privateKeyContent', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请上传 apiclient_key.pem 证书', - }, - dependencies: { - show(values) { - return values?.config?.apiVersion === 'v3'; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: '证书序列号', - fieldName: 'config.certSerialNo', - component: 'Input', - rules: 'required', - componentProps: { - placeholder: '请输入证书序列号', - }, - dependencies: { - show(values) { - return values?.config?.apiVersion === 'v3'; - }, - triggerFields: ['config.mode', 'mode', 'config'], - }, - }, - { - label: '备注', - fieldName: 'remark', - component: 'Textarea', - componentProps: { - rows: 3, - placeholder: '请输入备注', - }, - }, -]; diff --git a/apps/web-antd/src/views/pay/app/modules/channel/mock-channel-form.vue b/apps/web-antd/src/views/pay/app/modules/channel/mock-channel-form.vue deleted file mode 100644 index f7ad9167..00000000 --- a/apps/web-antd/src/views/pay/app/modules/channel/mock-channel-form.vue +++ /dev/null @@ -1,105 +0,0 @@ - - diff --git a/apps/web-antd/src/views/pay/app/modules/channel/wallet-channel-form.vue b/apps/web-antd/src/views/pay/app/modules/channel/wallet-channel-form.vue deleted file mode 100644 index f7ad9167..00000000 --- a/apps/web-antd/src/views/pay/app/modules/channel/wallet-channel-form.vue +++ /dev/null @@ -1,105 +0,0 @@ - - diff --git a/apps/web-antd/src/views/pay/app/modules/channel/weixin-channel-form.vue b/apps/web-antd/src/views/pay/app/modules/channel/weixin-channel-form.vue deleted file mode 100644 index 0c93c3df..00000000 --- a/apps/web-antd/src/views/pay/app/modules/channel/weixin-channel-form.vue +++ /dev/null @@ -1,148 +0,0 @@ - -