Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2d4e7e7d
authored
Mar 22, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vue3 重构:REVIEW 错误日志
parent
944b70c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
71 deletions
+62
-71
src/api/infra/apiErrorLog/index.ts
+3
-21
src/views/infra/apiErrorLog/ApiErrorLogDetail.vue
+12
-9
src/views/infra/apiErrorLog/index.vue
+47
-41
No files found.
src/api/infra/apiErrorLog/index.ts
View file @
2d4e7e7d
...
@@ -27,38 +27,20 @@ export interface ApiErrorLogVO {
...
@@ -27,38 +27,20 @@ export interface ApiErrorLogVO {
createTime
:
Date
createTime
:
Date
}
}
export
interface
ApiErrorLogPageReqVO
extends
PageParam
{
userId
?:
number
userType
?:
number
applicationName
?:
string
requestUrl
?:
string
exceptionTime
?:
Date
[]
processStatus
:
number
}
export
interface
ApiErrorLogExportReqVO
{
userId
?:
number
userType
?:
number
applicationName
?:
string
requestUrl
?:
string
exceptionTime
?:
Date
[]
processStatus
:
number
}
// 查询列表API 访问日志
// 查询列表API 访问日志
export
const
getApiErrorLogPage
Api
=
(
params
:
PageParam
)
=>
{
export
const
getApiErrorLogPage
=
(
params
:
PageParam
)
=>
{
return
request
.
get
({
url
:
'/infra/api-error-log/page'
,
params
})
return
request
.
get
({
url
:
'/infra/api-error-log/page'
,
params
})
}
}
// 更新 API 错误日志的处理状态
// 更新 API 错误日志的处理状态
export
const
updateApiErrorLogPage
Api
=
(
id
:
number
,
processStatus
:
number
)
=>
{
export
const
updateApiErrorLogPage
=
(
id
:
number
,
processStatus
:
number
)
=>
{
return
request
.
put
({
return
request
.
put
({
url
:
'/infra/api-error-log/update-status?id='
+
id
+
'&processStatus='
+
processStatus
url
:
'/infra/api-error-log/update-status?id='
+
id
+
'&processStatus='
+
processStatus
})
})
}
}
// 导出API 访问日志
// 导出API 访问日志
export
const
exportApiErrorLog
Api
=
(
params
)
=>
{
export
const
exportApiErrorLog
=
(
params
)
=>
{
return
request
.
download
({
return
request
.
download
({
url
:
'/infra/api-error-log/export-excel'
,
url
:
'/infra/api-error-log/export-excel'
,
params
params
...
...
src/views/infra/apiErrorLog/
d
etail.vue
→
src/views/infra/apiErrorLog/
ApiErrorLogD
etail.vue
View file @
2d4e7e7d
...
@@ -10,13 +10,18 @@
...
@@ -10,13 +10,18 @@
<el-descriptions-item
label=
"应用名"
>
<el-descriptions-item
label=
"应用名"
>
{{
detailData
.
applicationName
}}
{{
detailData
.
applicationName
}}
</el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item
label=
"用户
信息
"
>
<el-descriptions-item
label=
"用户
编号
"
>
{{
detailData
.
userId
}}
|
{{
detailData
.
userId
}}
<dict-tag
:type=
"DICT_TYPE.USER_TYPE"
:value=
"detailData.userType"
/>
<dict-tag
:type=
"DICT_TYPE.USER_TYPE"
:value=
"detailData.userType"
/>
|
{{
detailData
.
userIp
}}
|
{{
detailData
.
userAgent
}}
</el-descriptions-item>
<el-descriptions-item
label=
"用户 IP"
>
{{
detailData
.
userIp
}}
</el-descriptions-item>
<el-descriptions-item
label=
"用户 UA"
>
{{
detailData
.
userAgent
}}
</el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item
label=
"请求信息"
>
<el-descriptions-item
label=
"请求信息"
>
{{
detailData
.
requestMethod
}}
|
{{
detailData
.
requestUrl
}}
{{
detailData
.
requestMethod
}}
{{
detailData
.
requestUrl
}}
</el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item
label=
"请求参数"
>
<el-descriptions-item
label=
"请求参数"
>
{{
detailData
.
requestParams
}}
{{
detailData
.
requestParams
}}
...
@@ -27,7 +32,7 @@
...
@@ -27,7 +32,7 @@
<el-descriptions-item
label=
"异常名"
>
<el-descriptions-item
label=
"异常名"
>
{{
detailData
.
exceptionName
}}
{{
detailData
.
exceptionName
}}
</el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item
label=
"异常
名
"
v-if=
"detailData.exceptionStackTrace"
>
<el-descriptions-item
label=
"异常
堆栈
"
v-if=
"detailData.exceptionStackTrace"
>
<el-input
<el-input
type=
"textarea"
type=
"textarea"
:readonly=
"true"
:readonly=
"true"
...
@@ -50,7 +55,6 @@
...
@@ -50,7 +55,6 @@
</el-descriptions>
</el-descriptions>
</Dialog>
</Dialog>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
DICT_TYPE
}
from
'@/utils/dict'
import
{
DICT_TYPE
}
from
'@/utils/dict'
import
{
formatDate
}
from
'@/utils/formatTime'
import
{
formatDate
}
from
'@/utils/formatTime'
...
@@ -61,7 +65,7 @@ const detailLoading = ref(false) // 表单的加载中
...
@@ -61,7 +65,7 @@ const detailLoading = ref(false) // 表单的加载中
const
detailData
=
ref
()
// 详情数据
const
detailData
=
ref
()
// 详情数据
/** 打开弹窗 */
/** 打开弹窗 */
const
open
Modal
=
async
(
data
:
ApiErrorLog
.
ApiErrorLogVO
)
=>
{
const
open
=
async
(
data
:
ApiErrorLog
.
ApiErrorLogVO
)
=>
{
modelVisible
.
value
=
true
modelVisible
.
value
=
true
// 设置数据
// 设置数据
detailLoading
.
value
=
true
detailLoading
.
value
=
true
...
@@ -71,6 +75,5 @@ const openModal = async (data: ApiErrorLog.ApiErrorLogVO) => {
...
@@ -71,6 +75,5 @@ const openModal = async (data: ApiErrorLog.ApiErrorLogVO) => {
detailLoading
.
value
=
false
detailLoading
.
value
=
false
}
}
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
defineExpose
({
openModal
})
// 提供 openModal 方法,用于打开弹窗
</
script
>
</
script
>
src/views/infra/apiErrorLog/index.vue
View file @
2d4e7e7d
<
template
>
<
template
>
<
content-w
rap>
<
ContentW
rap>
<!-- 搜索工作栏 -->
<!-- 搜索工作栏 -->
<el-form
<el-form
class=
"-mb-15px"
class=
"-mb-15px"
...
@@ -25,10 +25,10 @@
...
@@ -25,10 +25,10 @@
class=
"!w-240px"
class=
"!w-240px"
>
>
<el-option
<el-option
v-for=
"dict in getDictOptions(DICT_TYPE.USER_TYPE)"
v-for=
"dict in get
Int
DictOptions(DICT_TYPE.USER_TYPE)"
:key=
"
parseInt(dict.value)
"
:key=
"
dict.value
"
:label=
"dict.label"
:label=
"dict.label"
:value=
"
parseInt(dict.value)
"
:value=
"
dict.value
"
/>
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
...
@@ -53,12 +53,17 @@
...
@@ -53,12 +53,17 @@
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"处理状态"
prop=
"processStatus"
>
<el-form-item
label=
"处理状态"
prop=
"processStatus"
>
<el-select
v-model=
"queryParams.processStatus"
placeholder=
"请选择处理状态"
clearable
>
<el-select
v-model=
"queryParams.processStatus"
placeholder=
"请选择处理状态"
clearable
class=
"!w-240px"
>
<el-option
<el-option
v-for=
"dict in getDictOptions(DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS)"
v-for=
"dict in get
Int
DictOptions(DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS)"
:key=
"
parseInt(dict.value)
"
:key=
"
dict.value
"
:label=
"dict.label"
:label=
"dict.label"
:value=
"
parseInt(dict.value)
"
:value=
"
dict.value
"
/>
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
...
@@ -76,9 +81,10 @@
...
@@ -76,9 +81,10 @@
</el-button>
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</content-wrap>
</ContentWrap>
<!-- 列表 -->
<!-- 列表 -->
<
content-w
rap>
<
ContentW
rap>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table-column
label=
"日志编号"
align=
"center"
prop=
"id"
/>
<el-table-column
label=
"日志编号"
align=
"center"
prop=
"id"
/>
<el-table-column
label=
"用户编号"
align=
"center"
prop=
"userId"
/>
<el-table-column
label=
"用户编号"
align=
"center"
prop=
"userId"
/>
...
@@ -87,15 +93,17 @@
...
@@ -87,15 +93,17 @@
<dict-tag
:type=
"DICT_TYPE.USER_TYPE"
:value=
"scope.row.userType"
/>
<dict-tag
:type=
"DICT_TYPE.USER_TYPE"
:value=
"scope.row.userType"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"应用名"
align=
"center"
prop=
"applicationName"
/>
<el-table-column
label=
"应用名"
align=
"center"
prop=
"applicationName"
width=
"200"
/>
<el-table-column
label=
"请求方法名"
align=
"center"
prop=
"requestMethod"
/>
<el-table-column
label=
"请求方法"
align=
"center"
prop=
"requestMethod"
width=
"80"
/>
<el-table-column
label=
"请求地址"
align=
"center"
prop=
"requestUrl"
width=
"250"
/>
<el-table-column
label=
"请求地址"
align=
"center"
prop=
"requestUrl"
width=
"180"
/>
<el-table-column
label=
"异常发生时间"
align=
"center"
prop=
"exceptionTime"
width=
"180"
>
<el-table-column
<
template
#
default=
"scope"
>
label=
"异常发生时间"
<span>
{{
scope
.
row
.
exceptionTime
}}
</span>
align=
"center"
</
template
>
prop=
"exceptionTime"
</el-table-column>
width=
"180"
<el-table-column
label=
"异常名"
align=
"center"
prop=
"exceptionName"
width=
"250"
/>
:formatter=
"dateFormatter"
/>
<el-table-column
label=
"异常名"
align=
"center"
prop=
"exceptionName"
width=
"180"
/>
<el-table-column
label=
"处理状态"
align=
"center"
prop=
"processStatus"
>
<el-table-column
label=
"处理状态"
align=
"center"
prop=
"processStatus"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<dict-tag
<dict-tag
...
@@ -104,12 +112,12 @@
...
@@ -104,12 +112,12 @@
/>
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
>
<el-table-column
label=
"操作"
align=
"center"
width=
"200"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"open
Moda
l(scope.row)"
@
click=
"open
Detai
l(scope.row)"
v-hasPermi=
"['infra:api-access-log:query']"
v-hasPermi=
"['infra:api-access-log:query']"
>
>
详细
详细
...
@@ -118,9 +126,7 @@
...
@@ -118,9 +126,7 @@
link
link
type=
"primary"
type=
"primary"
v-if=
"scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
v-if=
"scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
@
click=
"
@
click=
"handleProcess(scope.row.id, InfraApiErrorLogProcessStatusEnum.DONE)"
handleProcessClick(InfraApiErrorLogProcessStatusEnum.DONE, '已处理', scope.row.id)
"
v-hasPermi=
"['infra:api-error-log:update-status']"
v-hasPermi=
"['infra:api-error-log:update-status']"
>
>
已处理
已处理
...
@@ -128,11 +134,8 @@
...
@@ -128,11 +134,8 @@
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
icon=
"el-icon-check"
v-if=
"scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
v-if=
"scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
@
click=
"
@
click=
"handleProcess(scope.row.id, InfraApiErrorLogProcessStatusEnum.IGNORE)"
handleProcessClick(InfraApiErrorLogProcessStatusEnum.IGNORE, '已忽略', scope.row.id)
"
v-hasPermi=
"['infra:api-error-log:update-status']"
v-hasPermi=
"['infra:api-error-log:update-status']"
>
>
已忽略
已忽略
...
@@ -140,7 +143,6 @@
...
@@ -140,7 +143,6 @@
</
template
>
</
template
>
</el-table-column>
</el-table-column>
</el-table>
</el-table>
<!-- 分页组件 -->
<!-- 分页组件 -->
<Pagination
<Pagination
:total=
"total"
:total=
"total"
...
@@ -148,18 +150,20 @@
...
@@ -148,18 +150,20 @@
v-model:limit=
"queryParams.pageSize"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
@
pagination=
"getList"
/>
/>
</
content-w
rap>
</
ContentW
rap>
<!-- 表单弹窗:详情 -->
<!-- 表单弹窗:详情 -->
<
api-error-log-detail
ref=
"moda
lRef"
/>
<
ApiErrorLogDetail
ref=
"detai
lRef"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"ApiErrorLog"
>
<
script
setup
lang=
"ts"
name=
"ApiErrorLog"
>
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
download
from
'@/utils/download'
import
download
from
'@/utils/download'
import
*
as
ApiErrorLogApi
from
'@/api/infra/apiErrorLog'
import
*
as
ApiErrorLogApi
from
'@/api/infra/apiErrorLog'
import
ApiErrorLogDetail
from
'./
d
etail.vue'
import
ApiErrorLogDetail
from
'./
ApiErrorLogD
etail.vue'
import
{
InfraApiErrorLogProcessStatusEnum
}
from
'@/utils/constants'
import
{
InfraApiErrorLogProcessStatusEnum
}
from
'@/utils/constants'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
loading
=
ref
(
true
)
// 列表的加载中
const
loading
=
ref
(
true
)
// 列表的加载中
...
@@ -182,13 +186,14 @@ const exportLoading = ref(false) // 导出的加载中
...
@@ -182,13 +186,14 @@ const exportLoading = ref(false) // 导出的加载中
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
loading
.
value
=
true
loading
.
value
=
true
try
{
try
{
const
data
=
await
ApiErrorLogApi
.
getApiErrorLogPage
Api
(
queryParams
)
const
data
=
await
ApiErrorLogApi
.
getApiErrorLogPage
(
queryParams
)
list
.
value
=
data
.
list
list
.
value
=
data
.
list
total
.
value
=
data
.
total
total
.
value
=
data
.
total
}
finally
{
}
finally
{
loading
.
value
=
false
loading
.
value
=
false
}
}
}
}
/** 搜索按钮操作 */
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
queryParams
.
pageNo
=
1
...
@@ -202,18 +207,19 @@ const resetQuery = () => {
...
@@ -202,18 +207,19 @@ const resetQuery = () => {
}
}
/** 详情操作 */
/** 详情操作 */
const
moda
lRef
=
ref
()
const
detai
lRef
=
ref
()
const
open
Moda
l
=
(
data
:
ApiErrorLogApi
.
ApiErrorLogVO
)
=>
{
const
open
Detai
l
=
(
data
:
ApiErrorLogApi
.
ApiErrorLogVO
)
=>
{
modalRef
.
value
.
openModal
(
data
)
detailRef
.
value
.
open
(
data
)
}
}
/** 处理已处理 / 已忽略的操作 **/
/** 处理已处理 / 已忽略的操作 **/
const
handleProcess
Click
=
async
(
processStatus
:
number
,
type
:
string
,
id
:
number
)
=>
{
const
handleProcess
=
async
(
id
:
number
,
processStatus
:
number
)
=>
{
try
{
try
{
// 操作的二次确认
// 操作的二次确认
const
type
=
processStatus
===
InfraApiErrorLogProcessStatusEnum
.
DONE
?
'已处理'
:
'已忽略'
await
message
.
confirm
(
'确认标记为'
+
type
+
'?'
)
await
message
.
confirm
(
'确认标记为'
+
type
+
'?'
)
// 执行操作
// 执行操作
await
ApiErrorLogApi
.
updateApiErrorLogPage
Api
(
id
,
processStatus
)
await
ApiErrorLogApi
.
updateApiErrorLogPage
(
id
,
processStatus
)
await
message
.
success
(
type
)
await
message
.
success
(
type
)
// 刷新列表
// 刷新列表
await
getList
()
await
getList
()
...
@@ -227,8 +233,8 @@ const handleExport = async () => {
...
@@ -227,8 +233,8 @@ const handleExport = async () => {
await
message
.
exportConfirm
()
await
message
.
exportConfirm
()
// 发起导出
// 发起导出
exportLoading
.
value
=
true
exportLoading
.
value
=
true
const
data
=
await
ApiErrorLogApi
.
exportApiErrorLog
Api
(
queryParams
)
const
data
=
await
ApiErrorLogApi
.
exportApiErrorLog
(
queryParams
)
download
.
excel
(
data
,
'
操作
日志.xls'
)
download
.
excel
(
data
,
'
异常
日志.xls'
)
}
catch
{
}
catch
{
}
finally
{
}
finally
{
exportLoading
.
value
=
false
exportLoading
.
value
=
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment