From f2001d3409efa4d007cc900d629a638aec8d9c30 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Tue, 24 Jun 2025 16:06:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6):=20v?= =?UTF-8?q?2=E6=96=87=E6=9C=AC=E4=B8=8B=E6=8B=89=E6=A1=86=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=EF=BC=8C=E5=B8=8C=E6=9C=9B=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA=E5=8A=A8=E6=80=81=E5=80=BC=20#12071?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom-component/v-query/Component.vue | 4 +-- .../v-query/ConditionDefaultConfiguration.vue | 10 +++++++ .../v-query/QueryConditionConfiguration.vue | 1 + .../src/custom-component/v-query/Select.vue | 28 ++++++++++++++++++- core/core-frontend/src/locales/en.ts | 1 + core/core-frontend/src/locales/tw.ts | 1 + core/core-frontend/src/locales/zh-CN.ts | 1 + 7 files changed, 43 insertions(+), 3 deletions(-) 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 节点的语法,是否确认将类型改为单源?',