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