diff --git a/apps/web-antd/src/api/iot/rule/scene/index.ts b/apps/web-antd/src/api/iot/rule/scene/index.ts index fb30ed59b..11ff09308 100644 --- a/apps/web-antd/src/api/iot/rule/scene/index.ts +++ b/apps/web-antd/src/api/iot/rule/scene/index.ts @@ -11,6 +11,7 @@ export namespace RuleSceneApi { status?: number; triggers?: Trigger[]; actions?: Action[]; + lastTriggeredTime?: Date; createTime?: Date; } diff --git a/apps/web-antd/src/api/iot/statistics/index.ts b/apps/web-antd/src/api/iot/statistics/index.ts index 7e5943045..dc7971eb6 100644 --- a/apps/web-antd/src/api/iot/statistics/index.ts +++ b/apps/web-antd/src/api/iot/statistics/index.ts @@ -19,7 +19,7 @@ export namespace IotStatisticsApi { /** 设备消息数量统计(按日期) */ export interface DeviceMessageSummaryByDateRespVO { - time: Date; // 时间轴 + time: string; // 时间轴 upstreamCount: number; // 上行消息数量 downstreamCount: number; // 下行消息数量 } diff --git a/apps/web-antd/src/api/iot/thingmodel/index.ts b/apps/web-antd/src/api/iot/thingmodel/index.ts index 4c8d0bb76..45d50295d 100644 --- a/apps/web-antd/src/api/iot/thingmodel/index.ts +++ b/apps/web-antd/src/api/iot/thingmodel/index.ts @@ -68,6 +68,15 @@ export namespace ThingModelApi { dataSpecsList?: any[]; } + /** IoT 物模型 TSL(树形)响应 */ + export interface ThingModelTSL { + productId?: number; + productKey?: string; + properties?: Property[]; + events?: Event[]; + services?: Service[]; + } + /** IoT 数据定义(数值型) */ export interface DataSpecsNumberData { min?: number | string; @@ -236,7 +245,10 @@ export function deleteThingModel(id: number) { /** 获取物模型 TSL */ export function getThingModelTSL(productId: number) { - return requestClient.get('/iot/thing-model/get-tsl', { - params: { productId }, - }); + return requestClient.get( + '/iot/thing-model/get-tsl', + { + params: { productId }, + }, + ); } diff --git a/apps/web-antd/src/views/iot/alert/record/data.ts b/apps/web-antd/src/views/iot/alert/record/data.ts index 3ca168c7f..9afdb18a2 100644 --- a/apps/web-antd/src/views/iot/alert/record/data.ts +++ b/apps/web-antd/src/views/iot/alert/record/data.ts @@ -115,20 +115,20 @@ export function useGridColumns(): VxeTableGridOptions - productList.find((p) => p.id === cellValue)?.name || '-', + productList.find((product) => product.id === cellValue)?.name || '-', }, { field: 'deviceId', title: '设备名称', minWidth: 120, formatter: ({ cellValue }) => - deviceList.find((d) => d.id === cellValue)?.deviceName || '-', + deviceList.find((device) => device.id === cellValue)?.deviceName || + '-', }, { field: 'deviceMessage', diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/message.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/message.vue index 131f9c4a5..6c65ce216 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/message.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/message.vue @@ -24,16 +24,13 @@ const props = defineProps<{ deviceId: number; }>(); -/** 查询参数 */ const queryParams = reactive({ method: undefined, upstream: undefined, -}); +}); // 查询参数 -/** 自动刷新开关 */ -const autoRefresh = ref(false); -/** 自动刷新定时器 */ -let autoRefreshTimer: any = null; +const autoRefresh = ref(false); // 自动刷新开关 +let autoRefreshTimer: any = null; // 自动刷新定时器 /** 消息方法选项 */ const methodOptions = computed(() => { diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config-form.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config-form.vue index 0cfe57110..669b01fbf 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config-form.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config-form.vue @@ -5,7 +5,12 @@ import type { IotDeviceModbusConfigApi } from '#/api/iot/device/modbus/config'; import { computed, ref } from 'vue'; import { useVbenModal } from '@vben/common-ui'; -import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; +import { + CommonStatusEnum, + DICT_TYPE, + ModbusFrameFormatEnum, + ModbusModeEnum, +} from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; import { message } from 'ant-design-vue'; @@ -14,10 +19,6 @@ import { useVbenForm, z } from '#/adapter/form'; import { saveModbusConfig } from '#/api/iot/device/modbus/config'; import { ProtocolTypeEnum } from '#/api/iot/product/product'; import { $t } from '#/locales'; -import { - ModbusFrameFormatEnum, - ModbusModeEnum, -} from '#/views/iot/utils/constants'; const emit = defineEmits(['success']); diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config.vue index 62fce6014..672915a01 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-config.vue @@ -12,7 +12,7 @@ import type { DescriptionItemSchema } from '#/components/description'; import { computed, h, onMounted, ref } from 'vue'; import { confirm, useVbenModal } from '@vben/common-ui'; -import { DICT_TYPE } from '@vben/constants'; +import { DICT_TYPE, ModbusFunctionCodeOptions } from '@vben/constants'; import { Button, message } from 'ant-design-vue'; @@ -25,7 +25,6 @@ import { import { ProtocolTypeEnum } from '#/api/iot/product/product'; import { useDescription } from '#/components/description'; import { DictTag } from '#/components/dict-tag'; -import { ModbusFunctionCodeOptions } from '#/views/iot/utils/constants'; import DeviceModbusConfigForm from './modbus-config-form.vue'; import DeviceModbusPointForm from './modbus-point-form.vue'; diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-point-form.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-point-form.vue index d034f9a80..cce6c75f1 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-point-form.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/modbus-point-form.vue @@ -7,7 +7,14 @@ import type { ThingModelApi } from '#/api/iot/thingmodel'; import { computed, h, ref } from 'vue'; import { useVbenModal } from '@vben/common-ui'; -import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; +import { + CommonStatusEnum, + DICT_TYPE, + getByteOrderOptions, + IoTThingModelTypeEnum, + ModbusFunctionCodeOptions, + ModbusRawDataTypeOptions, +} from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; import { message } from 'ant-design-vue'; @@ -19,12 +26,6 @@ import { updateModbusPoint, } from '#/api/iot/device/modbus/point'; import { $t } from '#/locales'; -import { - getByteOrderOptions, - IoTThingModelTypeEnum, - ModbusFunctionCodeOptions, - ModbusRawDataTypeOptions, -} from '#/views/iot/utils/constants'; const emit = defineEmits(['success']); diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue index e131ddfc7..e3e1ef598 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue @@ -9,7 +9,11 @@ import type { ThingModelApi } from '#/api/iot/thingmodel'; import { computed, ref } from 'vue'; import { ContentWrap } from '@vben/common-ui'; -import { IotDeviceMessageMethodEnum } from '@vben/constants'; +import { + DeviceStateEnum, + IotDeviceMessageMethodEnum, + IoTThingModelTypeEnum, +} from '@vben/constants'; import { IconifyIcon } from '@vben/icons'; import { @@ -25,10 +29,6 @@ import { } from 'ant-design-vue'; import { sendDeviceMessage } from '#/api/iot/device/device'; -import { - DeviceStateEnum, - IoTThingModelTypeEnum, -} from '#/views/iot/utils/constants'; import DataDefinition from '../../../../thingmodel/modules/components/data-definition.vue'; import DeviceDetailsMessage from './message.vue'; diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-event.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-event.vue index 17672c828..52a175a06 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-event.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-event.vue @@ -6,7 +6,11 @@ import type { ThingModelApi } from '#/api/iot/thingmodel'; import { computed, onMounted, reactive, watch } from 'vue'; import { Page } from '@vben/common-ui'; -import { IotDeviceMessageMethodEnum } from '@vben/constants'; +import { + getEventTypeLabel, + IotDeviceMessageMethodEnum, + IoTThingModelTypeEnum, +} from '@vben/constants'; import { IconifyIcon } from '@vben/icons'; import { formatDateTime } from '@vben/utils'; @@ -14,10 +18,6 @@ import { Button, RangePicker, Select, Space, Tag } from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { getDeviceMessagePairPage } from '#/api/iot/device/device'; -import { - getEventTypeLabel, - IoTThingModelTypeEnum, -} from '#/views/iot/utils/constants'; const props = defineProps<{ deviceId: number; diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-property-history.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-property-history.vue index 7fefa811a..db252d76a 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-property-history.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/thing-model-property-history.vue @@ -8,9 +8,10 @@ import type { IotDeviceApi } from '#/api/iot/device/device'; import { computed, nextTick, reactive, ref, watch } from 'vue'; +import { IoTDataSpecsDataTypeEnum } from '@vben/constants'; import { IconifyIcon } from '@vben/icons'; import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; -import { formatDate, formatDateTime } from '@vben/utils'; +import { formatDate } from '@vben/utils'; import { Button, @@ -26,13 +27,11 @@ import dayjs from 'dayjs'; import { getHistoryDevicePropertyList } from '#/api/iot/device/device'; import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue'; -import { IoTDataSpecsDataTypeEnum } from '#/views/iot/utils/constants'; defineProps<{ deviceId: number }>(); const dialogVisible = ref(false); // 弹窗的是否展示 const loading = ref(false); -const exporting = ref(false); const viewMode = ref<'chart' | 'list'>('chart'); // 视图模式状态 const list = ref([]); // 列表的数据 const total = ref(0); // 总数据量 @@ -330,54 +329,6 @@ function handleRefresh() { getList(); } -/** 导出数据 */ -async function handleExport() { - if (list.value.length === 0) { - message.warning('暂无数据可导出'); - return; - } - - exporting.value = true; - try { - // 构建CSV内容 - const headers = ['序号', '时间', '属性值']; - const csvContent = [ - headers.join(','), - ...list.value.map((item, index) => { - return [ - index + 1, - formatDateTime(new Date(item.updateTime)), - isComplexDataType.value - ? `"${JSON.stringify(item.value)}"` - : item.value, - ].join(','); - }), - ].join('\n'); - - // 创建 BOM 头,解决中文乱码 - const BOM = '\uFEFF'; - const blob = new Blob([BOM + csvContent], { - type: 'text/csv;charset=utf-8', - }); - - // 下载文件 - const url = window.URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = `设备属性历史_${propertyIdentifier.value}_${formatDate(new Date(), 'YYYYMMDDHHmmss')}.csv`; - document.body.append(link); - link.click(); - link.remove(); - window.URL.revokeObjectURL(url); - - message.success('导出成功'); - } catch { - message.error('导出失败'); - } finally { - exporting.value = false; - } -} - /** 关闭弹窗 */ function handleClose() { dialogVisible.value = false; @@ -429,18 +380,6 @@ defineExpose({ open }); // 提供 open 方法,用于打开弹窗 刷新 - - -