|
@@ -35,6 +35,7 @@
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { useVModel } from '@vueuse/core'
|
|
import { useVModel } from '@vueuse/core'
|
|
|
|
|
+import { IotRuleSceneTriggerConditionParameterOperatorEnum } from '@/views/iot/utils/constants'
|
|
|
|
|
|
|
|
/** 操作符选择器组件 */
|
|
/** 操作符选择器组件 */
|
|
|
defineOptions({ name: 'OperatorSelector' })
|
|
defineOptions({ name: 'OperatorSelector' })
|
|
@@ -51,95 +52,103 @@ const emit = defineEmits<{
|
|
|
|
|
|
|
|
const localValue = useVModel(props, 'modelValue', emit)
|
|
const localValue = useVModel(props, 'modelValue', emit)
|
|
|
|
|
|
|
|
-// 所有操作符定义
|
|
|
|
|
|
|
+// 基于枚举的操作符定义
|
|
|
const allOperators = [
|
|
const allOperators = [
|
|
|
{
|
|
{
|
|
|
- value: '=',
|
|
|
|
|
- label: '等于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.name,
|
|
|
symbol: '=',
|
|
symbol: '=',
|
|
|
description: '值完全相等时触发',
|
|
description: '值完全相等时触发',
|
|
|
example: 'temperature = 25',
|
|
example: 'temperature = 25',
|
|
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: '!=',
|
|
|
|
|
- label: '不等于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_EQUALS.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_EQUALS.name,
|
|
|
symbol: '≠',
|
|
symbol: '≠',
|
|
|
description: '值不相等时触发',
|
|
description: '值不相等时触发',
|
|
|
example: 'power != false',
|
|
example: 'power != false',
|
|
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
|
supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: '>',
|
|
|
|
|
- label: '大于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN.name,
|
|
|
symbol: '>',
|
|
symbol: '>',
|
|
|
description: '值大于指定值时触发',
|
|
description: '值大于指定值时触发',
|
|
|
example: 'temperature > 30',
|
|
example: 'temperature > 30',
|
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: '>=',
|
|
|
|
|
- label: '大于等于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN_OR_EQUALS.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.GREATER_THAN_OR_EQUALS.name,
|
|
|
symbol: '≥',
|
|
symbol: '≥',
|
|
|
description: '值大于或等于指定值时触发',
|
|
description: '值大于或等于指定值时触发',
|
|
|
example: 'humidity >= 80',
|
|
example: 'humidity >= 80',
|
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: '<',
|
|
|
|
|
- label: '小于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN.name,
|
|
|
symbol: '<',
|
|
symbol: '<',
|
|
|
description: '值小于指定值时触发',
|
|
description: '值小于指定值时触发',
|
|
|
example: 'temperature < 10',
|
|
example: 'temperature < 10',
|
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: '<=',
|
|
|
|
|
- label: '小于等于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN_OR_EQUALS.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.LESS_THAN_OR_EQUALS.name,
|
|
|
symbol: '≤',
|
|
symbol: '≤',
|
|
|
description: '值小于或等于指定值时触发',
|
|
description: '值小于或等于指定值时触发',
|
|
|
example: 'battery <= 20',
|
|
example: 'battery <= 20',
|
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 'in',
|
|
|
|
|
- label: '包含于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.IN.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.IN.name,
|
|
|
symbol: '∈',
|
|
symbol: '∈',
|
|
|
description: '值在指定列表中时触发',
|
|
description: '值在指定列表中时触发',
|
|
|
example: 'status in [1,2,3]',
|
|
example: 'status in [1,2,3]',
|
|
|
supportedTypes: ['int', 'float', 'string', 'enum']
|
|
supportedTypes: ['int', 'float', 'string', 'enum']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 'between',
|
|
|
|
|
- label: '介于',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_IN.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_IN.name,
|
|
|
|
|
+ symbol: '∉',
|
|
|
|
|
+ description: '值不在指定列表中时触发',
|
|
|
|
|
+ example: 'status not in [1,2,3]',
|
|
|
|
|
+ supportedTypes: ['int', 'float', 'string', 'enum']
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.BETWEEN.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.BETWEEN.name,
|
|
|
symbol: '⊆',
|
|
symbol: '⊆',
|
|
|
description: '值在指定范围内时触发',
|
|
description: '值在指定范围内时触发',
|
|
|
example: 'temperature between 20,30',
|
|
example: 'temperature between 20,30',
|
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
supportedTypes: ['int', 'float', 'double', 'date']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 'contains',
|
|
|
|
|
- label: '包含',
|
|
|
|
|
- symbol: '⊃',
|
|
|
|
|
- description: '字符串包含指定内容时触发',
|
|
|
|
|
- example: 'message contains "error"',
|
|
|
|
|
- supportedTypes: ['string']
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_BETWEEN.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_BETWEEN.name,
|
|
|
|
|
+ symbol: '⊄',
|
|
|
|
|
+ description: '值不在指定范围内时触发',
|
|
|
|
|
+ example: 'temperature not between 20,30',
|
|
|
|
|
+ supportedTypes: ['int', 'float', 'double', 'date']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 'startsWith',
|
|
|
|
|
- label: '开始于',
|
|
|
|
|
- symbol: '⊢',
|
|
|
|
|
- description: '字符串以指定内容开始时触发',
|
|
|
|
|
- example: 'deviceName startsWith "sensor"',
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.LIKE.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.LIKE.name,
|
|
|
|
|
+ symbol: '≈',
|
|
|
|
|
+ description: '字符串匹配指定模式时触发',
|
|
|
|
|
+ example: 'message like "%error%"',
|
|
|
supportedTypes: ['string']
|
|
supportedTypes: ['string']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- value: 'endsWith',
|
|
|
|
|
- label: '结束于',
|
|
|
|
|
- symbol: '⊣',
|
|
|
|
|
- description: '字符串以指定内容结束时触发',
|
|
|
|
|
- example: 'fileName endsWith ".log"',
|
|
|
|
|
- supportedTypes: ['string']
|
|
|
|
|
|
|
+ value: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_NULL.value,
|
|
|
|
|
+ label: IotRuleSceneTriggerConditionParameterOperatorEnum.NOT_NULL.name,
|
|
|
|
|
+ symbol: '≠∅',
|
|
|
|
|
+ description: '值非空时触发',
|
|
|
|
|
+ example: 'data not null',
|
|
|
|
|
+ supportedTypes: ['int', 'float', 'double', 'string', 'bool', 'enum', 'date']
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|