feat:【IoT 物联网】调整“设备属性(运行状态)”的接口返回
This commit is contained in:
@ -30,17 +30,15 @@ export interface DeviceVO {
|
|||||||
groupIds?: number[] // 添加分组 ID
|
groupIds?: number[] // 添加分组 ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// IoT 设备数据 VO
|
// IoT 设备属性详细 VO
|
||||||
export interface DeviceDataVO {
|
export interface IotDevicePropertyDetailRespVO {
|
||||||
deviceId: number // 设备编号
|
|
||||||
thinkModelFunctionId: number // 物模型编号
|
|
||||||
productKey: string // 产品标识
|
|
||||||
deviceName: string // 设备名称
|
|
||||||
identifier: string // 属性标识符
|
identifier: string // 属性标识符
|
||||||
|
value: string // 最新值
|
||||||
|
updateTime: Date // 更新时间
|
||||||
name: string // 属性名称
|
name: string // 属性名称
|
||||||
dataType: string // 数据类型
|
dataType: string // 数据类型
|
||||||
updateTime: Date // 更新时间
|
dataSpecs: any // 数据定义
|
||||||
value: string // 最新值
|
dataSpecsList: any[] // 数据定义列表
|
||||||
}
|
}
|
||||||
|
|
||||||
// IoT 设备数据 VO
|
// IoT 设备数据 VO
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
<el-row :gutter="16" v-loading="loading">
|
<el-row :gutter="16" v-loading="loading">
|
||||||
<el-col
|
<el-col
|
||||||
v-for="item in list"
|
v-for="item in list"
|
||||||
:key="item.property.identifier"
|
:key="item.identifier"
|
||||||
:xs="24"
|
:xs="24"
|
||||||
:sm="12"
|
:sm="12"
|
||||||
:md="12"
|
:md="12"
|
||||||
@ -72,25 +72,23 @@
|
|||||||
<div class="mr-2.5 flex items-center">
|
<div class="mr-2.5 flex items-center">
|
||||||
<Icon icon="ep:cpu" class="text-[18px] text-[#0070ff]" />
|
<Icon icon="ep:cpu" class="text-[18px] text-[#0070ff]" />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-[16px] font-600 flex-1">{{
|
<div class="text-[16px] font-600 flex-1">{{ item.name }}</div>
|
||||||
item.property?.name || item.name
|
|
||||||
}}</div>
|
|
||||||
<!-- 标识符 -->
|
<!-- 标识符 -->
|
||||||
<div class="inline-flex items-center mr-2">
|
<div class="inline-flex items-center mr-2">
|
||||||
<el-tag size="small" type="primary">
|
<el-tag size="small" type="primary">
|
||||||
{{ item.property?.identifier || item.identifier }}
|
{{ item.identifier }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<!-- 数据类型标签 -->
|
<!-- 数据类型标签 -->
|
||||||
<div class="inline-flex items-center mr-2">
|
<div class="inline-flex items-center mr-2">
|
||||||
<el-tag size="small" type="info">
|
<el-tag size="small" type="info">
|
||||||
{{ item.property?.dataType || item.dataType }}
|
{{ item.dataType }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<!-- 数据图标 - 可点击 -->
|
<!-- 数据图标 - 可点击 -->
|
||||||
<div
|
<div
|
||||||
class="cursor-pointer flex items-center justify-center w-8 h-8 rounded-full hover:bg-blue-50 transition-colors"
|
class="cursor-pointer flex items-center justify-center w-8 h-8 rounded-full hover:bg-blue-50 transition-colors"
|
||||||
@click="openDetail(props.device.id, item.property?.identifier || item.identifier)"
|
@click="openDetail(props.device.id, item.identifier)"
|
||||||
>
|
>
|
||||||
<Icon icon="ep:data-line" class="text-[18px] text-[#0070ff]" />
|
<Icon icon="ep:data-line" class="text-[18px] text-[#0070ff]" />
|
||||||
</div>
|
</div>
|
||||||
@ -107,7 +105,7 @@
|
|||||||
<div class="mb-2.5 last:mb-0">
|
<div class="mb-2.5 last:mb-0">
|
||||||
<span class="text-[#717c8e] mr-2.5">更新时间</span>
|
<span class="text-[#717c8e] mr-2.5">更新时间</span>
|
||||||
<span class="text-[#0b1d30] text-[12px]">
|
<span class="text-[#0b1d30] text-[12px]">
|
||||||
{{ dateFormatter(null, null, item.updateTime) }}
|
{{ item.updateTime ? formatDate(item.updateTime) : '-' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -119,9 +117,9 @@
|
|||||||
|
|
||||||
<!-- 列表视图 -->
|
<!-- 列表视图 -->
|
||||||
<el-table v-else v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table v-else v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
<el-table-column label="属性标识符" align="center" prop="property.identifier" />
|
<el-table-column label="属性标识符" align="center" prop="identifier" />
|
||||||
<el-table-column label="属性名称" align="center" prop="property.name" />
|
<el-table-column label="属性名称" align="center" prop="name" />
|
||||||
<el-table-column label="数据类型" align="center" prop="property.dataType" />
|
<el-table-column label="数据类型" align="center" prop="dataType" />
|
||||||
<el-table-column label="属性值" align="center" prop="value" />
|
<el-table-column label="属性值" align="center" prop="value" />
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="更新时间"
|
label="更新时间"
|
||||||
@ -132,11 +130,7 @@
|
|||||||
/>
|
/>
|
||||||
<el-table-column label="操作" align="center">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button link type="primary" @click="openDetail(props.device.id, scope.row.identifier)">
|
||||||
link
|
|
||||||
type="primary"
|
|
||||||
@click="openDetail(props.device.id, scope.row.property.identifier)"
|
|
||||||
>
|
|
||||||
查看数据
|
查看数据
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
@ -149,15 +143,15 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ProductVO } from '@/api/iot/product/product'
|
import { ProductVO } from '@/api/iot/product/product'
|
||||||
import { DeviceApi, DeviceDataVO, DeviceVO } from '@/api/iot/device/device'
|
import { DeviceApi, IotDevicePropertyDetailRespVO, DeviceVO } from '@/api/iot/device/device'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter, formatDate } from '@/utils/formatTime'
|
||||||
import DeviceDataDetail from './DeviceDataDetail.vue'
|
import DeviceDataDetail from './DeviceDataDetail.vue'
|
||||||
|
|
||||||
const props = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
const props = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<DeviceDataVO[]>([]) // 显示的列表数据
|
const list = ref<IotDevicePropertyDetailRespVO[]>([]) // 显示的列表数据
|
||||||
const allList = ref<DeviceDataVO[]>([]) // 完整的数据列表
|
const filterList = ref<IotDevicePropertyDetailRespVO[]>([]) // 完整的数据列表
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
keyword: '' as string
|
keyword: '' as string
|
||||||
})
|
})
|
||||||
@ -176,30 +170,30 @@ const getList = async () => {
|
|||||||
identifier: undefined as string | undefined,
|
identifier: undefined as string | undefined,
|
||||||
name: undefined as string | undefined
|
name: undefined as string | undefined
|
||||||
}
|
}
|
||||||
allList.value = await DeviceApi.getLatestDeviceProperties(params)
|
filterList.value = await DeviceApi.getLatestDeviceProperties(params)
|
||||||
filterData()
|
handleFilter()
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 前端筛选数据 */
|
/** 前端筛选数据 */
|
||||||
const filterData = () => {
|
const handleFilter = () => {
|
||||||
if (!queryParams.keyword.trim()) {
|
if (!queryParams.keyword.trim()) {
|
||||||
list.value = allList.value
|
list.value = filterList.value
|
||||||
} else {
|
} else {
|
||||||
const keyword = queryParams.keyword.toLowerCase()
|
const keyword = queryParams.keyword.toLowerCase()
|
||||||
list.value = allList.value.filter(
|
list.value = filterList.value.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.property?.identifier?.toLowerCase().includes(keyword) ||
|
item.identifier?.toLowerCase().includes(keyword) ||
|
||||||
item.property?.name?.toLowerCase().includes(keyword)
|
item.name?.toLowerCase().includes(keyword)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
filterData()
|
handleFilter()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
|
|||||||
Reference in New Issue
Block a user