<!--分录题-->
<style>
  .entryProblemQuestion {
    width: 100%;
  }

  .entrytk_info {
    color: #A8A8B3;
    font-size: 12px;
    line-height: 24px;
    cursor: default;
  }

</style>
<template>
  <div class="entryProblemQuestion">
    <table v-if="data&&data.length>0" class="common_TiTable">
      <tr v-for="(item,index) in data">
        <td style="width:40px;text-align:center;padding-top:8px;">
          第{{index+1}}空</el-checkbox>
        </td>
        <td>
          <div class="InpDIV" style="border:0;margin-top:-2px;" v-html="item.Content"></div>
        </td>
        <td style="width:40px;text-align:center;">
        </td>
      </tr>
    </table>
    <br />
    <span v-if="setOption.IsMutex==1" style="font-size:13px;">答案顺序打乱也判正确</span>
    <br />
    <br />
    <div class="entrytk_info">
      1. 一个空有多种答案时请用";"隔开。如：水;H2O
      <br />
      2. 若试题答案是数字，可设置范围，两个数字之间用"-"。如：1-9，学生填写1到9之间的数字都算正确（包括1和9）
    </div>
  </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,
        },
        commonIndex: -1,
      };
    },
    created() {},
    methods: {
      //删除选项
      deleteOpion(index) {
        this.$q.dialog({
          title: "删除小题",
          message: "确实要删除该选项吗？",
          persistent: true,
          cancel: {
            label: "取消",
            flat: true
          },
          ok: {
            label: "确认",
            flat: true,
            focus: true
          }
        }).onOk(() => {
          this.data.splice(index, 1);
          this.commonIndex = -1;
        });
      },
      //新增选项
      addOption() {
        this.data.push({
          Content: "",
        });
      },
      //获取答案
      getAnswer() {
        if (this.data && this.data.length > 0) {
          var answer = "";
          this.data.forEach(item => {
            answer += "★" + item.Content;
          })
          if (answer != "") {
            answer = answer.substring(1);
          }
          this.setOption.Answer = answer;
        }
      },
      //返回数据到父组件
      returnDataToParent() {
        this.getAnswer();
        this.$emit('getChild', this.data);
      },
    },
    mounted() {

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

</script>
