Procházet zdrojové kódy

统一修改课程红包/修改课节顺序

三七 před 2 týdny
rodič
revize
59c90f1edd

+ 10 - 0
src/api/course/userCourse.js

@@ -35,6 +35,16 @@ export function updateUserCourse(data) {
   })
 }
 
+//统一修改课程红包
+export function updateUserCourseRedPage(data) {
+  return request({
+    url: '/course/userCourse/editRedPage',
+    method: 'post',
+    data: data
+  })
+}
+
+
 // 删除课程
 export function delUserCourse(courseId) {
   return request({

+ 17 - 0
src/api/course/userCourseVideo.js

@@ -85,6 +85,14 @@ export function exportUserCourseVideo(query) {
 }
 
 
+export function getVideoListByCourseIdAll(courseId) {
+  return request({
+    url: '/course/userCourseVideo/getVideoListByCourseIdAll',
+    method: 'get',
+    params: {courseId}
+  })
+}
+
 export function getVideoListByCourseId(query) {
   return request({
     url: '/course/userCourseVideo/getVideoListByCourseId',
@@ -93,6 +101,15 @@ export function getVideoListByCourseId(query) {
   })
 }
 
+export function sortCourseVideo(list) {
+  return request({
+    url: '/course/userCourseVideo/sortCourseVideo',
+    method: 'post',
+    data: list
+  })
+}
+
+
 // 获取选项列表
 export function getVideoListLikeName(query) {
   return request({

+ 77 - 3
src/views/components/course/userCourseCatalogDetails.vue

@@ -34,6 +34,10 @@
         <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
                    v-hasPermi="['course:userCourseVideo:remove']">删除</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button type="warning" plain icon="el-icon-edit" size="mini" @click="handleCourseSort"
+                   v-hasPermi="['course:userCourseVideo:sort']">修改课节排序</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
     <el-table border v-loading="loading" :data="userCourseVideoList" @selection-change="handleSelectionChange">
@@ -316,6 +320,19 @@
       </course-watch-comment>
     </el-dialog>
 
+
+    <el-dialog title="修改课节排序" :visible.sync="openVideoSort" style="width: 1600px;" append-to-body>
+      <draggable v-model="userCourseVideoSortList" @end="onDragEndDay" style="padding: 10px">
+        <el-button style="margin: 8px 4px;" v-for="(item, index) in userCourseVideoSortList" :class="item.newCourseSort != item.courseSort ? 'red':''">第{{
+            item.newCourseSort
+          }}序(原排序第{{ item.courseSort }})
+        </el-button>
+      </draggable>
+      <div style="float: right;margin-top: -20px">
+        <el-button type="primary" @click="saveSorts">保存</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -329,8 +346,8 @@ import {
   updates,
   batchSaveVideo,
   batchUpdateRed,
-  updateUserCourseVideo
-} from "@/api/course/userCourseVideo";
+  updateUserCourseVideo, getVideoListByCourseIdAll, sortCourseVideo
+} from '@/api/course/userCourseVideo'
 import QuestionBank from "@/views/course/courseQuestionBank/QuestionBank.vue";
 import CourseProduct from "@/views/course/fsCourseProduct/CourseProduct.vue";
 import VideoUpload from "@/components/VideoUpload/index.vue";
@@ -338,10 +355,11 @@ import { listVideoResource } from '@/api/course/videoResource';
 import { getByIds } from '@/api/course/courseQuestionBank'
 import CourseWatchComment from "./courseWatchComment.vue";
 import { getCateListByPid, getCatePidList } from '@/api/course/userCourseCategory'
+import draggable from 'vuedraggable'
 
 export default {
   name: "userCourseCatalog",
-  components: { VideoUpload, QuestionBank, CourseWatchComment, CourseProduct,},
+  components: { VideoUpload, QuestionBank, CourseWatchComment, CourseProduct,draggable},
   data() {
     return {
       duration: null,
@@ -387,6 +405,7 @@ export default {
       fileId: '',
       courseName: null,
       userCourseVideoList: [],
+      userCourseVideoSortList: [],
       total: 0,
       redData: {
         queryParams: {
@@ -434,6 +453,8 @@ export default {
       single: true,
       // 非多个禁用
       multiple: true,
+      loading3:false,
+      openVideoSort:false,
       // 表单参数
       form: {
         courseProducts:[]
@@ -502,6 +523,7 @@ export default {
       this.courseProduct.title = '拍商品选择';
     },
 
+
     //选择疗法
     selectPackage(row) {
       const drug = {};
@@ -857,6 +879,47 @@ export default {
         this.msgSuccess("删除成功");
       }).catch(() => { });
     },
+
+    handleCourseSort(){
+
+      getVideoListByCourseIdAll(this.queryParams.courseId).then(response => {
+
+        response.rows.forEach((item) => item.newCourseSort = item.courseSort);
+        this.userCourseVideoSortList = response.rows.sort((a, b) => a.courseSort - b.courseSort);
+        if (this.userCourseVideoSortList==null || this.userCourseVideoSortList.length==0){
+          this.$message.error("暂无课节天数")
+        }else {
+          this.openVideoSort = true;
+        }
+      })
+
+
+    },
+
+    onDragEndDay() {
+      this.userCourseVideoSortList.forEach((item, index) => {
+        item.newCourseSort = index + 1;
+      })
+      this.$forceUpdate()
+    },
+
+    saveSorts() {
+
+      console.log("this.userCourseVideoSortList",this.userCourseVideoSortList)
+      let list = this.userCourseVideoSortList.filter(e => e.courseSort != e.newCourseSort).map(e => {
+        return {courseSort: e.newCourseSort, videoId: e.videoId}
+      })
+      console.log("this.userCourseVideoSortList",this.userCourseVideoSortList)
+      this.loading3 = true;
+      console.log("list",list)
+      sortCourseVideo(list).then(e => {
+        this.getList();
+      }).finally(() => {
+        this.userCourseVideoSortList=[];
+        this.openVideoSort=false;
+      })
+    },
+
     openAdds() {
       this.addBatchData.open = true;
       this.getRootTypeList();
@@ -948,4 +1011,15 @@ export default {
   line-height: 150px;
   text-align: center;
 }
+
+
+.red:hover {
+  color: #dbdbdb !important;
+}
+
+.red {
+  background-color: #F56C6C !important;
+  color: #fff !important;
+}
+
 </style>

+ 71 - 2
src/views/course/userCourse/index.vue

@@ -145,6 +145,14 @@
             v-hasPermi="['course:userCourse:edit']"
           >修改
           </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdateRedPage(scope.row)"
+            v-hasPermi="['course:userCourse:editRedPage']"
+          >统一修改红包金额
+          </el-button>
           <el-button
             size="mini"
             type="text"
@@ -253,6 +261,20 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+
+    <el-dialog title="修改课程红包金额" :visible.sync="openRedPage.open" width="1000px" append-to-body>
+      <el-form ref="openRedPage" :model="openRedPage" :rules="rulesRedPage" label-width="110px">
+        <el-form-item label="红包金额" prop="redPacketMoney">
+          <el-input-number v-model="openRedPage.redPacketMoney" :min="0.1" :max="200" :step="0.1"></el-input-number>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFormRedPage">确 定</el-button>
+        <el-button @click="cancelRedPage">取 消</el-button>
+      </div>
+    </el-dialog>
+
     <el-drawer
       :with-header="false"
       size="75%"
@@ -273,8 +295,8 @@ import {
   updateIsShow,
   copyUserCourse,
   putOn,
-  pullOff
-} from "@/api/course/userCourse";
+  pullOff, updateUserCourseRedPage
+} from '@/api/course/userCourse'
 
 import {getSelectableRange} from "@/api/qw/sopTemp";
 import Treeselect from "@riophae/vue-treeselect";
@@ -285,10 +307,12 @@ import {listBySearch} from "@/api/course/userTalent";
 import userCourseCatalogDetails from '../../components/course/userCourseCatalogDetails.vue';
 import {getAllCourseCategoryList, getCatePidList, getCateListByPid} from "@/api/course/userCourseCategory";
 import {allList} from "@/api/company/company";
+import VideoUpload from '@/components/VideoUpload/index.vue'
 
 export default {
   name: "UserCourse",
   components: {
+    VideoUpload,
     Treeselect,
     Editor, ImageUpload, userCourseCatalogDetails
   },
@@ -337,6 +361,12 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      openRedPage:{
+        open:false,
+        courseId:null,
+        courseName:null,
+        redPacketMoney:0.1,
+      },
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -409,6 +439,12 @@ export default {
         integral: [
           {required: true, message: "小节兑换积分不能为空", trigger: "blur"}
         ],
+      },
+
+      rulesRedPage:{
+        redPacketMoney: [
+          {required: true, message: "红包金额不能为空", trigger: "blur"}
+        ],
       }
     };
   },
@@ -630,6 +666,13 @@ export default {
         this.title = "修改课程";
       });
     },
+
+    handleUpdateRedPage(row){
+      this.openRedPage.open=true;
+      this.openRedPage.courseId=row.courseId;
+      this.openRedPage.courseName=row.courseName;
+
+    },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
@@ -654,6 +697,32 @@ export default {
         }
       });
     },
+
+    submitFormRedPage(){
+
+      const courseId = this.openRedPage.courseId;
+      const redPacketMoney = this.openRedPage.redPacketMoney;
+      this.$confirm('是否确认将课程id 为"' + courseId + '"的红包批量修改为:【'+redPacketMoney+'】?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+
+        return updateUserCourseRedPage({courseId:courseId,redPacketMoney:redPacketMoney});
+      }).then(() => {
+        this.getList();
+        this.msgSuccess("修改成功");
+        this.openRedPage.open=false;
+      }).finally(() => {
+        this.getList();
+        this.openRedPage.open=false;
+      });
+
+    },
+    cancelRedPage(){
+      this.openRedPage.open=false;
+    },
+
     /** 复制按钮操作 */
     handleCopy(row) {
       const courseId = row.courseId;