xsc 1 year ago
parent
commit
93967dd908

+ 3 - 3
src/views/video/api/chapter.js

@@ -4,13 +4,13 @@
  * @Author: King
  * @Date: 2022-02-14 14:46:14
  * @LastEditors: king
- * @LastEditTime: 2023-03-24 17:01:56
+ * @LastEditTime: 2023-03-24 17:29:12
  */
 import request from '@/utils/request'
 //章节模块接口--------------------------------------------------------------
 export function chapterList(params) {
   return request({
-    url: '/course/chapters',
+    url: '/course/chapter',
     method: 'get',
     params,
   })
@@ -18,7 +18,7 @@ export function chapterList(params) {
 // 章节添加 ?????????
 export function chapterAdd(data) {
   return request({
-    url: '/course/' + data.course_id + '/chapter',
+    url: '/course/chapter',
     method: 'post',
     data,
   })

+ 3 - 3
src/views/video/api/index.js

@@ -4,7 +4,7 @@
  * @Author: King
  * @Date: 2022-02-14 10:45:11
  * @LastEditors: king
- * @LastEditTime: 2023-03-24 17:02:42
+ * @LastEditTime: 2023-03-24 18:02:57
  */
 import request from '@/utils/request'
 // 课程列表
@@ -18,7 +18,7 @@ export function courseList(params) {
 //课程添加
 export function doAdd(data) {
   return request({
-    url: '/course/info',
+    url: '/course',
     method: 'post',
     data,
   })
@@ -26,7 +26,7 @@ export function doAdd(data) {
 //课程修改 -->此处data需要穿一个id
 export function doEdit(data) {
   return request({
-    url: '/course/info/' + data.id,
+    url: '/course',
     method: 'put',
     data,
   })

+ 1 - 1
src/views/video/api/video.js

@@ -4,7 +4,7 @@
  * @Author: King
  * @Date: 2022-02-14 14:46:14
  * @LastEditors: king
- * @LastEditTime: 2023-03-24 15:35:20
+ * @LastEditTime: 2023-03-24 18:14:20
  */
 import request from '@/utils/request'
 //视频模块接口--------------------------------------------------------------

+ 170 - 193
src/views/video/chapter.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="department-management-container">
-    <vab-query-form style="display: flex;justify-content: space-between;">
+    <el-page-header @back="goBack" content="章节管理" style="margin-bottom: 20px;"> </el-page-header>
+    <vab-query-form style="display: flex; justify-content: space-between">
       <vab-query-form-left-panel :span="12">
         <el-button icon="el-icon-plus" type="primary" @click="handleEdit">
           添加
@@ -46,13 +47,6 @@
         prop="title"
         show-overflow-tooltip
       />
-      <el-table-column
-        align="center"
-        label="课程名称"
-        min-width="120"
-        prop="course.title"
-        show-overflow-tooltip
-      />
       <!-- 章节排序 -->
       <el-table-column
         align="center"
@@ -62,46 +56,33 @@
       >
         <template #default="{ row }">
           <div class="edit">
-            <i
-              v-if="editForm.id == row.id && editStatus == 1"
-              class="el-icon-circle-close"
-              @click.stop="cancelSort(row)"
-            ></i>
-            <span
-              v-if="editForm.id !== row.id || editStatus == 0"
-              class="sort-num"
-            >
-              {{ row.sort }}
-            </span>
-
-            <el-input
-              v-if="editForm.id == row.id && editStatus == 1"
-              ref="getFocus"
-              v-model="row.sort"
-              class="input-sort"
-              @input="inputSort"
-            />
-
-            <i
-              v-if="editForm.id !== row.id || editStatus == 0"
-              class="el-icon-edit"
-              @click="changeSort(row)"
-            ></i>
-            <i
-              v-if="editForm.id == row.id && editStatus == 1"
-              class="el-icon-circle-check"
-              @click.stop="sureChange"
-            ></i>
+            {{ row.sort }}
           </div>
         </template>
       </el-table-column>
+      <el-table-column
+        align="center"
+        label="状态"
+        min-width="80"
+        prop="status"
+        show-overflow-tooltip
+      >
+        <template #default="{ row }">
+          <el-tag v-if="row.status == 1">
+           正常
+          </el-tag>
+          <el-tag v-if="row.status == 0" type="danger">
+            禁用
+          </el-tag>
+        </template>
+      </el-table-column>
       <!-- 命名需要再改 -->
       <el-table-column
         align="center"
         fixed="right"
         label="创建时间"
         min-width="120"
-        prop="humans"
+        prop="created_at"
         show-overflow-tooltip
       />
       <el-table-column
@@ -111,12 +92,8 @@
         min-width="120"
       >
         <template #default="{ row }">
-          <el-button type="text" @click="handleEdit(row)">
-           编辑
-          </el-button>
-          <el-button type="text" @click="handleDelete(row)">
-            删除
-          </el-button>
+          <el-button type="text" @click="handleEdit(row)"> 编辑 </el-button>
+          <el-button type="text" @click="handleDelete(row)"> 删除 </el-button>
         </template>
       </el-table-column>
       <template #empty>
@@ -131,162 +108,162 @@
 </template>
 
 <script>
-  import { chapterList, chapterDelete, chapterEdit } from './api/chapter'
-  import Edit from './components/ChapterManage'
+import { chapterList, chapterDelete, chapterEdit } from "./api/chapter";
+import Edit from "./components/ChapterManage";
 
-  export default {
-    name: 'ChapterManage',
-    components: { Edit },
-    data() {
-      return {
-        //修改排序
-        editForm: {},
-        oldSort: 0,
-        editStatus: 0, //排序编辑状态 0为正常 1显示输入框
-        flag: false, //是否自动聚焦
-        list: [],
-        listLoading: true,
-        total: 0,
-        queryForm: {
-          title: '',
-          // courseId: '', //课程id
-        },
-        videoId: '', //视频id
+export default {
+  name: "ChapterManage",
+  components: { Edit },
+  data() {
+    return {
+      //修改排序
+      editForm: {},
+      oldSort: 0,
+      editStatus: 0, //排序编辑状态 0为正常 1显示输入框
+      flag: false, //是否自动聚焦
+      list: [],
+      listLoading: true,
+      total: 0,
+      queryForm: {
+        title: "",
+        // courseId: '', //课程id
+      },
+      videoId: "", //视频id
+    };
+  },
+  created() {
+    let route = this.$route;
+    console.log(route.query, "route.query11111");
+    // 章节列表里边接收上个页面的参数没有什么用目前!!!!!!!!!
+    // // 课程id
+    // this.courseId = route.query.courseId
+    // // 视频id
+    // this.queryForm.videoId = route.query.videoId
+    this.queryForm.courseId = route.query.courseId;
+    this.videoId = route.query.videoId;
+    this.getChapterList();
+  },
+  methods: {
+    goBack() {
+      this.$router.push({
+        path: "/video/index",
+      });
+    },
+    // 排序这块
+    cancelSort(row) {
+      this.editStatus = 0;
+      row.sort = this.oldSort;
+    },
+    //修改排序事件
+    async changeSort(row) {
+      console.log(row, "1111111111");
+      this.editStatus = 1;
+      this.editForm = row;
+      // 附件修改接口修改时这俩参数要求必填的
+      // this.editForm.course_id = this.queryForm.courseId
+      this.editForm.course_id = row.course.id;
+      // this.editForm.path = row.path_resource.id
+      this.oldSort = row.sort;
+      this.$nextTick(() => {
+        this.$refs["getFocus"].focus();
+      });
+      //await doEdit(this.editForm)
+    },
+    //修改排序
+    inputSort(e) {
+      console.log(e, "000000000");
+      this.editForm.sort = e;
+    },
+    async sureChange() {
+      this.editStatus = 0;
+      if (this.oldSort !== this.editForm.sort) {
+        console.log(this.editForm, "附件排序的内容");
+        const { message } = await chapterEdit(this.editForm);
+        console.log(message, "message");
+        // location.reload()
+        this.$baseMessage(message, "success", false, "vab-hey-message-success");
+        this.getChapterList();
+      } else {
+        return;
       }
     },
-    created() {
-      let route = this.$route
-      console.log(route.query, 'route.query11111')
-      // 章节列表里边接收上个页面的参数没有什么用目前!!!!!!!!!
-      // // 课程id
-      // this.courseId = route.query.courseId
-      // // 视频id
-      // this.queryForm.videoId = route.query.videoId
-      this.queryForm.courseId = route.query.courseId
-      this.videoId = route.query.videoId
-      this.getChapterList()
+    //跳转课程详情
+    courseVideo(row) {
+      this.$router.push({
+        path: "/course/video",
+        query: {
+          id: row.id,
+        },
+      });
     },
-    methods: {
-      // 排序这块
-      cancelSort(row) {
-        this.editStatus = 0
-        row.sort = this.oldSort
-      },
-      //修改排序事件
-      async changeSort(row) {
-        console.log(row, '1111111111')
-        this.editStatus = 1
-        this.editForm = row
-        // 附件修改接口修改时这俩参数要求必填的
-        // this.editForm.course_id = this.queryForm.courseId
-        this.editForm.course_id = row.course.id
-        // this.editForm.path = row.path_resource.id
-        this.oldSort = row.sort
-        this.$nextTick(() => {
-          this.$refs['getFocus'].focus()
-        })
-        //await doEdit(this.editForm)
-      },
-      //修改排序
-      inputSort(e) {
-        console.log(e, '000000000')
-        this.editForm.sort = e
-      },
-      async sureChange() {
-        this.editStatus = 0
-        if (this.oldSort !== this.editForm.sort) {
-          console.log(this.editForm, '附件排序的内容')
-          const { message } = await chapterEdit(this.editForm)
-          console.log(message, 'message')
-          // location.reload()
+    courseDetail(row) {
+      this.$router.push({
+        path: "/course/detail",
+        query: {
+          id: row.id,
+        },
+      });
+    },
+    handleEdit(row) {
+      if (row.id) {
+        this.$refs["edit"].showEdit(row);
+      } else {
+        this.$refs["edit"].showEdit();
+      }
+    },
+    handleDelete(row) {
+      if (row.id) {
+        this.$baseConfirm("你确定要删除当前项吗", null, async () => {
+          const { message } = await chapterDelete({ id: row.id });
           this.$baseMessage(
             message,
-            'success',
+            "success",
             false,
-            'vab-hey-message-success'
-          )
-          this.getChapterList()
-        } else {
-          return
-        }
-      },
-      //跳转课程详情
-      courseVideo(row) {
-        this.$router.push({
-          path: '/course/video',
-          query: {
-            id: row.id,
-          },
-        })
-      },
-      courseDetail(row) {
-        this.$router.push({
-          path: '/course/detail',
-          query: {
-            id: row.id,
-          },
-        })
-      },
-      handleEdit(row) {
-        if (row.id) {
-          this.$refs['edit'].showEdit(row)
-        } else {
-          this.$refs['edit'].showEdit()
-        }
-      },
-      handleDelete(row) {
-        if (row.id) {
-          this.$baseConfirm('你确定要删除当前项吗', null, async () => {
-            const { message } = await chapterDelete({ id: row.id })
-            this.$baseMessage(
-              message,
-              'success',
-              false,
-              'vab-hey-message-success'
-            )
-            await this.getChapterList()
-          })
-        }
-      },
-      // handleSizeChange(val) {
-      //   this.queryForm.pageSize = val
-      //   this.getChapterList()
-      // },
-      // handleCurrentChange(val) {
-      //   this.queryForm.pageNo = val
-      //   this.getChapterList()
-      // },
-      queryData() {
-        this.getChapterList()
-      },
-      async getChapterList() {
-        this.listLoading = true
-        const { data } = await chapterList(this.queryForm)
-        console.log(data, '章节列表')
-        this.list = data.data
-        console.log(this.list, '++++++++++')
-        this.listLoading = false
-      },
+            "vab-hey-message-success"
+          );
+          await this.getChapterList();
+        });
+      }
+    },
+    // handleSizeChange(val) {
+    //   this.queryForm.pageSize = val
+    //   this.getChapterList()
+    // },
+    // handleCurrentChange(val) {
+    //   this.queryForm.pageNo = val
+    //   this.getChapterList()
+    // },
+    queryData() {
+      this.getChapterList();
+    },
+    async getChapterList() {
+      this.listLoading = true;
+      const { data } = await chapterList(this.queryForm);
+      console.log(data, "章节列表");
+      this.list = data.data;
+      console.log(this.list, "++++++++++");
+      this.listLoading = false;
     },
-  }
+  },
+};
 </script>
 <style lang="scss" scoped>
-  /* 修改排序样式 */
-  .edit {
-    display: inline-block;
-    width: 110px;
-  }
-  .input-sort {
-    display: inline-block;
-    width: 100px;
-    margin-left: 10px;
-    border: none;
-  }
-  .sort-num {
-    display: inline-block;
-    margin-left: 10px;
-  }
-  .el-icon-edit {
-    color: #1890ff;
-  }
+/* 修改排序样式 */
+.edit {
+  display: inline-block;
+  width: 110px;
+}
+.input-sort {
+  display: inline-block;
+  width: 100px;
+  margin-left: 10px;
+  border: none;
+}
+.sort-num {
+  display: inline-block;
+  margin-left: 10px;
+}
+.el-icon-edit {
+  color: #1890ff;
+}
 </style>

+ 5 - 5
src/views/video/components/ChapterManage.vue

@@ -19,12 +19,12 @@
           type="number"
         />
       </el-form-item>
-      <!-- <el-form-item label="章节状态" prop="status">
+      <el-form-item label="章节状态" prop="status">
         <el-radio-group v-model="form.status">
           <el-radio :label="1">正常</el-radio>
           <el-radio :label="0">禁用</el-radio>
         </el-radio-group>
-      </el-form-item> -->
+      </el-form-item>
     </el-form>
     <template #footer>
       <el-button @click="close">取消</el-button>
@@ -32,7 +32,7 @@
         确定
       </el-button>
       <el-button v-if="title == '添加'" type="primary" @click="add">
-        添加暂时不要求
+        添加
       </el-button>
     </template>
   </el-dialog>
@@ -47,7 +47,7 @@
       return {
         form: {
           title: '',
-          // status: 1,
+          status: 1,
           course_id: '',
           sort: 0,
         },
@@ -90,7 +90,7 @@
           this.title = '添加'
           let route = this.$route
           console.log(route.query, 'route.que12121ry')
-          this.form.course_id = route.query.courseId
+          this.form.course_id = route.query.id
           console.log(this.form.course_id, 'route.que12121ry')
         } else {
           this.title = '编辑'

+ 6 - 6
src/views/video/components/CourseManage.vue

@@ -14,8 +14,8 @@
       :rules="rules"
       style="width: 80%; margin: 0 auto"
     >
-      <el-form-item label="课程分类" prop="category">
-        <!-- <el-select
+      <!-- <el-form-item label="课程分类" prop="category">
+        <el-select
           v-model="form.category.id"
           placeholder="请选择课程分类"
           style="width: 90%"
@@ -27,11 +27,11 @@
             style="height: auto; padding: 0 10px"
             :value="item.id"
           />
-        </el-select> -->
+        </el-select>
         <el-button style="margin-left: 10px" type="text" @click="courseSort">
           分类管理
         </el-button>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="课程名称" prop="title">
         <el-input v-model="form.title" />
       </el-form-item>
@@ -56,7 +56,7 @@
       <el-form-item label="课程封面" prop="thumb">
         <el-upload
           accept=".png,.jpg"
-          :action="action"
+          :action="base_url+'/upload'"
           class="upload-demo"
           :data="uploadData"
           :file-list="fileList"
@@ -253,7 +253,7 @@
           if (this.form.thumb_resource) {
             this.imageUrl = this.form.thumb_resource.url
           }
-          // if (this.form.category) {
+          // if (this.form.id) {
           //   this.category_id = this.form.category.id
           // }
         } else {

+ 6 - 8
src/views/video/video.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="department-management-container">
     <!-- <el-page-header content="视频列表" @back="goBack" /> -->
+    <el-page-header @back="goBack" content="视频管理" style="margin-bottom: 20px;"> </el-page-header>
     <vab-query-form style="display: flex;justify-content: space-between;">
       <vab-query-form-left-panel :span="12">
         <!-- 暂时不要求添加 -->
@@ -53,7 +54,7 @@
         align="center"
         label="所属章节"
         min-width="100"
-        prop="course_chapter.title"
+        prop="course_chapter_name"
         show-overflow-tooltip
       />
 
@@ -170,14 +171,11 @@
       this.getVideoList()
     },
     methods: {
-      // ...mapActions({
-      //   delVisitedRoute: 'tabs/delVisitedRoute',
-      // }),
-      //返回上一页
       goBack() {
-        // this.delVisitedRoute(handleActivePath(this.$route, true))
-        // this.$router.push('/course/courseList')
-      },
+      this.$router.push({
+        path: "/video/index",
+      });
+    },
       //章节管理
       chapterManage(row) {
         console.log(row.id, this.queryForm.id, '视频跳转到章节传递的参数')