diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue index 3f84e887..297674b7 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue @@ -177,7 +177,7 @@ const functionRules = [ return Promise.reject('请输入功能值'); } else { const hasValue = value?.find( - (item: { name: string; value: any }) => !item.value, + (item: { name: string; value: any }) => item.value === undefined, ); if (hasValue) { const functionItem = functions.value?.find( diff --git a/src/views/rule-engine/Scene/Save/components/DropdownButton/util.ts b/src/views/rule-engine/Scene/Save/components/DropdownButton/util.ts index 4fc4345c..9346be24 100644 --- a/src/views/rule-engine/Scene/Save/components/DropdownButton/util.ts +++ b/src/views/rule-engine/Scene/Save/components/DropdownButton/util.ts @@ -1,4 +1,4 @@ -import { isEqual } from 'lodash-es' +import { isBoolean, isEqual } from 'lodash-es' export type DropdownButtonOptions = { label: string; @@ -34,9 +34,10 @@ export const getComponent = (type: string): string => { export const getOption = (data: any[], value?: string | number | boolean, key: string = 'name'): DropdownButtonOptions | any => { let option if (value === undefined && value === null) return option + let _value = isBoolean(value) ? String(value) : value for (let i = 0; i < data.length; i++) { const item = data[i] - if (isEqual(item[key], value)) { + if (isEqual(item[key], _value)) { option = data[i] break } else if (item.children && item.children.length) { diff --git a/src/views/rule-engine/Scene/Save/components/ParamsDropdown/index.vue b/src/views/rule-engine/Scene/Save/components/ParamsDropdown/index.vue index 34042720..ec82f726 100644 --- a/src/views/rule-engine/Scene/Save/components/ParamsDropdown/index.vue +++ b/src/views/rule-engine/Scene/Save/components/ParamsDropdown/index.vue @@ -162,7 +162,7 @@ watchEffect(() => { const option = getOption(_options, props.value as string, props.valueName) // 回显label值 myValue.value = props.value mySource.value = props.source - console.log(option, _options, props.valueName) + console.log('paramsDropdown', option, _options, props.valueName, props.value, typeof props.value) if (option) { label.value = option[props.labelName] || option.name treeOpenKeys.value = openKeysByTree(_options, props.value, props.valueName)