From d0870beb40fc303f8e67ffcb02f33e353950a6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=97=B4=E8=B4=A7?= <252048765@qq.com> Date: Mon, 5 May 2025 16:29:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=B8=A0=E9=81=93=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B8=A0=E9=81=93=E8=8E=B7=E5=8F=96=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=B1=BB=E5=9E=8B=EF=BC=8C=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=B8=A0=E9=81=93?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/pay/channel/index.ts | 2 +- .../src/components/upload/file-upload.vue | 4 +- apps/web-antd/src/views/pay/app/data.ts | 2 +- apps/web-antd/src/views/pay/app/index.vue | 549 ++++++++++-------- .../app/modules/channel/AlipayChannelForm.vue | 48 +- .../app/modules/channel/MockChannelForm.vue | 105 ++++ .../app/modules/channel/WalletChannelForm.vue | 105 ++++ .../app/modules/channel/WeixinChannelForm.vue | 148 +++++ .../src/views/pay/app/modules/channel/data.ts | 254 +++++++- 9 files changed, 965 insertions(+), 252 deletions(-) create mode 100644 apps/web-antd/src/views/pay/app/modules/channel/MockChannelForm.vue create mode 100644 apps/web-antd/src/views/pay/app/modules/channel/WalletChannelForm.vue create mode 100644 apps/web-antd/src/views/pay/app/modules/channel/WeixinChannelForm.vue diff --git a/apps/web-antd/src/api/pay/channel/index.ts b/apps/web-antd/src/api/pay/channel/index.ts index 99a16c05..eb4c1d99 100644 --- a/apps/web-antd/src/api/pay/channel/index.ts +++ b/apps/web-antd/src/api/pay/channel/index.ts @@ -27,7 +27,7 @@ export function getChannelPage(params: PageParam) { } /** 查询支付渠道详情 */ -export function getChannel(appId: string, code: string) { +export function getChannel(appId: number, code: string) { return requestClient.get('/pay/channel/get', { params: { appId, code }, }); diff --git a/apps/web-antd/src/components/upload/file-upload.vue b/apps/web-antd/src/components/upload/file-upload.vue index 0d479942..b3b1276a 100644 --- a/apps/web-antd/src/components/upload/file-upload.vue +++ b/apps/web-antd/src/components/upload/file-upload.vue @@ -55,7 +55,7 @@ const props = withDefaults( showDescription: false, }, ); -const emit = defineEmits(['change', 'update:value', 'delete', 'getText']); +const emit = defineEmits(['change', 'update:value', 'delete', 'returnText']); const { accept, helpText, maxNumber, maxSize } = toRefs(props); const isInnerOperate = ref(false); const { getStringAccept } = useUploadType({ @@ -124,7 +124,7 @@ const handleRemove = async (file: UploadFile) => { const beforeUpload = async (file: File) => { // 使用现代的Blob.text()方法替代FileReader const fileContent = await file.text(); - emit('getText', fileContent); + emit('returnText', fileContent); const { maxSize, accept } = props; const isAct = checkFileType(file, accept); diff --git a/apps/web-antd/src/views/pay/app/data.ts b/apps/web-antd/src/views/pay/app/data.ts index 4ab54195..dcc83ba0 100644 --- a/apps/web-antd/src/views/pay/app/data.ts +++ b/apps/web-antd/src/views/pay/app/data.ts @@ -143,7 +143,7 @@ export const columns: VxeGridProps['columns'] = [ fixed: 'right', slots: { default: 'action' }, title: '操作', - width: 250, + minWidth: 160, }, ]; diff --git a/apps/web-antd/src/views/pay/app/index.vue b/apps/web-antd/src/views/pay/app/index.vue index 81ccaf6b..28ac5148 100644 --- a/apps/web-antd/src/views/pay/app/index.vue +++ b/apps/web-antd/src/views/pay/app/index.vue @@ -19,6 +19,9 @@ import { PayChannelEnum } from '#/utils/constants'; import { columns, querySchema } from './data'; import appFrom from './modules/app-form.vue'; import aliPayFrom from './modules/channel/AlipayChannelForm.vue'; +import mockFrom from './modules/channel/MockChannelForm.vue'; +import walletFrom from './modules/channel/WalletChannelForm.vue'; +import weixinFrom from './modules/channel/WeixinChannelForm.vue'; const formOptions: VbenFormProps = { commonConfig: { @@ -84,6 +87,18 @@ const [AliPayModal, modalAliPayApi] = useVbenModal({ connectedComponent: aliPayFrom, }); +const [MockModal, modalMockApi] = useVbenModal({ + connectedComponent: mockFrom, +}); + +const [WalletModal, modalWalletApi] = useVbenModal({ + connectedComponent: walletFrom, +}); + +const [WeixinModal, modalWeixinApi] = useVbenModal({ + connectedComponent: weixinFrom, +}); + const handleAdd = () => { modalApi.setData({}); modalApi.open(); @@ -123,17 +138,22 @@ const openChannelForm = async (row: PayApi.PayAppApi.App, payCode: string) => { if (payCode.indexOf('alipay_') === 0) { modalAliPayApi.setData({ id: row.id, payCode }); modalAliPayApi.open(); + return; + } + if (payCode.indexOf('wx_') === 0) { + modalWeixinApi.setData({ id: row.id, payCode }); + modalWeixinApi.open(); + return; + } + if (payCode.indexOf('mock') === 0) { + modalMockApi.setData({ id: row.id, payCode }); + modalMockApi.open(); + return; + } + if (payCode.indexOf('wallet') === 0) { + modalWalletApi.setData({ id: row.id, payCode }); + modalWalletApi.open(); } - // if (payCode.indexOf('wx_') === 0) { - // weixinFormRef.value.open(row.id, payCode); - // return; - // } - // if (payCode.indexOf('mock') === 0) { - // mockFormRef.value.open(row.id, payCode); - // } - // if (payCode.indexOf('wallet') === 0) { - // mockFormRef.value.open(row.id, payCode); - // } }; @@ -153,24 +173,26 @@ const openChannelForm = async (row: PayApi.PayAppApi.App, payCode: string) => { + + + diff --git a/apps/web-antd/src/views/pay/app/modules/channel/AlipayChannelForm.vue b/apps/web-antd/src/views/pay/app/modules/channel/AlipayChannelForm.vue index 30f7bc35..972a6093 100644 --- a/apps/web-antd/src/views/pay/app/modules/channel/AlipayChannelForm.vue +++ b/apps/web-antd/src/views/pay/app/modules/channel/AlipayChannelForm.vue @@ -8,7 +8,7 @@ import { cloneDeep } from '@vben/utils'; import { Row, Space, Textarea } from 'ant-design-vue'; import { useVbenForm } from '#/adapter/form'; -import * as PayApi from '#/api/pay/app'; +import * as ChannelApi from '#/api/pay/channel'; import { FileUpload } from '#/components/upload'; import { modalAliPaySchema } from './data'; @@ -48,14 +48,19 @@ const [BasicModal, modalApi] = useVbenModal({ } modalApi.modalLoading(true); - const { id } = modalApi.getData() as { - id?: number; + const { id, payCode } = modalApi.getData() as { + id?: string; + payCode?: string; }; - isUpdate.value = !!id; - if (isUpdate.value && id) { - const record = await PayApi.getApp(id); - await formApi.setValues(record); + if (id && payCode) { + const record = await ChannelApi.getChannel(id, payCode); + isUpdate.value = !!record; + record.code = payCode; + if (isUpdate.value) { + record.config = JSON.parse(record.config); + await formApi.setValues(record); + } } modalApi.modalLoading(false); @@ -70,8 +75,13 @@ async function handleConfirm() { return; } // getValues获取为一个readonly的对象 需要修改必须先深拷贝一次 - const data = cloneDeep(await formApi.getValues()) as PayApi.PayAppApi.App; - await (isUpdate.value ? PayApi.updateApp(data) : PayApi.createApp(data)); + const data = cloneDeep( + await formApi.getValues(), + ) as ChannelApi.PayChannelApi.Channel; + data.config = JSON.stringify(data.config); + await (isUpdate.value + ? ChannelApi.updateChannel(data) + : ChannelApi.createChannel(data)); emit('reload'); await handleCancel(); } catch (error) { @@ -101,7 +111,7 @@ async function handleCancel() { { slotProps.setValue(text); } @@ -120,7 +130,14 @@ async function handleCancel() { /> - + @@ -130,7 +147,14 @@ async function handleCancel() {