3 changed files with 370 additions and 1 deletions
@ -0,0 +1,49 @@ |
|||||||
|
<template> |
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? '编辑' : '新增'" @ok="handleSubmit"> |
||||||
|
<BasicForm @register="registerForm" /> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup name="AppModal"> |
||||||
|
import { ref, unref } from 'vue' |
||||||
|
import { BasicModal, useModalInner } from '@/components/Modal' |
||||||
|
import { BasicForm, useForm } from '@/components/Form' |
||||||
|
import { formSchema } from './app.data' |
||||||
|
import { createApp, updateApp, getApp } from '@/api/pay/app' |
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'register']) |
||||||
|
const isUpdate = ref(true) |
||||||
|
|
||||||
|
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
||||||
|
labelWidth: 120, |
||||||
|
baseColProps: { span: 24 }, |
||||||
|
schemas: formSchema, |
||||||
|
showActionButtonGroup: false, |
||||||
|
actionColOptions: { span: 23 } |
||||||
|
}) |
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
||||||
|
resetFields() |
||||||
|
setModalProps({ confirmLoading: false }) |
||||||
|
isUpdate.value = !!data?.isUpdate |
||||||
|
if (unref(isUpdate)) { |
||||||
|
const res = await getApp(data.record.id) |
||||||
|
setFieldsValue({ ...res }) |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
async function handleSubmit() { |
||||||
|
try { |
||||||
|
const values = await validate() |
||||||
|
setModalProps({ confirmLoading: true }) |
||||||
|
if (unref(isUpdate)) { |
||||||
|
await updateApp(values) |
||||||
|
} else { |
||||||
|
await createApp(values) |
||||||
|
} |
||||||
|
closeModal() |
||||||
|
emit('success') |
||||||
|
} finally { |
||||||
|
setModalProps({ confirmLoading: false }) |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
@ -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' |
||||||
|
} |
||||||
|
] |
@ -1,3 +1,90 @@ |
|||||||
<template> |
<template> |
||||||
<div>开发中</div> |
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #toolbar> |
||||||
|
<a-button type="primary" v-auth="['pay:app:create']" :preIcon="IconEnum.ADD" @click="handleCreate"> |
||||||
|
{{ t('action.create') }} |
||||||
|
</a-button> |
||||||
|
<a-button type="warning" v-auth="['pay:app:export']" :preIcon="IconEnum.EXPORT" @click="handleExport"> |
||||||
|
{{ t('action.export') }} |
||||||
|
</a-button> |
||||||
|
</template> |
||||||
|
<template #bodyCell="{ column, record }"> |
||||||
|
<template v-if="column.key === 'action'"> |
||||||
|
<TableAction |
||||||
|
:actions="[ |
||||||
|
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'pay:app:update', onClick: handleEdit.bind(null, record) }, |
||||||
|
{ |
||||||
|
icon: IconEnum.DELETE, |
||||||
|
color: 'error', |
||||||
|
label: t('action.delete'), |
||||||
|
auth: 'pay:app:delete', |
||||||
|
popConfirm: { |
||||||
|
title: t('common.delMessage'), |
||||||
|
placement: 'left', |
||||||
|
confirm: handleDelete.bind(null, record) |
||||||
|
} |
||||||
|
} |
||||||
|
]" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
</template> |
||||||
|
</BasicTable> |
||||||
|
<AppModal @register="registerModal" @success="reload()" /> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
|
<script lang="ts" setup name="App"> |
||||||
|
import { useI18n } from '@/hooks/web/useI18n' |
||||||
|
import { useMessage } from '@/hooks/web/useMessage' |
||||||
|
import { useModal } from '@/components/Modal' |
||||||
|
import AppModal from './AppModal.vue' |
||||||
|
import { IconEnum } from '@/enums/appEnum' |
||||||
|
import { BasicTable, useTable, TableAction } from '@/components/Table' |
||||||
|
import { AppExportReqVO, deleteApp, getAppPage, exportApp } from '@/api/pay/app' |
||||||
|
import { columns, searchFormSchema } from './app.data' |
||||||
|
|
||||||
|
const { t } = useI18n() |
||||||
|
const { createConfirm, createMessage } = useMessage() |
||||||
|
const [registerModal, { openModal }] = useModal() |
||||||
|
|
||||||
|
const [registerTable, { getForm, reload }] = useTable({ |
||||||
|
title: '应用列表', |
||||||
|
api: getAppPage, |
||||||
|
columns, |
||||||
|
formConfig: { labelWidth: 120, schemas: searchFormSchema }, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
actionColumn: { |
||||||
|
width: 140, |
||||||
|
title: t('common.action'), |
||||||
|
dataIndex: 'action', |
||||||
|
fixed: 'right' |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
function handleCreate() { |
||||||
|
openModal(true, { isUpdate: false }) |
||||||
|
} |
||||||
|
|
||||||
|
function handleEdit(record: Recordable) { |
||||||
|
openModal(true, { record, isUpdate: true }) |
||||||
|
} |
||||||
|
|
||||||
|
async function handleExport() { |
||||||
|
createConfirm({ |
||||||
|
title: t('common.exportTitle'), |
||||||
|
iconType: 'warning', |
||||||
|
content: t('common.exportMessage'), |
||||||
|
async onOk() { |
||||||
|
await exportApp(getForm().getFieldsValue() as AppExportReqVO) |
||||||
|
createMessage.success(t('common.exportSuccessText')) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) { |
||||||
|
await deleteApp(record.id) |
||||||
|
createMessage.success(t('common.delSuccessText')) |
||||||
|
reload() |
||||||
|
} |
||||||
|
</script> |
||||||
|
Reference in new issue