123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template>
- <div class="teacher_edu">
- <!-- 头部导航及搜索 -->
- <Header />
- <div>
- <HeaderOne :title="headerOneTitle" />
- </div>
- <!-- 课程列表 -->
- <div class="main" v-if="CourseList" v-loading="loading">
- <div>
- <component
- :is="getCurrentQuestionView"
- :classList="
- navName == 'COURSE' ? CourseList.course_list : CourseList.book_list
- "
- type="list"
- ></component>
- </div>
- <div class="paging" v-if="CourseList">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :page-sizes="[10, 20, 30, 40, 50]"
- layout="prev, pager, next,total, sizes,jumper"
- :current-page="pageNum"
- :page-size="pageSize"
- :total="CourseList.total_count"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Header from "@/components/Header";
- import Course from "@/components/learnCenter/Course";
- import Textbook from "@/components/learnCenter/Textbook";
- import { cousrseAPI, TextbookAPI } from "@/api/api";
- import HeaderOne from "@/components/learnCenter/HeaderOne";
- import { updateWordPack } from "@/utils/i18n";
- export default {
- name: "teacher_edu",
- components: {
- Header,
- Course,
- Textbook,
- HeaderOne,
- },
- data() {
- return {
- seekContent: "", //搜索内容
- navName: null,
- CourseList: null,
- targetPage: 1,
- gotoPage: null,
- pageNum: 1,
- pageSize: 8,
- loading: false,
- headerOneTitle: "",
- };
- },
- computed: {
- getCurrentQuestionView() {
- switch (this.navName) {
- case "COURSE":
- return Course;
- case "TEXTBOOK":
- return Textbook;
- default:
- return null;
- }
- },
- },
- watch: {
- // gotoPage(newval, oldval) {
- // if (newval > Math.ceil(CourseList.total / 20)) {
- // return;
- // } else if (newval != this.targetPage) {
- // this.targetPage = newval;
- // this.pageNum = newval;
- // this.getData(newval * 1);
- // }
- // },
- },
- methods: {
- // 切换导航
- handleSelect(key, keyPath) {
- console.log(key, keyPath);
- this.navName = key;
- },
- // 搜索
- seekList() {},
- handleSizeChange(val) {
- console.log(`每页 ${val} 条`);
- },
- handleCurrentChange(val) {
- this.pageNum = val;
- this.getData();
- },
- toPageChange() {
- this.gotoPage = this.gotoPage.replace(/[^\d]/g, ""); //使用空字符串去替换非数字的字符
- if (this.gotoPage > Math.ceil(this.CourseList.total_count / 8)) {
- return;
- } else if (this.gotoPage != this.targetPage) {
- this.targetPage = this.gotoPage * 1;
- this.pageNum = this.gotoPage * 1;
- this.getData();
- }
- },
- // 获取数据
- getData(val) {
- this.loading = true;
- if (this.navName == "COURSE") {
- // 获取课程列表
- cousrseAPI("page_query-PageQueryCourseList", {
- page_capacity: this.pageSize,
- cur_page: this.pageNum,
- finish_status: 53,
- release_status: 1,
- }).then((res) => {
- this.CourseList = res;
- this.loading = false;
- });
- }
- if (this.navName == "TEXTBOOK") {
- TextbookAPI("book-book_manager-PageQueryBookList", {
- page_capacity: this.pageSize + 2,
- cur_page: this.pageNum,
- publish_status: 1,
- is_control_publish_scope: "true",
- }).then((res) => {
- this.CourseList = res;
- this.loading = false;
- });
- }
- },
- },
- async created() {
- this.navName = this.$route.query.id;
- await updateWordPack({
- word_key_list: [
- "Key8",
- "Key38",
- "Key39",
- "Key573",
- "Key44",
- "Key46",
- "Key323",
- "Key215",
- ],
- });
- if (this.navName == "COURSE") {
- this.headerOneTitle = this.$t("Key215");
- }
- if (this.navName == "TEXTBOOK") {
- this.headerOneTitle = this.$t("Key44");
- }
- this.getData();
- },
- };
- </script>
- <style lang="scss" scoped>
- .teacher_edu {
- min-height: 100vh;
- background: #f6f6f6;
- .main {
- min-height: 100%;
- padding-top: 52px;
- background: #f6f6f6;
- padding-bottom: 20px;
- }
- .paging {
- width: 1200px;
- margin: 0 auto;
- display: flex;
- align-items: center;
- color: darkgrey;
- padding: 32px 0;
- .number {
- color: black;
- }
- span {
- margin-left: 10px;
- }
- .gotoPage {
- width: 40px;
- text-align: center;
- }
- }
- }
- </style>
- <style lang="scss">
- .el-pagination.is-background .el-pager li:not(.disabled).active {
- background: #ff9900;
- }
- .el-pagination.is-background .btn-next,
- .el-pagination.is-background .btn-prev,
- .el-pagination.is-background .el-pager li {
- background: #fff;
- min-width: 32px;
- height: 32px;
- line-height: 32px;
- border-radius: 4px;
- font-size: 18px;
- color: #2c2c2c;
- }
- .el-pagination button,
- .el-pagination span:not([class*="suffix"]) {
- height: 32px;
- line-height: 32px;
- }
- </style>
|