fix: bug#10956

This commit is contained in:
xieyonghong 2023-03-26 21:14:17 +08:00
parent 6f8f77bcd6
commit 1d782a1231
2 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import type { Slots } from 'vue'
import { TOKEN_KEY } from '@/utils/variable'
import { message } from 'jetlinks-ui-components';
import {cloneDeep} from "lodash-es";
/**
*
@ -133,4 +134,15 @@ export const handleParamsToString = (terms:SearchItemData[] = []) => {
})
return JSON.stringify({ terms: _terms})
}
export const treeFilter = (data: any[], value: any, key: string = 'name'): any[] => {
return data?.filter(item => {
if (item.children && item.children.length) {
item.children = treeFilter(item.children || [], value, key)
return !!item.children.length
} else {
return item[key] === value
}
}) || []
}

View File

@ -83,8 +83,9 @@ import ParamsDropdown, { DoubleParamsDropdown } from '../../components/ParamsDro
import { inject } from 'vue'
import { useSceneStore } from 'store/scene'
import { storeToRefs } from 'pinia';
import { flattenDeep, set } from 'lodash-es'
import {cloneDeep, flattenDeep, set} from 'lodash-es'
import { Form } from 'jetlinks-ui-components'
import {treeFilter} from "@/utils/comm";
const sceneStore = useSceneStore()
const { data: formModel } = storeToRefs(sceneStore)
@ -160,7 +161,7 @@ const columnOptions: any = inject('filter-params') //
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) //
const valueOptions = ref<any[]>([]) //
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin']
const valueColumnOptions = ref([])
const valueColumnOptions = ref<any[]>([])
const tabsOptions = ref<Array<TabsOption>>(
[
@ -183,7 +184,7 @@ const handOptionByColumn = (option: any) => {
} else{
valueOptions.value = option.options || []
}
valueColumnOptions.value = columnOptions.value
valueColumnOptions.value = treeFilter(cloneDeep(columnOptions.value), option.type, 'type')
} else {
termTypeOptions.value = []
valueOptions.value = []