feat:【IoT 物联网】场景联动执行器优化对齐后端

This commit is contained in:
puhui999
2025-07-01 21:04:40 +08:00
parent 508de312b3
commit 18758628f1
3 changed files with 90 additions and 28 deletions

View File

@@ -1,7 +1,13 @@
<template>
<div class="bg-[#dbe5f6] flex p-10px">
<div class="flex flex-col items-center justify-center mr-10px h-a">
<el-select v-model="deviceControlConfig.type" class="!w-160px" clearable placeholder="">
<el-select
v-model="deviceControlConfig.type"
disabled
class="!w-160px"
clearable
placeholder=""
>
<el-option label="属性" :value="IotDeviceMessageTypeEnum.PROPERTY" />
<el-option label="服务" :value="IotDeviceMessageTypeEnum.SERVICE" />
</el-select>
@@ -74,7 +80,8 @@ import { ThingModelApi } from '@/api/iot/thingmodel'
import {
ActionDeviceControl,
IotDeviceMessageIdentifierEnum,
IotDeviceMessageTypeEnum
IotDeviceMessageTypeEnum,
IotRuleSceneActionTypeEnum
} from '@/api/iot/rule/scene/scene.types'
import ThingModelParamInput from '../ThingModelParamInput.vue'
@@ -83,6 +90,7 @@ defineOptions({ name: 'DeviceControlAction' })
const props = defineProps<{
modelValue: any
actionType: number
productId?: number
productKey?: string
}>()
@@ -98,10 +106,6 @@ const addParameter = () => {
message.warning('请先选择一个产品')
return
}
if (parameters.value.length >= thingModels.value().length) {
message.warning(`该产品只有${thingModels.value().length}个物模型!!!`)
return
}
parameters.value.push({ identifier: '', value: undefined })
}
const removeParameter = (index: number) => {
@@ -140,8 +144,14 @@ const initDeviceControlConfig = () => {
deviceControlConfig.value = {
productKey: '',
deviceNames: [],
type: IotDeviceMessageTypeEnum.PROPERTY,
identifier: IotDeviceMessageIdentifierEnum.PROPERTY_SET,
type:
props.actionType === IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET
? IotDeviceMessageTypeEnum.PROPERTY
: IotDeviceMessageTypeEnum.SERVICE,
identifier:
props.actionType === IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET
? IotDeviceMessageIdentifierEnum.PROPERTY_SET
: IotDeviceMessageIdentifierEnum.SERVICE_INVOKE,
data: {}
} as ActionDeviceControl
} else {
@@ -208,6 +218,26 @@ watch(
}
)
/** 监听执行类型变化 */
watch(
() => props.actionType,
(val: any) => {
if (!val) {
return
}
// 切换执行类型时清空参数
deviceControlConfig.value.data = {}
parameters.value = []
if (val === IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET) {
deviceControlConfig.value.type = IotDeviceMessageTypeEnum.PROPERTY
deviceControlConfig.value.identifier = IotDeviceMessageIdentifierEnum.PROPERTY_SET
} else if (val === IotRuleSceneActionTypeEnum.DEVICE_SERVICE_INVOKE) {
deviceControlConfig.value.type = IotDeviceMessageTypeEnum.SERVICE
deviceControlConfig.value.identifier = IotDeviceMessageIdentifierEnum.SERVICE_INVOKE
}
}
)
/** 监听消息类型变化 */
watch(
() => deviceControlConfig.value.type,