Skip to content

Commit 3c73a67

Browse files
committed
【功能修改】IoT:设备状态从 status 到 state,移除已禁用
1 parent b9193dd commit 3c73a67

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

src/api/iot/device/device/index.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ export interface DeviceVO {
1010
deviceType: number // 设备类型
1111
nickname: string // 设备备注名称
1212
gatewayId: number // 网关设备 ID
13-
status: number // 设备状态
14-
statusLastUpdateTime: Date // 设备状态最后更新时间
15-
lastOnlineTime: Date // 最后上线时间
16-
lastOfflineTime: Date // 最后离线时间
13+
state: number // 设备状态
14+
onlineTime: Date // 最后上线时间
15+
offlineTime: Date // 最后离线时间
1716
activeTime: Date // 设备激活时间
1817
createTime: Date // 创建时间
1918
ip: string // 设备的 IP 地址
@@ -31,11 +30,6 @@ export interface DeviceVO {
3130
groupIds?: number[] // 添加分组 ID
3231
}
3332

34-
export interface DeviceUpdateStatusVO {
35-
id: number // 设备 ID,主键,自增
36-
status: number // 设备状态
37-
}
38-
3933
// IoT 设备数据 VO
4034
export interface DeviceDataVO {
4135
deviceId: number // 设备编号
@@ -93,11 +87,6 @@ export const DeviceApi = {
9387
return await request.put({ url: `/iot/device/update`, data })
9488
},
9589

96-
// 修改设备状态
97-
updateDeviceStatus: async (data: DeviceUpdateStatusVO) => {
98-
return await request.put({ url: `/iot/device/update-status`, data })
99-
},
100-
10190
// 修改设备分组
10291
updateDeviceGroup: async (data: { ids: number[]; groupIds: number[] }) => {
10392
return await request.put({ url: `/iot/device/update-group`, data })

src/utils/dict.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* 数据字典工具类
33
*/
4-
import {useDictStoreWithOut} from '@/store/modules/dict'
5-
import {ElementPlusInfoType} from '@/types/elementPlus'
4+
import { useDictStoreWithOut } from '@/store/modules/dict'
5+
import { ElementPlusInfoType } from '@/types/elementPlus'
66

77
const dictStore = useDictStoreWithOut()
88

@@ -235,7 +235,7 @@ export enum DICT_TYPE {
235235
IOT_PRODUCT_DEVICE_TYPE = 'iot_product_device_type', // IOT 产品设备类型
236236
IOT_DATA_FORMAT = 'iot_data_format', // IOT 数据格式
237237
IOT_PROTOCOL_TYPE = 'iot_protocol_type', // IOT 接入网关协议
238-
IOT_DEVICE_STATUS = 'iot_device_status', // IOT 设备状态
238+
IOT_DEVICE_STATE = 'iot_device_state', // IOT 设备状态
239239
IOT_THING_MODEL_TYPE = 'iot_thing_model_type', // IOT 产品功能类型
240240
IOT_DATA_TYPE = 'iot_data_type', // IOT 数据类型
241241
IOT_THING_MODEL_UNIT = 'iot_thing_model_unit', // IOT 物模型单位

src/views/iot/device/device/detail/DeviceDetailsInfo.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
{{ formatDate(device.activeTime) }}
2424
</el-descriptions-item>
2525
<el-descriptions-item label="最后上线时间">
26-
{{ formatDate(device.lastOnlineTime) }}
26+
{{ formatDate(device.onlineTime) }}
2727
</el-descriptions-item>
2828
<el-descriptions-item label="当前状态">
29-
<dict-tag :type="DICT_TYPE.IOT_DEVICE_STATUS" :value="device.status" />
29+
<dict-tag :type="DICT_TYPE.IOT_DEVICE_STATE" :value="device.status" />
3030
</el-descriptions-item>
3131
<el-descriptions-item label="最后离线时间" :span="3">
32-
{{ formatDate(device.lastOfflineTime) }}
32+
{{ formatDate(device.offlineTime) }}
3333
</el-descriptions-item>
3434
<el-descriptions-item label="MQTT 连接参数">
3535
<el-button type="primary" @click="openMqttParams">查看</el-button>

src/views/iot/device/device/index.vue

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
class="!w-240px"
6565
>
6666
<el-option
67-
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_DEVICE_STATUS)"
67+
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_DEVICE_STATE)"
6868
:key="dict.value"
6969
:label="dict.label"
7070
:value="dict.value"
@@ -161,7 +161,7 @@
161161
<div
162162
class="absolute top-0 left-0 right-0 h-[50px] pointer-events-none"
163163
:class="[
164-
item.status === DeviceStatusEnum.ONLINE
164+
item.state === DeviceStatusEnum.ONLINE
165165
? 'bg-gradient-to-b from-[#eefaff] to-transparent'
166166
: 'bg-gradient-to-b from-[#fff1f1] to-transparent'
167167
]"
@@ -179,17 +179,17 @@
179179
<div
180180
class="w-1 h-1 rounded-full mr-1.5"
181181
:class="
182-
item.status === DeviceStatusEnum.ONLINE
182+
item.state === DeviceStatusEnum.ONLINE
183183
? 'bg-[var(--el-color-success)]'
184184
: 'bg-[var(--el-color-danger)]'
185185
"
186186
>
187187
</div>
188188
<el-text
189189
class="!text-xs font-bold"
190-
:type="item.status === DeviceStatusEnum.ONLINE ? 'success' : 'danger'"
190+
:type="item.state === DeviceStatusEnum.ONLINE ? 'success' : 'danger'"
191191
>
192-
{{ getDictLabel(DICT_TYPE.IOT_DEVICE_STATUS, item.status) }}
192+
{{ getDictLabel(DICT_TYPE.IOT_DEVICE_STATE, item.state) }}
193193
</el-text>
194194
</div>
195195
</div>
@@ -199,17 +199,19 @@
199199
<div class="flex-1">
200200
<div class="mb-2.5 last:mb-0">
201201
<span class="text-[#717c8e] mr-2.5">所属产品</span>
202-
<span class="text-[#0070ff]">{{
203-
products.find((p) => p.id === item.productId)?.name
204-
}}</span>
202+
<span class="text-[#0070ff]">
203+
{{ products.find((p) => p.id === item.productId)?.name }}
204+
</span>
205205
</div>
206206
<div class="mb-2.5 last:mb-0">
207207
<span class="text-[#717c8e] mr-2.5">设备类型</span>
208208
<dict-tag :type="DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE" :value="item.deviceType" />
209209
</div>
210210
<div class="mb-2.5 last:mb-0">
211211
<span class="text-[#717c8e] mr-2.5">DeviceKey</span>
212-
<span class="text-[#0b1d30] inline-block align-middle overflow-hidden text-ellipsis whitespace-nowrap max-w-[130px]">
212+
<span
213+
class="text-[#0b1d30] inline-block align-middle overflow-hidden text-ellipsis whitespace-nowrap max-w-[130px]"
214+
>
213215
{{ item.deviceKey }}
214216
</span>
215217
</div>
@@ -306,13 +308,13 @@
306308
</el-table-column>
307309
<el-table-column label="设备状态" align="center" prop="status">
308310
<template #default="scope">
309-
<dict-tag :type="DICT_TYPE.IOT_DEVICE_STATUS" :value="scope.row.status" />
311+
<dict-tag :type="DICT_TYPE.IOT_DEVICE_STATE" :value="scope.row.status" />
310312
</template>
311313
</el-table-column>
312314
<el-table-column
313315
label="最后上线时间"
314316
align="center"
315-
prop="lastOnlineTime"
317+
prop="onlineTime"
316318
:formatter="dateFormatter"
317319
width="180px"
318320
/>

0 commit comments

Comments
 (0)