From cb1835928090ca99a71e9bc30f445ead9342fcc0 Mon Sep 17 00:00:00 2001 From: xingyuv Date: Thu, 30 Mar 2023 16:08:38 +0800 Subject: [PATCH] feat: app --- src/views/pay/app/AppModal.vue | 49 +++++++ src/views/pay/app/app.data.ts | 233 +++++++++++++++++++++++++++++++++ src/views/pay/app/index.vue | 89 ++++++++++++- 3 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 src/views/pay/app/AppModal.vue create mode 100644 src/views/pay/app/app.data.ts diff --git a/src/views/pay/app/AppModal.vue b/src/views/pay/app/AppModal.vue new file mode 100644 index 00000000..d5362595 --- /dev/null +++ b/src/views/pay/app/AppModal.vue @@ -0,0 +1,49 @@ + + diff --git a/src/views/pay/app/app.data.ts b/src/views/pay/app/app.data.ts new file mode 100644 index 00000000..9465f870 --- /dev/null +++ b/src/views/pay/app/app.data.ts @@ -0,0 +1,233 @@ +import { changeAppStatus } from '@/api/pay/app' +import { getMerchantListByName } from '@/api/pay/merchant' +import { BasicColumn, FormSchema, useRender } from '@/components/Table' +import { PayChannelEnum } from '@/enums/systemEnum' +import { useMessage } from '@/hooks/web/useMessage' +import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' +import { Tag, Switch } from 'ant-design-vue' +import { h } from 'vue' + +export const columns: BasicColumn[] = [ + { + title: '应用编号', + dataIndex: 'id', + width: 100 + }, + { + title: '应用名', + dataIndex: 'name', + width: 100 + }, + { + title: '开启状态', + dataIndex: 'status', + width: 100, + customRender: ({ record }) => { + if (!Reflect.has(record, 'pendingStatus')) { + record.pendingStatus = false + } + return h(Switch, { + checked: record.status === 0, + checkedChildren: '已启用', + unCheckedChildren: '已禁用', + loading: record.pendingStatus, + onChange(checked: boolean) { + record.pendingStatus = true + const newStatus = checked ? 0 : 1 + const { createMessage } = useMessage() + changeAppStatus({ id: record.id, status: newStatus }) + .then(() => { + record.status = newStatus + createMessage.success(`已成功修改应用状态`) + }) + .catch(() => { + createMessage.error('修改应用状态失败') + }) + .finally(() => { + record.pendingStatus = false + }) + } + }) + } + }, + { + title: '商户名称', + dataIndex: 'payMerchant.name', + width: 100, + customRender: ({ record }) => { + return record.payMerchant.name || '' + } + }, + { + title: '支付宝配置', + children: [ + { + title: PayChannelEnum.ALIPAY_APP.name, + dataIndex: PayChannelEnum.ALIPAY_APP.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.ALIPAY_APP.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + }, + { + title: PayChannelEnum.ALIPAY_PC.name, + dataIndex: PayChannelEnum.ALIPAY_PC.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.ALIPAY_PC.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + }, + { + title: PayChannelEnum.ALIPAY_WAP.name, + dataIndex: PayChannelEnum.ALIPAY_WAP.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.ALIPAY_WAP.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + }, + { + title: PayChannelEnum.ALIPAY_QR.name, + dataIndex: PayChannelEnum.ALIPAY_QR.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.ALIPAY_QR.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + }, + { + title: PayChannelEnum.ALIPAY_BAR.name, + dataIndex: PayChannelEnum.ALIPAY_BAR.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.ALIPAY_BAR.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + } + ] + }, + { + title: '微信配置', + children: [ + { + title: PayChannelEnum.WX_LITE.name, + dataIndex: PayChannelEnum.WX_LITE.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.WX_LITE.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + }, + { + title: PayChannelEnum.WX_PUB.name, + dataIndex: PayChannelEnum.WX_PUB.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.WX_PUB.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + }, + { + title: PayChannelEnum.WX_APP.name, + dataIndex: PayChannelEnum.WX_APP.code, + width: 160, + customRender: ({ record }) => { + const isUpdate = record.channelCodes.indexOf(PayChannelEnum.WX_APP.code) !== -1 + return h(Tag, { color: isUpdate ? '#108ee9' : '#f50000' }, () => (isUpdate ? '已设置' : '未设置')) + } + } + ] + }, + { + title: '创建时间', + dataIndex: 'createTime', + width: 180, + customRender: ({ text }) => { + return useRender.renderDate(text) + } + } +] + +export const searchFormSchema: FormSchema[] = [ + { + label: '应用名', + field: 'name', + component: 'Input', + colProps: { span: 8 } + }, + { + label: '商户名称', + field: 'merchantName', + component: 'Input', + colProps: { span: 8 } + }, + { + label: '开启状态', + field: 'status', + component: 'Select', + componentProps: { + options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + }, + colProps: { span: 8 } + }, + { + label: '创建时间', + field: 'createTime', + component: 'RangePicker', + colProps: { span: 8 } + } +] + +export const formSchema: FormSchema[] = [ + { + label: '编号', + field: 'id', + show: false, + component: 'Input' + }, + { + label: '应用名', + field: 'name', + required: true, + component: 'Input' + }, + { + label: '所属商户', + field: 'shortName', + required: true, + component: 'ApiSelect', + componentProps: { + api: () => getMerchantListByName(''), + labelField: 'name', + valueField: 'id' + } + }, + { + label: '开启状态', + field: 'status', + component: 'Select', + defaultValue: 0, + componentProps: { + options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + } + }, + { + label: '支付结果的回调地址', + field: 'payNotifyUrl', + required: true, + component: 'Input' + }, + { + label: '退款结果的回调地址', + field: 'refundNotifyUrl', + required: true, + component: 'Input' + }, + { + label: '备注', + field: 'remark', + component: 'InputTextArea' + } +] diff --git a/src/views/pay/app/index.vue b/src/views/pay/app/index.vue index 3b64cfc4..e7affae4 100644 --- a/src/views/pay/app/index.vue +++ b/src/views/pay/app/index.vue @@ -1,3 +1,90 @@ +