<!--判断题-->
<style>
  .v_judgeQuestion {
    width: 100%;
  }

  .v_judgeQuestionBold {
    font-weight: bold
  }
  .v_judgeTable tfoot:before{
    content: "-";
    display: block;
    line-height: 1em;
    color: transparent;
  } 
  .judgeTable tfoot:before{
    content: "-";
    display: block;
    line-height: 1em;
    color: transparent;
  }

</style>
<template>
  <div class="v_judgeQuestion">
    <table v-if="data&&data.QuestionContentObj&&data.QuestionContentObj.length>0" class="common_TiTable judgeTable">
      <tbody v-for="(item,index) in data.QuestionContentObj" :key="index">
        <tr>
          <td style="width:50px;text-align:center;">
            <template v-if="isOperate">
              <div class="Answer_List" style="cursor:pointer;" @click="ChangeItem(item)"
                :class="{'Is_Answer':item.IsAnswer}">
                {{item.Name}}
              </div>
            </template>
            <template v-else>
              <div class="Answer_List2">
                {{item.Name}}
              </div>
            </template>
          </td>
          <td style="vertical-align:middle;">
            {{item.Content}}
          </td>
        </tr>
      </tbody>
      <tfoot v-if="isShowAnswer">
        <tr>
          <td colspan="2" style="height:40px;" class="v_judgeQuestionBold">正确答案：{{data.Answer}}</td>
        </tr>
        <tr v-if="isShowStudentAnswer">
          <td colspan="2" class="v_judgeQuestionBold" style="height:40px;" :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" filled style="width:180px" v-model="data.StudentScore" label="得分："
              maxlength="20" @input="getQuestionScore" />
            <span v-else class="v_judgeQuestionBold">考生得分：{{data.StudentScore}}</span>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <div style="display:flex;align-items:center;">
              <span class="v_judgeQuestionBold">
                解析：
              </span>
              <span class="Fill_AnswerPaer" 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,
      };
    },
    created() {},
    methods: {
      ChangeItem(item) {
        if (this.data && this.data.QuestionContentObj && this.data.QuestionContentObj.length > 0) {
          this.data.QuestionContentObj.forEach(item => {
            item.IsAnswer = false;
          })
        }
        item.IsAnswer = true;
        this.data.Answer = item.Name;
      },
      //调用父组件计算学生分数
      getQuestionScore() {
        this.$emit('getScore');
      },
    },
    mounted() {

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

        },
        deep: true
      },
    }
  };

</script>
