<template>
  <div class="wrapper">
    <div class="content">
      <h2>{{ list.scaleName }}</h2>
      <div class="result">
        <div class="box">
          <p class="score">得分：{{ list.score }}分</p>
          <p class="title">结果：{{ list.result }}</p>
        </div>
      </div>
      <div class="item" v-for="(item, index) in scaleInfo" :key="index">
        <p>{{ item.title }}</p>
        <ul>
          <li v-for="(it, i) in item.scaleList" :key="i">
            <img :src="item.checked == it.score ? check : defaul" />
            <span>{{ it.title }}({{ it.score }})</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import api from "@utils/api.js";
export default {
  data() {
    return {
      list: [],
      scaleInfo: [],
      check: require("../images/radio-check.png"),
      defaul: require("../images/radio-default.png"),
    };
  },
  mounted() {
    let query = this.$route.query;
    this.getScale(query.inquiryId, query.scaleName);
  },
  methods: {
    getScale(inquiryId, scaleName) {
      const param = {
        inquiryId: inquiryId,
        scaleName: scaleName,
      };
      api.getScale(param).then((res) => {
        this.list = res.data.data;
        this.scaleInfo = JSON.parse(res.data.data.dataJson);
      });
    },
  },
};
</script>
<style lang="less" scoped>
.wrapper {
  height: 100vh;
  overflow-y: auto;
  background: #e6e6e6;
  .content {
    height: calc(100vh - 60px);
    overflow-y: auto;
    margin: 30px;
    background: #fff;
    & h2 {
      font-size: 20px;
      text-align: center;
      margin-top: 15px;
    }
    .result {
      display: flex;
      font-size: 14px;
      justify-content: center;
      align-items: center;
      padding: 0 24px;
      .box {
        display: flex;
        padding: 20px 0;
        border-bottom: 1px solid #e6e6e6;
        border-top: 1px solid #e6e6e6;
        & p {
          line-height: 20px;
        }
        .score {
          width: 100px;
          margin-right: 15px;
        }
        .title {
          flex: 1;
          margin: 0;
          color: #666666;
          font-weight: 500;
        }
      }
    }
    .item {
      margin: 15px 24px 0;
      font-size: 14px;
      padding-bottom: 15px;
      border-bottom: 1px solid #e6e6e6;
      & p {
        margin-bottom: 7px;
      }
      ul {
        display: flex;
        flex-flow: wrap;
        li {
          display: flex;
          align-items: center;
          margin-right: 15px;
        }
      }
      & img {
        width: 16px;
        margin-right: 7px;
      }
    }
    .item:last-child {
      border-bottom: none;
    }
  }
}
</style>