feat(查询组件): v2文本下拉框默认值,希望可以设置为动态值 #12071

This commit is contained in:
dataeaseShu
2025-06-24 16:06:08 +08:00
committed by xuwei-fit2cloud
parent 65ced556aa
commit f2001d3409
7 changed files with 43 additions and 3 deletions

View File

@@ -475,8 +475,8 @@ const getPlaceholder = computed(() => {
}
})
const isConfirmSearch = id => {
if (componentWithSure.value) return
const isConfirmSearch = (id, disabledFirstItem = false) => {
if (componentWithSure.value && !disabledFirstItem) return
queryDataForId(id)
}

View File

@@ -271,6 +271,11 @@ const relativeToCurrentListRange = computed(() => {
]
})
const defaultValueFirstItemShow = computed(() => {
const { displayType, optionValueSource, multiple } = curComponent.value
return +displayType === 0 && optionValueSource === 1 && !multiple
})
const aroundList = [
{
label: t('dynamic_time.before'),
@@ -662,6 +667,11 @@ defineExpose({
:class="dynamicTime && 'setting'"
>
<div class="setting-label" v-if="dynamicTime">{{ t('template_manage.preview') }}</div>
<div v-if="defaultValueFirstItemShow" class="first-item" style="margin-bottom: 8px">
<el-checkbox v-model="curComponent.defaultValueFirstItem">{{
$t('common.first_item')
}}</el-checkbox>
</div>
<div :class="dynamicTime ? 'setting-value' : 'w100'">
<component :config="curComponent" isConfig ref="inputCom" :is="filterTypeCom"></component>
</div>

View File

@@ -1789,6 +1789,7 @@ const parameterCompletion = ele => {
},
oldTreeLoad: false,
treeCheckedList: [],
defaultValueFirstItem: false,
treeFieldList: []
}
Object.entries(attributes).forEach(([key, val]) => {

View File

@@ -32,6 +32,7 @@ interface SelectConfig {
placeholder: string
resultMode: number
displayId: string
defaultValueFirstItem: boolean
sort: string
sortId: string
checkedFields: string[]
@@ -99,6 +100,10 @@ const cascade = computed(() => {
return cascadeList() || []
})
const disabledFirstItem = computed(() => {
const { defaultValueFirstItem, optionValueSource, multiple } = props.config
return defaultValueFirstItem && optionValueSource === 1 && !multiple
})
const setDefaultMapValue = arr => {
const { displayId, field } = config.value
if (config.value.optionValueSource !== 1) {
@@ -214,7 +219,7 @@ const handleValueChange = () => {
setCascadeValueBack(config.value.mapValue)
emitCascade()
nextTick(() => {
isConfirmSearch(config.value.id)
isConfirmSearch(config.value.id, disabledFirstItem.value)
})
return
}
@@ -366,6 +371,10 @@ const handleFieldIdChange = (val: EnumValue) => {
: selectValue.value
}
if (disabledFirstItem.value) {
setDefaultValueFirstItem()
}
isFromRemote.value = false
})
}
@@ -379,6 +388,20 @@ watch(
}
)
const setDefaultValueFirstItem = () => {
if (!options.value.length) return
selectValue.value = options.value[0].value
handleValueChange()
}
watch(
() => config.value.defaultValueFirstItem,
val => {
if (!val) return
setDefaultValueFirstItem()
}
)
const setEmptyData = () => {
const { showEmpty, displayType, optionValueSource } = config.value
if (+displayType !== 0 || optionValueSource === 1) return
@@ -440,6 +463,7 @@ watch(
}
nextTick(() => {
multiple.value = val
config.value.defaultValueFirstItem = false
if (!val) {
nextTick(() => {
selectValue.value = undefined
@@ -477,6 +501,7 @@ watch(
config.value.defaultValue = cloneDeep(selectValue.value)
}
debounceOptions(valNew)
config.value.defaultValueFirstItem = false
}
)
@@ -684,6 +709,7 @@ defineExpose({
v-loading="loading"
@change="handleValueChange"
clearable
:disabled="disabledFirstItem && props.isConfig"
ref="single"
:style="selectStyle"
filterable

View File

@@ -1,6 +1,7 @@
export default {
common: {
empty: ' ',
first_item: 'First Item',
cross_source: 'Cross-source',
single_source: 'Single-source',
source_tips:

View File

@@ -1,6 +1,7 @@
export default {
common: {
empty: '',
first_item: '首項',
cross_source: '跨源',
single_source: '單源',
source_tips: '資料集存在跨源情況請檢查其他 SQL 節點的語法是否確認將類型改為單源?',

View File

@@ -1,6 +1,7 @@
export default {
common: {
empty: '',
first_item: '首项',
cross_source: '跨源',
single_source: '单源',
source_tips: '数据集存在跨源情况请检查其他 SQL 节点的语法是否确认将类型改为单源?',