【功能完善】IoT: 场景联动
This commit is contained in:
parent
4eb7188ecf
commit
f46540759f
@ -58,7 +58,8 @@ interface TenantBaseDO {
|
|||||||
|
|
||||||
// 触发条件参数
|
// 触发条件参数
|
||||||
interface TriggerConditionParameter {
|
interface TriggerConditionParameter {
|
||||||
identifier: string // 标识符(属性、事件、服务)
|
identifier0: string // 标识符(事件、服务)
|
||||||
|
identifier: string // 标识符(属性)
|
||||||
operator: string // 操作符
|
operator: string // 操作符
|
||||||
value: string // 比较值
|
value: string // 比较值
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-model="selectedId"
|
v-model="selectedId"
|
||||||
:label="scope.row.id"
|
:value="scope.row.id"
|
||||||
@change="() => handleRadioChange(scope.row)"
|
@change="() => handleRadioChange(scope.row)"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-model="selectedId"
|
v-model="selectedId"
|
||||||
:label="scope.row.id"
|
:value="scope.row.id"
|
||||||
@change="() => handleRadioChange(scope.row)"
|
@change="() => handleRadioChange(scope.row)"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.value"
|
:value="dict.value"
|
||||||
>
|
>
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<div class="m-10px">
|
<div class="m-10px">
|
||||||
<!-- 产品设备回显区域 -->
|
<!-- 产品设备回显区域 -->
|
||||||
<div class="relative bg-[#eff3f7] h-50px flex items-center px-10px">
|
<div class="relative bg-[#eff3f7] h-50px flex items-center px-10px">
|
||||||
@ -76,6 +77,7 @@
|
|||||||
:product-id="product?.id"
|
:product-id="product?.id"
|
||||||
@success="handleDeviceSelect"
|
@success="handleDeviceSelect"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<div class="m-10px">
|
<div class="m-10px">
|
||||||
<div class="relative bg-[#eff3f7] h-50px flex items-center px-10px">
|
<div class="relative bg-[#eff3f7] h-50px flex items-center px-10px">
|
||||||
<div class="flex items-center mr-60px">
|
<div class="flex items-center mr-60px">
|
||||||
@ -62,11 +63,12 @@
|
|||||||
<el-option label="事件" :value="IotDeviceMessageTypeEnum.EVENT" />
|
<el-option label="事件" :value="IotDeviceMessageTypeEnum.EVENT" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
<div class="">
|
<div class="w-70%">
|
||||||
<DeviceListenerCondition
|
<DeviceListenerCondition
|
||||||
v-for="(parameter, index2) in condition.parameters"
|
v-for="(parameter, index2) in condition.parameters"
|
||||||
:key="index2"
|
:key="index2"
|
||||||
:model-value="parameter"
|
:model-value="parameter"
|
||||||
|
:condition-type="condition.type"
|
||||||
:thingModels="thingModels(condition)"
|
:thingModels="thingModels(condition)"
|
||||||
@update:model-value="(val) => (condition.parameters[index2] = val)"
|
@update:model-value="(val) => (condition.parameters[index2] = val)"
|
||||||
class="mb-10px last:mb-0"
|
class="mb-10px last:mb-0"
|
||||||
@ -135,6 +137,7 @@
|
|||||||
:product-id="product?.id"
|
:product-id="product?.id"
|
||||||
@success="handleDeviceSelect"
|
@success="handleDeviceSelect"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -272,12 +275,11 @@ const thingModels = computed(() => (condition: TriggerCondition) => {
|
|||||||
}
|
}
|
||||||
switch (condition.type) {
|
switch (condition.type) {
|
||||||
case IotDeviceMessageTypeEnum.PROPERTY:
|
case IotDeviceMessageTypeEnum.PROPERTY:
|
||||||
return thingModelTSL.value.properties
|
return thingModelTSL.value?.properties || []
|
||||||
// TODO puhui999: 服务和事件后续考虑
|
|
||||||
case IotDeviceMessageTypeEnum.SERVICE:
|
case IotDeviceMessageTypeEnum.SERVICE:
|
||||||
return thingModelTSL.value.services
|
return thingModelTSL.value?.services || []
|
||||||
case IotDeviceMessageTypeEnum.EVENT:
|
case IotDeviceMessageTypeEnum.EVENT:
|
||||||
return thingModelTSL.value.events
|
return thingModelTSL.value?.events || []
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="device-listener-condition">
|
<div class="flex items-center w-1/1">
|
||||||
|
<!-- 选择服务 -->
|
||||||
<el-select
|
<el-select
|
||||||
v-model="conditionParameter.identifier"
|
v-if="
|
||||||
class="!w-240px mr-10px"
|
[IotDeviceMessageTypeEnum.SERVICE, IotDeviceMessageTypeEnum.EVENT].includes(conditionType)
|
||||||
|
"
|
||||||
|
v-model="conditionParameter.identifier0"
|
||||||
|
class="!w-150px mr-10px"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择物模型"
|
placeholder="请选择服务"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="thingModel in thingModels"
|
v-for="thingModel in thingModels"
|
||||||
@ -13,23 +17,33 @@
|
|||||||
:value="thingModel.identifier"
|
:value="thingModel.identifier"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<el-select
|
||||||
|
v-model="conditionParameter.identifier"
|
||||||
|
class="!w-150px mr-10px"
|
||||||
|
clearable
|
||||||
|
placeholder="请选择物模型"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="thingModel in getThingModels"
|
||||||
|
:key="thingModel.identifier"
|
||||||
|
:label="thingModel.name"
|
||||||
|
:value="thingModel.identifier"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
<ConditionSelector
|
<ConditionSelector
|
||||||
v-model="conditionParameter.operator"
|
v-model="conditionParameter.operator"
|
||||||
:data-type="getDataType"
|
:data-type="model?.dataType"
|
||||||
class="!w-180px mr-10px"
|
class="!w-150px mr-10px"
|
||||||
/>
|
/>
|
||||||
<!-- TODO puhui999: 输入值范围校验? -->
|
<ThingModelParamInput
|
||||||
<el-input
|
|
||||||
v-if="
|
v-if="
|
||||||
conditionParameter.operator !==
|
conditionParameter.operator !==
|
||||||
IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_NULL.value
|
IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_NULL.value
|
||||||
"
|
"
|
||||||
|
class="!w-200px mr-10px"
|
||||||
v-model="conditionParameter.value"
|
v-model="conditionParameter.value"
|
||||||
class="!w-240px mr-10px"
|
:thing-model="model"
|
||||||
placeholder="请输入值"
|
/>
|
||||||
>
|
|
||||||
<template v-if="getUnitName" #append> {{ getUnitName }} </template>
|
|
||||||
</el-input>
|
|
||||||
<!-- 按钮插槽 -->
|
<!-- 按钮插槽 -->
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
@ -38,43 +52,36 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import ConditionSelector from './ConditionSelector.vue'
|
import ConditionSelector from './ConditionSelector.vue'
|
||||||
import {
|
import {
|
||||||
|
IotDeviceMessageTypeEnum,
|
||||||
IotRuleSceneTriggerConditionParameterOperatorEnum,
|
IotRuleSceneTriggerConditionParameterOperatorEnum,
|
||||||
TriggerConditionParameter
|
TriggerConditionParameter
|
||||||
} from '@/api/iot/rule/scene/scene.types'
|
} from '@/api/iot/rule/scene/scene.types'
|
||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
|
import ThingModelParamInput from '@/views/iot/rule/scene/components/ThingModelParamInput.vue'
|
||||||
|
|
||||||
|
/** 设备触发条件 */
|
||||||
defineOptions({ name: 'DeviceListenerCondition' })
|
defineOptions({ name: 'DeviceListenerCondition' })
|
||||||
const props = defineProps<{ modelValue: any; thingModels: any }>()
|
const props = defineProps<{ modelValue: any; conditionType: any; thingModels: any }>()
|
||||||
const emits = defineEmits(['update:modelValue'])
|
const emits = defineEmits(['update:modelValue'])
|
||||||
const conditionParameter = useVModel(props, 'modelValue', emits) as Ref<TriggerConditionParameter>
|
const conditionParameter = useVModel(props, 'modelValue', emits) as Ref<TriggerConditionParameter>
|
||||||
|
|
||||||
/** 获得物模型属性类型 */
|
/** 属性就是 thingModels,服务和事件取对应的 outputParams */
|
||||||
const getDataType = computed(() => {
|
const getThingModels = computed(() => {
|
||||||
const model = props.thingModels?.find(
|
switch (props.conditionType) {
|
||||||
(item: any) => item.identifier === conditionParameter.value.identifier
|
case IotDeviceMessageTypeEnum.PROPERTY:
|
||||||
|
return props.thingModels || []
|
||||||
|
case IotDeviceMessageTypeEnum.SERVICE:
|
||||||
|
case IotDeviceMessageTypeEnum.EVENT:
|
||||||
|
return (
|
||||||
|
props.thingModels.find(
|
||||||
|
(item: any) => item.identifier === conditionParameter.value.identifier0
|
||||||
|
)?.outputParams || []
|
||||||
)
|
)
|
||||||
// 属性
|
|
||||||
if (model?.dataSpecs) {
|
|
||||||
return model.dataSpecs.dataType
|
|
||||||
}
|
}
|
||||||
return ''
|
|
||||||
})
|
})
|
||||||
/** 获得属性单位 */
|
|
||||||
const getUnitName = computed(() => {
|
|
||||||
const model = props.thingModels?.find(
|
|
||||||
(item: any) => item.identifier === conditionParameter.value.identifier
|
|
||||||
)
|
|
||||||
// 属性
|
|
||||||
if (model?.dataSpecs) {
|
|
||||||
return model.dataSpecs.unitName
|
|
||||||
}
|
|
||||||
// TODO puhui999: 先不考虑服务和事件的情况
|
|
||||||
// 服务和事件
|
|
||||||
// if (model?.outputParams) {
|
|
||||||
// return model.dataSpecs.unitName
|
|
||||||
// }
|
|
||||||
return ''
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
/** 获得物模型属性、类型 */
|
||||||
|
const model = computed(() =>
|
||||||
|
getThingModels.value.find((item: any) => item.identifier === conditionParameter.value.identifier)
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user