<template>
  <el-select
    v-model="selected"
    class="size-select"
    placeholder="考试类型"
    @change="select"
    :style="styles"
    clearable
    :disabled="disabled"
  >
    <el-option
      v-for="item in optionList"
      :key="item.code"
      :label="item.name"
      :value="item.code"
    >
      <span>{{ item.name }}</span>
    </el-option>
  </el-select>
</template>

<script>
export default {
  name: "ExamTypeSelect",
  props: {
    value: {
      type: String,
      default: "",
    },
    styles: { type: String },
    disabled: { type: Boolean, default: false },
  },
  data() {
    return {
      optionList: [
        { code: "ANYTIME", name: "随到随考" },
        { code: "TOGETHER", name: "集中统一" },
      ],
      selected: "",
    };
  },
  async created() {},
  watch: {
    value: {
      immediate: true,
      handler(val) {
        this.selected = val;
      },
    },
  },
  methods: {
    select() {
      this.$emit("input", this.selected);
      this.$emit("change", this.selected);
    },
  },
};
</script>

<style></style>
