PageStructDialog.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 curTopicId = 0;
  44. this.topics.forEach((topic) => {
  45. if (!topic.parent) return;
  46. if (curTopicId !== topic.parent.id) {
  47. curTopicId = topic.parent.id;
  48. let questionsCount = 0;
  49. if (topic.type === "COMPOSITION") {
  50. questionsCount = 1;
  51. } else {
  52. questionsCount = topic.parent.questionsCount;
  53. }
  54. let data = {
  55. topicNo: topic.parent.topicNo,
  56. topicName: topic.parent.topicName,
  57. questionsCount,
  58. };
  59. structData.push(data);
  60. }
  61. });
  62. this.structData = structData;
  63. },
  64. cancel() {
  65. this.modalIsShow = false;
  66. },
  67. open() {
  68. this.modalIsShow = true;
  69. },
  70. },
  71. };
  72. </script>