| | |
| | | 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={ |
| | | <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> |
| | | ) |
| | | } |