提交 | 用户 | 时间
|
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="userId"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.userId" |
|
14 |
placeholder="请输入用户编号" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
class="!w-240px" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="用户类型" prop="userType"> |
|
21 |
<el-select |
|
22 |
v-model="queryParams.userType" |
|
23 |
placeholder="请选择用户类型" |
|
24 |
clearable |
|
25 |
class="!w-240px" |
|
26 |
> |
|
27 |
<el-option |
|
28 |
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)" |
|
29 |
:key="dict.value" |
|
30 |
:label="dict.label" |
|
31 |
:value="dict.value" |
|
32 |
/> |
|
33 |
</el-select> |
|
34 |
</el-form-item> |
|
35 |
<el-form-item label="应用名" prop="applicationName"> |
|
36 |
<el-input |
|
37 |
v-model="queryParams.applicationName" |
|
38 |
placeholder="请输入应用名" |
|
39 |
clearable |
|
40 |
@keyup.enter="handleQuery" |
|
41 |
class="!w-240px" |
|
42 |
/> |
|
43 |
</el-form-item> |
|
44 |
<el-form-item label="请求时间" prop="beginTime"> |
|
45 |
<el-date-picker |
|
46 |
v-model="queryParams.beginTime" |
|
47 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
48 |
type="daterange" |
|
49 |
start-placeholder="开始日期" |
|
50 |
end-placeholder="结束日期" |
|
51 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
52 |
class="!w-240px" |
|
53 |
/> |
|
54 |
</el-form-item> |
|
55 |
<el-form-item label="执行时长" prop="duration"> |
|
56 |
<el-input |
|
57 |
v-model="queryParams.duration" |
|
58 |
placeholder="请输入执行时长" |
|
59 |
clearable |
|
60 |
@keyup.enter="handleQuery" |
|
61 |
class="!w-240px" |
|
62 |
/> |
|
63 |
</el-form-item> |
|
64 |
<el-form-item label="结果码" prop="resultCode"> |
|
65 |
<el-input |
|
66 |
v-model="queryParams.resultCode" |
|
67 |
placeholder="请输入结果码" |
|
68 |
clearable |
|
69 |
@keyup.enter="handleQuery" |
|
70 |
class="!w-240px" |
|
71 |
/> |
|
72 |
</el-form-item> |
|
73 |
<el-form-item> |
|
74 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
75 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
76 |
<el-button |
|
77 |
type="success" |
|
78 |
plain |
|
79 |
@click="handleExport" |
|
80 |
:loading="exportLoading" |
|
81 |
v-hasPermi="['infra:api-access-log:export']" |
|
82 |
> |
|
83 |
<Icon icon="ep:download" class="mr-5px" /> 导出 |
|
84 |
</el-button> |
|
85 |
</el-form-item> |
|
86 |
</el-form> |
|
87 |
</ContentWrap> |
|
88 |
|
|
89 |
<!-- 列表 --> |
|
90 |
<ContentWrap> |
|
91 |
<el-table v-loading="loading" :data="list"> |
|
92 |
<el-table-column label="日志编号" align="center" prop="id" width="100" fix="right" /> |
|
93 |
<el-table-column label="用户编号" align="center" prop="userId" /> |
|
94 |
<el-table-column label="用户类型" align="center" prop="userType"> |
|
95 |
<template #default="scope"> |
|
96 |
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" /> |
|
97 |
</template> |
|
98 |
</el-table-column> |
|
99 |
<el-table-column label="应用名" align="center" prop="applicationName" width="150" /> |
|
100 |
<el-table-column label="请求方法" align="center" prop="requestMethod" width="80" /> |
|
101 |
<el-table-column label="请求地址" align="center" prop="requestUrl" width="500" /> |
|
102 |
<el-table-column label="请求时间" align="center" prop="beginTime" width="180"> |
|
103 |
<template #default="scope"> |
|
104 |
<span>{{ formatDate(scope.row.beginTime) }}</span> |
|
105 |
</template> |
|
106 |
</el-table-column> |
|
107 |
<el-table-column label="执行时长" align="center" prop="duration" width="180"> |
|
108 |
<template #default="scope"> {{ scope.row.duration }} ms </template> |
|
109 |
</el-table-column> |
|
110 |
<el-table-column label="操作结果" align="center" prop="status"> |
|
111 |
<template #default="scope"> |
|
112 |
{{ scope.row.resultCode === 0 ? '成功' : '失败(' + scope.row.resultMsg + ')' }} |
|
113 |
</template> |
|
114 |
</el-table-column> |
|
115 |
<el-table-column label="操作模块" align="center" prop="operateModule" width="180" /> |
|
116 |
<el-table-column label="操作名" align="center" prop="operateName" width="180" /> |
|
117 |
<el-table-column label="操作类型" align="center" prop="operateType"> |
|
118 |
<template #default="scope"> |
|
119 |
<dict-tag :type="DICT_TYPE.INFRA_OPERATE_TYPE" :value="scope.row.operateType" /> |
|
120 |
</template> |
|
121 |
</el-table-column> |
|
122 |
<el-table-column label="操作" align="center" fixed="right" width="60"> |
|
123 |
<template #default="scope"> |
|
124 |
<el-button |
|
125 |
link |
|
126 |
type="primary" |
|
127 |
@click="openDetail(scope.row)" |
|
128 |
v-hasPermi="['infra:api-access-log:query']" |
|
129 |
> |
|
130 |
详细 |
|
131 |
</el-button> |
|
132 |
</template> |
|
133 |
</el-table-column> |
|
134 |
</el-table> |
|
135 |
<!-- 分页组件 --> |
|
136 |
<Pagination |
|
137 |
:total="total" |
|
138 |
v-model:page="queryParams.pageNo" |
|
139 |
v-model:limit="queryParams.pageSize" |
|
140 |
@pagination="getList" |
|
141 |
/> |
|
142 |
</ContentWrap> |
|
143 |
|
|
144 |
<!-- 表单弹窗:详情 --> |
|
145 |
<ApiAccessLogDetail ref="detailRef" /> |
|
146 |
</template> |
|
147 |
<script lang="ts" setup> |
|
148 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
149 |
import download from '@/utils/download' |
|
150 |
import { formatDate } from '@/utils/formatTime' |
|
151 |
import * as ApiAccessLogApi from '@/api/infra/apiAccessLog' |
|
152 |
import ApiAccessLogDetail from './ApiAccessLogDetail.vue' |
|
153 |
|
|
154 |
defineOptions({ name: 'InfraApiAccessLog' }) |
|
155 |
|
|
156 |
const message = useMessage() // 消息弹窗 |
|
157 |
|
|
158 |
const loading = ref(true) // 列表的加载中 |
|
159 |
const total = ref(0) // 列表的总页数 |
|
160 |
const list = ref([]) // 列表的数据 |
|
161 |
const queryParams = reactive({ |
|
162 |
pageNo: 1, |
|
163 |
pageSize: 10, |
|
164 |
userId: null, |
|
165 |
userType: null, |
|
166 |
applicationName: null, |
|
167 |
requestUrl: null, |
|
168 |
duration: null, |
|
169 |
resultCode: null, |
|
170 |
beginTime: [] |
|
171 |
}) |
|
172 |
const queryFormRef = ref() // 搜索的表单 |
|
173 |
const exportLoading = ref(false) // 导出的加载中 |
|
174 |
|
|
175 |
/** 查询列表 */ |
|
176 |
const getList = async () => { |
|
177 |
loading.value = true |
|
178 |
try { |
|
179 |
const data = await ApiAccessLogApi.getApiAccessLogPage(queryParams) |
|
180 |
list.value = data.list |
|
181 |
total.value = data.total |
|
182 |
} finally { |
|
183 |
loading.value = false |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
/** 搜索按钮操作 */ |
|
188 |
const handleQuery = () => { |
|
189 |
queryParams.pageNo = 1 |
|
190 |
getList() |
|
191 |
} |
|
192 |
|
|
193 |
/** 重置按钮操作 */ |
|
194 |
const resetQuery = () => { |
|
195 |
queryFormRef.value.resetFields() |
|
196 |
handleQuery() |
|
197 |
} |
|
198 |
|
|
199 |
/** 详情操作 */ |
|
200 |
const detailRef = ref() |
|
201 |
const openDetail = (data: ApiAccessLogApi.ApiAccessLogVO) => { |
|
202 |
detailRef.value.open(data) |
|
203 |
} |
|
204 |
|
|
205 |
/** 导出按钮操作 */ |
|
206 |
const handleExport = async () => { |
|
207 |
try { |
|
208 |
// 导出的二次确认 |
|
209 |
await message.exportConfirm() |
|
210 |
// 发起导出 |
|
211 |
exportLoading.value = true |
|
212 |
const data = await ApiAccessLogApi.exportApiAccessLog(queryParams) |
|
213 |
download.excel(data, 'API 访问日志.xls') |
|
214 |
} catch { |
|
215 |
} finally { |
|
216 |
exportLoading.value = false |
|
217 |
} |
|
218 |
} |
|
219 |
|
|
220 |
/** 初始化 **/ |
|
221 |
onMounted(() => { |
|
222 |
getList() |
|
223 |
}) |
|
224 |
</script> |