Initial commit: OneOS frontend based on yudao-ui-admin-vben
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled

This commit is contained in:
k kfluous
2026-03-11 22:18:23 +08:00
commit 2650d1cdf0
5166 changed files with 641242 additions and 0 deletions

View File

@@ -0,0 +1,664 @@
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 '@vben/constants';
import { getDictOptions } from '@vben/hooks';
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: '请输入应用名',
clearable: true,
},
},
{
fieldName: 'status',
label: '开启状态',
component: 'Select',
componentProps: {
placeholder: '请选择开启状态',
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
clearable: 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: {
activeValue: CommonStatusEnum.ENABLE,
inactiveValue: 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'),
},
},
{
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: {
placeholder: '请输入渠道费率',
addonAfter: '%',
controlsPosition: 'right',
class: '!w-full',
},
defaultValue: 0,
},
{
label: '渠道状态',
fieldName: 'status',
component: 'RadioGroup',
rules: z.number().default(CommonStatusEnum.ENABLE),
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
},
},
];
// 添加通用字段
// 根据类型添加特定字段
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: '沙箱环境',
},
],
},
},
{
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: 1,
label: '公钥模式',
},
{
value: 2,
label: '证书模式',
},
],
},
},
{
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',
},
],
},
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',
},
],
},
},
{
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;
}

View File

@@ -0,0 +1,262 @@
<script lang="ts" setup>
import type { ActionItem, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { PayAppApi } from '#/api/pay/app';
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { CommonStatusEnum, PayChannelEnum } from '@vben/constants';
import { ElLoading, ElMessage } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteApp, getAppPage, updateAppStatus } from '#/api/pay/app';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import AppForm from './modules/app-form.vue';
import ChannelForm from './modules/channel-form.vue';
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
const [AppFormModal, appFormModalApi] = useVbenModal({
connectedComponent: AppForm,
destroyOnClose: true,
});
const [ChannelFormModal, channelFormModalApi] = useVbenModal({
connectedComponent: ChannelForm,
destroyOnClose: true,
});
/** 创建应用 */
function handleCreate() {
appFormModalApi.setData(null).open();
}
/** 编辑应用 */
function handleEdit(row: PayAppApi.App) {
appFormModalApi.setData({ id: row.id }).open();
}
/** 创建/编辑渠道 */
async function handleChannelForm(row: PayAppApi.App, payCode: string) {
channelFormModalApi.setData({ appId: row.id, code: payCode }).open();
}
/** 删除应用 */
async function handleDelete(row: PayAppApi.App) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.name]),
});
try {
await deleteApp(row.id!);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
handleRefresh();
} finally {
loadingInstance.close();
}
}
/** 更新应用状态 */
async function handleStatusChange(
newStatus: number,
row: PayAppApi.App,
): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newStatus === CommonStatusEnum.ENABLE ? '启用' : '停用';
confirm({
content: `确认要${text + row.name}应用吗?`,
})
.then(async () => {
// 更新状态
await updateAppStatus({
id: row.id!,
status: newStatus,
});
// 提示并返回成功
ElMessage.success(`${text}成功`);
resolve(true);
})
.catch(() => {
reject(new Error('取消操作'));
});
});
}
/** 生成渠道配置按钮 */
function createChannelConfigAction(
row: PayAppApi.App,
channelCode: string,
): ActionItem[] {
const exists = row.channelCodes?.includes(channelCode);
return [
{
type: exists ? 'primary' : 'danger',
size: 'small',
icon: exists ? 'lucide:check' : 'lucide:x',
onClick: handleChannelForm.bind(null, row, channelCode),
},
];
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(handleStatusChange),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getAppPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<PayAppApi.App>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
</template>
<AppFormModal @success="handleRefresh" />
<ChannelFormModal @success="handleRefresh" />
<Grid table-title="应用列表">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['应用']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['pay:app:create'],
onClick: handleCreate,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['pay:app:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['pay:app:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
<template #alipayAppConfig="{ row }">
<TableAction
:actions="
createChannelConfigAction(row, PayChannelEnum.ALIPAY_APP.code)
"
/>
</template>
<template #alipayPCConfig="{ row }">
<TableAction
:actions="
createChannelConfigAction(row, PayChannelEnum.ALIPAY_PC.code)
"
/>
</template>
<template #alipayWAPConfig="{ row }">
<TableAction
:actions="
createChannelConfigAction(row, PayChannelEnum.ALIPAY_WAP.code)
"
/>
</template>
<template #alipayQrConfig="{ row }">
<TableAction
:actions="
createChannelConfigAction(row, PayChannelEnum.ALIPAY_QR.code)
"
/>
</template>
<template #alipayBarConfig="{ row }">
<TableAction
:actions="
createChannelConfigAction(row, PayChannelEnum.ALIPAY_BAR.code)
"
/>
</template>
<template #wxLiteConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.WX_LITE.code)"
/>
</template>
<template #wxPubConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.WX_PUB.code)"
/>
</template>
<template #wxAppConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.WX_APP.code)"
/>
</template>
<template #wxNativeConfig="{ row }">
<TableAction
:actions="
createChannelConfigAction(row, PayChannelEnum.WX_NATIVE.code)
"
/>
</template>
<template #wxWapConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.WX_WAP.code)"
/>
</template>
<template #wxBarConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.WX_BAR.code)"
/>
</template>
<template #walletConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.WALLET.code)"
/>
</template>
<template #mockConfig="{ row }">
<TableAction
:actions="createChannelConfigAction(row, PayChannelEnum.MOCK.code)"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,83 @@
<script lang="ts" setup>
import type { PayAppApi } from '#/api/pay/app';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { ElMessage } from 'element-plus';
import { useVbenForm } from '#/adapter/form';
import { createApp, getApp, updateApp } from '#/api/pay/app';
import { useAppFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<PayAppApi.App>();
const title = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['应用'])
: $t('ui.actionTitle.create', ['应用']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 160,
},
layout: 'horizontal',
schema: useAppFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as PayAppApi.App;
try {
await (formData.value?.id ? updateApp(data) : createApp(data));
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const { id } = modalApi.getData() as {
id?: number;
};
if (!id) {
return;
}
modalApi.lock();
try {
formData.value = await getApp(id);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="title" class="w-2/5">
<Form />
</Modal>
</template>

View File

@@ -0,0 +1,139 @@
<script lang="ts" setup>
import type { PayChannelApi } from '#/api/pay/channel';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { CommonStatusEnum } from '@vben/constants';
import { $t } from '@vben/locales';
import { ElMessage } from 'element-plus';
import { useVbenForm } from '#/adapter/form';
import { createChannel, getChannel, updateChannel } from '#/api/pay/channel';
import { useChannelFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<any>();
const title = computed(() => {
return formData.value?.id === 0
? $t('ui.actionTitle.create', ['渠道'])
: $t('ui.actionTitle.edit', ['渠道']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 160,
},
layout: 'horizontal',
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as PayChannelApi.Channel;
data.config = JSON.stringify(data.config || {});
try {
await (data.id ? updateChannel(data) : createChannel(data));
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const { appId, code } = modalApi.getData() as {
appId?: number;
code?: string;
};
if (!appId || !code) {
return;
}
modalApi.lock();
formData.value = {
appId,
code,
status: CommonStatusEnum.ENABLE,
remark: '',
feeRate: 0,
config: {},
};
if (code.includes('alipay_')) {
formData.value.config = {
appId: undefined,
serverUrl: undefined,
signType: 'RSA2',
mode: undefined,
privateKey: undefined,
alipayPublicKey: undefined,
appCertContent: undefined,
alipayPublicCertContent: undefined,
rootCertContent: undefined,
encryptType: undefined,
encryptKey: undefined,
};
} else if (code.includes('mock')) {
formData.value.config = {
name: 'mock-conf',
};
} else if (code.includes('wallet')) {
formData.value.config = {
config: {
name: 'wallet-conf',
},
};
} else if (code.includes('wx')) {
formData.value.config = {
appId: undefined,
mchId: undefined,
apiVersion: undefined,
mchKey: undefined,
keyContent: undefined,
privateKeyContent: undefined,
certSerialNo: undefined,
apiV3Key: undefined,
publicKeyContent: undefined,
publicKeyId: undefined,
};
}
try {
const res = await getChannel(appId, code);
if (res) {
formData.value = {
...res,
config: JSON.parse(res.config),
};
}
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="title" class="w-2/5">
<Form :schema="useChannelFormSchema(formData?.code)" />
</Modal>
</template>