forked from github/dataease
Merge pull request #11281 from dataease/pr@dev-v2_st
fix(查询组件): 过滤组件更新过滤条件级联中过滤条件没有置空或变更
This commit is contained in:
commit
788bbbfadc
@ -19,7 +19,7 @@ import { getThisStart, getLastStart, getAround } from './time-format-dayjs'
|
||||
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { fieldType } from '@/utils/attr'
|
||||
import { ElMessage, ElSelect } from 'element-plus-secondary'
|
||||
import { ElMessage, ElSelect, ElMessageBox } from 'element-plus-secondary'
|
||||
import type { DatasetDetail } from '@/api/dataset'
|
||||
import { getDsDetailsWithPerm, getSqlParams, listFieldsWithPermissions } from '@/api/dataset'
|
||||
import EmptyBackground from '@/components/empty-background/src/EmptyBackground.vue'
|
||||
@ -156,7 +156,6 @@ const datasetTree = shallowRef([])
|
||||
const fields = ref<DatasetDetail[]>()
|
||||
|
||||
const { queryElement } = toRefs(props)
|
||||
|
||||
const getDetype = (id, arr) => {
|
||||
return arr.flat().find(ele => ele.id === id)?.deType
|
||||
}
|
||||
@ -419,8 +418,39 @@ const computedTree = computed(() => {
|
||||
}
|
||||
return dfs(datasetTree.value)
|
||||
})
|
||||
let newDatasetId = ''
|
||||
let oldDatasetId = ''
|
||||
const handleCurrentChange = node => {
|
||||
oldDatasetId = curComponent.value.dataset?.id
|
||||
newDatasetId = node.id
|
||||
}
|
||||
|
||||
const confirmIdChange = () => {
|
||||
curComponent.value.dataset.id = newDatasetId
|
||||
clearCascadeArrDataset(`${oldDatasetId}--${curComponent.value.id}`)
|
||||
newDatasetId = ''
|
||||
oldDatasetId = ''
|
||||
handleDatasetChange()
|
||||
}
|
||||
|
||||
const handleDatasetChange = () => {
|
||||
if (!!newDatasetId && !!oldDatasetId) {
|
||||
curComponent.value.dataset.id = oldDatasetId
|
||||
ElMessageBox.confirm(
|
||||
'数据集的修改,会导致级联配置失效,因此对应的级联关系将被清除,确定修改吗?',
|
||||
{
|
||||
confirmButtonType: 'primary',
|
||||
type: 'warning',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
autofocus: false,
|
||||
showClose: false
|
||||
}
|
||||
).then(() => {
|
||||
confirmIdChange()
|
||||
})
|
||||
return
|
||||
}
|
||||
curComponent.value.field.id = ''
|
||||
curComponent.value.displayId = ''
|
||||
curComponent.value.sortId = ''
|
||||
@ -580,6 +610,18 @@ const openCascadeDialog = () => {
|
||||
cascadeDialog.value.init(cascadeMap, cascadeArr)
|
||||
}
|
||||
|
||||
const clearCascadeArrDataset = id => {
|
||||
for (let i in cascadeArr) {
|
||||
const [fir, sec] = cascadeArr[i]
|
||||
if (fir?.datasetId.includes(id)) {
|
||||
cascadeArr[i] = []
|
||||
} else if (sec?.datasetId.includes(id)) {
|
||||
cascadeArr[i] = [fir]
|
||||
}
|
||||
}
|
||||
cascadeArr = cascadeArr.filter(ele => !!ele.length)
|
||||
}
|
||||
|
||||
const indexCascade = ' 一二三四五'
|
||||
|
||||
const validateConditionType = ({
|
||||
@ -1639,6 +1681,7 @@ defineExpose({
|
||||
:data="computedTree"
|
||||
placeholder="请选择数据集"
|
||||
@change="handleDatasetChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:props="dsSelectProps"
|
||||
placement="bottom"
|
||||
:render-after-expand="false"
|
||||
|
Loading…
Reference in New Issue
Block a user