From c06f7f9ebd76025988a9fbcbd39bd89405345e65 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 28 Mar 2025 17:22:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E3=80=91IoT:=20=E5=9C=BA=E6=99=AF=E8=81=94=E5=8A=A8=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/action/ActionExecutor.vue | 63 +++-- .../components/action/DeviceActionControl.vue | 95 ------- .../components/action/DeviceControlAction.vue | 223 +++++++++------- .../components/action/PropertyValueInput.vue | 238 ------------------ 4 files changed, 163 insertions(+), 456 deletions(-) delete mode 100644 src/views/iot/rule/scene/components/action/DeviceActionControl.vue delete mode 100644 src/views/iot/rule/scene/components/action/PropertyValueInput.vue diff --git a/src/views/iot/rule/scene/components/action/ActionExecutor.vue b/src/views/iot/rule/scene/components/action/ActionExecutor.vue index fdcdcc322..dbf4fb0d2 100644 --- a/src/views/iot/rule/scene/components/action/ActionExecutor.vue +++ b/src/views/iot/rule/scene/components/action/ActionExecutor.vue @@ -22,7 +22,7 @@ class="flex items-center mr-60px" > 产品 - + {{ product ? product.name : '选择产品' }} @@ -31,8 +31,8 @@ class="flex items-center mr-60px" > 设备 - - {{ isEmpty(deviceList) ? '选择设备' : actionConfig.deviceControl?.deviceNames.join(',') }} + + {{ isEmpty(deviceList) ? '选择设备' : deviceList.map(d => d.deviceName).join(',') }} @@ -47,6 +47,7 @@ @@ -86,12 +87,13 @@ import AlertAction from './AlertAction.vue' import DataBridgeAction from './DataBridgeAction.vue' import { ProductVO } from '@/api/iot/product/product' import { DeviceVO } from '@/api/iot/device/device' -import { ThingModelApi } from '@/api/iot/thingmodel' import { ActionAlert, ActionConfig, ActionDeviceControl, - IotRuleSceneActionTypeEnum + IotRuleSceneActionTypeEnum, + IotDeviceMessageTypeEnum, + IotDeviceMessageIdentifierEnum } from '@/api/iot/rule/scene/scene.types' /** 场景联动之执行器组件 */ @@ -114,7 +116,13 @@ const initActionConfig = () => { actionConfig.value.type === IotRuleSceneActionTypeEnum.DEVICE_CONTROL && !actionConfig.value.deviceControl ) { - actionConfig.value.deviceControl = {} as ActionDeviceControl + actionConfig.value.deviceControl = { + productKey: '', + deviceNames: [], + type: IotDeviceMessageTypeEnum.PROPERTY, + identifier: IotDeviceMessageIdentifierEnum.PROPERTY_SET, + data: {} + } as ActionDeviceControl } // 告警执行器初始化 @@ -146,22 +154,13 @@ const deviceTableSelectRef = ref>() const product = ref() const deviceList = ref([]) -/** 处理产品选择 */ -const handleProductSelect = (val: ProductVO) => { - product.value = val - actionConfig.value.deviceControl!.productKey = val.productKey - deviceList.value = [] - getThingModelTSL() +/** 处理选择产品 */ +const handleSelectProduct = () => { + productTableSelectRef.value?.open() } -/** 处理设备选择 */ -const handleDeviceSelect = (val: DeviceVO[]) => { - deviceList.value = val - actionConfig.value.deviceControl!.deviceNames = val.map((item) => item.deviceName) -} - -/** 打开设备选择器 */ -const openDeviceSelect = () => { +/** 处理选择设备 */ +const handleSelectDevice = () => { if (!product.value) { message.warning('请先选择一个产品') return @@ -169,12 +168,24 @@ const openDeviceSelect = () => { deviceTableSelectRef.value?.open() } -/** 获取产品物模型 */ -const thingModelTSL = ref() -const getThingModelTSL = async () => { - if (!product.value) { - return +/** 处理产品选择成功 */ +const handleProductSelect = (val: ProductVO) => { + product.value = val + if (actionConfig.value.deviceControl) { + actionConfig.value.deviceControl.productKey = val.productKey + } + // 重置设备选择 + deviceList.value = [] + if (actionConfig.value.deviceControl) { + actionConfig.value.deviceControl.deviceNames = [] + } +} + +/** 处理设备选择成功 */ +const handleDeviceSelect = (val: DeviceVO[]) => { + deviceList.value = val + if (actionConfig.value.deviceControl) { + actionConfig.value.deviceControl.deviceNames = val.map((item) => item.deviceName) } - thingModelTSL.value = await ThingModelApi.getThingModelTSLByProductId(product.value.id) } diff --git a/src/views/iot/rule/scene/components/action/DeviceActionControl.vue b/src/views/iot/rule/scene/components/action/DeviceActionControl.vue deleted file mode 100644 index a1d29cb58..000000000 --- a/src/views/iot/rule/scene/components/action/DeviceActionControl.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - - - diff --git a/src/views/iot/rule/scene/components/action/DeviceControlAction.vue b/src/views/iot/rule/scene/components/action/DeviceControlAction.vue index 52adf7fd3..b04474915 100644 --- a/src/views/iot/rule/scene/components/action/DeviceControlAction.vue +++ b/src/views/iot/rule/scene/components/action/DeviceControlAction.vue @@ -1,78 +1,61 @@ +}) +/** 获得属性单位 */ +const getUnitName = computed(() => (identifier: string) => { + const model = thingModels.value?.find((item: any) => item.identifier === identifier) + // 属性 + if (model?.dataSpecs) { + return model.dataSpecs.unitName + } + // TODO puhui999: 先不考虑服务和事件的情况 + // 服务和事件 + // if (model?.outputParams) { + // return model.dataSpecs.unitName + // } + return '' +}) + diff --git a/src/views/iot/rule/scene/components/action/PropertyValueInput.vue b/src/views/iot/rule/scene/components/action/PropertyValueInput.vue deleted file mode 100644 index 5b03db09e..000000000 --- a/src/views/iot/rule/scene/components/action/PropertyValueInput.vue +++ /dev/null @@ -1,238 +0,0 @@ - - - - -