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
5243f584
authored
Nov 05, 2024
by
安浩浩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增功能】IOT:设备历史数据展示
parent
9ea45b3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
9 deletions
+109
-9
src/api/iot/device/index.ts
+11
-0
src/views/iot/device/detail/DeviceDataDetail.vue
+98
-9
No files found.
src/api/iot/device/index.ts
View file @
5243f584
...
@@ -48,6 +48,12 @@ export interface DeviceDataVO {
...
@@ -48,6 +48,12 @@ export interface DeviceDataVO {
value
:
string
// 最新值
value
:
string
// 最新值
}
}
// IoT 设备数据 VO
export
interface
DeviceHistoryDataVO
{
time
:
number
// 时间
data
:
string
// 数据
}
// 设备 API
// 设备 API
export
const
DeviceApi
=
{
export
const
DeviceApi
=
{
// 查询设备分页
// 查询设备分页
...
@@ -88,5 +94,10 @@ export const DeviceApi = {
...
@@ -88,5 +94,10 @@ export const DeviceApi = {
// 获取设备属性最新数据
// 获取设备属性最新数据
getDevicePropertiesLatestData
:
async
(
params
:
any
)
=>
{
getDevicePropertiesLatestData
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/device/data/latest-data`
,
params
})
return
await
request
.
get
({
url
:
`/iot/device/data/latest-data`
,
params
})
},
// 获取设备属性历史数据
getDevicePropertiesHistoryData
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/iot/device/data/history-data`
,
params
})
}
}
}
}
src/views/iot/device/detail/DeviceDataDetail.vue
View file @
5243f584
<
template
>
<
template
>
<Dialog
title=
"查看数据"
v-model=
"dialogVisible"
>
<Dialog
title=
"查看数据"
v-model=
"dialogVisible"
>
<p>
查看数据
</p>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"时间"
prop=
"createTime"
>
<el-date-picker
v-model=
"queryParams.times"
value-format=
"YYYY-MM-DD HH:mm:ss"
type=
"datetimerange"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
class=
"!w-350px"
/>
</el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
>
<Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
>
<Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table
v-loading=
"detailLoading"
:data=
"list"
:stripe=
"true"
:show-overflow-tooltip=
"true"
>
<el-table-column
label=
"时间"
align=
"center"
prop=
"time"
:formatter=
"dateFormatter"
width=
"180px"
/>
<el-table-column
label=
"原始值"
align=
"center"
prop=
"data"
/>
</el-table>
<!-- 分页 -->
<Pagination
:total=
"total"
v-model:page=
"queryParams.pageNo"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
/>
</ContentWrap>
</Dialog>
</Dialog>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
DeviceApi
,
DeviceVO
}
from
'@/api/iot/device'
import
{
DeviceApi
,
DeviceHistoryDataVO
,
DeviceVO
}
from
'@/api/iot/device'
import
{
ProductApi
}
from
'@/api/iot/product'
import
{
ProductVO
}
from
'@/api/iot/product'
import
{
beginOfDay
,
dateFormatter
,
endOfDay
,
formatDate
}
from
'@/utils/formatTime'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
/** IoT 设备 表单 */
const
props
=
defineProps
<
{
product
:
ProductVO
;
device
:
DeviceVO
}
>
()
defineOptions
({
name
:
'IoTDeviceForm'
})
/** IoT 设备 数据详情 */
defineOptions
({
name
:
'IoTDeviceDataDetail'
})
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
detailLoading
=
ref
(
false
)
const
detailLoading
=
ref
(
false
)
/** 打开弹窗 */
const
list
=
ref
<
DeviceHistoryDataVO
[]
>
([])
// 列表的数据
const
open
=
async
(
deviceId
:
number
,
identifier
:
String
)
=>
{
const
total
=
ref
(
0
)
// 列表的总页数
dialogVisible
.
value
=
true
const
queryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
,
deviceId
:
-
1
,
identifier
:
undefined
as
string
|
undefined
,
times
:
[
// 默认显示最近一周的数据
formatDate
(
beginOfDay
(
new
Date
(
new
Date
().
getTime
()
-
3600
*
1000
*
24
*
7
))),
formatDate
(
endOfDay
(
new
Date
()))
]
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
getList
=
async
()
=>
{
detailLoading
.
value
=
true
detailLoading
.
value
=
true
try
{
try
{
// formData.value = await DeviceApi.getDevice(id)
const
data
=
await
DeviceApi
.
getDevicePropertiesHistoryData
(
queryParams
)
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
finally
{
}
finally
{
detailLoading
.
value
=
false
detailLoading
.
value
=
false
}
}
}
}
/** 打开弹窗 */
const
open
=
async
(
deviceId
:
number
,
identifier
:
String
)
=>
{
dialogVisible
.
value
=
true
queryParams
.
deviceId
=
deviceId
queryParams
.
identifier
=
identifier
getList
()
}
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
getList
()
}
/** 重置按钮操作 */
const
resetQuery
=
()
=>
{
queryFormRef
.
value
.
resetFields
()
handleQuery
()
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
</
script
>
</
script
>
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