index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="data_body">
  3. <div style="width: 100%; height: 100%;overflow: auto;">
  4. <el-table :data="tableData" style="width: 100%" :header-cell-style="{ background: '#E0EAFB',color: '#000' }"
  5. :row-class-name="tableRowClassName" class="tableClass">
  6. <el-table-column prop="subject" label="学科" min-width="30" align="center">
  7. </el-table-column>
  8. <el-table-column prop="score1" label="其他考试均分占比(%)" min-width="100" align="center">
  9. </el-table-column>
  10. <el-table-column prop="score2" label="期末分组占比(%)" min-width="90" align="center">
  11. </el-table-column>
  12. </el-table>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. courseNumberArray: {
  20. type: Array,
  21. },
  22. },
  23. data() {
  24. return {
  25. tableData: [
  26. { subject: "体育", score1: "60", score2: "40" },
  27. { subject: "信息技术", score1: "60", score2: "40" },
  28. { subject: "形体", score1: "60", score2: "40" },
  29. { subject: "数学", score1: "60", score2: "40" },
  30. { subject: "科学", score1: "60", score2: "40" },
  31. { subject: "美术", score1: "60", score2: "40" },
  32. { subject: "英语", score1: "60", score2: "40" },
  33. { subject: "语文", score1: "60", score2: "40" },
  34. { subject: "道德与法治", score1: "60", score2: "40" },
  35. { subject: "音乐", score1: "60", score2: "40" },
  36. ],
  37. };
  38. },
  39. methods: {
  40. tableRowClassName({ row, rowIndex }) {
  41. if ((rowIndex + 1) % 2 === 0) {
  42. return "even_row";
  43. } else {
  44. return "";
  45. }
  46. },
  47. setArray(array){
  48. this.tableData = []
  49. for(var i = 0;i<array.length;i++){
  50. this.tableData.push({
  51. sum:array[i].course,
  52. name:array[i].name
  53. })
  54. }
  55. this.tableData = this.tableData.sort(function(a,b){
  56. return b.sum - a.sum;
  57. })
  58. }
  59. },
  60. watch: {
  61. courseNumberArray: {
  62. immediate: true,
  63. deep: true,
  64. handler(newValue, oldValue) {
  65. // this.setArray(newValue)
  66. this.$forceUpdate();
  67. },
  68. },
  69. },
  70. mounted() {
  71. // this.setArray(this.courseNumberArray)
  72. },
  73. };
  74. </script>
  75. <style scoped>
  76. .el-table>>>.even_row {
  77. background-color: #f2f7ff !important;
  78. }
  79. .data_body {
  80. height: 100%;
  81. /* display: flex; */
  82. position: relative;
  83. border-radius: 5px;
  84. /* border: 1px solid #eee; */
  85. margin: 0 auto;
  86. box-sizing: border-box;
  87. padding: 0;
  88. width: 95%;
  89. background: #fff;
  90. }
  91. .tableClass >>> td, .tableClass >>> th{
  92. padding: 5px 0;
  93. }
  94. </style>