timetable.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="tablebox">
  3. <table class='table'>
  4. <thead class='thead'>
  5. <tr class="tr_one">
  6. <th style="width: 80rpx;flex: 0 0 auto;"></th>
  7. <th v-for="(item,idx) in week" :key="idx">{{item.tit}}</th>
  8. </tr>
  9. </thead>
  10. <tbody class="tbody" v-if="week.length>0">
  11. <tr v-for="(item,index) in timelist" :key="index">
  12. <td class="tbodyl">
  13. <view>{{item.val}}</view>
  14. <view v-if="item.time">{{item.time}}</view>
  15. </td>
  16. <td v-for="(weekite,idx) in week" :key="idx">
  17. <block v-for="(ite,idx) in timetables" :key="idx">
  18. <block v-if="ite.week==weekite.val">
  19. <view v-if="item.val==1" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(1)?'act':''" @click="getChose(ite.oneClass,ite.week,item.val)">
  20. <view class="tit">{{ite.oneClass||''}}</view>
  21. <view class="txt">{{ite.oneTeacher||''}}</view>
  22. </view>
  23. <view v-if="item.val==2" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(2)?'act':''" @click="getChose(ite.twoClass,ite.week,item.val)">
  24. <view class="tit">{{ite.twoClass||''}}</view>
  25. <view class="txt">{{ite.twoTeacher||''}}</view>
  26. </view>
  27. <view v-if="item.val==3" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(3)?'act':''" @click="getChose(ite.threeClass,ite.week,item.val)">
  28. <view class="tit">{{ite.threeClass||''}}</view>
  29. <view class="txt">{{ite.threeTeacher||''}}</view>
  30. </view>
  31. <view v-if="item.val==4" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(4)?'act':''" @click="getChose(ite.fourClass,ite.week,item.val)">
  32. <view class="tit">{{ite.fourClass||''}}</view>
  33. <view class="txt">{{ite.fourTeacher||''}}</view>
  34. </view>
  35. <view v-if="item.val==5" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(5)?'act':''" @click="getChose(ite.fiveClass,ite.week,item.val)">
  36. <view class="tit">{{ite.fiveClass||''}}</view>
  37. <view class="txt">{{ite.fiveTeacher||''}}</view>
  38. </view>
  39. <view v-if="item.val==6" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(6)?'act':''" @click="getChose(ite.sixClass,ite.week,item.val)">
  40. <view class="tit">{{ite.sixClass||''}}</view>
  41. <view class="txt">{{ite.sixTeacher||''}}</view>
  42. </view>
  43. <view v-if="item.val==7" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(7)?'act':''" @click="getChose(ite.sevenClass,ite.week,item.val)">
  44. <view class="tit">{{ite.sevenClass||''}}</view>
  45. <view class="txt">{{ite.sevenTeacher||''}}</view>
  46. </view>
  47. <view v-if="item.val==8" class="lit" :class="ite.teacherClassNum&&ite.teacherClassNum.includes(8)?'act':''" @click="getChose(ite.eightClass,ite.week,item.val)">
  48. <view class="tit">{{ite.eightClass||''}}</view>
  49. <view class="txt">{{ite.eightTeacher||''}}</view>
  50. </view>
  51. </block>
  52. </block>
  53. </td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. </view>
  58. </template>
  59. <script>
  60. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  61. export default {
  62. name: 'Timetable',
  63. props: {
  64. timelist: {
  65. type: Array,
  66. default: () => {
  67. return [{ val: '1'},{ val: '2'}, { val: '3'},{ val: '4'},{ val: '5'},{ val: '6'},{ val: '7'},{ val: '8'}]
  68. }
  69. },
  70. week: {
  71. type: Array,
  72. default: () => {
  73. return [{tit:'周一',val:1}, {tit:'周二',val:2}, {tit:'周三',val:3}, {tit:'周四',val:4}, {tit:'周五',val:5}]
  74. }
  75. },
  76. timetables: {
  77. type: Array,
  78. default: () => {
  79. return []
  80. }
  81. },
  82. palette: {
  83. type: Array,
  84. default: () => {
  85. return []
  86. }
  87. },
  88. roles:{
  89. }
  90. },
  91. data () {
  92. return {
  93. allPalette: [...this.palette, '#f05261', '#48a8e4', '#ffd061', '#52db9a', '#70d3e6', '#52db9a', '#3f51b5', '#f3d147', '#4adbc3', '#673ab7', '#f3db49', '#76bfcd', '#b495e1', '#ff9800', '#8bc34a']
  94. }
  95. },
  96. mounted() {
  97. // console.log(this.timelist)
  98. },
  99. computed: {
  100. todayWeekIndex () {
  101. let weekIndex = new Date().getDay() - 1
  102. if (weekIndex === -1) {
  103. weekIndex = 6
  104. }
  105. return weekIndex
  106. }
  107. },
  108. methods: {
  109. checkPermi, checkRole,
  110. handleCourseClick (course, weekIndex, courseIndex) {
  111. const data = {
  112. index: courseIndex + 1,
  113. length: course.length,
  114. week: this.week[weekIndex],
  115. weekIndex: weekIndex,
  116. name: course.name
  117. }
  118. console.log(`星期${data.week}; 第${data.index}节课; 课程名:${data.name}; 课节:${data.length}`)
  119. console.log(data)
  120. this.$emit('courseClick', data)
  121. },
  122. getChose(course,zweek,val){
  123. if(checkPermi(['course:change:add'])){
  124. var newobj={
  125. subject:course,
  126. subjectWeek:zweek,
  127. isNum:val,
  128. }
  129. this.$emit("getChose",newobj)
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped lang="scss">
  136. .tablebox{
  137. .table{border-spacing: 0;width: 100%;display: flex;flex-direction: column;overflow: hidden;
  138. tr{display: flex;}
  139. .thead{width: 100%;background-color:#F5F5F5;flex: 0 0 auto;border-radius: 10rpx;
  140. th{padding:10rpx 8rpx;box-sizing: border-box;font-size: 24rpx;color: #838383;font-weight: 500;text-align: center;flex: 1;
  141. }
  142. }
  143. .tbody {flex: 1;overflow: auto;
  144. td{min-height: 100rpx;box-sizing: border-box;font-weight: 500;color: #343434;font-size: 28rpx;text-align: center;word-break: break-all;flex: 1;display: flex;align-items: center;justify-content: center;flex-direction: column;background-color: #ffffff;padding: 0;
  145. .lit{padding: 16rpx 12rpx;box-sizing: border-box;width: 100%;height: 100%;
  146. // &.act{background-color:#fbb0b0;
  147. &.act{background-color:#EBEBEB;
  148. .txt{color: #6f6f6f;}
  149. }
  150. }
  151. }
  152. .tbodyl{display: flex;align-items: center;justify-content: center;flex: 0 0 auto;width: 80rpx;background-color:#F5F5F5;font-size: 24rpx;color: #838383;font-weight: 500;
  153. }
  154. .tit{font-size: 30rpx;color: #161616;}
  155. .txt{font-size: 26rpx;color: #AAAAAA;}
  156. }
  157. }
  158. }
  159. table, td,th{
  160. border: 1rpx solid #E6E6E6;;
  161. border-collapse: collapse;
  162. }
  163. </style>