From 9bec4dcae002f36aa23231da11cb03a156b40110 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周三, 30 4月 2025 16:24:16 +0800 Subject: [PATCH] 222 --- PipeLineLems/web/src/components/Select/Select.tsx | 43 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 34 insertions(+), 9 deletions(-) diff --git a/PipeLineLems/web/src/components/Select/Select.tsx b/PipeLineLems/web/src/components/Select/Select.tsx index 055b737..a794f4d 100644 --- a/PipeLineLems/web/src/components/Select/Select.tsx +++ b/PipeLineLems/web/src/components/Select/Select.tsx @@ -1,23 +1,48 @@ -import { defineComponent } from 'vue' +import { computed, defineComponent, SetupContext } from 'vue' import IconButton from '@/components/IconButton/IconButton' import { CaretBottom } from '@element-plus/icons-vue' import { useVModel } from '@vueuse/core' +import Option from './Option' +import { has } from 'lodash' -export default defineComponent({ - name: 'Select', - props: {}, - setup(props, { attrs, slots, emit }) { +interface SelectProps { + [key: string]: any +} + +export default defineComponent<SelectProps, any>({ + //@ts-ignore + props: ['disabled', 'optionData', 'options'], + setup(props: SelectProps, { attrs, slots, emit }: any) { + const options = computed(() => { + return ( + props.optionData?.value || + (props.optionData as Array<any>) || + props.options + ) + }) return () => { + const disabled = + typeof props.disabled?.value === 'boolean' + ? props.disabled?.value + : (props.disabled as boolean) return ( <el-select {...attrs} + disabled={disabled} suffix-icon={ - <el-icon> - <CaretBottom /> - </el-icon> + <span style={{ marginRight: '-3px' }}> + <el-icon> + <CaretBottom /> + </el-icon> + </span> } > - {slots.default?.()} + {options.value + ? options.value.map((item: any) => { + const label = item.label || item.name || item.description + return <Option {...item} label={label} /> + }) + : slots.default?.()} </el-select> ) } -- Gitblit v1.9.3