243 lines
7.0 KiB
Vue
Raw Normal View History

<template>
<ContentWrap>
2023-04-02 10:24:03 +08:00
<!-- 搜索工作栏 -->
2023-03-30 21:42:42 +08:00
<el-form
2023-04-02 10:24:03 +08:00
class="-mb-15px"
2023-03-30 21:42:42 +08:00
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
2023-04-02 10:24:03 +08:00
>
<el-form-item label="商户号" prop="no">
<el-input v-model="queryParams.no" placeholder="请输入商户号" clearable class="!w-240px" />
2023-03-30 21:42:42 +08:00
</el-form-item>
<el-form-item label="商户全称" prop="name">
2023-04-02 10:24:03 +08:00
<el-input
v-model="queryParams.name"
placeholder="请输入商户全称"
clearable
class="!w-240px"
/>
2023-03-30 21:42:42 +08:00
</el-form-item>
<el-form-item label="商户简称" prop="shortName">
2023-04-02 10:24:03 +08:00
<el-input
v-model="queryParams.shortName"
placeholder="请输入商户简称"
clearable
class="!w-240px"
/>
2023-03-30 21:42:42 +08:00
</el-form-item>
<el-form-item label="开启状态" prop="status">
<el-select v-model="queryParams.status" placeholder="字典状态" clearable class="!w-240px">
<el-option
2023-04-02 10:24:03 +08:00
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
2023-03-30 21:42:42 +08:00
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
2023-04-02 10:24:03 +08:00
<el-input
v-model="queryParams.remark"
placeholder="请输入备注"
clearable
class="!w-240px"
/>
2023-03-30 21:42:42 +08:00
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="datetimerange"
start-placeholder="开始日期"
end-placeholder="结束日期"
2023-04-02 10:24:03 +08:00
class="!w-240px"
2023-03-30 21:42:42 +08:00
/>
</el-form-item>
<el-form-item>
2023-04-02 10:24:03 +08:00
<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>
2023-03-30 21:42:42 +08:00
<el-button
plain
2023-04-02 10:24:03 +08:00
type="primary"
@click="openForm('create')"
v-hasPermi="['pay:merchant:create']"
2023-03-30 21:42:42 +08:00
>
2023-04-02 10:24:03 +08:00
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
2023-03-30 21:42:42 +08:00
<el-button
2023-04-02 10:24:03 +08:00
type="success"
2023-03-30 21:42:42 +08:00
plain
@click="handleExport"
2023-04-02 10:24:03 +08:00
:loading="exportLoading"
v-hasPermi="['pay:merchant:export']"
2023-03-30 21:42:42 +08:00
>
2023-04-02 10:24:03 +08:00
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
2023-04-02 10:24:03 +08:00
<!-- 列表 -->
<ContentWrap>
2023-03-30 21:42:42 +08:00
<el-table v-loading="loading" :data="list">
<el-table-column label="商户编号" align="center" prop="id" />
<el-table-column label="商户号" align="center" prop="no" />
<el-table-column label="商户全称" align="center" prop="name" />
<el-table-column label="商户简称" align="center" prop="shortName" />
<el-table-column label="开启状态" align="center" prop="status">
<template #default="scope">
<el-switch
v-model="scope.row.status"
:active-value="0"
:inactive-value="1"
@change="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
2023-04-02 10:24:03 +08:00
:formatter="dateFormatter"
2023-03-30 21:42:42 +08:00
width="180"
/>
2023-04-02 10:24:03 +08:00
<el-table-column label="操作" align="center">
2023-03-30 21:42:42 +08:00
<template #default="scope">
<el-button
link
type="primary"
2023-04-02 10:24:03 +08:00
@click="openForm('update', scope.row.id)"
2023-03-30 21:42:42 +08:00
v-hasPermi="['pay:merchant:update']"
>
2023-04-02 10:24:03 +08:00
修改
</el-button>
2023-03-30 21:42:42 +08:00
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['pay:merchant:delete']"
>
2023-04-02 10:24:03 +08:00
删除
</el-button>
2023-03-30 21:42:42 +08:00
</template>
</el-table-column>
</el-table>
2023-04-02 10:24:03 +08:00
<!-- 分页 -->
<Pagination
2023-03-30 21:42:42 +08:00
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
2023-03-30 21:42:42 +08:00
2023-04-02 10:24:03 +08:00
<!-- 表单弹窗添加/修改 -->
<MerchantForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts" name="PayMerchant">
2023-04-02 10:24:03 +08:00
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
2023-03-30 21:42:42 +08:00
import { CommonStatusEnum } from '@/utils/constants'
2023-04-02 10:24:03 +08:00
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() // 消息弹窗
2023-03-30 21:42:42 +08:00
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
2023-04-02 10:24:03 +08:00
pageNo: 1,
pageSize: 10,
2023-03-30 21:42:42 +08:00
name: '',
shortName: '',
2023-04-02 10:24:03 +08:00
status: undefined
})
2023-03-30 21:42:42 +08:00
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
2023-04-02 10:24:03 +08:00
2023-03-30 21:42:42 +08:00
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
2023-04-02 10:24:03 +08:00
const data = await MerchantApi.getMerchantPage(queryParams)
2023-03-30 21:42:42 +08:00
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
2023-03-30 21:42:42 +08:00
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
2023-03-30 21:42:42 +08:00
/** 添加/修改操作 */
2023-04-02 10:24:03 +08:00
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
2023-03-30 21:42:42 +08:00
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
2023-04-02 10:24:03 +08:00
await MerchantApi.deleteMerchant(id)
2023-03-30 21:42:42 +08:00
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
2023-04-02 10:24:03 +08:00
/** 修改状态操作 */
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
}
}
2023-03-30 21:42:42 +08:00
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
2023-04-02 10:24:03 +08:00
const data = await MerchantApi.exportMerchant(queryParams)
2023-03-30 21:42:42 +08:00
download.excel(data, '商户信息.xls')
} catch {
} finally {
exportLoading.value = false
}
}
2023-03-30 21:42:42 +08:00
/** 初始化 **/
onMounted(() => {
getList()
})
</script>