提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form |
|
5 |
ref="queryFormRef" |
|
6 |
:inline="true" |
|
7 |
:model="queryParams" |
|
8 |
class="-mb-15px" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="角色名称" prop="name"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.name" |
|
14 |
class="!w-240px" |
|
15 |
clearable |
|
16 |
placeholder="请输入角色名称" |
|
17 |
@keyup.enter="handleQuery" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="角色标识" prop="code"> |
|
21 |
<el-input |
|
22 |
v-model="queryParams.code" |
|
23 |
class="!w-240px" |
|
24 |
clearable |
|
25 |
placeholder="请输入角色标识" |
|
26 |
@keyup.enter="handleQuery" |
|
27 |
/> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item label="状态" prop="status"> |
|
30 |
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择状态"> |
|
31 |
<el-option |
|
32 |
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" |
|
33 |
:key="dict.value" |
|
34 |
:label="dict.label" |
|
35 |
:value="dict.value" |
|
36 |
/> |
|
37 |
</el-select> |
|
38 |
</el-form-item> |
|
39 |
<el-form-item label="创建时间" prop="createTime"> |
|
40 |
<el-date-picker |
|
41 |
v-model="queryParams.createTime" |
|
42 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
43 |
class="!w-240px" |
|
44 |
end-placeholder="结束日期" |
|
45 |
start-placeholder="开始日期" |
|
46 |
type="daterange" |
|
47 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
48 |
/> |
|
49 |
</el-form-item> |
|
50 |
<el-form-item> |
|
51 |
<el-button @click="handleQuery"> |
|
52 |
<Icon class="mr-5px" icon="ep:search" /> |
|
53 |
搜索 |
|
54 |
</el-button> |
|
55 |
<el-button @click="resetQuery"> |
|
56 |
<Icon class="mr-5px" icon="ep:refresh" /> |
|
57 |
重置 |
|
58 |
</el-button> |
|
59 |
<el-button |
|
60 |
v-hasPermi="['system:role:create']" |
|
61 |
plain |
|
62 |
type="primary" |
|
63 |
@click="openForm('create')" |
|
64 |
> |
|
65 |
<Icon class="mr-5px" icon="ep:plus" /> |
|
66 |
新增 |
|
67 |
</el-button> |
|
68 |
<el-button |
|
69 |
v-hasPermi="['system:role:export']" |
|
70 |
:loading="exportLoading" |
|
71 |
plain |
|
72 |
type="success" |
|
73 |
@click="handleExport" |
|
74 |
> |
|
75 |
<Icon class="mr-5px" icon="ep:download" /> |
|
76 |
导出 |
|
77 |
</el-button> |
|
78 |
</el-form-item> |
|
79 |
</el-form> |
|
80 |
</ContentWrap> |
|
81 |
|
|
82 |
<!-- 列表 --> |
|
83 |
<ContentWrap> |
|
84 |
<el-table v-loading="loading" :data="list"> |
|
85 |
<el-table-column align="center" label="角色编号" prop="id" /> |
|
86 |
<el-table-column align="center" label="角色名称" prop="name" /> |
|
87 |
<el-table-column label="角色类型" align="center" prop="type"> |
|
88 |
<template #default="scope"> |
|
89 |
<dict-tag :type="DICT_TYPE.SYSTEM_ROLE_TYPE" :value="scope.row.type" /> |
|
90 |
</template> |
|
91 |
</el-table-column> |
|
92 |
<el-table-column align="center" label="角色标识" prop="code" /> |
|
93 |
<el-table-column align="center" label="显示顺序" prop="sort" /> |
|
94 |
<el-table-column align="center" label="备注" prop="remark" /> |
|
95 |
<el-table-column align="center" label="状态" prop="status"> |
|
96 |
<template #default="scope"> |
|
97 |
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
|
98 |
</template> |
|
99 |
</el-table-column> |
|
100 |
<el-table-column |
|
101 |
:formatter="dateFormatter" |
|
102 |
align="center" |
|
103 |
label="创建时间" |
|
104 |
prop="createTime" |
|
105 |
width="180" |
|
106 |
/> |
|
107 |
<el-table-column :width="300" align="center" label="操作"> |
|
108 |
<template #default="scope"> |
|
109 |
<el-button |
|
110 |
v-hasPermi="['system:role:update']" |
|
111 |
link |
|
112 |
type="primary" |
|
113 |
@click="openForm('update', scope.row.id)" |
|
114 |
> |
|
115 |
编辑 |
|
116 |
</el-button> |
|
117 |
<el-button |
|
118 |
v-hasPermi="['system:permission:assign-role-menu']" |
|
119 |
link |
|
120 |
preIcon="ep:basketball" |
|
121 |
title="菜单权限" |
|
122 |
type="primary" |
|
123 |
@click="openAssignMenuForm(scope.row)" |
|
124 |
> |
|
125 |
菜单权限 |
|
126 |
</el-button> |
|
127 |
<el-button |
9259c2
|
128 |
v-hasPermi="['system:permission:assign-role-data-scope']" |
H |
129 |
link |
|
130 |
preIcon="ep:coin" |
|
131 |
title="数据权限" |
|
132 |
type="primary" |
|
133 |
@click="openDataPermissionForm(scope.row)" |
|
134 |
> |
|
135 |
数据权限 |
|
136 |
</el-button> |
|
137 |
<el-button |
820397
|
138 |
v-hasPermi="['system:role:delete']" |
H |
139 |
link |
|
140 |
type="danger" |
|
141 |
@click="handleDelete(scope.row.id)" |
|
142 |
> |
|
143 |
删除 |
|
144 |
</el-button> |
|
145 |
</template> |
|
146 |
</el-table-column> |
|
147 |
</el-table> |
|
148 |
<!-- 分页 --> |
|
149 |
<Pagination |
|
150 |
v-model:limit="queryParams.pageSize" |
|
151 |
v-model:page="queryParams.pageNo" |
|
152 |
:total="total" |
|
153 |
@pagination="getList" |
|
154 |
/> |
|
155 |
</ContentWrap> |
|
156 |
|
|
157 |
<!-- 表单弹窗:添加/修改 --> |
|
158 |
<RoleForm ref="formRef" @success="getList" /> |
|
159 |
<!-- 表单弹窗:菜单权限 --> |
|
160 |
<RoleAssignMenuForm ref="assignMenuFormRef" @success="getList" /> |
|
161 |
<!-- 表单弹窗:数据权限 --> |
|
162 |
<RoleDataPermissionForm ref="dataPermissionFormRef" @success="getList" /> |
|
163 |
</template> |
|
164 |
<script lang="ts" setup> |
|
165 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
166 |
import { dateFormatter } from '@/utils/formatTime' |
|
167 |
import download from '@/utils/download' |
|
168 |
import * as RoleApi from '@/api/system/role' |
|
169 |
import RoleForm from './RoleForm.vue' |
|
170 |
import RoleAssignMenuForm from './RoleAssignMenuForm.vue' |
|
171 |
import RoleDataPermissionForm from './RoleDataPermissionForm.vue' |
|
172 |
|
|
173 |
defineOptions({ name: 'SystemRole' }) |
|
174 |
|
|
175 |
const message = useMessage() // 消息弹窗 |
|
176 |
const { t } = useI18n() // 国际化 |
|
177 |
|
|
178 |
const loading = ref(true) // 列表的加载中 |
|
179 |
const total = ref(0) // 列表的总页数 |
|
180 |
const list = ref([]) // 列表的数据 |
|
181 |
const queryParams = reactive({ |
|
182 |
pageNo: 1, |
|
183 |
pageSize: 10, |
|
184 |
code: '', |
|
185 |
name: '', |
|
186 |
status: undefined, |
|
187 |
createTime: [] |
|
188 |
}) |
|
189 |
const queryFormRef = ref() // 搜索的表单 |
|
190 |
const exportLoading = ref(false) // 导出的加载中 |
|
191 |
|
|
192 |
/** 查询角色列表 */ |
|
193 |
const getList = async () => { |
|
194 |
loading.value = true |
|
195 |
try { |
|
196 |
const data = await RoleApi.getRolePage(queryParams) |
|
197 |
list.value = data.list |
|
198 |
total.value = data.total |
|
199 |
} finally { |
|
200 |
loading.value = false |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
/** 搜索按钮操作 */ |
|
205 |
const handleQuery = () => { |
|
206 |
queryParams.pageNo = 1 |
|
207 |
getList() |
|
208 |
} |
|
209 |
|
|
210 |
/** 重置按钮操作 */ |
|
211 |
const resetQuery = () => { |
|
212 |
queryFormRef.value.resetFields() |
|
213 |
handleQuery() |
|
214 |
} |
|
215 |
|
|
216 |
/** 添加/修改操作 */ |
|
217 |
const formRef = ref() |
|
218 |
const openForm = (type: string, id?: number) => { |
|
219 |
formRef.value.open(type, id) |
|
220 |
} |
|
221 |
|
|
222 |
/** 数据权限操作 */ |
|
223 |
const dataPermissionFormRef = ref() |
|
224 |
const openDataPermissionForm = async (row: RoleApi.RoleVO) => { |
|
225 |
dataPermissionFormRef.value.open(row) |
|
226 |
} |
|
227 |
|
|
228 |
/** 菜单权限操作 */ |
|
229 |
const assignMenuFormRef = ref() |
|
230 |
const openAssignMenuForm = async (row: RoleApi.RoleVO) => { |
|
231 |
assignMenuFormRef.value.open(row) |
|
232 |
} |
|
233 |
|
|
234 |
/** 删除按钮操作 */ |
|
235 |
const handleDelete = async (id: number) => { |
|
236 |
try { |
|
237 |
// 删除的二次确认 |
|
238 |
await message.delConfirm() |
|
239 |
// 发起删除 |
|
240 |
await RoleApi.deleteRole(id) |
|
241 |
message.success(t('common.delSuccess')) |
|
242 |
// 刷新列表 |
|
243 |
await getList() |
|
244 |
} catch {} |
|
245 |
} |
|
246 |
|
|
247 |
/** 导出按钮操作 */ |
|
248 |
const handleExport = async () => { |
|
249 |
try { |
|
250 |
// 导出的二次确认 |
|
251 |
await message.exportConfirm() |
|
252 |
// 发起导出 |
|
253 |
exportLoading.value = true |
|
254 |
const data = await RoleApi.exportRole(queryParams) |
|
255 |
download.excel(data, '角色列表.xls') |
|
256 |
} catch { |
|
257 |
} finally { |
|
258 |
exportLoading.value = false |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
/** 初始化 **/ |
|
263 |
onMounted(() => { |
|
264 |
getList() |
|
265 |
}) |
|
266 |
</script> |