Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
Apper-Admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0930a536
authored
Nov 13, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
校验
1 parent
2c698cd8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
67 additions
and
37 deletions
.env.development
src/api/index.ts
src/api/modules/device.ts
src/utils/dict.ts
src/views/log/list/components/Dailog.vue
src/views/log/list/components/Detail.vue
src/views/log/list/components/LogFile.vue
src/views/log/list/components/Report.vue
src/views/log/list/index.vue
.env.development
View file @
0930a53
...
...
@@ -2,7 +2,7 @@
# @Author: 前端 qianduan01@didihu.com.cn
# @Date: 2024-09-04 14:38:00
# @LastEditors: 前端 qianduan01@didihu.com.cn
# @LastEditTime: 2024-
09-27 21:04:03
# @LastEditTime: 2024-
11-07 10:10:01
# @FilePath: \Apper-Admin-master\.env.development
# @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
###
...
...
src/api/index.ts
View file @
0930a53
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-09-04 14:38:00
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-11-0
1 18:19:37
* @LastEditTime: 2024-11-0
7 11:18:01
* @FilePath: \Apper-Admin-master\src\api\index.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -73,7 +73,6 @@ class RequestHttp {
this
.
service
.
interceptors
.
response
.
use
(
(
response
:
AxiosResponse
&
{
config
:
CustomAxiosRequestConfig
})
=>
{
const
{
data
,
config
}
=
response
;
const
userStore
=
useUserStore
();
axiosCanceler
.
removePending
(
config
);
config
.
loading
&&
tryHideFullScreenLoading
();
...
...
@@ -92,12 +91,12 @@ class RequestHttp {
// 成功请求(在页面上除非特殊情况,否则不用处理失败逻辑)
return
data
;
},
async
(
error
:
AxiosError
)
=>
{
async
(
error
:
AxiosError
&
{
config
:
{
errorMsg
?:
string
}
}
)
=>
{
tryHideFullScreenLoading
();
const
{
config
}
=
error
;
// 请求超时 && 网络错误单独判断,没有 response
if
(
error
.
message
.
indexOf
(
"timeout"
)
!==
-
1
)
ElMessage
.
error
(
"请求超时!请您稍后重试"
);
if
(
error
.
message
.
indexOf
(
"Network Error"
)
!==
-
1
||
error
.
message
.
indexOf
(
"500"
)
!==
-
1
)
ElMessage
.
error
(
"网络错误!请您稍后重试"
);
else
ElMessage
.
error
(
config
?.
errorMsg
||
"网络错误!请您稍后重试"
);
// 服务器结果都没有返回(可能服务器错误可能客户端断网),断网处理:可以跳转到断网页面
// if (!window.navigator.onLine) router.replace("/500");
...
...
src/api/modules/device.ts
View file @
0930a53
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-09-04 19:39:51
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-11-07 11:03:44
* @FilePath: \Apper-Admin-master\src\api\modules\device.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import
{
ResPage
,
Device
}
from
"@/api/interface/index"
;
import
http
from
"@/api"
;
...
...
@@ -39,7 +47,7 @@ export const deleteDevice = params => {
// 给设备发指令
export
const
sendCmd
=
params
=>
{
return
http
.
post
(
`/broadcast/cmd`
,
params
);
return
http
.
post
(
`/broadcast/cmd`
,
params
,
{
errorMsg
:
"设备已离线"
}
);
};
// 获取文件列表
...
...
src/utils/dict.ts
View file @
0930a53
...
...
@@ -28,10 +28,10 @@ export const cmdList = [
value
:
"getStorage"
,
label
:
"获取缓存"
},
{
value
:
"message"
,
label
:
"发送信息"
},
//
{
//
value: "message",
//
label: "发送信息"
//
},
{
value
:
"getLogList"
,
...
...
src/views/log/list/components/Dailog.vue
View file @
0930a53
...
...
@@ -37,6 +37,7 @@ const checkPhone = (rule: any, value: any, callback: any) => {
if
(
!
/^1
\d{10}
$/
.
test
(
value
))
{
return
callback
(
new
Error
(
"请填写正确手机号"
));
}
callback
();
};
const
rules
=
reactive
({
user
:
[{
required
:
true
,
message
:
"请填写用户名"
}],
...
...
@@ -77,13 +78,14 @@ const acceptParams = async (params: DialogProps) => {
const
ruleFormRef
=
ref
<
FormInstance
>
();
const
handleSubmit
=
()
=>
{
ruleFormRef
.
value
!
.
validate
(
async
valid
=>
{
console
.
log
(
valid
,
"valid"
);
if
(
!
valid
)
return
;
try
{
if
(
dialogProps
.
value
.
row
!
.
device_id
)
{
delete
dialogProps
.
value
!
.
row
.
sn
;
}
const
{
sn
}
=
dialogProps
.
value
.
row
;
await
dialogProps
.
value
.
api
!
({
sn
,
device_info
:
dialogProps
.
value
.
row
});
const
{
sn
,
device_id
}
=
dialogProps
.
value
.
row
;
await
dialogProps
.
value
.
api
!
({
device_id
,
sn
,
device_info
:
dialogProps
.
value
.
row
});
ElMessage
.
success
({
message
:
`
${
dialogProps
.
value
.
title
}
成功!`
});
dialogProps
.
value
.
getTableList
!
();
dialogVisible
.
value
=
false
;
...
...
src/views/log/list/components/Detail.vue
View file @
0930a53
...
...
@@ -7,7 +7,7 @@
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<
template
>
<el-dialog
:before-close=
"handleClose"
v-model=
"detailVisible"
width=
"
5
0%"
title=
"日志详情"
>
<el-dialog
:before-close=
"handleClose"
v-model=
"detailVisible"
width=
"
8
0%"
title=
"日志详情"
>
<el-input
v-model=
"detail"
:rows=
"27"
type=
"textarea"
/>
</el-dialog>
</
template
>
...
...
src/views/log/list/components/LogFile.vue
View file @
0930a53
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-09-04 21:13:18
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-1
0-11 15:29:07
* @LastEditTime: 2024-1
1-07 16:37:29
* @FilePath: \Apper-Admin-master\src\views\log\dictionary\components\Dailog.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
...
...
@@ -10,7 +10,7 @@
<el-dialog
:before-close=
"handleClose"
v-model=
"showLog"
width=
"50%"
title=
"日志文件列表"
>
<el-table
class=
"table-box"
:data=
"tableData"
style=
"width: 100%"
>
<el-table-column
prop=
"filename"
label=
"文件名"
/>
<el-table-column
prop=
"created_at"
label=
"日期"
>
<el-table-column
prop=
"created_at"
label=
"日期"
width=
"160"
>
<template
#
default=
"scope"
>
{{
new
Date
(
scope
.
row
.
created_at
).
toLocaleString
()
}}
</
template
>
</el-table-column>
<el-table-column
fixed=
"right"
label=
"操作"
width=
"120"
>
...
...
src/views/log/list/components/Report.vue
View file @
0930a53
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-09-04 21:58:42
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-1
0-11 18:03:07
* @LastEditTime: 2024-1
1-07 11:24:31
* @FilePath: \Apper-Admin-master\src\views\log\list\components\Report.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
...
...
@@ -16,21 +16,14 @@
-->
<
template
>
<el-dialog
v-model=
"showReport"
width=
"30%"
:before-close=
"handleClose"
title=
"开启通信"
>
<el-form
ref=
"ruleFormRef"
label-width=
"120px"
label-suffix=
" :"
:rules=
"rules"
:model=
"dialogProps"
:hide-required-asterisk=
"dialogProps"
>
<el-form
ref=
"ruleFormRef"
label-width=
"120px"
label-suffix=
" :"
:rules=
"rules"
:model=
"dialogProps"
>
<el-form-item
label=
"指令"
prop=
"command"
>
<el-select
v-model=
"dialogProps.command"
placeholder=
"请选择日志字段"
clearable
>
<el-option
v-for=
"item in cmdList"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
/>
</el-select>
</el-form-item>
<template
v-for=
"(item, index) in formList[dialogProps.command]"
:key=
"index"
>
<el-form-item
:label=
"item.label"
:prop=
"item.
valu
e"
>
<el-form-item
:label=
"item.label"
:prop=
"item.
nam
e"
>
<el-select
v-model=
"dialogProps[item.name]"
placeholder=
"请选择"
v-if=
"item.type === 'select'"
clearable
>
<el-option
v-for=
"i in item.optionList"
...
...
@@ -66,7 +59,7 @@
</el-form>
<
template
#
footer
>
<el-button
@
click=
"handleClose"
>
取消
</el-button>
<el-button
type=
"primary"
@
click=
"handleSubmit"
>
确定
</el-button>
<el-button
type=
"primary"
@
click=
"handleSubmit"
:loading=
"loading"
>
确定
</el-button>
</
template
>
</el-dialog>
</template>
...
...
@@ -80,12 +73,15 @@ import { formList } from "@/utils/dict";
const
rules
=
reactive
({
command
:
[{
required
:
true
,
message
:
"请选择指令"
}],
storage
:
[{
required
:
true
,
message
:
"请用户信息"
}],
days
:
[{
required
:
true
,
message
:
"请填写上报日志天数"
}]
days
:
[{
required
:
true
,
message
:
"请输入天数"
}],
id
:
[{
required
:
true
,
message
:
"请输入id"
}],
key
:
[{
required
:
true
,
message
:
"请选择缓存字段"
}],
times
:
[{
required
:
true
,
message
:
"请选择时间"
}]
});
interface
DialogProps
{
id
?:
string
;
days
?:
number
|
null
;
days
?:
number
;
interval
?:
number
;
command
:
string
;
key
?:
string
;
...
...
@@ -93,6 +89,7 @@ interface DialogProps {
times
?:
string
[];
beginDate
?:
string
;
endDate
?:
string
;
force
?:
number
;
}
const
props
=
defineProps
<
{
showReport
:
boolean
;
...
...
@@ -101,7 +98,10 @@ const props = defineProps<{
const
{
showReport
,
deviceId
}
=
toRefs
(
props
);
console
.
log
(
deviceId
);
const
dialogProps
=
ref
<
DialogProps
>
({
command
:
cmdList
[
0
].
value
command
:
cmdList
[
0
].
value
,
interval
:
300
,
force
:
0
,
days
:
1
});
watch
(
()
=>
dialogProps
.
value
.
command
,
...
...
@@ -115,9 +115,11 @@ const emit = defineEmits<{
const
handleClose
=
()
=>
{
emit
(
"close"
);
};
const
loading
=
ref
(
false
);
// 提交数据
const
ruleFormRef
=
ref
<
FormInstance
>
();
const
handleSubmit
=
()
=>
{
loading
.
value
=
true
;
ruleFormRef
.
value
!
.
validate
(
async
valid
=>
{
if
(
!
valid
)
return
;
try
{
...
...
@@ -138,6 +140,7 @@ const handleSubmit = () => {
handleClose
();
}
finally
{
handleClose
();
loading
.
value
=
false
;
}
});
};
...
...
src/views/log/list/index.vue
View file @
0930a53
...
...
@@ -55,7 +55,9 @@ const dataCallback = (data: any) => {
total
:
data
.
total
};
};
const
formatDate
=
(
date
?:
string
)
=>
{
return
date
?
new
Date
(
date
).
toLocaleString
()
:
"-"
;
};
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getDeviceList"
const
getTableList
=
(
params
:
any
)
=>
{
...
...
@@ -74,7 +76,11 @@ const columns = reactive<ColumnProps<Device.ResDeviceList>[]>([
label
:
"手机号"
,
search
:
{
el
:
"input"
,
props
:
{
placeholder
:
"请输入手机号"
,
maxlength
:
11
}
}
},
{
prop
:
"sn"
,
label
:
"设备编号"
},
{
prop
:
"sn"
,
label
:
"设备编号"
,
search
:
{
el
:
"input"
,
props
:
{
placeholder
:
"请输入设备编号"
,
maxlength
:
50
}
}
},
{
prop
:
"log_saved_days"
,
label
:
"日志存储时间"
,
...
...
@@ -87,28 +93,28 @@ const columns = reactive<ColumnProps<Device.ResDeviceList>[]>([
prop
:
"last_log_remove_time"
,
label
:
"删除日志时间"
,
render
:
scope
=>
{
return
new
Date
(
scope
.
row
.
last_log_remove_time
).
toLocaleString
(
);
return
formatDate
(
scope
.
row
.
last_log_remove_time
);
}
},
{
prop
:
"last_log_upload_time"
,
label
:
"上传日志时间"
,
render
:
scope
=>
{
return
new
Date
(
scope
.
row
.
last_log_upload_time
).
toLocaleString
(
);
return
formatDate
(
scope
.
row
.
last_log_upload_time
);
}
},
{
prop
:
"last_offline_time"
,
label
:
"上次上线时间"
,
render
:
scope
=>
{
return
new
Date
(
scope
.
row
.
last_offline_time
).
toLocaleString
(
);
return
formatDate
(
scope
.
row
.
last_offline_time
);
}
},
{
prop
:
"last_login_time"
,
label
:
"上次登录时间"
,
render
:
scope
=>
{
return
new
Date
(
scope
.
row
.
last_login_time
).
toLocaleString
(
);
return
formatDate
(
scope
.
row
.
last_login_time
);
}
},
{
...
...
@@ -117,7 +123,19 @@ const columns = reactive<ColumnProps<Device.ResDeviceList>[]>([
width
:
90
,
render
:
scope
=>
{
return
<
el
-
tag
type
=
{
scope
.
row
.
status
==
1
?
"success"
:
"danger"
}
>
{
scope
.
row
.
status
==
1
?
"在线"
:
"离线"
}
<
/el-tag>
;
}
},
enum
:
[
{
label
:
"在线"
,
value
:
1
},
{
label
:
"离线"
,
value
:
2
}
],
search
:
{
el
:
"select"
,
props
:
{
placeholder
:
"请选择在线状态"
}
},
fieldNames
:
{
label
:
"label"
,
value
:
"value"
}
},
{
prop
:
"operation"
,
label
:
"操作"
,
fixed
:
"right"
,
width
:
320
}
]);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment