<template>
  <section class="paper-basic-composition">
    <el-form>
      <el-form-item label="整卷属性">
        <div class="topic-set-list">
          <div
            v-for="(paperTag, tagIndex) in paperData.tags"
            :key="tagIndex"
            class="topic-set"
          >
            <div class="topic-set-title">{{ paperTag.tag }}</div>
            <div class="topic-set-content">
              {{ paperTag.content }}
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item label="组成结构">
        <el-table :data="paperData.data" border>
          <el-table-column
            v-for="(colval, colIndex) in paperData.head"
            :key="colIndex"
          >
            <template slot="header">
              <span style="margin-left: 10px">{{ colval }}</span>
            </template>
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row[colIndex] }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
    </el-form>
  </section>
</template>
<script>
import { QUESTION_API } from "@/constants/constants.js";
import { mapState } from "vuex";

export default {
  name: "PaperBasicComposition",
  props: {
    paperId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      paperData: {},
      loading: false,
    };
  },
  computed: {
    ...mapState({ user: (state) => state.user }),
  },
  //初始化查询
  created() {
    this.init();
  },
  methods: {
    init() {
      this.$http
        .get(QUESTION_API + "/paper/basic/composition?id=" + this.paperId)
        .then((response) => {
          this.paperData = response.data;
        });
    },
  },
};
</script>
