feat 支付通道管理

This commit is contained in:
xxm1995
2023-05-24 17:28:36 +08:00
parent 9ec3ee4a48
commit 1b8378346c
3 changed files with 313 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
import { defHttp } from '/@/utils/http/axios'
import { PageResult, Result } from '/#/axios'
import { BaseEntity } from '/#/web'
/**
* 分页
*/
export function page(params) {
return defHttp.get<Result<PageResult<PayChannelConfig>>>({
url: '/channel/page',
params,
})
}
/**
* 查询全部
*/
export function findAll() {
return defHttp.get<Result<PayChannelConfig[]>>({
url: '/channel/findAll',
})
}
/**
* 获取单条
*/
export function get(id) {
return defHttp.get<Result<PayChannelConfig>>({
url: '/channel/findById',
params: { id },
})
}
/**
* 添加
*/
export function add(obj: PayChannelConfig) {
return defHttp.post({
url: '/channel/add',
data: obj,
})
}
/**
* 更新
*/
export function update(obj: PayChannelConfig) {
return defHttp.post({
url: '/channel/update',
data: obj,
})
}
/**
* 删除
*/
export function del(id) {
return defHttp.delete({
url: '/channel/delete',
params: { id },
})
}
/**
* 支付通道配置
*/
export interface PayChannelConfig extends BaseEntity {
// 通道编码
code?: string
// 支付通道名称
name?: string
// 图片
image?: string
}

View File

@@ -0,0 +1,122 @@
<template>
<basic-drawer
showFooter
v-bind="$attrs"
:title="title"
:width="modalWidth"
:visible="visible"
:maskClosable="false"
@close="handleCancel"
>
<a-spin :spinning="confirmLoading">
<a-form
class="small-from-item"
ref="formRef"
:model="form"
:rules="rules"
:validate-trigger="['blur', 'change']"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item label="主键" :hidden="true">
<a-input v-model:value="form.id" :disabled="showable" />
</a-form-item>
<a-form-item label="通道编码" name="code">
<a-input v-model:value="form.code" :disabled="showable" placeholder="请输入通道编码" />
</a-form-item>
<a-form-item label="支付通道名称" name="channelName">
<a-input v-model:value="form.channelName" :disabled="showable" placeholder="请输入支付通道名称" />
</a-form-item>
<a-form-item label="图片" name="image">
<a-input v-model:value="form.image" :disabled="showable" placeholder="请输入图片" />
</a-form-item>
</a-form>
</a-spin>
<template #footer>
<a-space>
<a-button key="cancel" @click="handleCancel">取消</a-button>
<a-button v-if="!showable" key="forward" :loading="confirmLoading" type="primary" @click="handleOk">保存</a-button>
</a-space>
</template>
</basic-drawer>
</template>
<script lang="ts" setup>
import { nextTick, reactive } from 'vue'
import { $ref } from 'vue/macros'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { add, get, update, PayChannelConfig } from './PayChannelConfig.api'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { FormEditType } from '/@/enums/formTypeEnum'
import { BasicDrawer } from '/@/components/Drawer'
const {
initFormEditType,
handleCancel,
search,
labelCol,
wrapperCol,
modalWidth,
title,
confirmLoading,
visible,
editable,
showable,
formEditType,
} = useFormEdit()
// 表单
const formRef = $ref<FormInstance>()
let form = $ref<PayChannelConfig>({
id: null,
code: '',
name: '',
image: '',
})
// 校验
const rules = reactive({} as Record<string, Rule[]>)
// 事件
const emits = defineEmits(['ok'])
// 入口
function init(id, editType: FormEditType) {
initFormEditType(editType)
resetForm()
getInfo(id, editType)
}
// 获取信息
function getInfo(id, editType: FormEditType) {
if ([FormEditType.Edit, FormEditType.Show].includes(editType)) {
confirmLoading.value = true
get(id).then(({ data }) => {
form = data
confirmLoading.value = false
})
} else {
confirmLoading.value = false
}
}
// 保存
function handleOk() {
formRef?.validate().then(async () => {
confirmLoading.value = true
if (formEditType.value === FormEditType.Add) {
await add(form)
} else if (formEditType.value === FormEditType.Edit) {
await update(form)
}
confirmLoading.value = false
handleCancel()
emits('ok')
})
}
// 重置表单
function resetForm() {
nextTick(() => {
formRef?.resetFields()
})
}
defineExpose({
init,
})
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,117 @@
<template>
<div>
<div class="m-3 p-3 pt-5 bg-white">
<b-query :query-params="model.queryParam" :fields="fields" @query="queryPage" @reset="resetQueryParams" />
</div>
<div class="m-3 p-3 bg-white">
<vxe-toolbar ref="xToolbar" custom :refresh="{ query: queryPage }">
<template #buttons>
<a-space>
<a-button type="primary" pre-icon="ant-design:plus-outlined" @click="add">新建</a-button>
</a-space>
</template>
</vxe-toolbar>
<vxe-table row-id="id" ref="xTable" :data="pagination.records" :loading="loading">
<vxe-column type="seq" width="60" />
<vxe-column field="code" title="通道编码" />
<vxe-column field="name" title="支付通道名称" />
<vxe-column field="image" title="图片" />
<vxe-column field="createTime" title="创建时间" />
<vxe-column fixed="right" width="150" :showOverflow="false" title="操作">
<template #default="{ row }">
<span>
<a-link @click="show(row)">查看</a-link>
</span>
<a-divider type="vertical" />
<span>
<a-link @click="edit(row)">编辑</a-link>
</span>
<a-divider type="vertical" />
<a-link danger @click="remove(row)" >删除</a-link>
</template>
</vxe-column>
</vxe-table>
<vxe-pager
size="medium"
:loading="loading"
:current-page="pagination.current"
:page-size="pagination.size"
:total="pagination.total"
@page-change="handleTableChange"
/>
<pay-channel-config-edit ref="payChannelConfigEdit" @ok="queryPage" />
</div>
</div>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue'
import { $ref } from 'vue/macros'
import { del, page } from './PayChannelConfig.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import PayChannelConfigEdit from './PayChannelConfigEdit.vue'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import BQuery from '/@/components/Bootx/Query/BQuery.vue'
import { FormEditType } from '/@/enums/formTypeEnum'
import { useMessage } from '/@/hooks/web/useMessage'
import { QueryField } from '/@/components/Bootx/Query/Query'
// 使用hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, pages, model, loading } = useTablePage(queryPage)
const { notification, createMessage, createConfirm } = useMessage()
// 查询条件
const fields = [] as QueryField[]
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
const payChannelConfigEdit = $ref<any>()
onMounted(() => {
vxeBind()
queryPage()
})
function vxeBind() {
xTable?.connect(xToolbar as VxeToolbarInstance)
}
// 分页查询
function queryPage() {
loading.value = true
page({
...model.queryParam,
...pages,
}).then(({ data }) => {
pageQueryResHandel(data)
})
}
// 新增
function add() {
payChannelConfigEdit.init(null, FormEditType.Add)
}
// 编辑
function edit(record) {
payChannelConfigEdit.init(record.id, FormEditType.Edit)
}
// 查看
function show(record) {
payChannelConfigEdit.init(record.id, FormEditType.Show)
}
// 删除
function remove(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否删除该数据',
onOk: () => {
del(record.id).then(() => {
createMessage.success('删除成功')
queryPage()
})
},
})
}
</script>
<style lang="less" scoped></style>