index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="aggregate">
  3. <el-table :data="tableData" border style="width: 100%" v-loading="tabLoading" @header-click="handleHeaderClick">
  4. <el-table-column fixed align="center" type="index" width="50">
  5. </el-table-column>
  6. <el-table-column fixed align="center" prop="username" label="教师姓名" width="150">
  7. </el-table-column>
  8. <el-table-column fixed align="center" label="教研室" width="130">
  9. <template slot-scope="scope">
  10. <div class="TabBtn" v-if="!scope.row.tea">/</div>
  11. <div class="TabBtn" v-else>{{ scope.row.tea }}</div>
  12. </template>
  13. </el-table-column>
  14. <div v-for="item in titList" :key="item.id">
  15. <el-table-column align="center" :label="item.name">
  16. <div v-for="e in allFrom" :key="e.courseId">
  17. <el-table-column v-if="e.typeid == item.id" align="center" :prop="e.courseId" :label="e.title"
  18. :cell-style="{ color: '#000' }" width="130">
  19. <template slot-scope="scope">
  20. <div v-if="e.juri2 && arrayToArray(scope.row.teaId ? scope.row.teaId.split(',') : [],e.juri2 ? e.juri2.split(',') : []).length && scope.row.works.indexOf(e.courseId) !== -1"
  21. class="yuan blacky"></div>
  22. <div v-else-if="scope.row.works.indexOf(e.courseId) !== -1" class="yuan blacky"></div>
  23. <div v-else-if="e.juri2 && arrayToArray(scope.row.teaId ? scope.row.teaId.split(',') : [],e.juri2 ? e.juri2.split(',') : []).length == 0" class="yuan greyy"></div>
  24. <div v-else class="yuan"></div>
  25. </template>
  26. </el-table-column>
  27. </div>
  28. </el-table-column>
  29. </div>
  30. </el-table>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. userid: this.$route.query.userid,
  38. oid: this.$route.query.oid,
  39. org: this.$route.query.org,
  40. tableData: [],
  41. titList: [],
  42. allFrom: [],
  43. tabLoading: false
  44. };
  45. },
  46. mounted() {
  47. this.getData();
  48. },
  49. methods: {
  50. arrayToArray(arrayo, arrayt) {
  51. let array1 = arrayo;
  52. let array2 = arrayt;
  53. let commonElements = [];
  54. for (let i = 0; i < array1.length; i++) {
  55. for (let j = 0; j < array2.length; j++) {
  56. if (array1[i] === array2[j]) {
  57. commonElements.push(array1[i]);
  58. }
  59. }
  60. }
  61. return commonElements;
  62. },
  63. getData() {
  64. this.tabLoading = true;
  65. let params = {
  66. oid: this.oid,
  67. org: this.org
  68. };
  69. this.ajax
  70. .get(this.$store.state.api + "selectTestWorksAggregate", params)
  71. .then(res => {
  72. let data = res.data[0]; //所有老师
  73. this.titList = res.data[1]; // 所有分类
  74. this.allFrom = res.data[2]; //所有表单
  75. let data3 = res.data[3]; //所有老师填写表单
  76. data.forEach(e => {
  77. e.works = [];
  78. data3.forEach(k => {
  79. if (e.userid == k.userid) {
  80. e.works.push(k.courseid);
  81. }
  82. });
  83. });
  84. this.tableData = data;
  85. this.tabLoading = false;
  86. })
  87. .catch(error => {
  88. console.log(error);
  89. });
  90. },
  91. handleHeaderClick(column, event) {
  92. // console.log("表头被点击", column, event);
  93. this.$router.push(
  94. "/checkToTest?cid=" +
  95. column.property +
  96. "&oid=" +
  97. this.oid +
  98. "&org=" +
  99. this.org +
  100. "&type=" +
  101. 2 +
  102. "&role=" +
  103. this.role
  104. );
  105. // 在这里处理点击事件
  106. }
  107. }
  108. };
  109. </script>
  110. <style scoped>
  111. .yuan {
  112. width: 13px;
  113. height: 13px;
  114. border: 1px solid #000;
  115. border-radius: 100%;
  116. box-sizing: border-box;
  117. margin: 0 auto;
  118. }
  119. .blacky {
  120. background-color: #000;
  121. }
  122. .greyy {
  123. background-color: #eee;
  124. border: 1px solid #eee;
  125. }
  126. </style>