【代码评审】IoT:场景联动的 review

This commit is contained in:
YunaiV
2025-03-23 08:40:37 +08:00
parent eaefbabea2
commit cbdcffb20c
8 changed files with 32 additions and 13 deletions

View File

@ -6,6 +6,7 @@
:placeholder="placeholder"
>
<!-- TODO puhui999: 考虑根据属性类型不同展示不同的可选条件 -->
<!-- TODO @puhui999可以在 scene.types.ts IotRuleSceneTriggerConditionParameterOperatorEnum 枚举下 -->
<el-option label="等于" value="=" />
<el-option label="不等于" value="!=" />
<el-option label="大于" value=">" />
@ -45,6 +46,7 @@ const selectedOperator = computed({
})
</script>
<!-- TODO @puhui999尽量用 unocss -->
<style scoped>
.condition-selector {
width: 100%;

View File

@ -19,13 +19,14 @@
</div>
<div class="flex items-center mr-60px">
<span class="mr-10px">产品</span>
<el-button type="primary" @click="productTableSelectRef?.open()">
<el-button type="primary" @click="productTableSelectRef?.open()" size="small" plain>
<!-- TODO @puhui999最终最好是product ? product.name : '选择产品'减少取反 -->
{{ !product ? '选择产品' : product.name }}
</el-button>
</div>
<div class="flex items-center mr-60px">
<span class="mr-10px">设备</span>
<el-button type="primary" @click="openDeviceSelect">
<el-button type="primary" @click="openDeviceSelect" size="small" plain>
{{ isEmpty(deviceList) ? '选择设备' : triggerConfig.deviceNames.join(',') }}
</el-button>
</div>
@ -106,6 +107,7 @@
<el-text class="ml-10px!" type="primary" @click="addCondition">添加触发条件</el-text>
</div>
<!-- 产品、设备的选择 -->
<IoTProductTableSelect ref="productTableSelectRef" @success="handleProductSelect" />
<IoTDeviceTableSelect
ref="deviceTableSelectRef"
@ -152,6 +154,7 @@ const addCondition = () => {
const removeCondition = (index: number) => {
triggerConfig.value.conditions.splice(index, 1)
}
/** 添加参数 */
const addConditionParameter = (conditionParameters: IotRuleSceneTriggerConditionParameter[]) => {
if (!product.value) {
@ -196,6 +199,7 @@ const openDeviceSelect = () => {
/** 获取产品物模型 */
const thingModelTSL = ref<any>()
const thingModels = computed(() => (condition: IotRuleSceneTriggerCondition) => {
// TODO @puhui999这里最好也用枚举
switch (condition.type) {
case 'property':
return thingModelTSL.value.properties
@ -215,6 +219,7 @@ const getThingModelTSL = async () => {
}
</script>
<!-- TODO @puhui999建议使用 unocss 哈 -->
<style lang="scss" scoped>
.device-listener {
.device-listener-header {