diff --git a/core/core-frontend/src/custom-component/v-query/Component.vue b/core/core-frontend/src/custom-component/v-query/Component.vue index eec37c3e98..c6463758b4 100644 --- a/core/core-frontend/src/custom-component/v-query/Component.vue +++ b/core/core-frontend/src/custom-component/v-query/Component.vue @@ -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) } diff --git a/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue b/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue index 93d02ed83b..cfd3150c5d 100644 --- a/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/ConditionDefaultConfiguration.vue @@ -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'" >
{{ t('template_manage.preview') }}
+
+ {{ + $t('common.first_item') + }} +
diff --git a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue index 97df2583b4..9ecae85dcf 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -1789,6 +1789,7 @@ const parameterCompletion = ele => { }, oldTreeLoad: false, treeCheckedList: [], + defaultValueFirstItem: false, treeFieldList: [] } Object.entries(attributes).forEach(([key, val]) => { diff --git a/core/core-frontend/src/custom-component/v-query/Select.vue b/core/core-frontend/src/custom-component/v-query/Select.vue index cdb52fcfea..3b5f5b7d3c 100644 --- a/core/core-frontend/src/custom-component/v-query/Select.vue +++ b/core/core-frontend/src/custom-component/v-query/Select.vue @@ -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 diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts index d8af667b11..f9f717d68e 100644 --- a/core/core-frontend/src/locales/en.ts +++ b/core/core-frontend/src/locales/en.ts @@ -1,6 +1,7 @@ export default { common: { empty: ' ', + first_item: 'First Item', cross_source: 'Cross-source', single_source: 'Single-source', source_tips: diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts index 9396019072..db68a46316 100644 --- a/core/core-frontend/src/locales/tw.ts +++ b/core/core-frontend/src/locales/tw.ts @@ -1,6 +1,7 @@ export default { common: { empty: '', + first_item: '首項', cross_source: '跨源', single_source: '單源', source_tips: '資料集存在跨源情況,請檢查其他 SQL 節點的語法,是否確認將類型改為單源?', diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 33d9d4cb36..fea34e1507 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -1,6 +1,7 @@ export default { common: { empty: '', + first_item: '首项', cross_source: '跨源', single_source: '单源', source_tips: '数据集存在跨源情况,请检查其他 SQL 节点的语法,是否确认将类型改为单源?',