提交 | 用户 | 时间
|
aff5c9
|
1 |
<template> |
潘 |
2 |
<!-- 搜索工作栏 --> |
|
3 |
<ContentWrap> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="模型名称" prop="iconName"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.iconName" |
|
14 |
placeholder="请输入名称" |
|
15 |
clearable |
|
16 |
class="!w-240px" |
|
17 |
/> |
|
18 |
</el-form-item> |
|
19 |
<el-form-item> |
|
20 |
<el-button @click="handleQuery"> |
|
21 |
<Icon icon="ep:search" class="mr-5px"/> |
|
22 |
搜索 |
|
23 |
</el-button> |
|
24 |
<el-button @click="resetQuery"> |
|
25 |
<Icon icon="ep:refresh" class="mr-5px"/> |
|
26 |
重置 |
|
27 |
</el-button> |
|
28 |
<el-button |
|
29 |
type="primary" |
|
30 |
plain |
|
31 |
@click="openForm('create')" |
|
32 |
v-hasPermi="['mpk:icon:create']" |
|
33 |
> |
|
34 |
<Icon icon="ep:plus" class="mr-5px" /> |
|
35 |
新增 |
|
36 |
</el-button> |
|
37 |
|
|
38 |
</el-form-item> |
|
39 |
</el-form> |
|
40 |
</ContentWrap> |
|
41 |
|
|
42 |
<!-- 列表 --> |
|
43 |
<ContentWrap> |
|
44 |
<el-table |
|
45 |
v-loading="loading" |
|
46 |
:data="list" |
|
47 |
row-key="id" |
|
48 |
> |
|
49 |
<el-table-column prop="iconName" label="名称"/> |
|
50 |
<el-table-column prop="iconDesc" label="描述"/> |
15ff71
|
51 |
<el-table-column align="center" label="图标" prop="icon" width="100"> |
潘 |
52 |
<template #default="scope"> |
|
53 |
<img :src="'/SimtreeUnitImage/' + scope.row.iconName" class="mpk-icon-list" :alt=" scope.row.iconDesc" /> |
|
54 |
</template> |
|
55 |
</el-table-column> |
aff5c9
|
56 |
<el-table-column prop="sort" label="排序"/> |
潘 |
57 |
<el-table-column label="操作" align="center" width="200px"> |
|
58 |
<template #default="scope"> |
|
59 |
<div class="flex items-center justify-center"> |
|
60 |
<el-button |
|
61 |
link |
|
62 |
type="primary" |
|
63 |
@click="openForm('update', scope.row.id)" |
|
64 |
v-hasPermi="['mpk:icon:update']" |
|
65 |
> |
|
66 |
编辑 |
|
67 |
</el-button> |
|
68 |
<el-button link type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['mpk:icon:delete']"> |
|
69 |
<Icon icon="ep:delete"/>删除 |
|
70 |
</el-button> |
|
71 |
</div> |
|
72 |
</template> |
|
73 |
</el-table-column> |
|
74 |
</el-table> |
|
75 |
<!-- 分页 --> |
|
76 |
<Pagination |
|
77 |
v-model:limit="queryParams.pageSize" |
b45bad
|
78 |
v-model:page="queryParams.pageNo" |
aff5c9
|
79 |
:total="total" |
潘 |
80 |
@pagination="getList" |
|
81 |
/> |
|
82 |
</ContentWrap> |
|
83 |
|
|
84 |
<!-- 表单弹窗:添加/修改 --> |
|
85 |
<IconForm ref="formRef" @success="getList" /> |
|
86 |
</template> |
|
87 |
<script lang="ts" setup> |
|
88 |
import {dateFormatter} from '@/utils/formatTime' |
|
89 |
import * as MpkIconApi from '@/api/model/mpk/icon' |
|
90 |
import IconForm from './IconForm.vue' |
|
91 |
|
|
92 |
defineOptions({name: 'MpkIcon'}) |
|
93 |
|
|
94 |
const message = useMessage() // 消息弹窗 |
|
95 |
const {t} = useI18n() // 国际化 |
|
96 |
|
|
97 |
const loading = ref(true) // 列表的加载中 |
|
98 |
const total = ref(0) // 列表的总页数 |
|
99 |
const list = ref([]) // 字典表格数据 |
|
100 |
const queryParams = reactive({ |
b45bad
|
101 |
pageNo: 1, |
aff5c9
|
102 |
pageSize: 10, |
潘 |
103 |
iconName: '' |
|
104 |
}) |
|
105 |
const queryFormRef = ref() // 搜索的表单 |
|
106 |
|
|
107 |
const getList = async () => { |
|
108 |
loading.value = true |
|
109 |
try { |
|
110 |
const data = await MpkIconApi.getPage(queryParams) |
|
111 |
list.value = data.list |
|
112 |
total.value = data.total |
|
113 |
} finally { |
|
114 |
loading.value = false |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
/** 搜索按钮操作 */ |
|
119 |
const handleQuery = () => { |
|
120 |
getList() |
|
121 |
} |
|
122 |
|
|
123 |
/** 重置按钮操作 */ |
|
124 |
const resetQuery = () => { |
b45bad
|
125 |
queryParams.pageNo = 1 |
aff5c9
|
126 |
queryFormRef.value.resetFields() |
潘 |
127 |
handleQuery() |
|
128 |
} |
|
129 |
|
|
130 |
/** 添加/修改操作 */ |
|
131 |
const formRef = ref() |
|
132 |
const openForm = (type: string, id?: string) => { |
|
133 |
formRef.value.open(type, id) |
|
134 |
} |
|
135 |
|
|
136 |
/** 删除按钮操作 */ |
|
137 |
const handleDelete = async (id: string) => { |
|
138 |
try { |
|
139 |
// 删除的二次确认 |
|
140 |
await message.delConfirm() |
|
141 |
// 发起删除 |
|
142 |
await MpkIconApi.deleteIcon(id) |
|
143 |
message.success(t('common.delSuccess')) |
|
144 |
// 刷新列表 |
|
145 |
await getList() |
|
146 |
} catch { |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
/** 初始化 **/ |
|
151 |
onMounted(async () => { |
|
152 |
await getList() |
|
153 |
}) |
|
154 |
</script> |
15ff71
|
155 |
<style scoped> |
潘 |
156 |
.mpk-icon-list { |
|
157 |
height: 30px; |
|
158 |
margin: 0; |
|
159 |
} |
|
160 |
|
|
161 |
</style> |