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 })
}
// 查询详情支付商户
export const getMerchantApi = (id: number) => {
export const getMerchant = (id: number) => {
return request.get({ url: '/pay/merchant/get?id=' + id })
}
// 根据商户名称搜索商户列表
export const getMerchantListByNameApi = (name: string) => {
export const getMerchantListByName = (name: string) => {
return request.get({
url: '/pay/merchant/list-by-name?id=',
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 })
}
// 修改支付商户
export const updateMerchantApi = (data: MerchantVO) => {
export const updateMerchant = (data: MerchantVO) => {
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 })
}
// 导出支付商户
export const exportMerchantApi = (params: MerchantExportReqVO) => {
export const exportMerchant = (params: MerchantExportReqVO) => {
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 = {
id,
status

View File

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

View File

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

View File

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