<template>
|
<!-- 搜索 -->
|
<ContentWrap>
|
<el-form
|
class="-mb-15px"
|
:model="queryParams"
|
ref="queryFormRef"
|
:inline="true"
|
label-width="68px"
|
>
|
<el-form-item label="套餐名" prop="name">
|
<el-input
|
v-model="queryParams.name"
|
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
|
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>
|
<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
|
type="primary"
|
plain
|
@click="openForm('create')"
|
v-hasPermi="['system:tenant-package:create']"
|
>
|
<Icon icon="ep:plus" class="mr-5px"/>
|
新增
|
</el-button>
|
</el-form-item>
|
</el-form>
|
</ContentWrap>
|
<!-- 列表 -->
|
<ContentWrap>
|
<el-skeleton :loading="loading">
|
<div class="package-card" v-for="(item, index) in packages" :key="`dynamics-${index}`">
|
<div class="card-content">
|
<img class="card-icon" :src="item.icon"/>
|
<div class="card-middle">
|
<div class="tenant-title">{{ item.name }}</div>
|
<div class="tenant-operation">
|
<el-dropdown @command="(command) => handleCommand(command, item)"
|
v-hasPermi="[
|
'system:tenant-package:update',
|
'system:tenant-package:delete'
|
]">
|
<el-button type="primary" link>
|
<Icon icon="ep:more-filled"/>
|
</el-button>
|
<template #dropdown>
|
<el-dropdown-menu>
|
<el-dropdown-item
|
command="handleUpdate"
|
v-if="checkPermi(['system:tenant-package:update'])"
|
>
|
<Icon icon="ep:edit"/>
|
修改
|
</el-dropdown-item>
|
<el-dropdown-item
|
command="handleDelete"
|
v-if="checkPermi(['system:tenant-package:delete'])"
|
>
|
<Icon icon="ep:delete"/>
|
删除
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</template>
|
</el-dropdown>
|
</div>
|
</div>
|
<div class="description">{{ item.description }}</div>
|
<div class="label-areas">
|
<el-tag
|
:disable-transitions="true"
|
:key="i"
|
v-for="(label, i) in item.labels"
|
:index="i"
|
class="label"
|
>
|
{{ label }}
|
</el-tag>
|
</div>
|
</div>
|
</div>
|
</el-skeleton>
|
<!-- 分页 -->
|
<Pagination
|
class="pagination"
|
:total="total"
|
v-model:page="queryParams.pageNo"
|
v-model:limit="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</ContentWrap>
|
|
<!-- 表单弹窗:添加/修改 -->
|
<TenantPackageForm ref="formRef" @success="getList"/>
|
</template>
|
<script lang="ts" setup>
|
import {DICT_TYPE, getIntDictOptions} from '@/utils/dict'
|
import * as TenantPackageApi from '@/api/system/tenantPackage'
|
import TenantPackageForm from './TenantPackageForm.vue'
|
import {TenantPackageVO} from "@/api/system/tenantPackage";
|
import {checkPermi} from "@/utils/permission";
|
|
defineOptions({name: 'SystemTenantPackage'})
|
|
const message = useMessage() // 消息弹窗
|
const {t} = useI18n() // 国际化
|
|
const loading = ref(true) // 列表的加载中
|
const total = ref(0) // 列表的总页数
|
const packages = ref([])
|
|
const queryParams = reactive({
|
pageNo: 1,
|
pageSize: 10,
|
name: undefined,
|
status: undefined,
|
remark: undefined,
|
createTime: []
|
})
|
const queryFormRef = ref() // 搜索的表单
|
|
/** 查询列表 */
|
const getList = async () => {
|
try {
|
const data = await TenantPackageApi.getTenantPackagePage(queryParams)
|
packages.value = data.list
|
total.value = data.total
|
} finally {
|
loading.value = false
|
}
|
}
|
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
queryParams.pageNo = 1
|
getList()
|
}
|
|
/** 重置按钮操作 */
|
const resetQuery = () => {
|
queryFormRef.value?.resetFields()
|
getList()
|
}
|
|
/** 添加/修改操作 */
|
const formRef = ref()
|
const openForm = (type: string, id?: number) => {
|
formRef.value.open(type, id)
|
}
|
|
/** 操作分发 */
|
const handleCommand = (command: string, row: TenantPackageVO) => {
|
switch (command) {
|
case 'handleUpdate':
|
openForm('update', row.id)
|
break
|
case 'handleDelete':
|
handleDelete(row.id)
|
break
|
default:
|
break
|
}
|
}
|
|
/** 删除按钮操作 */
|
const handleDelete = async (id: number) => {
|
try {
|
// 删除的二次确认
|
await message.delConfirm()
|
// 发起删除
|
await TenantPackageApi.deleteTenantPackage(id)
|
message.success(t('common.delSuccess'))
|
// 刷新列表
|
await getList()
|
} catch {
|
}
|
}
|
|
const initData = async () => {
|
await Promise.all([
|
getList()
|
])
|
}
|
|
/** 初始化 **/
|
initData()
|
|
</script>
|
<style lang="scss" scoped>
|
.package-card {
|
display: inline-block;
|
width: 396px;
|
height: 379px;
|
background: #FFFFFF;
|
border-radius: 4px 4px 4px 4px;
|
border: 1px solid #EBEDF0;
|
margin: 0px 8px 8px 0;
|
}
|
|
.card-content {
|
margin-left: 10px;
|
}
|
|
.card-icon {
|
width: 372px;
|
height: 200px;
|
margin: 10px 0 10px 2px;
|
}
|
|
.card-middle {
|
width: 396px;
|
height: 25px;
|
margin: 0 12px;
|
display: flex;
|
}
|
|
.tenant-title {
|
width: 340px;
|
height: 25px;
|
font-family: Microsoft YaHei UI, Microsoft YaHei UI;
|
font-weight: bold;
|
font-size: 20px;
|
color: #282F3D;
|
}
|
|
.tenant-operation {
|
margin-right: 12px;
|
}
|
|
.description {
|
margin: 8px 12px;
|
width: 372px;
|
height: 36px;
|
font-family: Microsoft YaHei, Microsoft YaHei;
|
font-weight: 400;
|
font-size: 14px;
|
color: #6B7785;
|
line-height: 18px;
|
word-wrap: break-word;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
display: -webkit-box;
|
-webkit-line-clamp: 2;
|
-webkit-box-orient: vertical;
|
}
|
|
.label-areas {
|
display: flex;
|
flex-wrap: wrap;
|
height: 54px;
|
width: 396px;
|
margin: 0 8px;
|
}
|
|
.label {
|
width: 80px;
|
height: 20px;
|
margin: 4px;
|
border-radius: 80px 80px 80px 80px;
|
border: 1px solid #417CFF;
|
}
|
.pagination {
|
margin-right: 30px;
|
margin-top: 400px;
|
}
|
</style>
|