<template>
  <div class="question-item">
    <div class="question-title">
      <span>{{ questionIndex || 1 }}、</span>
      <span>({{ $getQuestionTypeText(data.questionType) }})</span>
      <span v-html="data.questionName"></span>
    </div>
    <div class="options-box">
      <ul class="answer-list">
        <!-- <li :class="{'success-li' : index == 2}" v-for="(item, index) in options" :key="index">
          <span>{{ optionKeys[index] }}、</span>{{ item.label }}
        </li> -->
        <li v-if="data.answerA || data.answerA === 0" :class="{'success-li' : data.rightAnswers.indexOf('A') !== -1}"><span>A、</span>{{ data.answerA }}</li>
        <li v-if="data.answerB || data.answerB === 0" :class="{'success-li' : data.rightAnswers.indexOf('B') !== -1}"><span>B、</span>{{ data.answerB }}</li>
        <li v-if="data.answerC || data.answerC === 0" :class="{'success-li' : data.rightAnswers.indexOf('C') !== -1}"><span>C、</span>{{ data.answerC }}</li>
        <li v-if="data.answerD || data.answerD === 0" :class="{'success-li' : data.rightAnswers.indexOf('D') !== -1}"><span>D、</span>{{ data.answerD }}</li>
        <li v-if="data.answerE || data.answerE === 0" :class="{'success-li' : data.rightAnswers.indexOf('E') !== -1}"><span>E、</span>{{ data.answerE }}</li>
        <li v-if="data.answerF || data.answerF === 0" :class="{'success-li' : data.rightAnswers.indexOf('F') !== -1}"><span>F、</span>{{ data.answerF }}</li>
      </ul>
    </div>
    <div class="flex-center justify-between" style="margin-top: 10px;">
      <div style="flex: 1;">
        <a-button @click="analysisVisible = false" style="padding: 0;" v-if="analysisVisible" type="link">收起答题解析</a-button>
        <a-button @click="analysisVisible = true" style="padding: 0;" v-else type="link">展开答题解析</a-button>
      </div>
      <div style="flex: 1;"></div>
    </div>
    <div class="box" v-show="analysisVisible">
      <div class="flex-center analysis">
        <div class="analysis-label">
          <div class="flex-center" style="height: 30px;">
            <a-tag color="blue" >统计</a-tag>
          </div>
        </div>
        <div class="analysis-value">答题时间：{{data.answerTime}}秒，全站正确率：{{data.accuracyRate}}%，易错项：{{data.wrongItem || '无'}}。</div>
      </div>
      <div class="flex-center analysis">
        <div class="analysis-label">
          <a-tag color="blue" style="margin-top: 6px;">解析</a-tag>
        </div>
        <div class="analysis-value" style="color: #333;">{{data.answerParse || '无'}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default: () => ({})
    },
    questionIndex: {
      type: [Number],
      default: 1
    }, // 题目序号
    type: {
      type: [String, Number], // 1: 单选, 2: 多选, 3: 判断题, 4: 填空题, 5: 简答题
      default: 1
    }
  },
  data () {
    return {
      analysisVisible: true,
      optionKeys: ['A', 'B', 'C', 'D', 'E'],
      radioStyle: {
        display: 'block',
        height: '30px',
        lineHeight: '30px'
      },
      title: '党的十九大报告指出 ，要推动社会主义文化繁荣兴盛，建设社会主义文化强国。下列关于推动社会主义文化繁荣兴盛的说法不正确的是?',
      answer: null, // 选中的选项, 单选: String/Number, 多选: Array
      options: [
        { label: '是提高国家硬实力的必然要求', value: 1 },
        { label: '是新时代坚持和发展中国特色社会主义的必然要求', value: 2 },
        { label: '是实现中华民族伟大复兴中国梦的必然要求', value: 3 },
        { label: '是实现人民对美好生活向往的必然要求', value: 4 }
      ]
    }
  }
}
</script>

<style lang="less" scoped>
.question-item {
  margin-top: 15px;
  font-size: 15px;
}
.question-title {
  margin-bottom: 10px;
  color: #333;
}
.options-box {
  padding-left: 30px;
}

.answer-list{
  margin: 0;
  padding: 0;
  li{
    line-height: 2;
  }
  .success-li{
    color: #52c41a;
  }
}

.box{
    width: 100%;
}
.draw-enter-active, .draw-leave-active {
    transition: all 1s ease;
}
.draw-enter, .draw-leave-to {
    height: 0;
}

.analysis{
  justify-content: center;
  align-items: stretch;
}

.analysis-label{
  flex: 0 0 40px;
  flex-shrink: 0;
}

.analysis-value{
  flex: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-size: 15px;
  color: #000;
  vertical-align: top;
  line-height: 2;
}
</style>
