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

fix(查询组件): 查询组件选择数据集设置默认值切换手动输入默认值置空
This commit is contained in:
dataeaseShu 2024-06-03 14:19:20 +08:00 committed by GitHub
commit 48c7cb4b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 13 deletions

View File

@ -389,7 +389,7 @@ const autoStyle = computed(() => {
</script> </script>
<template> <template>
<div class="v-query-container" :style="autoStyle"> <div class="v-query-container" :style="autoStyle" @keydown.stop @keyup.stop>
<p v-if="customStyle.titleShow" class="title" :style="titleStyle"> <p v-if="customStyle.titleShow" class="title" :style="titleStyle">
{{ customStyle.title }} {{ customStyle.title }}
</p> </p>

View File

@ -501,7 +501,6 @@ const validate = () => {
const isMultiple = +ele.displayType === 7 || ele.multiple const isMultiple = +ele.displayType === 7 || ele.multiple
ele.selectValue = isMultiple ? [] : undefined ele.selectValue = isMultiple ? [] : undefined
ele.defaultValue = isMultiple ? [] : undefined ele.defaultValue = isMultiple ? [] : undefined
return false
} }
if (ele.displayType === '1') { if (ele.displayType === '1') {
@ -587,7 +586,7 @@ const validate = () => {
return false return false
} }
if (ele.optionValueSource === 2 && !ele.valueSource?.length) { if (ele.optionValueSource === 2 && !ele.valueSource?.filter(ele => !!ele).length) {
ElMessage.error('手工输入-选项值不能为空') ElMessage.error('手工输入-选项值不能为空')
return true return true
} }
@ -687,6 +686,19 @@ const setConditionOut = () => {
init(conditions.value[conditions.value.length - 1].id) init(conditions.value[conditions.value.length - 1].id)
} }
const setActiveSelectTab = (arr, id) => {
let activelist = 'dimensionList'
arr.some((ele, index) => {
if ((ele || []).some(itx => itx.id === id)) {
activelist = ['dimensionList', 'quotaList', 'parameterList'][index]
return true
}
return false
})
return activelist
}
const init = (queryId: string) => { const init = (queryId: string) => {
if (!datasetTree.value.length) { if (!datasetTree.value.length) {
initDataset() initDataset()
@ -725,7 +737,12 @@ const init = (queryId: string) => {
fields.value = datasetFieldList.value fields.value = datasetFieldList.value
.map(ele => { .map(ele => {
if (!datasetMap[ele.tableId]) return null if (!datasetMap[ele.tableId]) return null
return { ...datasetMap[ele.tableId], componentId: ele.id } const activeCom = datasetMap[ele.tableId].fields || {}
const activelist = setActiveSelectTab(
[activeCom.dimensionList, activeCom.quotaList, activeCom.parameterList],
curComponent.value.checkedFieldsMap[ele.id]
)
return { ...datasetMap[ele.tableId], componentId: ele.id, activelist }
}) })
.filter(ele => !!ele) .filter(ele => !!ele)
}) })
@ -813,6 +830,13 @@ const handleCondition = item => {
idMap.includes(ele) idMap.includes(ele)
) )
if (!!fields.value?.length) { if (!!fields.value?.length) {
fields.value.forEach(ele => {
const activeCom = ele.fields
ele.activelist = setActiveSelectTab(
[activeCom.dimensionList, activeCom.quotaList, activeCom.parameterList],
curComponent.value.checkedFieldsMap[ele.componentId]
)
})
handleCheckedFieldsChange(curComponent.value.checkedFields) handleCheckedFieldsChange(curComponent.value.checkedFields)
} }
multipleChange(curComponent.value.multiple) multipleChange(curComponent.value.multiple)
@ -1337,7 +1361,7 @@ defineExpose({
value="1" value="1"
/> />
<el-option <el-option
:disabled="!['1', '7'].includes(curComponent.displayType)" :disabled="!['1', '7'].includes(curComponent.displayType) || isTimeParameter"
label="时间范围" label="时间范围"
value="7" value="7"
/> />
@ -1544,11 +1568,7 @@ defineExpose({
</el-icon> </el-icon>
</template> </template>
<el-option <el-option
v-for="ele in curComponent.dataset.fields.filter( v-for="ele in curComponent.dataset.fields"
ele =>
ele.deType === +curComponent.displayType ||
([3, 4].includes(ele.deType) && +curComponent.displayType === 2)
)"
:key="ele.id" :key="ele.id"
:label="ele.name" :label="ele.name"
:value="ele.id" :value="ele.id"
@ -1603,6 +1623,13 @@ defineExpose({
<div :key="index" v-for="(_, index) in valueSource" class="select-item"> <div :key="index" v-for="(_, index) in valueSource" class="select-item">
<el-input <el-input
maxlength="20" maxlength="20"
v-if="curComponent.displayType === '2'"
@blur="weightlessness"
v-model.number="valueSource[index]"
></el-input>
<el-input
maxlength="20"
v-else
@blur="weightlessness" @blur="weightlessness"
v-model="valueSource[index]" v-model="valueSource[index]"
></el-input> ></el-input>

View File

@ -334,15 +334,19 @@ watch(
watch( watch(
() => config.value.optionValueSource, () => config.value.optionValueSource,
val => { (valNew, newOld) => {
debounceOptions(val) if ([valNew, newOld].includes(2)) {
selectValue.value = Array.isArray(selectValue.value) ? [] : undefined
config.value.selectValue = cloneDeep(selectValue.value)
config.value.defaultValue = cloneDeep(selectValue.value)
}
debounceOptions(valNew)
} }
) )
watch( watch(
[() => config.value.checkedFields, () => config.value.checkedFieldsMap], [() => config.value.checkedFields, () => config.value.checkedFieldsMap],
() => { () => {
if (!props.isConfig) return
debounceOptions(config.value.optionValueSource) debounceOptions(config.value.optionValueSource)
}, },
{ {