perf: 【IoT 物联网】场景联动时间条件配置组件优化

pull/808/head
puhui999 2025-08-07 21:59:28 +08:00
parent 0d91d4bdc0
commit 250fc66c98
2 changed files with 21 additions and 26 deletions

View File

@ -197,7 +197,7 @@ const isDeviceCondition = computed(() => {
* @param field 字段名 * @param field 字段名
* @param value 字段值 * @param value 字段值
*/ */
const updateConditionField = (field: keyof TriggerCondition, value: any) => { const updateConditionField = (field: any, value: any) => {
;(condition.value as any)[field] = value ;(condition.value as any)[field] = value
emit('update:modelValue', condition.value) emit('update:modelValue', condition.value)
} }
@ -216,32 +216,27 @@ const updateCondition = (newCondition: TriggerCondition) => {
* @param type 条件类型 * @param type 条件类型
*/ */
const handleConditionTypeChange = (type: number) => { const handleConditionTypeChange = (type: number) => {
// //
if (type === IotRuleSceneTriggerConditionTypeEnum.DEVICE_STATUS) { const isCurrentTime = type === IotRuleSceneTriggerConditionTypeEnum.CURRENT_TIME
const isDeviceStatus = type === IotRuleSceneTriggerConditionTypeEnum.DEVICE_STATUS
//
if (isCurrentTime || isDeviceStatus) {
condition.value.identifier = undefined condition.value.identifier = undefined
//
if ('timeValue' in condition.value) {
delete (condition.value as any).timeValue
}
if ('timeValue2' in condition.value) {
delete (condition.value as any).timeValue2
}
} else if (type === IotRuleSceneTriggerConditionTypeEnum.CURRENT_TIME) {
condition.value.identifier = undefined
condition.value.productId = undefined
condition.value.deviceId = undefined
} else if (type === IotRuleSceneTriggerConditionTypeEnum.DEVICE_PROPERTY) {
//
if ('timeValue' in condition.value) {
delete (condition.value as any).timeValue
}
if ('timeValue2' in condition.value) {
delete (condition.value as any).timeValue2
}
} }
// 使 //
condition.value.operator = IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.value if (isCurrentTime) {
condition.value.productId = undefined
condition.value.deviceId = undefined
}
//
condition.value.operator = isCurrentTime
? 'at_time'
: IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.value
//
condition.value.param = '' condition.value.param = ''
} }

View File

@ -266,8 +266,8 @@ const deviceStatusChangeOptions = getDeviceStatusChangeOptions() // 设备状态
* @param field 字段名 * @param field 字段名
* @param value 字段值 * @param value 字段值
*/ */
const updateConditionField = (field: keyof Trigger, value: any) => { const updateConditionField = (field: any, value: any) => {
;(condition.value as any)[field] = value condition.value[field] = value
} }
/** /**