vue3/src/views/combo/index.vue
2025-09-03 15:41:21 +08:00

403 lines
9.2 KiB
Vue

<template>
<div class="doctor-notice-container">
<!-- 页面标题 -->
<div class="page-header">
<h2 class="page-title">
<Icon icon="ep:box" class="mr-2" />
会员套餐管理
</h2>
<p class="page-description">查看与管理系统中的会员套餐</p>
</div>
<!-- 搜索区域 -->
<ContentWrap>
<el-form
ref="queryFormRef"
:model="queryParams"
:inline="true"
label-width="80px"
class="search-form"
>
<el-form-item label="套餐名称" prop="comboname">
<el-input
v-model="queryParams.comboname"
placeholder="请输入套餐名称"
clearable
@keyup.enter="handleQuery"
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 label="启用" :value="1" />
<el-option label="禁用" :value="0" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">
<Icon icon="ep:search" class="mr-1" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-1" />
重置
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<div class="table-header">
<div class="table-title">
<Icon icon="ep:box" class="mr-2" />
套餐列表
</div>
<div class="table-actions">
<el-button type="primary" @click="openForm('create')">
<Icon icon="ep:plus" class="mr-1" />
新增
</el-button>
<el-button type="success" @click="handleExport" :loading="exportLoading">
<Icon icon="ep:download" class="mr-1" />
导出
</el-button>
<el-button type="primary" @click="refreshList">
<Icon icon="ep:refresh" class="mr-1" />
刷新
</el-button>
</div>
</div>
<el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
class="notice-table"
>
<el-table-column label="序号" type="index" width="60" align="center" />
<el-table-column label="套餐名称" align="center" prop="comboname" min-width="160" />
<el-table-column label="套餐价格(元)" align="center" prop="price" width="140" />
<el-table-column label="套餐时长(天)" align="center" prop="period" width="140" />
<el-table-column label="状态" align="center" prop="status" width="120">
<template #default="scope">
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">{{ scope.row.status === 1 ? '启用' : '禁用' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="套餐描述" align="center" prop="description" min-width="200" />
<el-table-column
label="创建时间"
align="center"
prop="createtime"
:formatter="dateFormatter"
width="180"
/>
<el-table-column
label="更新时间"
align="center"
prop="updatetime"
:formatter="dateFormatter"
width="180"
/>
<el-table-column label="操作" align="center" width="150" fixed="right">
<template #default="scope">
<el-button
link
type="primary"
size="small"
@click="openForm('update', scope.row.id)"
>
编辑
</el-button>
<el-button
link
type="danger"
size="small"
@click="handleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<ComboForm ref="formRef" @success="getList" />
</div>
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { ComboApi, ComboVO } from '@/api/combo'
import ComboForm from './ComboForm.vue'
import { getUserProfile } from '@/api/system/user/profile'
/** 会员套餐 列表 */
defineOptions({ name: 'Combo' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const list = ref<ComboVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
orgid: undefined,
comboname: undefined,
price: undefined,
period: undefined,
status: undefined,
description: undefined,
createtime: [],
updatetime: [],
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const userProfile = await getUserProfile()
queryParams.orgid = userProfile.dept.orgid
console.log(queryParams)
const data = await ComboApi.getComboPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 刷新列表 */
const refreshList = () => {
getList()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
await ComboApi.deleteCombo(id)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await ComboApi.exportCombo(queryParams)
download.excel(data, '会员套餐.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
.doctor-notice-container {
padding: 20px;
background-color: #f5f7fa;
height: 100%;
overflow-y: auto;
}
.page-header {
margin-bottom: 20px;
padding: 20px;
background: linear-gradient(135deg, #1890ff 0%, #36cfc9 100%);
border-radius: 12px;
color: white;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
.page-title {
margin: 0 0 8px 0;
font-size: 24px;
font-weight: 600;
display: flex;
align-items: center;
}
.page-description {
margin: 0;
opacity: 0.9;
font-size: 14px;
}
}
.search-form {
.el-form-item {
margin-bottom: 16px;
}
}
.table-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
padding: 16px 0;
border-bottom: 1px solid #ebeef5;
.table-title {
font-size: 16px;
font-weight: 600;
color: #303133;
display: flex;
align-items: center;
}
.table-actions {
display: flex;
gap: 8px;
align-items: center;
}
}
.notice-table {
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
:deep(.el-table__header) {
background-color: #fafafa;
}
:deep(.el-table__row) {
cursor: pointer;
transition: all 0.3s ease;
&:hover {
background-color: #f5f7fa !important;
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
}
}
@media (max-width: 768px) {
.doctor-notice-container {
padding: 10px;
}
.page-header {
padding: 16px;
.page-title {
font-size: 20px;
}
}
.table-header {
flex-direction: column;
gap: 12px;
align-items: flex-start;
.table-actions {
width: 100%;
justify-content: flex-end;
}
}
.search-form {
.el-form-item {
margin-bottom: 12px;
}
}
}
.notice-table {
:deep(.el-table__row) {
animation: fadeInUp 0.3s ease-out;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
::deep(.el-loading-mask) {
background-color: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(2px);
}
::deep(.el-tag) {
border-radius: 4px;
font-weight: 500;
}
::deep(.el-button) {
border-radius: 6px;
font-weight: 500;
transition: all 0.3s ease;
&:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
}
::deep(.el-pagination) {
margin-top: 20px;
justify-content: center;
padding: 16px 0;
border-top: 1px solid #ebeef5;
}
</style>