fix(查询组件): 文本下拉组件的选项新增空数据选项

This commit is contained in:
dataeaseShu 2024-03-14 10:07:53 +08:00
parent 52860c678b
commit 5d12c10806
2 changed files with 39 additions and 6 deletions

View File

@ -635,6 +635,7 @@ const parameterCompletion = () => {
aroundRange: 'f',
arbitraryTimeRange: new Date(),
setTimeRange: false,
showEmpty: false,
timeRange: {
intervalType: 'none',
dynamicWindow: false,
@ -1405,6 +1406,11 @@ defineExpose({
>
</div>
</div>
<div class="list-item" v-if="+curComponent.displayType === 0">
<div class="label">
<el-checkbox v-model="curComponent.showEmpty" label="选项值包含空数据" />
</div>
</div>
<div class="list-item">
<div class="label">
<el-checkbox v-model="curComponent.parametersCheck" label="绑定参数" />

View File

@ -8,6 +8,7 @@ interface SelectConfig {
defaultValue: any
checkedFieldsMap: object
displayType: string
showEmpty: boolean
id: string
checkedFields: string[]
field: {
@ -71,12 +72,14 @@ const handleFieldIdChange = (val: string[]) => {
loading.value = true
getEnumValue(val)
.then(res => {
options.value = (res || []).map(ele => {
return {
label: ele,
value: ele
}
})
options.value = (res || [])
.filter(ele => ele !== null)
.map(ele => {
return {
label: ele,
value: ele
}
})
})
.finally(() => {
loading.value = false
@ -89,6 +92,7 @@ const handleFieldIdChange = (val: string[]) => {
? [...selectValue.value]
: selectValue.value
}
setEmptyData()
})
}
@ -99,6 +103,28 @@ const visibleChange = (val: boolean) => {
}, 50)
}
watch(
() => config.value.showEmpty,
() => {
setEmptyData()
}
)
const setEmptyData = () => {
const { showEmpty, displayType } = config.value
if (+displayType !== 0) return
const [s] = options.value
if (showEmpty) {
if (s?.value !== '_empty_$') {
options.value = [{ label: '空数据', value: '_empty_$' }, ...options.value]
}
} else {
if (s?.value === '_empty_$') {
options.value = options.value.slice(1)
}
}
}
watch(
() => config.value.defaultValue,
val => {
@ -214,6 +240,7 @@ const setOptions = (num: number) => {
}
})
)
setEmptyData()
break
default:
break