22
schangxiang@126.com
2025-04-29 3fdd40af6a7c4ca1b9c833fd7fbe17a9bcc9258f
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
51
52
/**
 * 禁止在非Setting配置下使用
 */
import { 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 './ElOption'
import { has } from 'lodash'
import './index.scss'
 
interface SelectProps {
  [key: string]: any
}
 
export default defineComponent<SelectProps, any>({
  //@ts-ignore
  props: ['disabled'],
  setup(props: SelectProps, { attrs, slots, emit }: any) {
    const namespace = import.meta.env.VITE_APP_NAMESPACE
 
    const options = attrs.optionData?.value || (attrs.optionData as Array<any>)
 
    return () => {
      const disabled =
        typeof props.disabled?.value === 'boolean'
          ? props.disabled?.value
          : (props.disabled as boolean)
      return (
        <el-config-provider namespace={namespace} z-index={500}>
          <el-select
            {...attrs}
            disabled={disabled}
            class="cs-setting-select_custom_style"
            popper-class="settings-cs-select_check"
            suffix-icon={
              <el-icon>
                <CaretBottom />
              </el-icon>
            }
          >
            {options
              ? options.map((item: any) => {
                  return <Option {...item} />
                })
              : slots.default?.()}
          </el-select>
        </el-config-provider>
      )
    }
  },
})