CurriculaList.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="curricula">
  3. <!-- 查询条件 -->
  4. <div class="curricula-search">
  5. <div class="curricula-search-condition">
  6. <el-input v-model="search" prefix-icon="el-icon-search">
  7. <el-button slot="append" @click="queryMyCourseList">搜索</el-button>
  8. </el-input>
  9. </div>
  10. <div class="curricula-search-button">
  11. <el-select v-if="userType === 'STUDENT'" v-model="teacher_id">
  12. <el-option label="-请选择-" value="" />
  13. <el-option
  14. v-for="item in teacher_list"
  15. :key="item.teacher_id"
  16. :label="item.teacher_name"
  17. :value="item.teacher_id"
  18. />
  19. </el-select>
  20. <el-select v-model="finish_status">
  21. <el-option label="-请选择-" :value="-1" />
  22. <el-option
  23. v-for="item in finish_status_list"
  24. :key="userType === 'TEACHER' ? item.finish_status : item.status"
  25. :label="item.name"
  26. :value="userType === 'TEACHER' ? item.finish_status : item.status"
  27. ></el-option>
  28. </el-select>
  29. <el-button type="primary" @click="queryMyCourseList">查询</el-button>
  30. </div>
  31. </div>
  32. <!-- 课程列表 -->
  33. <div class="curricula-container">
  34. <div class="curricula-container-title">
  35. <div>
  36. <span class="title">课程列表</span>
  37. <span v-if="userType === 'STUDENT'" class="tip">
  38. 你也可以去 学习中心 选择更多的课程。
  39. </span>
  40. </div>
  41. <div v-if="userType === 'TEACHER'">
  42. <el-button class="create" @click="$router.push('/create_course')">
  43. <div><svg-icon icon-class="create" /><span>创建课程</span></div>
  44. </el-button>
  45. </div>
  46. </div>
  47. <div class="curricula-container-list">
  48. <el-table :data="courseList">
  49. <el-table-column
  50. :prop="userType === 'TEACHER' ? 'name' : 'course_name'"
  51. label="课程名称"
  52. width="320"
  53. />
  54. <el-table-column
  55. v-if="userType === 'STUDENT'"
  56. label="教师"
  57. prop="teacher_name_desc"
  58. width="200"
  59. />
  60. <el-table-column label="课程周期">
  61. <template slot-scope="{ row }">
  62. <template v-if="userType === 'TEACHER'">
  63. <i class="el-icon-date" /> {{ row.begin_date }} - {{ row.end_date }}
  64. </template>
  65. <template v-else>
  66. <i class="el-icon-date" /> {{ row.date_space_view_text }}
  67. </template>
  68. </template>
  69. </el-table-column>
  70. <el-table-column v-if="userType === 'TEACHER'" fixed="right" width="80">
  71. <template slot-scope="{ row }">
  72. <el-dropdown trigger="click">
  73. <span class="el-dropdown-link">
  74. <svg-icon icon-class="more"></svg-icon>
  75. </span>
  76. <el-dropdown-menu slot="dropdown">
  77. <el-dropdown-item @click.native="edit(row.id)">
  78. <svg-icon icon-class="edit" /> 编辑
  79. </el-dropdown-item>
  80. <el-dropdown-item @click.native="studentList(row.id)">
  81. <svg-icon icon-class="students" /> 学生列表
  82. </el-dropdown-item>
  83. </el-dropdown-menu>
  84. </el-dropdown>
  85. </template>
  86. </el-table-column>
  87. <el-table-column v-if="userType === 'STUDENT'" label="状态">
  88. <template slot-scope="{ row }">
  89. <span class="status-name" :style="{ 'background-color': statusColor(row.status) }" />
  90. <span :style="{ color: statusColor(row.status) }">{{ row.status_name }}</span>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </div>
  96. <el-pagination
  97. background
  98. :page-sizes="[10, 20, 30, 40, 50]"
  99. :page-size="page_capacity"
  100. layout="prev, pager, next, total, sizes, jumper"
  101. :total="total_count"
  102. :current-page="cur_page"
  103. @prev-click="changePage"
  104. @next-click="changePage"
  105. @current-change="changePage"
  106. @size-change="changePageSize"
  107. />
  108. </div>
  109. </template>
  110. <script>
  111. import { updateWordPack } from '@/utils/i18n';
  112. import { PageQueryMyCourseList, PageQueryMyJoinCourseList_Student } from '@/api/table';
  113. import {
  114. GetFinishStatusList_Course,
  115. GetMyJoinCourseTeacherList_Student,
  116. GetStudentCourseStatusList
  117. } from '@/api/select';
  118. export default {
  119. name: 'CurriculaList',
  120. data() {
  121. return {
  122. userType: this.$store.state.user.user_type,
  123. search: '',
  124. finish_status_list: [],
  125. teacher_list: [],
  126. teacher_id: '',
  127. finish_status: -1,
  128. page_capacity: 10,
  129. cur_page: 1,
  130. total_count: 0,
  131. courseList: []
  132. };
  133. },
  134. created() {
  135. this.queryMyCourseList();
  136. this.getFinishStatusList_Course();
  137. if (this.userType === 'STUDENT') {
  138. this.getMyJoinCourseTeacherList_Student();
  139. }
  140. updateWordPack({
  141. word_key_list: ['Learn_New_Courses']
  142. });
  143. },
  144. methods: {
  145. getFinishStatusList_Course() {
  146. if (this.userType === 'TEACHER') {
  147. GetFinishStatusList_Course().then(({ finish_status_list }) => {
  148. this.finish_status_list = finish_status_list;
  149. });
  150. } else {
  151. GetStudentCourseStatusList().then(({ status_list }) => {
  152. this.finish_status_list = status_list;
  153. });
  154. }
  155. },
  156. getMyJoinCourseTeacherList_Student() {
  157. GetMyJoinCourseTeacherList_Student().then(({ teacher_list }) => {
  158. this.teacher_list = teacher_list;
  159. });
  160. },
  161. selectTab(status, i) {
  162. this.status = status;
  163. this.curTab = i;
  164. this.search();
  165. },
  166. changePage(newPage) {
  167. this.cur_page = newPage;
  168. this.queryMyCourseList();
  169. },
  170. changePageSize(pageSize) {
  171. this.page_capacity = pageSize;
  172. this.queryMyCourseList();
  173. },
  174. queryMyCourseList() {
  175. if (this.userType === 'TEACHER') {
  176. const queryCriteria = {
  177. finish_status: this.finish_status,
  178. name: this.search,
  179. page_capacity: this.page_capacity,
  180. cur_page: this.cur_page
  181. };
  182. PageQueryMyCourseList(queryCriteria).then(({ course_list, total_count }) => {
  183. this.courseList = course_list;
  184. this.total_count = total_count;
  185. });
  186. } else {
  187. let data = {
  188. teacher_id: this.teacher_id,
  189. status_list: [this.finish_status],
  190. course_name: this.search,
  191. page_capacity: this.page_capacity,
  192. cur_page: this.cur_page
  193. };
  194. PageQueryMyJoinCourseList_Student(data).then(({ course_list, total_count }) => {
  195. this.courseList = course_list;
  196. this.total_count = total_count;
  197. });
  198. }
  199. },
  200. statusColor(val) {
  201. if (val === 0) {
  202. return '#68CEFA';
  203. }
  204. if (val === 1) {
  205. return '#2ECE5B';
  206. }
  207. if (val === 3) {
  208. return '#f90';
  209. }
  210. if (val === 4) {
  211. return '#4F8EEC';
  212. }
  213. },
  214. studentList(id) {
  215. this.$router.push(`/student_list/index/${id}`);
  216. },
  217. edit(id) {
  218. this.$router.push(`/create_course_step_table/course_info?id=${id}`);
  219. }
  220. }
  221. };
  222. </script>
  223. <style lang="scss">
  224. @import '~@/styles/mixin.scss';
  225. .curricula {
  226. @include pagination;
  227. &-search {
  228. display: flex;
  229. justify-content: space-between;
  230. &-condition {
  231. > .el-input {
  232. width: 528px;
  233. }
  234. }
  235. &-button {
  236. .el-button {
  237. width: 114px;
  238. }
  239. .el-select {
  240. width: 225px;
  241. margin-right: 12px;
  242. }
  243. }
  244. }
  245. &-container {
  246. width: 100%;
  247. min-height: calc(100vh - 325px);
  248. margin-top: 16px;
  249. background-color: #fff;
  250. border-radius: 8px;
  251. &-title {
  252. height: 88px;
  253. padding: 24px 32px;
  254. display: flex;
  255. justify-content: space-between;
  256. align-items: center;
  257. .title {
  258. font-size: 20px;
  259. font-weight: 700;
  260. margin-right: 36px;
  261. }
  262. .tip {
  263. color: #aaa;
  264. }
  265. .create {
  266. width: 138px;
  267. div {
  268. display: flex;
  269. justify-content: space-around;
  270. }
  271. }
  272. }
  273. &-list {
  274. @include list;
  275. margin-top: 0;
  276. .el-dropdown {
  277. cursor: pointer;
  278. .svg-icon {
  279. font-size: 19px;
  280. }
  281. }
  282. .status-name {
  283. display: inline-block;
  284. width: 8px;
  285. height: 8px;
  286. border-radius: 50%;
  287. margin-right: 8px;
  288. margin-bottom: 1px;
  289. }
  290. }
  291. }
  292. }
  293. </style>
  294. <style scope>
  295. .el-dropdown-menu .svg-icon {
  296. margin-right: 8px;
  297. }
  298. </style>