<!--填空题-->
<style>

</style>
<template>
  <div class="fillInQuestion">
    <table v-if="data&&data.length>0">
      <tr v-for="(item,index) in data">
        <td>
          第 {{index+1}} 空</el-checkbox>
        </td>
        <td>
          <UeEditor v-model="item.Content" :config="config"></UeEditor>
        </td>
        <td>
          <a style="cursor:pointer;" @click="deleteOpion(index)">删除</a>
        </td>
      </tr>
      <tfoot>
        <tr>
          <td colspan="3">
            <a style="cursor:pointer;" @click="addOption()">添加选项</a>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <el-checkbox v-model="setOption.IsMutex" :true-label="1" :false-label="0">答案顺序打乱也判正确</el-checkbox>
            <br />
            1. 一个空有多种答案时请用";"隔开。如：水;H2O
            <br />
            2. 若试题答案是数字，可设置范围，两个数字之间用"-"。如：1-9，学生填写1到9之间的数字都算正确（包括1和9）
          </td>
        </tr>
      </tfoot>
    </table>
  </div>
</template>
<script>
  import UeEditor from '../editor/UeEditor'
  export default {
    props: {
      questionData: {
        type: Array,
      },
      setOption: {
        type: Object,
      }
    },
    components: {
      UeEditor
    },
    data() {
      return {
        data: this.questionData,
        config: {
          initialFrameWidth: null,
          initialFrameHeight: 80,
        },
      };
    },
    created() {},
    methods: {
      //删除选项
      deleteOpion(index) {
        this.data.splice(index, 1);
        this.calcOptionTitle();
      },
      //新增选项
      addOption() {
        this.data.push({
          Content: "",
        });
      },
      //返回数据到父组件
      returnDataToParent() {
        this.$emit('getChild', this.data);
      },
    },
    mounted() {

    },
    watch: {
      data: {
        handler(newValue) {
          this.returnDataToParent();
        },
        deep: true
      },
    }
  };

</script>
