REVIEW 支付商户

This commit is contained in:
YunaiV 2023-04-02 10:24:03 +08:00
parent aea1270d8f
commit a319d090bb
4 changed files with 118 additions and 114 deletions

View File

@ -29,17 +29,17 @@ export interface MerchantExportReqVO {
} }
// 查询列表支付商户 // 查询列表支付商户
export const getMerchantPageApi = (params: MerchantPageReqVO) => { export const getMerchantPage = (params: MerchantPageReqVO) => {
return request.get({ url: '/pay/merchant/page', params }) return request.get({ url: '/pay/merchant/page', params })
} }
// 查询详情支付商户 // 查询详情支付商户
export const getMerchantApi = (id: number) => { export const getMerchant = (id: number) => {
return request.get({ url: '/pay/merchant/get?id=' + id }) return request.get({ url: '/pay/merchant/get?id=' + id })
} }
// 根据商户名称搜索商户列表 // 根据商户名称搜索商户列表
export const getMerchantListByNameApi = (name: string) => { export const getMerchantListByName = (name: string) => {
return request.get({ return request.get({
url: '/pay/merchant/list-by-name?id=', url: '/pay/merchant/list-by-name?id=',
params: { params: {
@ -49,26 +49,27 @@ export const getMerchantListByNameApi = (name: string) => {
} }
// 新增支付商户 // 新增支付商户
export const createMerchantApi = (data: MerchantVO) => { export const createMerchant = (data: MerchantVO) => {
return request.post({ url: '/pay/merchant/create', data }) return request.post({ url: '/pay/merchant/create', data })
} }
// 修改支付商户 // 修改支付商户
export const updateMerchantApi = (data: MerchantVO) => { export const updateMerchant = (data: MerchantVO) => {
return request.put({ url: '/pay/merchant/update', data }) return request.put({ url: '/pay/merchant/update', data })
} }
// 删除支付商户 // 删除支付商户
export const deleteMerchantApi = (id: number) => { export const deleteMerchant = (id: number) => {
return request.delete({ url: '/pay/merchant/delete?id=' + id }) return request.delete({ url: '/pay/merchant/delete?id=' + id })
} }
// 导出支付商户 // 导出支付商户
export const exportMerchantApi = (params: MerchantExportReqVO) => { export const exportMerchant = (params: MerchantExportReqVO) => {
return request.download({ url: '/pay/merchant/export-excel', params }) return request.download({ url: '/pay/merchant/export-excel', params })
} }
// 支付商户状态修改 // 支付商户状态修改
export const changeMerchantStatusApi = (id: number, status: number) => { export const updateMerchantStatus = (id: number, status: number) => {
const data = { const data = {
id, id,
status status

View File

@ -1,15 +1,14 @@
<template> <template>
<Dialog :title="modelTitle" v-model="modelVisible" width="800"> <Dialog :title="modelTitle" v-model="modelVisible">
<!-- 对话框(添加 / 修改) --> <el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
<el-form-item label="商户全称" prop="name"> <el-form-item label="商户全称" prop="name">
<el-input v-model="form.name" placeholder="请输入商户全称" /> <el-input v-model="formData.name" placeholder="请输入商户全称" />
</el-form-item> </el-form-item>
<el-form-item label="商户简称" prop="shortName"> <el-form-item label="商户简称" prop="shortName">
<el-input v-model="form.shortName" placeholder="请输入商户简称" /> <el-input v-model="formData.shortName" placeholder="请输入商户简称" />
</el-form-item> </el-form-item>
<el-form-item label="开启状态" prop="status"> <el-form-item label="开启状态" prop="status">
<el-select v-model="form.status" placeholder="请选择状态" clearable> <el-select v-model="formData.status" placeholder="请选择状态" clearable>
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :key="dict.value"
@ -19,7 +18,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" /> <el-input type="textarea" v-model="formData.remark" placeholder="请输入备注" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -31,6 +30,7 @@
<script setup lang="ts"> <script setup lang="ts">
import * as MerchantApi from '@/api/pay/merchant' import * as MerchantApi from '@/api/pay/merchant'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { CommonStatusEnum } from '@/utils/constants'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -38,11 +38,11 @@ const modelVisible = ref(false) // 弹窗的是否展示
const modelTitle = ref('') // const modelTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
const form = ref({ const formData = ref({
id: undefined, id: undefined,
name: '', name: '',
shortName: '', shortName: '',
status: undefined, status: CommonStatusEnum.ENABLE,
remark: '' remark: ''
}) })
const formRules = reactive({ const formRules = reactive({
@ -53,7 +53,7 @@ const formRules = reactive({
const formRef = ref() // Ref const formRef = ref() // Ref
/** 打开弹窗 */ /** 打开弹窗 */
const openModal = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
modelVisible.value = true modelVisible.value = true
modelTitle.value = t('action.' + type) modelTitle.value = t('action.' + type)
formType.value = type formType.value = type
@ -62,13 +62,13 @@ const openModal = async (type: string, id?: number) => {
if (id) { if (id) {
formLoading.value = true formLoading.value = true
try { try {
form.value = await MerchantApi.getMerchantApi(id) formData.value = await MerchantApi.getMerchant(id)
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
} }
defineExpose({ openModal }) // openModal defineExpose({ open }) // open
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success const emit = defineEmits(['success']) // success
@ -80,12 +80,12 @@ const submitForm = async () => {
// //
formLoading.value = true formLoading.value = true
try { try {
const data = form.value as unknown as MerchantApi.MerchantVO const data = formData.value as unknown as MerchantApi.MerchantVO
if (formType.value === 'create') { if (formType.value === 'create') {
await MerchantApi.createMerchantApi(data) await MerchantApi.createMerchant(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await MerchantApi.updateMerchantApi(data) await MerchantApi.updateMerchant(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
modelVisible.value = false modelVisible.value = false
@ -98,11 +98,11 @@ const submitForm = async () => {
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
form.value = { formData.value = {
id: undefined, id: undefined,
name: '', name: '',
shortName: '', shortName: '',
status: undefined, status: CommonStatusEnum.ENABLE,
remark: '' remark: ''
} }
formRef.value?.resetFields() formRef.value?.resetFields()

View File

@ -1,79 +1,86 @@
<template> <template>
<content-wrap> <content-wrap>
<!-- 搜索工作栏 -->
<el-form <el-form
class="-mb-15px"
:model="queryParams" :model="queryParams"
ref="queryFormRef" ref="queryFormRef"
:inline="true" :inline="true"
v-show="showSearch"
label-width="68px" label-width="68px"
><el-form-item label="商户号" prop="no"> >
<el-input v-model="queryParams.no" placeholder="请输入商户号" clearable /> <el-form-item label="商户号" prop="no">
<el-input v-model="queryParams.no" placeholder="请输入商户号" clearable class="!w-240px" />
</el-form-item> </el-form-item>
<el-form-item label="商户全称" prop="name"> <el-form-item label="商户全称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入商户全称" clearable /> <el-input
v-model="queryParams.name"
placeholder="请输入商户全称"
clearable
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="商户简称" prop="shortName"> <el-form-item label="商户简称" prop="shortName">
<el-input v-model="queryParams.shortName" placeholder="请输入商户简称" clearable /> <el-input
v-model="queryParams.shortName"
placeholder="请输入商户简称"
clearable
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="开启状态" prop="status"> <el-form-item label="开启状态" prop="status">
<el-select v-model="queryParams.status" placeholder="字典状态" clearable class="!w-240px"> <el-select v-model="queryParams.status" placeholder="字典状态" clearable class="!w-240px">
<el-option <el-option
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="parseInt(dict.value)" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="queryParams.remark" placeholder="请输入备注" clearable /> <el-input
v-model="queryParams.remark"
placeholder="请输入备注"
clearable
class="!w-240px"
/>
</el-form-item> </el-form-item>
<el-form-item label="创建时间" prop="createTime"> <el-form-item label="创建时间" prop="createTime">
<el-date-picker <el-date-picker
v-model="queryParams.createTime" v-model="queryParams.createTime"
style="width: 240px"
value-format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
type="datetimerange" type="datetimerange"
range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
plain
type="primary"
@click="openForm('create')"
v-hasPermi="['pay:merchant:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['pay:merchant:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="small"
@click="openModal('create')"
v-hasPermi="['pay:merchant:create']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="small"
:loading="exportLoading"
@click="handleExport"
v-hasPermi="['pay:merchant:export']"
>导出</el-button
>
</el-col>
</el-row>
</content-wrap> </content-wrap>
<content-wrap>
<!-- 列表 --> <!-- 列表 -->
<content-wrap>
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="商户编号" align="center" prop="id" /> <el-table-column label="商户编号" align="center" prop="id" />
<el-table-column label="商户号" align="center" prop="no" /> <el-table-column label="商户号" align="center" prop="no" />
@ -92,52 +99,51 @@
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column <el-table-column
label="创建时间" label="创建时间"
:formatter="dateFormatter"
align="center" align="center"
prop="createTime" prop="createTime"
:formatter="dateFormatter"
width="180" width="180"
/> />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center">
<template #default="scope"> <template #default="scope">
<el-button <el-button
link link
type="primary" type="primary"
icon="el-icon-edit" @click="openForm('update', scope.row.id)"
@click="openModal('update', scope.row.id)"
v-hasPermi="['pay:merchant:update']" v-hasPermi="['pay:merchant:update']"
>修改</el-button
> >
修改
</el-button>
<el-button <el-button
link link
type="danger" type="danger"
icon="el-icon-delete"
@click="handleDelete(scope.row.id)" @click="handleDelete(scope.row.id)"
v-hasPermi="['pay:merchant:delete']" v-hasPermi="['pay:merchant:delete']"
>删除</el-button
> >
删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页 -->
<pagination <Pagination
v-show="total > 0"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<!-- 表单弹窗添加/修改 -->
<MerchantForm ref="modalRef" @success="getList" />
</content-wrap> </content-wrap>
</template>
<!-- 表单弹窗添加/修改 -->
<MerchantForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts" name="Merchant"> <script setup lang="ts" name="Merchant">
import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as MerchantApi from '@/api/pay/merchant'
import MerchantForm from './form.vue'
import download from '@/utils/download'
import { dateFormatter } from '@/utils/formatTime'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as MerchantApi from '@/api/pay/merchant'
import MerchantForm from './MerchantForm.vue'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -145,21 +151,20 @@ const loading = ref(true) // 列表的加载中
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: '', name: '',
shortName: '', shortName: '',
status: undefined, status: undefined
pageNo: 1,
pageSize: 100
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const showSearch = ref(true)
const exportLoading = ref(false) // const exportLoading = ref(false) //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await MerchantApi.getMerchantPageApi(queryParams) const data = await MerchantApi.getMerchantPage(queryParams)
list.value = data.list list.value = data.list
total.value = data.total total.value = data.total
} finally { } finally {
@ -180,9 +185,9 @@ const resetQuery = () => {
} }
/** 添加/修改操作 */ /** 添加/修改操作 */
const modalRef = ref() const formRef = ref()
const openModal = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
modalRef.value.openModal(type, id) formRef.value.open(type, id)
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
@ -191,30 +196,28 @@ const handleDelete = async (id: number) => {
// //
await message.delConfirm() await message.delConfirm()
// //
await MerchantApi.deleteMerchantApi(id) await MerchantApi.deleteMerchant(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch {} } catch {}
} }
// /** 修改状态操作 */
const handleStatusChange = (row: MerchantApi.MerchantVO) => { const handleStatusChange = async (row: MerchantApi.MerchantVO) => {
let info = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用' try {
message //
.confirm('确认要"' + info + '""' + row.name + '"商户吗?', t('common.reminder')) const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
.then(async () => { await message.confirm('确认要"' + text + '""' + row.name + '"商户吗?', t('common.reminder'))
row.status = //
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.ENABLE : CommonStatusEnum.DISABLE await MerchantApi.updateMerchantStatus(row.id, row.status)
await MerchantApi.updateMerchantApi(row)
message.success(info + '成功')
// //
getList() await getList()
}) } catch {
.catch(() => { //
row.status = row.status =
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
}) }
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
@ -224,7 +227,7 @@ const handleExport = async () => {
await message.exportConfirm() await message.exportConfirm()
// //
exportLoading.value = true exportLoading.value = true
const data = await MerchantApi.exportMerchantApi(queryParams) const data = await MerchantApi.exportMerchant(queryParams)
download.excel(data, '商户信息.xls') download.excel(data, '商户信息.xls')
} catch { } catch {
} finally { } finally {

View File

@ -114,11 +114,11 @@ const loading = ref(true) // 列表的加载中
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1,
pageSize: 10,
title: '', title: '',
type: undefined, type: undefined,
status: undefined, status: undefined
pageNo: 1,
pageSize: 100
}) })
const queryFormRef = ref() // const queryFormRef = ref() //