<template>
  <el-dialog
    title="基础构成"
    width="100%"
    :visible.sync="modalIsShow"
    :modal="false"
    append-to-body
    custom-class="side-dialog"
    @open="getData"
  >
    <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>
  </el-dialog>
</template>

<script>
import { paperBaseInfoApi } from "../api";

export default {
  name: "PaperBaseInfo",
  props: {
    paperId: {
      type: [String, Number],
      default: "",
    },
  },
  data() {
    return {
      modalIsShow: false,
      paperData: {
        tags: [],
        head: [],
      },
    };
  },
  methods: {
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    },
    async getData() {
      const res = await paperBaseInfoApi(this.paperId);
      this.paperData = res.data;
    },
  },
};
</script>
