From e3f61a2057463cbf793c91837783289de7a84965 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期三, 18 十二月 2024 15:36:00 +0800 Subject: [PATCH] 指定 result_group_index --- src/components/chat/chatComponents/summaryCom/components/recordSet/components/List.vue | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/components/List.vue b/src/components/chat/chatComponents/summaryCom/components/recordSet/components/List.vue index 065427b..eccf785 100644 --- a/src/components/chat/chatComponents/summaryCom/components/recordSet/components/List.vue +++ b/src/components/chat/chatComponents/summaryCom/components/recordSet/components/List.vue @@ -1,16 +1,25 @@ <template> - <el-select class="w-32" v-model="selectValue" @change="changeValue" :disabled="disabled"> - <el-option v-for="item in data.list" :key="item.value" :value="item.value" :label="item.title"></el-option> + <el-select + class="w-32" + :style="{ width: selectWidth }" + v-model="selectValue" + @change="changeValue" + :disabled="disabled" + :placeholder="data.title" + > + <el-option v-for="item in selectList" :key="item.value" :value="item.value" :label="item.title"></el-option> </el-select> </template> <script setup lang="ts"> -import type { PropType } from 'vue'; -import type { ListParam } from '../types'; +import { ref, type PropType, computed } from 'vue'; +import { getTextWidth } from '/@/utils/util'; +import { StepParam } from '../types'; +import { DAY_STEP_LIST, HOUR_STEP_LIST, IS_DAY_LIST } from './constants'; const props = defineProps({ data: { - type: Object as PropType<ListParam>, + type: Object as PropType<StepParam>, }, disabled: { type: Boolean, @@ -18,7 +27,34 @@ }, }); +const getSelectList = (defaultStepValue: string) => { + if (IS_DAY_LIST.includes(defaultStepValue)) { + return DAY_STEP_LIST; + } else { + return HOUR_STEP_LIST; + } +}; + +const selectList = getSelectList(props.data?.origin?.step_value); +// const fontSize = ref('14px'); + const emit = defineEmits(['change']); +const SELECT_OFFSET = 47; +const selectWidth = computed(() => { + if (props.data?.list?.length > 0) { + // 浠ユ渶澶у瓧闀夸负瀹藉害 + const widthList = props.data.list.map((item) => + getTextWidth(item.title, { + size:'14px', + }) + ); + const maxWidth = Math.max(...widthList); + const realWidth = maxWidth + SELECT_OFFSET; + return realWidth + 'px'; + } else { + return 0; + } +}); const selectValue = defineModel({ type: String, @@ -28,4 +64,8 @@ emit('change', val); }; </script> -<style scoped lang="scss"></style> +<style scoped lang="scss"> +:deep(.el-input) { + font-size: 14px; +} +</style> -- Gitblit v1.9.3