【代码优化】IoT: 场景联动执行器设备控制器信息回显
This commit is contained in:
parent
c8fce1e254
commit
04cfded36f
@ -49,6 +49,7 @@
|
|||||||
v-if="actionConfig.type === IotRuleSceneActionTypeEnum.DEVICE_CONTROL"
|
v-if="actionConfig.type === IotRuleSceneActionTypeEnum.DEVICE_CONTROL"
|
||||||
:model-value="actionConfig.deviceControl"
|
:model-value="actionConfig.deviceControl"
|
||||||
:product-id="product?.id"
|
:product-id="product?.id"
|
||||||
|
:product-key="product?.productKey"
|
||||||
@update:model-value="(val) => (actionConfig.deviceControl = val)"
|
@update:model-value="(val) => (actionConfig.deviceControl = val)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ defineOptions({ name: 'DeviceControlAction' })
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: any
|
modelValue: any
|
||||||
productId?: number
|
productId?: number
|
||||||
|
productKey?: string
|
||||||
}>()
|
}>()
|
||||||
const emits = defineEmits(['update:modelValue'])
|
const emits = defineEmits(['update:modelValue'])
|
||||||
const deviceControlConfig = useVModel(props, 'modelValue', emits) as Ref<ActionDeviceControl>
|
const deviceControlConfig = useVModel(props, 'modelValue', emits) as Ref<ActionDeviceControl>
|
||||||
@ -169,11 +170,7 @@ const getThingModelTSL = async () => {
|
|||||||
if (!props.productId) {
|
if (!props.productId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
thingModelTSL.value = await ThingModelApi.getThingModelTSLByProductId(props.productId)
|
||||||
thingModelTSL.value = await ThingModelApi.getThingModelTSLByProductId(props.productId)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取物模型失败', error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const thingModels = computed(() => (identifier?: string): any[] => {
|
const thingModels = computed(() => (identifier?: string): any[] => {
|
||||||
if (isEmpty(thingModelTSL.value)) {
|
if (isEmpty(thingModelTSL.value)) {
|
||||||
@ -183,8 +180,7 @@ const thingModels = computed(() => (identifier?: string): any[] => {
|
|||||||
case IotDeviceMessageTypeEnum.PROPERTY:
|
case IotDeviceMessageTypeEnum.PROPERTY:
|
||||||
return thingModelTSL.value?.properties || []
|
return thingModelTSL.value?.properties || []
|
||||||
case IotDeviceMessageTypeEnum.SERVICE:
|
case IotDeviceMessageTypeEnum.SERVICE:
|
||||||
// TODO puhui999: 要限制只过滤出 set 类型的 service 吗?
|
const service = thingModelTSL.value.services?.find(
|
||||||
const service = thingModelTSL.value.services.find(
|
|
||||||
(item: any) => item.identifier === identifier
|
(item: any) => item.identifier === identifier
|
||||||
)
|
)
|
||||||
return service?.inputParams || []
|
return service?.inputParams || []
|
||||||
@ -200,23 +196,22 @@ const getUnitName = computed(() => (identifier: string) => {
|
|||||||
if (model?.dataSpecs) {
|
if (model?.dataSpecs) {
|
||||||
return model.dataSpecs.unitName
|
return model.dataSpecs.unitName
|
||||||
}
|
}
|
||||||
|
// TODO puhui999: enum、bool、struct 类型数据处理
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 监听 productId 变化 */
|
/** 监听 productId 变化 */
|
||||||
watch(
|
watch(
|
||||||
() => props.productId,
|
() => props.productId,
|
||||||
(newVal) => {
|
() => {
|
||||||
if (!newVal) {
|
getThingModelTSL()
|
||||||
thingModelTSL.value = undefined
|
if (deviceControlConfig.value && deviceControlConfig.value.productKey === props.productKey) {
|
||||||
parameters.value = []
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
getThingModelTSL()
|
|
||||||
// 当产品ID变化时,清空原有数据
|
// 当产品ID变化时,清空原有数据
|
||||||
deviceControlConfig.value.data = {}
|
deviceControlConfig.value.data = {}
|
||||||
},
|
parameters.value = []
|
||||||
{ immediate: true }
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 监听消息类型变化 */
|
/** 监听消息类型变化 */
|
||||||
|
Loading…
Reference in New Issue
Block a user