Merge pull request #11063 from dataease/pr@dev-v2_st

fix(查询组件): 过滤组件没有查询按钮情况下无法触发清空和重置
This commit is contained in:
dataeaseShu 2024-07-22 10:35:09 +08:00 committed by GitHub
commit 7c5025222b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 11 deletions

View File

@ -410,6 +410,7 @@ const resetData = () => {
pre = [...new Set([...keyList, ...pre])] pre = [...new Set([...keyList, ...pre])]
return pre return pre
}, []) }, [])
!componentWithSure.value && queryData()
} }
const clearData = () => { const clearData = () => {
@ -427,6 +428,7 @@ const clearData = () => {
pre = [...new Set([...keyList, ...pre])] pre = [...new Set([...keyList, ...pre])]
return pre return pre
}, []) }, [])
!componentWithSure.value && queryData()
} }
const listVisible = computed(() => { const listVisible = computed(() => {
return list.value.filter(itx => itx.visible) return list.value.filter(itx => itx.visible)

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, shallowRef, computed, watch, onBeforeUnmount } from 'vue' import { ref, shallowRef, computed, watch, onBeforeUnmount, nextTick } from 'vue'
import { ElMessageBox } from 'element-plus-secondary' import { ElMessageBox } from 'element-plus-secondary'
import { import {
getDatasetTree, getDatasetTree,
@ -42,6 +42,7 @@ const dfs = arr => {
return ele.leaf return ele.leaf
}) })
} }
const computedTree = computed(() => { const computedTree = computed(() => {
if (datasetTree.value[0]?.id === '0') { if (datasetTree.value[0]?.id === '0') {
return dfs(datasetTree.value[0].children) return dfs(datasetTree.value[0].children)
@ -52,16 +53,44 @@ const computedTree = computed(() => {
const isActive = computed(() => { const isActive = computed(() => {
return questionInput.value.trim().length && !!datasetId.value return questionInput.value.trim().length && !!datasetId.value
}) })
const initDataset = () => { const initDataset = async () => {
getDatasetTree({}).then(res => { await getDatasetTree({}).then(res => {
datasetTree.value = (res as unknown as Tree[]) || [] datasetTree.value = (res as unknown as Tree[]) || []
}) })
getListCopilot().then(res => {
const allList = (res as unknown as { history: object }[]) || []
historyBack = allList[allList.length - 1]?.history || []
historyArr.value = cloneDeep(allList).map(ele => ({ ...ele, loading: false }))
if (!!allList.length) {
datasetId.value = allList[0].datasetGroupId
oldId = datasetId.value
datasetId.value && getOptions(datasetId.value)
if (oldId && !oldName) {
nextTick(() => {
dfsName(computedTree.value)
})
}
}
})
} }
const treeSelectRef = ref() const treeSelectRef = ref()
let oldId = '' let oldId = ''
let currentId = '' let currentId = ''
let oldName = '' let oldName = ''
const dfsName = arr => {
return arr.filter(ele => {
if (ele.id === oldId) {
oldName = ele.name
}
if (!!ele.children?.length && !ele.leaf) {
ele.children = dfsName(ele.children)
return !!ele.children?.length
}
return ele.leaf
})
}
const handleDatasetChange = () => { const handleDatasetChange = () => {
if (!!oldId && !!historyArr.value.length) { if (!!oldId && !!historyArr.value.length) {
currentId = datasetId.value currentId = datasetId.value
@ -97,14 +126,7 @@ const getOptions = id => {
} }
initDataset() initDataset()
let historyBack = [] let historyBack = []
getListCopilot().then(res => {
historyBack = (res as unknown as string[]) || []
historyArr.value = cloneDeep(historyBack).map(ele => ({ ...ele, loading: false }))
if (!!historyBack.length) {
datasetId.value = historyBack[0].datasetGroupId
datasetId.value && getOptions(datasetId.value)
}
})
const questionInputRef = ref() const questionInputRef = ref()
const overHeight = ref(false) const overHeight = ref(false)
const { height } = useElementSize(questionInputRef) const { height } = useElementSize(questionInputRef)