From b2a8aa545ec9c5474ee49ee3227e64331542aedf Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Mon, 25 Aug 2025 15:08:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E3=80=81=E8=BF=90=E8=A1=8C=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E3=80=81=E8=AE=BE=E5=A4=87=E6=A8=A1=E6=8B=9F=E3=80=81=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增日志管理组件 - 重构运行状态组件,采用标签页布局 - 新增事件面板组件 - 优化参数模态框,支持数据类型和表单类型联动 - 调整设备模拟组件名称 --- .../detail/components/DeviceSimulation.vue | 69 ++ .../detail/components/LogManagement.vue | 257 +++++ .../detail/components/RunningStatus.vue | 570 +--------- .../detail/components/running/EventsPanel.vue | 219 ++++ .../components/running/RealtimePanel.vue | 481 +++++++++ .../simulation/FunctionSimulation.vue | 975 ++++++++++++++++++ .../src/views/device/device/detail/index.vue | 30 +- .../detail/components/ParameterModal.vue | 177 +++- 8 files changed, 2194 insertions(+), 584 deletions(-) create mode 100644 apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue create mode 100644 apps/web-antd/src/views/device/device/detail/components/LogManagement.vue create mode 100644 apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue create mode 100644 apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue create mode 100644 apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue diff --git a/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue new file mode 100644 index 0000000..0ca9811 --- /dev/null +++ b/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/apps/web-antd/src/views/device/device/detail/components/LogManagement.vue b/apps/web-antd/src/views/device/device/detail/components/LogManagement.vue new file mode 100644 index 0000000..589da6d --- /dev/null +++ b/apps/web-antd/src/views/device/device/detail/components/LogManagement.vue @@ -0,0 +1,257 @@ + + + + + diff --git a/apps/web-antd/src/views/device/device/detail/components/RunningStatus.vue b/apps/web-antd/src/views/device/device/detail/components/RunningStatus.vue index a8b41c4..f99942f 100644 --- a/apps/web-antd/src/views/device/device/detail/components/RunningStatus.vue +++ b/apps/web-antd/src/views/device/device/detail/components/RunningStatus.vue @@ -1,26 +1,10 @@ diff --git a/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue b/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue new file mode 100644 index 0000000..050338e --- /dev/null +++ b/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue b/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue new file mode 100644 index 0000000..2c76b07 --- /dev/null +++ b/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue @@ -0,0 +1,481 @@ + + + + + diff --git a/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue new file mode 100644 index 0000000..25b4cba --- /dev/null +++ b/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue @@ -0,0 +1,975 @@ + + + + + diff --git a/apps/web-antd/src/views/device/device/detail/index.vue b/apps/web-antd/src/views/device/device/detail/index.vue index d0dadb8..1a6200a 100644 --- a/apps/web-antd/src/views/device/device/detail/index.vue +++ b/apps/web-antd/src/views/device/device/detail/index.vue @@ -12,7 +12,7 @@ import { deviceStateOptions } from '#/constants/dicts'; import { useDeviceStore } from '#/store/device'; import BasicInfo from './components/BasicInfo.vue'; -import DeviceFunction from './components/DeviceFunction.vue'; +import DeviceSimulation from './components/DeviceSimulation.vue'; import LogManagement from './components/LogManagement.vue'; import RunningStatus from './components/RunningStatus.vue'; @@ -36,12 +36,12 @@ const loadDeviceInfo = async () => { // 处理状态变更 const handleStatusChange = async (checked: boolean) => { try { - console.log('checked', checked); // await deviceUpdateStatus({ // id: deviceId.value, // enabled: checked, // }); // await loadDeviceInfo(); + console.log("checked",checked) } catch { message.error('状态更新失败'); } @@ -98,7 +98,11 @@ onUnmounted(() => { :class="deviceStateOptions.find((item) => item.value === currentDevice.deviceState)?.type" >• - {{ deviceStateOptions.find((item) => item.value === currentDevice.deviceState)?.label }} + {{ + deviceStateOptions.find( + (item) => item.value === currentDevice.deviceState, + )?.label + }} { - + - - + + @@ -264,11 +276,5 @@ onUnmounted(() => { } } } - - .detail-tabs { - :deep(.ant-tabs-content-holder) { - padding-top: 16px; - } - } } diff --git a/apps/web-antd/src/views/device/product/detail/components/ParameterModal.vue b/apps/web-antd/src/views/device/product/detail/components/ParameterModal.vue index 4ebbae8..ecb31ad 100644 --- a/apps/web-antd/src/views/device/product/detail/components/ParameterModal.vue +++ b/apps/web-antd/src/views/device/product/detail/components/ParameterModal.vue @@ -13,20 +13,43 @@ import { Modal, Row, Select, - SelectOption, Switch, } from 'ant-design-vue'; -import { dataTypeOptions, formTypeOptions } from '#/constants/dicts'; +import { + dataTypeOptions, + formTypeOptions, + timeOptions, +} from '#/constants/dicts'; import EnumListModal from './EnumListModal.vue'; interface ParameterItem { id: string; name: string; - dataType: string; + sort: number; + description: string; required: boolean; - formType: string; + expands: { + source: string; + type: string; + }; + valueParams: { + dataType: string; + enumConf: any[]; + falseText?: string; + falseValue?: string; + format?: string; + formType: string; + length: any; + max?: number; + min?: number; + scale?: number; + trueText?: string; + trueValue?: string; + unit: string; + viewType: string; + }; } interface Props { @@ -48,8 +71,66 @@ const visible = computed({ set: (value) => emit('update:open', value), }); +// 根据数据类型过滤表单类型选项 +const filterFormTypeOptions = computed(() => { + switch (formData?.value?.valueParams?.dataType) { + case 'boolean': { + return formTypeOptions.filter((item) => { + return item.value === 'switch'; + }); + } + case 'date': { + return formTypeOptions.filter((item) => { + return item.value === 'time'; + }); + } + case 'double': + case 'float': + case 'int': + case 'long': { + return formTypeOptions.filter((item) => { + return item.value === 'number' || item.value === 'progress'; + }); + } + case 'enum': { + return formTypeOptions.filter((item) => { + return item.value === 'select'; + }); + } + case 'string': { + return formTypeOptions.filter((item) => { + return ( + item.value === 'input' || + item.value === 'switch' || + item.value === 'select' || + item.value === 'time' + ); + }); + } + default: { + return formTypeOptions; + } + } +}); + +// 根据数据类型过滤时间格式选项 +const filterTimeOptions = computed(() => { + switch (formData?.value?.valueParams?.dataType) { + case 'date': { + return timeOptions.filter((item) => { + return ( + item.value === 'YYYY-MM-DD' || item.value === 'YYYY-MM-DD HH:mm:ss' + ); + }); + } + default: { + return timeOptions; + } + } +}); + // 默认数据 -const defaultPropertyData: PropertyData = { +const defaultPropertyData: ParameterItem = { id: '', name: '', sort: 1, @@ -114,6 +195,36 @@ const modalTitle = computed(() => { return props.parameterType === 'add' ? '新增参数' : '编辑参数'; }); +// 处理数据类型变化 +const handleDataTypeChange = (value: string) => { + switch (value) { + case 'boolean': { + formData.value.valueParams.formType = 'switch'; + break; + } + case 'date': { + formData.value.valueParams.formType = 'time'; + break; + } + case 'double': + case 'float': + case 'int': + case 'long': { + formData.value.valueParams.formType = 'number'; + break; + } + case 'enum': { + formData.value.valueParams.formType = 'select'; + break; + } + case 'string': { + formData.value.valueParams.formType = 'input'; + break; + } + // No default + } +}; + // 验证数据 const validateData = (): boolean => { try { @@ -162,6 +273,19 @@ watch( }, { immediate: true }, ); + +// 监听表单类型变化,设置开关默认值 +watch( + () => formData.value.valueParams.formType, + (newVal) => { + if (newVal === 'switch') { + formData.value.valueParams.trueText = '是'; + formData.value.valueParams.trueValue = 'true'; + formData.value.valueParams.falseText = '否'; + formData.value.valueParams.falseValue = 'false'; + } + }, +);