<!--多选题查看-->
<style>
  .v_multipleQuestion {
    width: 100%;
  }

  .v_multipleQuestionBold {
    font-weight: bold;
    height:40px;
  }
  .mutiTable tfoot:before{
     content: "-";
      display: block;
      line-height: 1em;
      color: transparent;
  }

</style>
<template>
  <div class="v_multipleQuestion">
    <table v-if="data&&data.QuestionContentObj&&data.QuestionContentObj.length>0" class="common_TiTable mutiTable">
      <tbody v-for="(item,index) in data.QuestionContentObj" :key="index">
        <tr>
          <td style="width:40px;text-align:center;">
            <template v-if="isOperate">
              <div class="num_option_dx" style="cursor:pointer;" @click="ChangeItem(item)"
                :class="{'Is_Answer':item.IsAnswer}">
                {{item.ShowName}}
              </div>
            </template>
            <template v-else>
              <div class="num_option_dx2">
                {{item.Name}}
              </div>
            </template>
          </td>
          <td style="height:40px;">
            <div class="InpDIV" style="border:0;" v-html="item.Content"></div>
          </td>
        </tr>
      </tbody>
      <tfoot v-if="isShowAnswer">
        <tr>
          <td colspan="2" class="v_multipleQuestionBold">正确答案：{{data.Answer}}</td>
        </tr>
        <tr v-if="isShowStudentAnswer">
          <td colspan="2" class="v_multipleQuestionBold"
            :style="{color:data.Answer ==data.StundetAnswer?'#67c23a':'red'}">考生答案：{{data.StundetAnswer}}</td>
        </tr>
        <tr v-if="isShowStudentAnswer">
          <td colspan="2" style="height:70px;">
            <q-input v-if="isEditStudentScore" style="width:180px;" filled v-model="data.StudentScore" label="得分："
              maxlength="20" @input="getQuestionScore" />
            <span v-else class="v_multipleQuestionBold">考生得分：{{data.StudentScore}}</span>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <div style="display:flex;">
              <span class="v_multipleQuestionBold">
                解析：
              </span>
              <span v-html="data.AnswerParse"></span>
            </div>
          </td>
        </tr>
      </tfoot>
    </table>
  </div>
</template>
<script>
  export default {
    props: {
      questionObj: {
        type: Object,
      },
      //是否显示答案和解析
      isShowAnswer: {
        type: Boolean,
        default: false,
      },
      //是否可操作(PC端考试使用【可以点击选中】)
      isOperate: {
        type: Boolean,
        default: false,
      },
      //是否显示学生答案
      isShowStudentAnswer: {
        type: Boolean,
        default: false
      },
      //是否可以编辑学生得分
      isEditStudentScore: {
        type: Boolean,
        default: false,
      }
    },
    data() {
      return {
        data: this.questionObj,
      };
    },
    methods: {
      //获取选项答案
      getAnswer() {
        if (this.data && this.data.QuestionContentObj && this.data.QuestionContentObj.length > 0) {
          var answer = "";
          this.data.QuestionContentObj.forEach(item => {
            if (item.IsAnswer) {
              answer += "," + item.Name;
            }
          })
          if (answer != "") {
            answer = answer.substring(1);
          }
          this.data.Answer = answer;
        }
      },
      //点击设为答案
      ChangeItem(item) {
        item.IsAnswer = !item.IsAnswer;
        this.getAnswer();
      },
      //调用父组件计算学生分数
      getQuestionScore() {
        this.$emit('getScore');
      },
    },
    mounted() {

    },
    watch: {
      isShowAnswer: {
        handler(newValue) {

        },
        deep: true
      },
    }
  };

</script>
