schangxiang@126.com
2025-05-07 cace264ad9d86a7831099810b079da1141957add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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'
 
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>
          }
        >
          {options.value
            ? options.value.map((item: any) => {
              const label = item.label || item.name || item.description
              return <Option {...item} label={label} />
            })
            : slots.default?.()}
        </el-select>
      )
    }
  },
})