PageStructDialog.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <el-dialog
  3. class="page-struct-dialog"
  4. :visible.sync="modalIsShow"
  5. title="题卡结构"
  6. top="10vh"
  7. width="600px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <el-table :data="structData">
  14. <el-table-column
  15. prop="topicNo"
  16. label="大题号"
  17. width="80"
  18. ></el-table-column>
  19. <el-table-column prop="topicName" label="大题名称"></el-table-column>
  20. <el-table-column prop="questionsCount" label="小题数" width="80">
  21. <span slot-scope="scope">{{ scope.row.questionsCount || "--" }}</span>
  22. </el-table-column>
  23. </el-table>
  24. <div slot="footer"></div>
  25. </el-dialog>
  26. </template>
  27. <script>
  28. import { mapState } from "vuex";
  29. export default {
  30. name: "PageStructDialog",
  31. data() {
  32. return {
  33. modalIsShow: false,
  34. structData: []
  35. };
  36. },
  37. computed: {
  38. ...mapState("card", ["topics"])
  39. },
  40. methods: {
  41. visibleChange() {
  42. let structData = {};
  43. let curTopicNo = "";
  44. this.topics.forEach(topic => {
  45. if (!topic.parent) return;
  46. curTopicNo = topic.parent.topicNo;
  47. if (structData[curTopicNo]) {
  48. if (topic.type !== "COMPOSITION" && topic.type !== "EXPLAIN") {
  49. structData[curTopicNo].questionsCount += topic.questionsCount;
  50. }
  51. } else {
  52. let sd = {
  53. topicNo: curTopicNo,
  54. topicName: topic.parent.topicName,
  55. questionsCount: topic.questionsCount
  56. };
  57. if (topic.type === "EXPLAIN")
  58. sd.questionsCount = topic.parent.questionsCount;
  59. structData[curTopicNo] = sd;
  60. }
  61. });
  62. structData = Object.values(structData);
  63. structData.sort((a, b) => a.topicNo - b.topicNo);
  64. this.structData = structData;
  65. },
  66. cancel() {
  67. this.modalIsShow = false;
  68. },
  69. open() {
  70. this.modalIsShow = true;
  71. }
  72. }
  73. };
  74. </script>