11 changed files with 125 additions and 455 deletions
@ -1,77 +0,0 @@
|
||||
import { defHttp } from '@/utils/http/axios' |
||||
|
||||
export interface MerchantVO { |
||||
id: number |
||||
no: string |
||||
name: string |
||||
shortName: string |
||||
status: number |
||||
remark: string |
||||
createTime: Date |
||||
} |
||||
|
||||
export interface MerchantPageReqVO extends PageParam { |
||||
no?: string |
||||
name?: string |
||||
shortName?: string |
||||
status?: number |
||||
remark?: string |
||||
createTime?: Date[] |
||||
} |
||||
|
||||
export interface MerchantExportReqVO { |
||||
no?: string |
||||
name?: string |
||||
shortName?: string |
||||
status?: number |
||||
remark?: string |
||||
createTime?: Date[] |
||||
} |
||||
|
||||
// 查询列表支付商户
|
||||
export function getMerchantPage(params: MerchantPageReqVO) { |
||||
return defHttp.get({ url: '/pay/merchant/page', params }) |
||||
} |
||||
|
||||
// 查询详情支付商户
|
||||
export function getMerchant(id: number) { |
||||
return defHttp.get({ url: `/pay/merchant/get?id=${id}` }) |
||||
} |
||||
|
||||
// 根据商户名称搜索商户列表
|
||||
export function getMerchantListByName(name: string) { |
||||
return defHttp.get({ |
||||
url: '/pay/merchant/list-by-name?id=', |
||||
params: { |
||||
name, |
||||
}, |
||||
}) |
||||
} |
||||
|
||||
// 新增支付商户
|
||||
export function createMerchant(data: MerchantVO) { |
||||
return defHttp.post({ url: '/pay/merchant/create', data }) |
||||
} |
||||
|
||||
// 修改支付商户
|
||||
export function updateMerchant(data: MerchantVO) { |
||||
return defHttp.put({ url: '/pay/merchant/update', data }) |
||||
} |
||||
|
||||
// 删除支付商户
|
||||
export function deleteMerchant(id: number) { |
||||
return defHttp.delete({ url: `/pay/merchant/delete?id=${id}` }) |
||||
} |
||||
|
||||
// 导出支付商户
|
||||
export function exportMerchant(params: MerchantExportReqVO) { |
||||
return defHttp.download({ url: '/pay/merchant/export-excel', params }, '支付商户.xls') |
||||
} |
||||
// 支付商户状态修改
|
||||
export function changeMerchantStatus(id: number, status: number) { |
||||
const data = { |
||||
id, |
||||
status, |
||||
} |
||||
return defHttp.put({ url: '/pay/merchant/update-status', data }) |
||||
} |
@ -0,0 +1,113 @@
|
||||
import type { DescItem } from '@/components/Description' |
||||
import { useRender } from '@/components/Table' |
||||
|
||||
// 导入图标
|
||||
import svg_alipay_pc from '@/assets/svgs/pay/icon/alipay_pc.svg' |
||||
import svg_alipay_wap from '@/assets/svgs/pay/icon/alipay_wap.svg' |
||||
import svg_alipay_app from '@/assets/svgs/pay/icon/alipay_app.svg' |
||||
import svg_alipay_qr from '@/assets/svgs/pay/icon/alipay_qr.svg' |
||||
import svg_alipay_bar from '@/assets/svgs/pay/icon/alipay_bar.svg' |
||||
import svg_wx_pub from '@/assets/svgs/pay/icon/wx_pub.svg' |
||||
import svg_wx_lite from '@/assets/svgs/pay/icon/wx_lite.svg' |
||||
import svg_wx_app from '@/assets/svgs/pay/icon/wx_app.svg' |
||||
import svg_wx_native from '@/assets/svgs/pay/icon/wx_native.svg' |
||||
import svg_wx_bar from '@/assets/svgs/pay/icon/wx_bar.svg' |
||||
import svg_mock from '@/assets/svgs/pay/icon/mock.svg' |
||||
|
||||
export const descSchema: DescItem[] = [ |
||||
{ |
||||
label: '支付单号', |
||||
field: 'id', |
||||
}, |
||||
{ |
||||
label: '商品标题', |
||||
field: 'subject', |
||||
}, |
||||
{ |
||||
label: '商品内容', |
||||
field: 'body', |
||||
}, |
||||
{ |
||||
label: '支付金额', |
||||
field: 'amount', |
||||
render: (curVal) => { |
||||
return useRender.renderText('¥', Number.parseFloat(curVal || 0 / 100).toFixed(2)) |
||||
}, |
||||
}, |
||||
{ |
||||
label: '创建时间', |
||||
field: 'createTime', |
||||
render: (curVal) => { |
||||
return useRender.renderDate(curVal) |
||||
}, |
||||
}, |
||||
{ |
||||
label: '过期时间', |
||||
field: 'expireTime', |
||||
render: (curVal) => { |
||||
return useRender.renderDate(curVal) |
||||
}, |
||||
}, |
||||
] |
||||
|
||||
export const channelsAlipay = [ |
||||
{ |
||||
name: '支付宝 PC 网站支付', |
||||
icon: svg_alipay_pc, |
||||
code: 'alipay_pc', |
||||
}, |
||||
{ |
||||
name: '支付宝 Wap 网站支付', |
||||
icon: svg_alipay_wap, |
||||
code: 'alipay_wap', |
||||
}, |
||||
{ |
||||
name: '支付宝 App 网站支付', |
||||
icon: svg_alipay_app, |
||||
code: 'alipay_app', |
||||
}, |
||||
{ |
||||
name: '支付宝扫码支付', |
||||
icon: svg_alipay_qr, |
||||
code: 'alipay_qr', |
||||
}, |
||||
{ |
||||
name: '支付宝条码支付', |
||||
icon: svg_alipay_bar, |
||||
code: 'alipay_bar', |
||||
}, |
||||
] |
||||
export const channelsWechat = [ |
||||
{ |
||||
name: '微信公众号支付', |
||||
icon: svg_wx_pub, |
||||
code: 'wx_pub', |
||||
}, |
||||
{ |
||||
name: '微信小程序支付', |
||||
icon: svg_wx_lite, |
||||
code: 'wx_lite', |
||||
}, |
||||
{ |
||||
name: '微信 App 支付', |
||||
icon: svg_wx_app, |
||||
code: 'wx_app', |
||||
}, |
||||
{ |
||||
name: '微信扫码支付', |
||||
icon: svg_wx_native, |
||||
code: 'wx_native', |
||||
}, |
||||
{ |
||||
name: '微信条码支付', |
||||
icon: svg_wx_bar, |
||||
code: 'wx_bar', |
||||
}, |
||||
] |
||||
export const channelsMock = [ |
||||
{ |
||||
name: '模拟支付', |
||||
icon: svg_mock, |
||||
code: 'mock', |
||||
}, |
||||
] |
@ -1,58 +0,0 @@
|
||||
<script lang="ts" setup> |
||||
import { ref, unref } from 'vue' |
||||
import { formSchema } from './merchant.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { BasicForm, useForm } from '@/components/Form' |
||||
import { BasicModal, useModalInner } from '@/components/Modal' |
||||
import { createMerchant, getMerchant, updateMerchant } from '@/api/pay/merchant' |
||||
|
||||
defineOptions({ name: 'PayMerchantModal' }) |
||||
|
||||
const emit = defineEmits(['success', 'register']) |
||||
const { t } = useI18n() |
||||
const { createMessage } = useMessage() |
||||
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 getMerchant(data.record.id) |
||||
setFieldsValue({ ...res }) |
||||
} |
||||
}) |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate() |
||||
setModalProps({ confirmLoading: true }) |
||||
if (unref(isUpdate)) |
||||
await updateMerchant(values) |
||||
else |
||||
await createMerchant(values) |
||||
|
||||
closeModal() |
||||
emit('success') |
||||
createMessage.success(t('common.saveSuccessText')) |
||||
} |
||||
finally { |
||||
setModalProps({ confirmLoading: false }) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<BasicModal v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal" @ok="handleSubmit"> |
||||
<BasicForm @register="registerForm" /> |
||||
</BasicModal> |
||||
</template> |
@ -1,94 +0,0 @@
|
||||
<script lang="ts" setup> |
||||
import MerchantModal from './MerchantModal.vue' |
||||
import { columns, searchFormSchema } from './merchant.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { useModal } from '@/components/Modal' |
||||
import { IconEnum } from '@/enums/appEnum' |
||||
import { BasicTable, TableAction, useTable } from '@/components/Table' |
||||
import type { MerchantExportReqVO } from '@/api/pay/merchant' |
||||
import { deleteMerchant, exportMerchant, getMerchantPage } from '@/api/pay/merchant' |
||||
|
||||
defineOptions({ name: 'PayMerchant' }) |
||||
|
||||
const { t } = useI18n() |
||||
const { createConfirm, createMessage } = useMessage() |
||||
const [registerModal, { openModal }] = useModal() |
||||
|
||||
const [registerTable, { getForm, reload }] = useTable({ |
||||
title: '商户列表', |
||||
api: getMerchantPage, |
||||
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 exportMerchant(getForm().getFieldsValue() as MerchantExportReqVO) |
||||
createMessage.success(t('common.exportSuccessText')) |
||||
}, |
||||
}) |
||||
} |
||||
|
||||
async function handleDelete(record: Recordable) { |
||||
await deleteMerchant(record.id) |
||||
createMessage.success(t('common.delSuccessText')) |
||||
reload() |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<template #toolbar> |
||||
<a-button v-auth="['pay:merchant:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> |
||||
{{ t('action.create') }} |
||||
</a-button> |
||||
<a-button v-auth="['pay:merchant:export']" :pre-icon="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:merchant:update', onClick: handleEdit.bind(null, record) }, |
||||
{ |
||||
icon: IconEnum.DELETE, |
||||
danger: true, |
||||
label: t('action.delete'), |
||||
auth: 'pay:merchant:delete', |
||||
popConfirm: { |
||||
title: t('common.delMessage'), |
||||
placement: 'left', |
||||
confirm: handleDelete.bind(null, record), |
||||
}, |
||||
}, |
||||
]" |
||||
/> |
||||
</template> |
||||
</template> |
||||
</BasicTable> |
||||
<MerchantModal @register="registerModal" @success="reload()" /> |
||||
</div> |
||||
</template> |
@ -1,151 +0,0 @@
|
||||
import { Switch } from 'ant-design-vue' |
||||
import { h } from 'vue' |
||||
import { changeMerchantStatus } from '@/api/pay/merchant' |
||||
import type { BasicColumn, FormSchema } from '@/components/Table' |
||||
import { useRender } from '@/components/Table' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict' |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '商户编号', |
||||
dataIndex: 'id', |
||||
width: 100, |
||||
}, |
||||
{ |
||||
title: '商户号', |
||||
dataIndex: 'no', |
||||
width: 180, |
||||
}, |
||||
{ |
||||
title: '商户全称', |
||||
dataIndex: 'name', |
||||
width: 100, |
||||
}, |
||||
{ |
||||
title: '商户简称', |
||||
dataIndex: 'shortName', |
||||
width: 120, |
||||
}, |
||||
{ |
||||
title: '开启状态', |
||||
dataIndex: 'status', |
||||
width: 180, |
||||
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() |
||||
changeMerchantStatus(record.id, newStatus) |
||||
.then(() => { |
||||
record.status = newStatus |
||||
createMessage.success('已成功修改商户状态') |
||||
}) |
||||
.catch(() => { |
||||
createMessage.error('修改商户状态失败') |
||||
}) |
||||
.finally(() => { |
||||
record.pendingStatus = false |
||||
}) |
||||
}, |
||||
}) |
||||
}, |
||||
}, |
||||
{ |
||||
title: '备注', |
||||
dataIndex: 'remark', |
||||
width: 180, |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime', |
||||
width: 180, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDate(text) |
||||
}, |
||||
}, |
||||
] |
||||
|
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
label: '商户号', |
||||
field: 'no', |
||||
component: 'Input', |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '商户全称', |
||||
field: 'name', |
||||
component: 'Input', |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '商户简称', |
||||
field: 'shortName', |
||||
component: 'Input', |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '状态', |
||||
field: 'status', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS), |
||||
}, |
||||
colProps: { span: 8 }, |
||||
}, |
||||
{ |
||||
label: '备注', |
||||
field: 'remark', |
||||
component: 'Input', |
||||
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: 'Input', |
||||
}, |
||||
{ |
||||
label: '开启状态', |
||||
field: 'status', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS), |
||||
}, |
||||
}, |
||||
{ |
||||
label: '备注', |
||||
field: 'remark', |
||||
component: 'InputTextArea', |
||||
}, |
||||
] |
@ -1,38 +0,0 @@
|
||||
import type { DescItem } from '@/components/Description' |
||||
import { useRender } from '@/components/Table' |
||||
|
||||
export const descSchema: DescItem[] = [ |
||||
{ |
||||
label: '支付单号', |
||||
field: 'id', |
||||
}, |
||||
{ |
||||
label: '商品标题', |
||||
field: 'subject', |
||||
}, |
||||
{ |
||||
label: '商品内容', |
||||
field: 'body', |
||||
}, |
||||
{ |
||||
label: '支付金额', |
||||
field: 'amount', |
||||
render: (curVal) => { |
||||
return useRender.renderText('¥', Number.parseFloat(curVal || 0 / 100).toFixed(2)) |
||||
}, |
||||
}, |
||||
{ |
||||
label: '创建时间', |
||||
field: 'createTime', |
||||
render: (curVal) => { |
||||
return useRender.renderDate(curVal) |
||||
}, |
||||
}, |
||||
{ |
||||
label: '过期时间', |
||||
field: 'expireTime', |
||||
render: (curVal) => { |
||||
return useRender.renderDate(curVal) |
||||
}, |
||||
}, |
||||
] |
Reference in new issue