|
@@ -1,140 +1,143 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="m-10px">
|
|
|
|
|
- <div class="relative bg-[#eff3f7] h-50px flex items-center px-10px">
|
|
|
|
|
- <div class="flex items-center mr-60px">
|
|
|
|
|
- <span class="mr-10px">触发条件</span>
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="triggerConfig.type"
|
|
|
|
|
- class="!w-240px"
|
|
|
|
|
- clearable
|
|
|
|
|
- placeholder="请选择触发条件"
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="dict in getIntDictOptions(DICT_TYPE.IOT_RULE_SCENE_TRIGGER_TYPE_ENUM)"
|
|
|
|
|
- :key="dict.value"
|
|
|
|
|
- :label="dict.label"
|
|
|
|
|
- :value="dict.value"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div
|
|
|
|
|
- v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE"
|
|
|
|
|
- class="flex items-center mr-60px"
|
|
|
|
|
- >
|
|
|
|
|
- <span class="mr-10px">产品</span>
|
|
|
|
|
- <el-button type="primary" @click="productTableSelectRef?.open()" size="small" plain>
|
|
|
|
|
- {{ product ? product.name : '选择产品' }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div
|
|
|
|
|
- v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE"
|
|
|
|
|
- class="flex items-center mr-60px"
|
|
|
|
|
- >
|
|
|
|
|
- <span class="mr-10px">设备</span>
|
|
|
|
|
- <el-button type="primary" @click="openDeviceSelect" size="small" plain>
|
|
|
|
|
- {{ isEmpty(deviceList) ? '选择设备' : triggerConfig.deviceNames.join(',') }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
- <!-- 删除触发器 -->
|
|
|
|
|
- <div class="absolute top-auto right-16px bottom-auto">
|
|
|
|
|
- <el-tooltip content="删除触发器" placement="top">
|
|
|
|
|
- <slot></slot>
|
|
|
|
|
- </el-tooltip>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <!-- 设备触发器条件 -->
|
|
|
|
|
- <template v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE">
|
|
|
|
|
- <div
|
|
|
|
|
- class="bg-[#dbe5f6] flex p-10px"
|
|
|
|
|
- v-for="(condition, index) in triggerConfig.conditions"
|
|
|
|
|
- :key="index"
|
|
|
|
|
- >
|
|
|
|
|
- <div class="flex flex-col items-center justify-center mr-10px h-a">
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div class="m-10px">
|
|
|
|
|
+ <div class="relative bg-[#eff3f7] h-50px flex items-center px-10px">
|
|
|
|
|
+ <div class="flex items-center mr-60px">
|
|
|
|
|
+ <span class="mr-10px">触发条件</span>
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="condition.type"
|
|
|
|
|
- @change="condition.parameters = []"
|
|
|
|
|
- class="!w-160px"
|
|
|
|
|
|
|
+ v-model="triggerConfig.type"
|
|
|
|
|
+ class="!w-240px"
|
|
|
clearable
|
|
clearable
|
|
|
- placeholder=""
|
|
|
|
|
|
|
+ placeholder="请选择触发条件"
|
|
|
>
|
|
>
|
|
|
- <el-option label="属性" :value="IotDeviceMessageTypeEnum.PROPERTY" />
|
|
|
|
|
- <el-option label="服务" :value="IotDeviceMessageTypeEnum.SERVICE" />
|
|
|
|
|
- <el-option label="事件" :value="IotDeviceMessageTypeEnum.EVENT" />
|
|
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="dict in getIntDictOptions(DICT_TYPE.IOT_RULE_SCENE_TRIGGER_TYPE_ENUM)"
|
|
|
|
|
+ :key="dict.value"
|
|
|
|
|
+ :label="dict.label"
|
|
|
|
|
+ :value="dict.value"
|
|
|
|
|
+ />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</div>
|
|
</div>
|
|
|
- <div class="">
|
|
|
|
|
- <DeviceListenerCondition
|
|
|
|
|
- v-for="(parameter, index2) in condition.parameters"
|
|
|
|
|
- :key="index2"
|
|
|
|
|
- :model-value="parameter"
|
|
|
|
|
- :thingModels="thingModels(condition)"
|
|
|
|
|
- @update:model-value="(val) => (condition.parameters[index2] = val)"
|
|
|
|
|
- class="mb-10px last:mb-0"
|
|
|
|
|
- >
|
|
|
|
|
- <el-tooltip content="删除参数" placement="top">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE"
|
|
|
|
|
+ class="flex items-center mr-60px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span class="mr-10px">产品</span>
|
|
|
|
|
+ <el-button type="primary" @click="productTableSelectRef?.open()" size="small" plain>
|
|
|
|
|
+ {{ product ? product.name : '选择产品' }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE"
|
|
|
|
|
+ class="flex items-center mr-60px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span class="mr-10px">设备</span>
|
|
|
|
|
+ <el-button type="primary" @click="openDeviceSelect" size="small" plain>
|
|
|
|
|
+ {{ isEmpty(deviceList) ? '选择设备' : triggerConfig.deviceNames.join(',') }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- 删除触发器 -->
|
|
|
|
|
+ <div class="absolute top-auto right-16px bottom-auto">
|
|
|
|
|
+ <el-tooltip content="删除触发器" placement="top">
|
|
|
|
|
+ <slot></slot>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- 设备触发器条件 -->
|
|
|
|
|
+ <template v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE">
|
|
|
|
|
+ <div
|
|
|
|
|
+ class="bg-[#dbe5f6] flex p-10px"
|
|
|
|
|
+ v-for="(condition, index) in triggerConfig.conditions"
|
|
|
|
|
+ :key="index"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div class="flex flex-col items-center justify-center mr-10px h-a">
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="condition.type"
|
|
|
|
|
+ @change="condition.parameters = []"
|
|
|
|
|
+ class="!w-160px"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder=""
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option label="属性" :value="IotDeviceMessageTypeEnum.PROPERTY" />
|
|
|
|
|
+ <el-option label="服务" :value="IotDeviceMessageTypeEnum.SERVICE" />
|
|
|
|
|
+ <el-option label="事件" :value="IotDeviceMessageTypeEnum.EVENT" />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="w-70%">
|
|
|
|
|
+ <DeviceListenerCondition
|
|
|
|
|
+ v-for="(parameter, index2) in condition.parameters"
|
|
|
|
|
+ :key="index2"
|
|
|
|
|
+ :model-value="parameter"
|
|
|
|
|
+ :condition-type="condition.type"
|
|
|
|
|
+ :thingModels="thingModels(condition)"
|
|
|
|
|
+ @update:model-value="(val) => (condition.parameters[index2] = val)"
|
|
|
|
|
+ class="mb-10px last:mb-0"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-tooltip content="删除参数" placement="top">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="danger"
|
|
|
|
|
+ circle
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ @click="removeConditionParameter(condition.parameters, index2)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Icon icon="ep:delete" />
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ </DeviceListenerCondition>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- 添加参数 -->
|
|
|
|
|
+ <div class="flex flex-1 flex-col items-center justify-center w-60px h-a">
|
|
|
|
|
+ <el-tooltip content="添加参数" placement="top">
|
|
|
<el-button
|
|
<el-button
|
|
|
- type="danger"
|
|
|
|
|
|
|
+ type="primary"
|
|
|
circle
|
|
circle
|
|
|
size="small"
|
|
size="small"
|
|
|
- @click="removeConditionParameter(condition.parameters, index2)"
|
|
|
|
|
|
|
+ @click="addConditionParameter(condition.parameters)"
|
|
|
>
|
|
>
|
|
|
|
|
+ <Icon icon="ep:plus" />
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- 删除条件 -->
|
|
|
|
|
+ <div
|
|
|
|
|
+ class="device-listener-condition flex flex-1 flex-col items-center justify-center w-a h-a"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-tooltip content="删除条件" placement="top">
|
|
|
|
|
+ <el-button type="danger" size="small" @click="removeCondition(index)">
|
|
|
<Icon icon="ep:delete" />
|
|
<Icon icon="ep:delete" />
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
|
- </DeviceListenerCondition>
|
|
|
|
|
- </div>
|
|
|
|
|
- <!-- 添加参数 -->
|
|
|
|
|
- <div class="flex flex-1 flex-col items-center justify-center w-60px h-a">
|
|
|
|
|
- <el-tooltip content="添加参数" placement="top">
|
|
|
|
|
- <el-button
|
|
|
|
|
- type="primary"
|
|
|
|
|
- circle
|
|
|
|
|
- size="small"
|
|
|
|
|
- @click="addConditionParameter(condition.parameters)"
|
|
|
|
|
- >
|
|
|
|
|
- <Icon icon="ep:plus" />
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </el-tooltip>
|
|
|
|
|
- </div>
|
|
|
|
|
- <!-- 删除条件 -->
|
|
|
|
|
- <div
|
|
|
|
|
- class="device-listener-condition flex flex-1 flex-col items-center justify-center w-a h-a"
|
|
|
|
|
- >
|
|
|
|
|
- <el-tooltip content="删除条件" placement="top">
|
|
|
|
|
- <el-button type="danger" size="small" @click="removeCondition(index)">
|
|
|
|
|
- <Icon icon="ep:delete" />
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </el-tooltip>
|
|
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <!-- 定时触发 -->
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.TIMER"
|
|
|
|
|
+ class="bg-[#dbe5f6] flex items-center justify-between p-10px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span class="w-120px">CRON 表达式</span>
|
|
|
|
|
+ <crontab v-model="triggerConfig.cronExpression" />
|
|
|
</div>
|
|
</div>
|
|
|
- </template>
|
|
|
|
|
- <!-- 定时触发 -->
|
|
|
|
|
- <div
|
|
|
|
|
- v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.TIMER"
|
|
|
|
|
- class="bg-[#dbe5f6] flex items-center justify-between p-10px"
|
|
|
|
|
- >
|
|
|
|
|
- <span class="w-120px">CRON 表达式</span>
|
|
|
|
|
- <crontab v-model="triggerConfig.cronExpression" />
|
|
|
|
|
|
|
+ <!-- 设备触发才可以设置多个触发条件 -->
|
|
|
|
|
+ <el-text
|
|
|
|
|
+ v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE"
|
|
|
|
|
+ class="ml-10px!"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="addCondition"
|
|
|
|
|
+ >
|
|
|
|
|
+ 添加触发条件
|
|
|
|
|
+ </el-text>
|
|
|
</div>
|
|
</div>
|
|
|
- <!-- 设备触发才可以设置多个触发条件 -->
|
|
|
|
|
- <el-text
|
|
|
|
|
- v-if="triggerConfig.type === IotRuleSceneTriggerTypeEnum.DEVICE"
|
|
|
|
|
- class="ml-10px!"
|
|
|
|
|
- type="primary"
|
|
|
|
|
- @click="addCondition"
|
|
|
|
|
- >
|
|
|
|
|
- 添加触发条件
|
|
|
|
|
- </el-text>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
|
|
|
- <!-- 产品、设备的选择 -->
|
|
|
|
|
- <ProductTableSelect ref="productTableSelectRef" @success="handleProductSelect" />
|
|
|
|
|
- <DeviceTableSelect
|
|
|
|
|
- ref="deviceTableSelectRef"
|
|
|
|
|
- multiple
|
|
|
|
|
- :product-id="product?.id"
|
|
|
|
|
- @success="handleDeviceSelect"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <!-- 产品、设备的选择 -->
|
|
|
|
|
+ <ProductTableSelect ref="productTableSelectRef" @success="handleProductSelect" />
|
|
|
|
|
+ <DeviceTableSelect
|
|
|
|
|
+ ref="deviceTableSelectRef"
|
|
|
|
|
+ multiple
|
|
|
|
|
+ :product-id="product?.id"
|
|
|
|
|
+ @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
|
|
|
|
|
- // TODO puhui999: 服务和事件后续考虑
|
|
|
|
|
|
|
+ return thingModelTSL.value?.properties || []
|
|
|
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 []
|
|
|
})
|
|
})
|