<template>
  <a-select
    placeholder="试卷类型"
    allowClear
    :disabled="props.disabled"
    :value="valueStr"
    style="width: 120px"
    @change="handleChange"
  >
    <a-select-option
      v-for="(item, index) in optionList"
      :key="index"
      :value="item"
    >
      {{ item }}
    </a-select-option>
  </a-select>
</template>

<script setup lang="ts">
import { computed } from "vue";

const optionList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");

const props = withDefaults(
  defineProps<{
    value?: string;
    disabled?: boolean;
  }>(),
  {
    value: undefined,
    disabled: false,
  }
);
const emit = defineEmits(["update:value"]);

const valueStr = computed(() => {
  let res: undefined | string = props.value ?? undefined;
  return res as undefined | string;
});

function handleChange(v: undefined | string) {
  emit("update:value", v);
}
</script>
