<!--完型填空-->
<style>
  .vClozeQuestion {
    width: 100%;
  }

  .vClozeQuestion .question_Title {
    color: #A8A8B3;
    font-size: 12px;
    margin-top: 20px;
  }

  .vClozeQuestion .clozeTest_question_tit {
    width: 100%;
    height: 40px;
    background: #F7F8FA;
    padding: 0 20px;
    line-height: 40px;
    font-size: 14px;
    color: #646873;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .vClozeQuestion .clozeTest_question_tit i {
    color: #acbfd9;
    cursor: pointer;
  }  

</style>
<template>
  <div class="vClozeQuestion">
    <template v-if="data&&data.length>0" v-for="(item,index) in data">
      <table class="common_TiTable">
        <thead>
          <tr>
            <th colspan="2">
              <div class="clozeTest_question_tit">
                <div>
                  第{{index+1}}小题
                </div>
              </div>
            </th>
          </tr>
        </thead>
        <tbody class="contant">
          <tr v-for="(subItem,subIndex) in item">
            <td style="width:40px;text-align:center;">
              <div class="Answer_List2" :class="{'Is_Answer':subItem.IsAnswer}">
                {{subItem.Name}}
              </div>
            </td>
            <td>
              <div class="InpDIV" style="border:0;margin-top:-2px;" v-html="subItem.Content">
              </div>
            </td>
          </tr>
        </tbody>
      </table>
    </template>
  </div>
</template>
<script>
  export default {
    props: {
      questionData: {
        type: Array,
      },
      setOption: {
        type: Object,
      }
    },
    components: {

    },
    data() {
      return {
        data: this.questionData,
      };
    },
    created() {

    },
    methods: {
      //返回数据到父组件
      returnDataToParent() {
        this.getAnswer();
        this.$emit('getChild', this.data);
      },
      //获取答案
      getAnswer() {
        this.setOption.Answer = "";
        if (this.data && this.data.length > 0) {
          var answer = "";
          this.data.forEach((item) => {
            item.forEach((subItem) => {
              if (subItem.IsAnswer) {
                answer += "," + subItem.Name;
              }
            })
          })
          if (answer != "") {
            answer = answer.substring(1);
          }
          this.setOption.Answer = answer;
        }
      },
    },
    mounted() {

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

</script>
