<template>
  <el-dialog
    class="preview-more-teacher-list-dialog"
    :visible.sync="modalIsShow"
    title="试题难度得分情况分析"
    top="10vh"
    width="800px"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
  >
    <el-table ref="TableList" :data="datas" border @sort-change="sortChange">
      <el-table-column prop="dimensionCode" label="编号"></el-table-column>
      <el-table-column prop="moduleName" label="模块"></el-table-column>
      <el-table-column
        prop="dimensionName"
        label="一级分析维度"
      ></el-table-column>
      <el-table-column
        prop="totalCount"
        label="题数"
        sortable="custom"
      ></el-table-column>
      <el-table-column
        prop="degree"
        label="难度"
        sortable="custom"
      ></el-table-column>
      <el-table-column prop="colScoreRate" label="得分率" sortable="custom">
        <span slot-scope="scope">{{ scope.row.colScoreRate }}%</span>
      </el-table-column>
    </el-table>
    <div slot="footer"></div>
  </el-dialog>
</template>

<script>
export default {
  name: "preview-more-difficult-list-dialog",
  props: {
    datas: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      modalIsShow: false
    };
  },
  methods: {
    sortChange({ prop, order }) {
      if (!order) {
        this.datas.sort((a, b) =>
          a["dimensionCode"] > b["dimensionCode"] ? 1 : -1
        );
      } else {
        const num = order === "ascending" ? 1 : -1;
        this.datas.sort((a, b) => (a[prop] * 1 > b[prop] * 1 ? num : -num));
      }
    },
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    }
  }
};
</script>
