<template>
    <template v-if="mode === 'DESIGN'">
      <el-select class="max-fill" v-if="!expanding" size="medium" v-model="_value" disabled :placeholder="placeholder"  filterable clearable/>
      <el-radio-group v-model="_value" v-else>
        <el-radio disabled v-for="(op, index) in options" :key="index" :label="op">{{op}}</el-radio>
      </el-radio-group>
    </template>
    <template v-else>
      <template v-if="perm === 'E'">
        <el-select class="max-fill" v-if="!expanding" v-model="_value" size="medium" clearable :placeholder="placeholder" filterable>
          <el-option v-for="(op, index) in options" :key="index" :value="op" :label="op"></el-option>
        </el-select>
        <el-radio-group v-model="_value" v-else>
          <el-radio v-for="(op, index) in options" :key="index" :label="op">{{op}}</el-radio>
        </el-radio-group>
      </template>
      <template v-else-if="perm === 'R'">
        <span>{{ _value }}</span>
      </template>
    </template>
</template>

<script setup>
import {defineProps,defineEmits} from 'vue'
const emit = defineEmits()

const props = defineProps({
  mode: {
    type: String,
    default: 'DESIGN'
  },
  required: {
    type: Boolean,
    default: false
  },    value:{
    type: String,
    default: null
  },
  perm: {
    type: String,
    default: 'E'
  },
  placeholder:{
    type: String,
    default: '请选择选项'
  },
  expanding:{
    type: Boolean,
    default: false
  },
  options:{
    type: Array,
    default: () => {
      return []
    }
  },
})

const _value = computed({
  get() {
    return props.value;
  },
  set(value) {
    emit('update:value', value)
  }
})
watch(()=>props.value,(value)=>{
  _value.value = value
})

</script>

<style scoped>

</style>
