<template>
  <el-select
    v-model="selected"
    class="size-select"
    placeholder="请选择"
    @change="select"
    :style="styles"
    clearable
  >
    <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: "TaskSelect",
  props: {
    value: {
      type: String,
      default: "",
    },
    options: { type: Array, default: () => null },
    styles: { type: String, default: "width: 100px;" },
  },
  data() {
    return {
      optionList: this.options || [
        { code: "CALCULATE_EXAM_SCORE", name: "考试重新算分" },
        { code: "IMPORT_EXAM_STUDENT", name: "导入考生" },
        { code: "IMPORT_EXAM_PAPER", name: "导入试卷" },
        { code: "IMPORT_INVIGILATE_USER", name: "导入监考员" },
        { code: "EXPORT_INVIGILATE_USER", 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>
