<template>
|
<!-- 搜索工作栏 -->
|
<ContentWrap>
|
<el-form
|
class="-mb-15px"
|
:model="queryParams"
|
ref="queryFormRef"
|
:inline="true"
|
label-width="68px"
|
@submit.prevent
|
>
|
<el-form-item label="模型名称" prop="iconName">
|
<el-input
|
v-model="queryParams.iconName"
|
placeholder="请输入名称"
|
clearable
|
class="!w-240px"
|
/>
|
</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="['mpk:icon:create']"
|
>
|
<Icon icon="ep:plus" class="mr-5px" />
|
新增
|
</el-button>
|
|
</el-form-item>
|
</el-form>
|
</ContentWrap>
|
|
<!-- 列表 -->
|
<ContentWrap>
|
<el-table
|
v-loading="loading"
|
:data="list"
|
row-key="id"
|
>
|
<el-table-column prop="iconName" label="名称"/>
|
<el-table-column prop="iconDesc" label="描述"/>
|
<el-table-column align="center" label="图标" prop="icon" width="100">
|
<template #default="scope">
|
<img :src="staticDir + 'SimtreeUnitImage/' + scope.row.iconName" class="mpk-icon-list" :alt=" scope.row.iconDesc" />
|
</template>
|
</el-table-column>
|
<el-table-column prop="sort" label="排序"/>
|
<el-table-column label="操作" align="center" width="200px">
|
<template #default="scope">
|
<div class="flex items-center justify-center">
|
<el-button
|
link
|
type="primary"
|
@click="openForm('update', scope.row.id)"
|
v-hasPermi="['mpk:icon:update']"
|
>
|
编辑
|
</el-button>
|
<el-button link type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['mpk:icon:delete']">
|
<Icon icon="ep:delete"/>删除
|
</el-button>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!-- 分页 -->
|
<Pagination
|
v-model:limit="queryParams.pageSize"
|
v-model:page="queryParams.pageNo"
|
:total="total"
|
@pagination="getList"
|
/>
|
</ContentWrap>
|
|
<!-- 表单弹窗:添加/修改 -->
|
<IconForm ref="formRef" @success="getList" />
|
</template>
|
<script lang="ts" setup>
|
import {dateFormatter} from '@/utils/formatTime'
|
import * as MpkIconApi from '@/api/model/mpk/icon'
|
import IconForm from './IconForm.vue'
|
|
defineOptions({name: 'MpkIcon'})
|
|
const staticDir = ref(import.meta.env.VITE_STATIC_DIR)
|
|
const message = useMessage() // 消息弹窗
|
const {t} = useI18n() // 国际化
|
|
const loading = ref(true) // 列表的加载中
|
const total = ref(0) // 列表的总页数
|
const list = ref([]) // 字典表格数据
|
const queryParams = reactive({
|
pageNo: 1,
|
pageSize: 10,
|
iconName: ''
|
})
|
const queryFormRef = ref() // 搜索的表单
|
|
const getList = async () => {
|
loading.value = true
|
try {
|
const data = await MpkIconApi.getPage(queryParams)
|
list.value = data.list
|
total.value = data.total
|
} finally {
|
loading.value = false
|
}
|
}
|
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
getList()
|
}
|
|
/** 重置按钮操作 */
|
const resetQuery = () => {
|
queryParams.pageNo = 1
|
queryFormRef.value.resetFields()
|
handleQuery()
|
}
|
|
/** 添加/修改操作 */
|
const formRef = ref()
|
const openForm = (type: string, id?: string) => {
|
formRef.value.open(type, id)
|
}
|
|
/** 删除按钮操作 */
|
const handleDelete = async (id: string) => {
|
try {
|
// 删除的二次确认
|
await message.delConfirm()
|
// 发起删除
|
await MpkIconApi.deleteIcon(id)
|
message.success(t('common.delSuccess'))
|
// 刷新列表
|
await getList()
|
} catch {
|
}
|
}
|
|
/** 初始化 **/
|
onMounted(async () => {
|
await getList()
|
})
|
</script>
|
<style scoped>
|
.mpk-icon-list {
|
height: 30px;
|
margin: 0;
|
}
|
|
</style>
|