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 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") {
  49. structData[curTopicNo].questionsCount +=
  50. topic.parent.questionsCount;
  51. }
  52. } else {
  53. let sd = {
  54. topicNo: curTopicNo,
  55. topicName: topic.parent.topicName,
  56. questionsCount: topic.parent.questionsCount
  57. };
  58. structData[curTopicNo] = sd;
  59. }
  60. });
  61. structData = Object.values(structData);
  62. structData.sort((a, b) => a.topicNo - b.topicNo);
  63. this.structData = structData;
  64. },
  65. cancel() {
  66. this.modalIsShow = false;
  67. },
  68. open() {
  69. this.modalIsShow = true;
  70. }
  71. }
  72. };
  73. </script>