提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
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="username"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.username" |
|
14 |
placeholder="请输入用户名称" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
class="!w-240px" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="登录地址" prop="userIp"> |
|
21 |
<el-input |
|
22 |
v-model="queryParams.userIp" |
|
23 |
placeholder="请输入登录地址" |
|
24 |
clearable |
|
25 |
@keyup.enter="handleQuery" |
|
26 |
class="!w-240px" |
|
27 |
/> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item label="登录日期" prop="createTime"> |
|
30 |
<el-date-picker |
|
31 |
v-model="queryParams.createTime" |
|
32 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
33 |
type="daterange" |
|
34 |
start-placeholder="开始日期" |
|
35 |
end-placeholder="结束日期" |
|
36 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
37 |
class="!w-240px" |
|
38 |
/> |
|
39 |
</el-form-item> |
|
40 |
<el-form-item> |
|
41 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
42 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
43 |
<el-button |
|
44 |
type="success" |
|
45 |
plain |
|
46 |
@click="handleExport" |
|
47 |
:loading="exportLoading" |
|
48 |
v-hasPermi="['infra:login-log:export']" |
|
49 |
> |
|
50 |
<Icon icon="ep:download" class="mr-5px" /> 导出 |
|
51 |
</el-button> |
|
52 |
</el-form-item> |
|
53 |
</el-form> |
|
54 |
</ContentWrap> |
|
55 |
|
|
56 |
<!-- 列表 --> |
|
57 |
<ContentWrap> |
|
58 |
<el-table v-loading="loading" :data="list"> |
|
59 |
<el-table-column label="日志编号" align="center" prop="id" /> |
|
60 |
<el-table-column label="操作类型" align="center" prop="logType"> |
|
61 |
<template #default="scope"> |
|
62 |
<dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="scope.row.logType" /> |
|
63 |
</template> |
|
64 |
</el-table-column> |
|
65 |
<el-table-column label="用户名称" align="center" prop="username" width="180" /> |
|
66 |
<el-table-column label="登录地址" align="center" prop="userIp" width="180" /> |
|
67 |
<el-table-column label="浏览器" align="center" prop="userAgent" /> |
|
68 |
<el-table-column label="登陆结果" align="center" prop="result"> |
|
69 |
<template #default="scope"> |
|
70 |
<dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="scope.row.result" /> |
|
71 |
</template> |
|
72 |
</el-table-column> |
|
73 |
<el-table-column |
|
74 |
label="登录日期" |
|
75 |
align="center" |
|
76 |
prop="createTime" |
|
77 |
width="180" |
|
78 |
:formatter="dateFormatter" |
|
79 |
/> |
|
80 |
<el-table-column label="操作" align="center"> |
|
81 |
<template #default="scope"> |
|
82 |
<el-button |
|
83 |
link |
|
84 |
type="primary" |
|
85 |
@click="openDetail(scope.row)" |
|
86 |
v-hasPermi="['infra:login-log:query']" |
|
87 |
> |
|
88 |
详情 |
|
89 |
</el-button> |
|
90 |
</template> |
|
91 |
</el-table-column> |
|
92 |
</el-table> |
|
93 |
<!-- 分页 --> |
|
94 |
<Pagination |
|
95 |
:total="total" |
|
96 |
v-model:page="queryParams.pageNo" |
|
97 |
v-model:limit="queryParams.pageSize" |
|
98 |
@pagination="getList" |
|
99 |
/> |
|
100 |
</ContentWrap> |
|
101 |
|
|
102 |
<!-- 表单弹窗:详情 --> |
|
103 |
<LoginLogDetail ref="detailRef" /> |
|
104 |
</template> |
|
105 |
<script lang="ts" setup> |
|
106 |
import { DICT_TYPE } from '@/utils/dict' |
|
107 |
import { dateFormatter } from '@/utils/formatTime' |
|
108 |
import download from '@/utils/download' |
|
109 |
import * as LoginLogApi from '@/api/system/loginLog' |
|
110 |
import LoginLogDetail from './LoginLogDetail.vue' |
|
111 |
|
|
112 |
defineOptions({ name: 'SystemLoginLog' }) |
|
113 |
|
|
114 |
const message = useMessage() // 消息弹窗 |
|
115 |
|
|
116 |
const loading = ref(true) // 列表的加载中 |
|
117 |
const total = ref(0) // 列表的总页数 |
|
118 |
const list = ref([]) // 列表的数据 |
|
119 |
const queryParams = reactive({ |
|
120 |
pageNo: 1, |
|
121 |
pageSize: 10, |
|
122 |
username: undefined, |
|
123 |
userIp: undefined, |
|
124 |
createTime: [] |
|
125 |
}) |
|
126 |
const queryFormRef = ref() // 搜索的表单 |
|
127 |
const exportLoading = ref(false) // 导出的加载中 |
|
128 |
|
|
129 |
/** 查询列表 */ |
|
130 |
const getList = async () => { |
|
131 |
loading.value = true |
|
132 |
try { |
|
133 |
const data = await LoginLogApi.getLoginLogPage(queryParams) |
|
134 |
list.value = data.list |
|
135 |
total.value = data.total |
|
136 |
} finally { |
|
137 |
loading.value = false |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
/** 搜索按钮操作 */ |
|
142 |
const handleQuery = () => { |
|
143 |
queryParams.pageNo = 1 |
|
144 |
getList() |
|
145 |
} |
|
146 |
|
|
147 |
/** 重置按钮操作 */ |
|
148 |
const resetQuery = () => { |
|
149 |
queryFormRef.value.resetFields() |
|
150 |
handleQuery() |
|
151 |
} |
|
152 |
|
|
153 |
/** 详情操作 */ |
|
154 |
const detailRef = ref() |
|
155 |
const openDetail = (data: LoginLogApi.LoginLogVO) => { |
|
156 |
detailRef.value.open(data) |
|
157 |
} |
|
158 |
|
|
159 |
/** 导出按钮操作 */ |
|
160 |
const handleExport = async () => { |
|
161 |
try { |
|
162 |
// 导出的二次确认 |
|
163 |
await message.exportConfirm() |
|
164 |
// 发起导出 |
|
165 |
exportLoading.value = true |
|
166 |
const data = await LoginLogApi.exportLoginLog(queryParams) |
|
167 |
download.excel(data, '登录日志.xls') |
|
168 |
} catch { |
|
169 |
} finally { |
|
170 |
exportLoading.value = false |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
/** 初始化 **/ |
|
175 |
onMounted(() => { |
|
176 |
getList() |
|
177 |
}) |
|
178 |
</script> |