time-table.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div id="index" style="padding-left:0rem">
  3. <el-row type="flex" align="middle" justify="end" class="btn_bar">
  4. <el-col :span="4" class="printingBtn">
  5. <el-button type="primary" size="mini" @click="toPrint()">打印课程表</el-button>
  6. </el-col>
  7. </el-row>
  8. <el-row class="rowLesson" type="flex" justify="center" ref="print">
  9. <el-col :span="21" class="timeTable">
  10. <el-col :span="24" class="top">
  11. <el-col :span="24" class="title"> {{ titleYear }}年第({{ data.term }})期高校大学生就业能力拓展训练课程表({{ getClassName(data.name) }}) </el-col>
  12. <el-col :span="24" class="date"> ({{ th[0] }}—{{ th[th.length - 1] }}) </el-col>
  13. </el-col>
  14. <el-col :span="24" class="info">
  15. <table border="1" class="table">
  16. <tr>
  17. <th colspan="2" class="th">
  18. <p style="text-align:right;padding:0 10px;color:#000;">星期</p>
  19. <p style="text-align:center;padding:0 10px;color:#000;">课程</p>
  20. <p style="text-align:left;padding:0 10px;color:#000;">时间</p>
  21. </th>
  22. <th class="ths" v-for="(date, index) in th" :key="index">
  23. <p>{{ date | getWeekDay }}</p>
  24. <p>({{ date | getDay }})</p>
  25. </th>
  26. <th class="ths beizhu">备注</th>
  27. </tr>
  28. <!-- 第一行需要合并2行单元格显示上午 -->
  29. <!-- 第三行需要合并3行单元格显示下午 -->
  30. <!-- rowspan="5" 班主任,礼仪课教师等其他信息 -->
  31. <tr v-for="(time, ti) in tr" :key="ti">
  32. <td rowspan="2" v-if="ti == 0">上午</td>
  33. <td :rowspan="length" v-if="ti == 2">下午</td>
  34. <td>{{ getTime(ti) }}</td>
  35. <td v-for="(date, di) in th" :key="di" v-html="getLesson(date, getTime(ti))"></td>
  36. <td rowspan="6" v-if="ti == 0">
  37. <div class="classInfo">
  38. <p>上课地点</p>
  39. <p>{{ data.jslocation || '' }}</p>
  40. </div>
  41. <div class="classInfo">
  42. <p>开班地点</p>
  43. <p>{{ data.kbyslocation || '' }}</p>
  44. </div>
  45. <div class="classInfo">
  46. <p>用餐地点</p>
  47. <p>{{ data.yclocation || '' }}</p>
  48. </div>
  49. <div class="classInfo">
  50. <p>扩展训练地点</p>
  51. <p>{{ data.kzjhlocation || '' }}</p>
  52. </div>
  53. <div class="classInfo">
  54. <p>班主任</p>
  55. <p>{{ data.headteacher || '' }}</p>
  56. </div>
  57. <div class="classInfo">
  58. <p>礼仪课</p>
  59. <p>{{ data.lyteacher || '暂无' }}</p>
  60. </div>
  61. <div class="classInfo">
  62. <p>督导值班</p>
  63. <p>{{ data.reteacher || '' }}</p>
  64. </div>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td colspan="2">教师签字</td>
  69. <td v-for="(date, di) in th" :key="di"></td>
  70. </tr>
  71. </table>
  72. </el-col>
  73. </el-col>
  74. </el-row>
  75. </div>
  76. </template>
  77. <script>
  78. import _ from 'lodash';
  79. const moment = require('moment');
  80. moment.locale('zh-cn');
  81. import { mapState, createNamespacedHelpers } from 'vuex';
  82. export default {
  83. name: 'index',
  84. props: {
  85. th: { type: Array, default: () => [] },
  86. tr: { type: Array, default: () => [] },
  87. lessons: { type: Array, default: () => [] },
  88. data: null,
  89. },
  90. components: {},
  91. data: () => ({
  92. length: 0,
  93. }),
  94. async created() {
  95. console.log('in function:');
  96. },
  97. computed: {
  98. timeList() {
  99. const today = moment().format('YYYY-MM-DD');
  100. let mid = _.orderBy(
  101. _.uniqBy(
  102. this.lessons.map(i => {
  103. let m = i.time;
  104. m = m.split('-');
  105. const obj = { time: i.time, start: moment(`${today} ${m[0]}`).format('YYYY-MM-DD HH:mm') };
  106. return obj;
  107. }),
  108. 'start'
  109. ),
  110. ['start'],
  111. ['asc']
  112. ).map(i => i.time);
  113. return mid;
  114. },
  115. titleYear() {
  116. let year;
  117. const day = _.head(this.th);
  118. if (day) {
  119. year = moment(day).year();
  120. } else {
  121. year = moment().year();
  122. }
  123. return year;
  124. },
  125. ...mapState(['user']),
  126. },
  127. methods: {
  128. getLesson(date, time) {
  129. this.$set(this, `length`, this.tr.length - 2);
  130. let r = this.lessons.find(f => f.date == date && f.time == time);
  131. // 需要查下,最后一天的下午第一节课,如果是,就要看day,为1则不显示
  132. if (_.isArray(this.th) && _.isArray(this.tr) && this.th.length > 0 && this.tr.length > 0) {
  133. const lastDate = _.last(this.th);
  134. const timeIndex = this.tr.findIndex(f => f === time);
  135. if (lastDate === date && timeIndex === 2) {
  136. if (r.day === '1') return '--';
  137. }
  138. }
  139. if (!r) return '--';
  140. else {
  141. let { subname, teaname = '', reason, time } = r;
  142. if (time == this.timeList[0]) {
  143. let text = `${subname || ''}<br/><span style="color:red">${teaname || ''}</span>`;
  144. if (this.user.type == '0') text += `<br/><span>${reason || ''}</span>`;
  145. return text;
  146. } else {
  147. let text = `${subname || ''}<br/><span style="color:red">${teaname || ''}</span>`;
  148. // if (reason && teaname !== '') text = `${text}<br/><span style="color:red">${reason}</span>`;
  149. return text;
  150. }
  151. }
  152. },
  153. toPrint() {
  154. this.$print(this.$refs.print);
  155. },
  156. getClassName(data) {
  157. if (data) {
  158. if (_.isString(data) && data.includes('班')) return data;
  159. else return `${data}班`;
  160. }
  161. },
  162. getTime(index) {
  163. return this.timeList[index];
  164. },
  165. },
  166. filters: {
  167. getWeekDay(date) {
  168. return moment(date).format('dddd');
  169. },
  170. getDay(date) {
  171. return moment(date).format('MM月DD日');
  172. },
  173. },
  174. };
  175. </script>
  176. <style lang="less" scoped>
  177. @import '~@frame/style/timeTable.less';
  178. .classInfo {
  179. margin: 10px 0;
  180. p:first-child {
  181. padding: 5px 0;
  182. }
  183. p:last-child {
  184. color: #ff0000;
  185. font-size: 12px;
  186. }
  187. }
  188. </style>