<template>
  <div>
    <div class="info">
      <div class="shape">
        <img :src="info.id_photo ? info.id_photo : 'https://zws-imgs-pub.ezijing.com/static/public/e0c63e4d4554f0852e1558426aad20d1.png'" alt="">
      </div>
      <div class="right">
        <div class="name">{{ info.name }}</div>
        <div class="code">{{ info.examinee_number }}</div>
      </div>
    </div>
    <div class="order-num">
      <template v-for="(item, index) in questionParams.question.question_items">
        <div :key="index" v-if="item.question_item_type != 5">
          <div class="tit">{{ item.question_item_title }}</div>
          <ul>
            <template v-for="(cItem, cIndex) in item.question_list">
              <!-- stu1已答  stu2当前  stu3标记 -->
              <li
                :key="cItem.q_order + '-' + cIndex"
                @click="goQuestion(cItem.q_order)"
                :class="questionParams.questionIndex + 1 === cItem.q_order
                  ? questionParams.answerRecord[item.question_item_id]
                    ? questionParams.answerRecord[item.question_item_id][cItem.id]
                      ? questionParams.answerRecord[item.question_item_id][cItem.id].answer.length !== 0
                        ? questionParams.answerRecord[item.question_item_id][cItem.id].sign
                          ? 'stu1 stu2 stu3'
                          : 'stu1 stu2'
                        : questionParams.answerRecord[item.question_item_id][cItem.id].sign
                          ? 'stu2 stu3'
                          : 'stu2'
                      : 'stu2'
                    : 'stu2'
                  : questionParams.answerRecord[item.question_item_id]
                    ? questionParams.answerRecord[item.question_item_id][cItem.id]
                      ? questionParams.answerRecord[item.question_item_id][cItem.id].answer.length !== 0
                        ? questionParams.answerRecord[item.question_item_id][cItem.id].sign
                          ? 'stu1 stu3'
                          : 'stu1'
                        : questionParams.answerRecord[item.question_item_id][cItem.id].sign
                          ? 'stu3'
                          : ''
                      : ''
                    : ''
                "
                >{{ cItem.q_order }}</li>
            </template>
          </ul>
        </div>
        <div :key="index" v-else>
          <div class="tit">{{ item.question_item_title }}</div>
          <ul>
            <template v-for="cItem in item.question_list">
              <template v-for="(lItem, lIndex) in cItem.list">
                <li
                  :key="lItem.q_order +'-'+ lIndex"
                  @click="goQuestion(lItem.q_order)"
                  :class="questionParams.questionIndex + 1 === lItem.q_order
                    ? questionParams.answerRecord[item.question_item_id]
                      ? questionParams.answerRecord[item.question_item_id][lItem.id]
                        ? questionParams.answerRecord[item.question_item_id][lItem.id].answer.length !== 0
                          ? questionParams.answerRecord[item.question_item_id][lItem.id].sign
                            ? 'stu1 stu2 stu3'
                            : 'stu1 stu2'
                          : questionParams.answerRecord[item.question_item_id][lItem.id].sign
                            ? 'stu2 stu3'
                            : 'stu2'
                        : 'stu2'
                      : 'stu2'
                    : questionParams.answerRecord[item.question_item_id]
                      ? questionParams.answerRecord[item.question_item_id][lItem.id]
                        ? questionParams.answerRecord[item.question_item_id][lItem.id].answer.length !== 0
                          ? questionParams.answerRecord[item.question_item_id][lItem.id].sign
                            ? 'stu1 stu3'
                            : 'stu1'
                          : questionParams.answerRecord[item.question_item_id][lItem.id].sign
                            ? 'stu3'
                            : ''
                        : ''
                      : ''
                    "
                  >{{ lItem.q_order }}</li>
              </template>
            </template>
          </ul>
        </div>
      </template>
    </div>
    <ul class="flag-tips">
      <li>
        <div class="circle1"></div>
        <div class="txt">已答</div>
      </li>
      <li>
        <div class="circle2"></div>
        <div class="txt">未答</div>
      </li>
      <li>
        <div class="circle3"></div>
        <div class="txt">当前</div>
      </li>
      <li>
        <div class="circle4"></div>
        <div class="txt">标记</div>
      </li>
    </ul>
  </div>
</template>
<script>
import Bus from '../../components/common/bus.js'
export default {
  props: {
    questionParams: { type: Object, default: () => {} },
    info: { type: Object, default: () => {} }
  },
  mounted() {
    Bus.$on('monitoringChanges', target => {
      this.$forceUpdate()
    })
  },
  methods: {
    goQuestion(n) {
      this.questionParams.questionIndex = n - 1
    }
  }
}
</script>
<style lang="scss" scoped>
.info{
  display: flex;
  align-items: center;
  height: 100px;
  .shape{
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
  }
  img{
    width: 100%;
    // transform: scale(1);
    display: block;
  }
  .right{
    margin-left: 22px;
    .name{
      font-size: 18px;
      color: #222222;
      line-height: 25px;
    }
    .code{
      font-size: 14px;
      color: #222222;
      line-height: 20px;
      margin-top: 5px;
    }
  }
}
.order-num{
  padding-bottom: 90px;
  .tit{
    font-size: 12px;
    color: #999999;
    line-height: 17px;
    margin-bottom: 10px;
  }
  ul{
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
    li{
      cursor: pointer;
      position: relative;
      border-radius: 50px;
      width: 24px;
      height: 24px;
      border: 1px solid #CCCCCC;
      font-size: 14px;
      color: #666666;
      line-height: 24px;
      margin-right: 20px;
      margin-bottom: 10px;
      text-align: center;
      &:nth-child(5n+5){
        margin-right: 0;
      }
      &.stu1{
        background: #999;
        border: 1px solid #999;
      }
      &.stu2{
        width: 22px;
        height: 22px;
        line-height: 22px;
        border: 2px solid #0FC118;
        background: rgba(15, 193, 24, 0.1);
      }
      &.stu3{
        &::after{
          content: '';
          position: absolute;
          top: -1px;
          right: -1px;
          width: 4px;
          height: 4px;
          background: #C01540;
          border-radius: 50%;
        }
      }
    }
  }
}
.flag-tips{
  width: 260px;
  position: fixed;
  bottom: 60px;
  right:0;
  display: flex;
  justify-content: space-around;
  padding: 15px 0 10px;
  background: #fff;
  margin: 0;
  list-style: none;
  li{
    .circle1{
      width: 24px;
      height: 24px;
      background: #999;
      border: 1px solid #999;
      border-radius: 50%;
    }
    .circle2{
      width: 24px;
      height: 24px;
      border: 1px solid #CCCCCC;
      border-radius: 50%;
    }
    .circle3{
      width: 24px;
      height: 24px;
      border: 2px solid #0FC118;
      background: rgba(15, 193, 24, 0.1);
      border-radius: 50%;
    }
    .circle4{
      position: relative;
      width: 24px;
      height: 24px;
      border: 1px solid #CCCCCC;
      border-radius: 50%;
      &::after{
        content: '';
        position: absolute;
        top: -1px;
        right: -1px;
        width: 4px;
        height: 4px;
        background: #C01540;
        border-radius: 50%;
      }
    }
    .txt{
      margin-top: 5px;
      font-size: 12px;
      color: #CCCCCC;
      line-height: 17px;
    }
  }
}
</style>
