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