PaperBlueInfo.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <el-dialog
  3. title="蓝图分布"
  4. width="100%"
  5. :visible.sync="modalIsShow"
  6. :modal="false"
  7. append-to-body
  8. custom-class="side-dialog"
  9. @open="visibleChange"
  10. >
  11. <el-form>
  12. <el-form-item label="可选属性">
  13. <property-select
  14. v-model="coursePropertyId"
  15. :course-id="courseId"
  16. @change="getPaperData"
  17. >
  18. </property-select>
  19. </el-form-item>
  20. </el-form>
  21. <el-table
  22. :data="paperData.data"
  23. style="width: 100%"
  24. border
  25. :span-method="objectSpanMethod"
  26. >
  27. <el-table-column label="蓝图属性" align="center">
  28. <el-table-column
  29. v-for="(colval, colIndex) in headFirst"
  30. :key="colIndex"
  31. >
  32. <template slot="header">
  33. <span style="margin-left: 10px">{{ colval }}</span>
  34. </template>
  35. <template slot-scope="scope">
  36. <span style="margin-left: 10px">{{ scope.row[colIndex] }}</span>
  37. </template>
  38. </el-table-column>
  39. </el-table-column>
  40. <el-table-column label="大题" align="center">
  41. <el-table-column
  42. v-for="(colval, colIndex) in headSecond"
  43. :key="colIndex"
  44. >
  45. <template slot="header">
  46. <span style="margin-left: 10px">{{ colval }}</span>
  47. </template>
  48. <template slot-scope="scope">
  49. <span style="margin-left: 10px">{{ scope.row[colIndex + 2] }}</span>
  50. </template>
  51. </el-table-column>
  52. </el-table-column>
  53. </el-table>
  54. </el-dialog>
  55. </template>
  56. <script>
  57. import { paperBlueInfoApi } from "../api";
  58. export default {
  59. name: "PaperBlueInfo",
  60. props: {
  61. paperId: {
  62. type: [String, Number],
  63. default: "",
  64. },
  65. courseId: {
  66. type: [String, Number],
  67. default: null,
  68. },
  69. },
  70. data() {
  71. return {
  72. modalIsShow: false,
  73. coursePropertyId: "",
  74. paperData: { head: [] },
  75. headFirst: [],
  76. headSecond: [],
  77. };
  78. },
  79. methods: {
  80. visibleChange() {
  81. this.getPaperData();
  82. },
  83. cancel() {
  84. this.modalIsShow = false;
  85. },
  86. open() {
  87. this.modalIsShow = true;
  88. },
  89. async getPaperData() {
  90. if (!this.coursePropertyId) return;
  91. const res = await paperBlueInfoApi({
  92. paperId: this.paperId,
  93. courseId: this.courseId,
  94. coursePropertyId: this.coursePropertyId,
  95. });
  96. this.paperData = res.data;
  97. this.headFirst = this.paperData.head.slice(0, 2);
  98. this.headSecond = this.paperData.head.slice(2);
  99. },
  100. objectSpanMethod({ rowIndex, columnIndex }) {
  101. if (columnIndex === 0) {
  102. for (let span of this.paperData.rowspan) {
  103. if (span[0] == rowIndex) {
  104. return {
  105. rowspan: span[1] - span[0] + 1,
  106. colspan: 1,
  107. };
  108. } else if (span[0] < rowIndex && span[1] >= rowIndex) {
  109. return {
  110. rowspan: 0,
  111. colspan: 0,
  112. };
  113. }
  114. }
  115. }
  116. },
  117. },
  118. };
  119. </script>