ListPage.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="teacher_edu">
  3. <!-- 头部导航及搜索 -->
  4. <Header />
  5. <div>
  6. <HeaderOne :title="headerOneTitle" />
  7. </div>
  8. <!-- 课程列表 -->
  9. <div class="main" v-if="CourseList" v-loading="loading">
  10. <div>
  11. <component
  12. :is="getCurrentQuestionView"
  13. :classList="
  14. navName == 'COURSE' ? CourseList.course_list : CourseList.book_list
  15. "
  16. type="list"
  17. ></component>
  18. </div>
  19. <div class="paging" v-if="CourseList">
  20. <el-pagination
  21. background
  22. @size-change="handleSizeChange"
  23. @current-change="handleCurrentChange"
  24. :page-sizes="[10, 20, 30, 40, 50]"
  25. layout="prev, pager, next,total, sizes,jumper"
  26. :current-page="pageNum"
  27. :page-size="pageSize"
  28. :total="CourseList.total_count"
  29. >
  30. </el-pagination>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import Header from "@/components/Header";
  37. import Course from "@/components/learnCenter/Course";
  38. import Textbook from "@/components/learnCenter/Textbook";
  39. import { cousrseAPI, TextbookAPI } from "@/api/api";
  40. import HeaderOne from "@/components/learnCenter/HeaderOne";
  41. import { updateWordPack } from "@/utils/i18n";
  42. export default {
  43. name: "teacher_edu",
  44. components: {
  45. Header,
  46. Course,
  47. Textbook,
  48. HeaderOne,
  49. },
  50. data() {
  51. return {
  52. seekContent: "", //搜索内容
  53. navName: null,
  54. CourseList: null,
  55. targetPage: 1,
  56. gotoPage: null,
  57. pageNum: 1,
  58. pageSize: 8,
  59. loading: false,
  60. headerOneTitle: "",
  61. };
  62. },
  63. computed: {
  64. getCurrentQuestionView() {
  65. switch (this.navName) {
  66. case "COURSE":
  67. return Course;
  68. case "TEXTBOOK":
  69. return Textbook;
  70. default:
  71. return null;
  72. }
  73. },
  74. },
  75. watch: {
  76. // gotoPage(newval, oldval) {
  77. // if (newval > Math.ceil(CourseList.total / 20)) {
  78. // return;
  79. // } else if (newval != this.targetPage) {
  80. // this.targetPage = newval;
  81. // this.pageNum = newval;
  82. // this.getData(newval * 1);
  83. // }
  84. // },
  85. },
  86. methods: {
  87. // 切换导航
  88. handleSelect(key, keyPath) {
  89. console.log(key, keyPath);
  90. this.navName = key;
  91. },
  92. // 搜索
  93. seekList() {},
  94. handleSizeChange(val) {
  95. console.log(`每页 ${val} 条`);
  96. },
  97. handleCurrentChange(val) {
  98. this.pageNum = val;
  99. this.getData();
  100. },
  101. toPageChange() {
  102. this.gotoPage = this.gotoPage.replace(/[^\d]/g, ""); //使用空字符串去替换非数字的字符
  103. if (this.gotoPage > Math.ceil(this.CourseList.total_count / 8)) {
  104. return;
  105. } else if (this.gotoPage != this.targetPage) {
  106. this.targetPage = this.gotoPage * 1;
  107. this.pageNum = this.gotoPage * 1;
  108. this.getData();
  109. }
  110. },
  111. // 获取数据
  112. getData(val) {
  113. this.loading = true;
  114. if (this.navName == "COURSE") {
  115. // 获取课程列表
  116. cousrseAPI("page_query-PageQueryCourseList", {
  117. page_capacity: this.pageSize,
  118. cur_page: this.pageNum,
  119. finish_status: 53,
  120. release_status: 1,
  121. }).then((res) => {
  122. this.CourseList = res;
  123. this.loading = false;
  124. });
  125. }
  126. if (this.navName == "TEXTBOOK") {
  127. TextbookAPI("book-book_manager-PageQueryBookList", {
  128. page_capacity: this.pageSize + 2,
  129. cur_page: this.pageNum,
  130. publish_status: 1,
  131. is_control_publish_scope: "true",
  132. }).then((res) => {
  133. this.CourseList = res;
  134. this.loading = false;
  135. });
  136. }
  137. },
  138. },
  139. async created() {
  140. this.navName = this.$route.query.id;
  141. await updateWordPack({
  142. word_key_list: [
  143. "Key8",
  144. "Key38",
  145. "Key39",
  146. "Key573",
  147. "Key44",
  148. "Key46",
  149. "Key323",
  150. "Key215",
  151. ],
  152. });
  153. if (this.navName == "COURSE") {
  154. this.headerOneTitle = this.$t("Key215");
  155. }
  156. if (this.navName == "TEXTBOOK") {
  157. this.headerOneTitle = this.$t("Key44");
  158. }
  159. this.getData();
  160. },
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .teacher_edu {
  165. min-height: 100vh;
  166. background: #f6f6f6;
  167. .main {
  168. min-height: 100%;
  169. padding-top: 52px;
  170. background: #f6f6f6;
  171. padding-bottom: 20px;
  172. }
  173. .paging {
  174. width: 1200px;
  175. margin: 0 auto;
  176. display: flex;
  177. align-items: center;
  178. color: darkgrey;
  179. padding: 32px 0;
  180. .number {
  181. color: black;
  182. }
  183. span {
  184. margin-left: 10px;
  185. }
  186. .gotoPage {
  187. width: 40px;
  188. text-align: center;
  189. }
  190. }
  191. }
  192. </style>
  193. <style lang="scss">
  194. .el-pagination.is-background .el-pager li:not(.disabled).active {
  195. background: #ff9900;
  196. }
  197. .el-pagination.is-background .btn-next,
  198. .el-pagination.is-background .btn-prev,
  199. .el-pagination.is-background .el-pager li {
  200. background: #fff;
  201. min-width: 32px;
  202. height: 32px;
  203. line-height: 32px;
  204. border-radius: 4px;
  205. font-size: 18px;
  206. color: #2c2c2c;
  207. }
  208. .el-pagination button,
  209. .el-pagination span:not([class*="suffix"]) {
  210. height: 32px;
  211. line-height: 32px;
  212. }
  213. </style>