From e56be3212a94b3b6f1c69f0bad5f09e62411519b Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Fri, 31 Mar 2023 13:41:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bug#11261=E3=80=8110943=E3=80=8110942?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Save/action/ListItem/FilterCondition.vue | 2 +- .../Scene/Save/components/Terms/ParamsItem.vue | 16 +++++++++++++--- .../Scene/Save/components/Terms/util.ts | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue b/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue index 6c24a00f..8ff62501 100644 --- a/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue +++ b/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue @@ -160,7 +160,7 @@ const showDelete = ref(false) const columnOptions: any = inject('filter-params') // const termTypeOptions = ref>([]) // 条件值 const valueOptions = ref([]) // 默认手动输入下拉 -const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin'] +const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains'] const valueColumnOptions = ref([]) const tabsOptions = ref>( diff --git a/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue b/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue index 21495ac7..0584fa46 100644 --- a/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue +++ b/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue @@ -77,7 +77,7 @@ import DropdownButton from '../DropdownButton' import { getOption } from '../DropdownButton/util' import ParamsDropdown, { DoubleParamsDropdown } from '../ParamsDropdown' import { inject } from 'vue' -import { ContextKey } from './util' +import { ContextKey, arrayParamsKey, timeTypeKeys } from './util' import { useSceneStore } from 'store/scene' import { storeToRefs } from 'pinia'; import { Form } from 'jetlinks-ui-components' @@ -157,7 +157,6 @@ const valueOptions = ref([]) // 默认手动输入下拉 const metricOption = ref([]) // 根据termType获取对应指标值 const isMetric = ref(false) // 是否为指标值 const tabsOptions = ref>([{ label: '手动输入', key: 'manual', component: 'string' }]) -const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin'] const metricsCacheOption = ref([]) // 缓存指标值 const handOptionByColumn = (option: any) => { @@ -280,7 +279,18 @@ const columnSelect = (option: any) => { const termsTypeSelect = (e: { key: string, name: string }) => { const oldValue = isArray(paramsValue.value!.value) ? paramsValue.value!.value[0] : paramsValue.value!.value - const value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue + let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue + // 如果上次的值 在 timeTypeKeys中 则不变 + if (timeTypeKeys.includes(e.key)) { + if (tabsOptions.value[0].component !== 'int') { + value = undefined + } + tabsOptions.value[0].component = 'int' + } else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') { + value = undefined + tabsOptions.value[0].component = 'date' + } + paramsValue.value = { source: paramsValue.value?.source || tabsOptions.value[0].key, value: value diff --git a/src/views/rule-engine/Scene/Save/components/Terms/util.ts b/src/views/rule-engine/Scene/Save/components/Terms/util.ts index fe34cea8..4728f0ba 100644 --- a/src/views/rule-engine/Scene/Save/components/Terms/util.ts +++ b/src/views/rule-engine/Scene/Save/components/Terms/util.ts @@ -1,6 +1,9 @@ import { BranchesThen } from '@/views/rule-engine/Scene/typings' export const ContextKey = 'columnOptions' +export const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains'] +export const timeTypeKeys = ['time_gt_now', 'time_lt_now'] + export const handleParamsData = (data: any[], key: string = 'column'): any[] => { return data?.map(item => {