浏览代码

如果是会员就是三级联动查课,如果是企微,就两级联动

xw 2 天之前
父节点
当前提交
bb6e21a1b4

+ 14 - 0
src/api/course/courseRedPacketLog.js

@@ -37,6 +37,13 @@ export function courseList() {
     method: 'get',
   })
 }
+// 查询企微课程列表(企微用户绑定课程)
+export function qwCourseList() {
+  return request({
+    url: '/course/courseRedPacketLog/qwcourseList',
+    method: 'get',
+  })
+}
 // 查询营期列表
 export function periodList(query) {
   return request({
@@ -52,6 +59,13 @@ export function videoList(id) {
     method: 'get'
   })
 }
+// 查询企微小节列表(通过课程ID)
+export function qwVideoList(courseId) {
+  return request({
+    url: '/course/courseRedPacketLog/qwvideoList/' + courseId,
+    method: 'get'
+  })
+}
 // 新增短链课程看课记录
 export function addCourseRedPacketLog(data) {
   return request({

+ 72 - 12
src/views/course/courseWatchLog/index.vue

@@ -48,8 +48,8 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="训练营" prop="courseId">
-        <el-select filterable  v-model="queryParams.courseId" placeholder="请选择训练营"  clearable size="small" @change="handleCourseChange">
+      <el-form-item label="课程" prop="courseId">
+        <el-select filterable  v-model="queryParams.courseId" placeholder="请选择课程"  clearable size="small" @change="handleCourseChange">
           <el-option
             v-for="dict in courseLists"
             :key="dict.dictValue"
@@ -58,7 +58,8 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item label="营期" prop="periodId">
+      <!-- 营期:仅在会员方式(sendType=1)时显示 -->
+      <el-form-item label="营期" prop="periodId" v-if="queryParams.sendType == 1">
         <el-select filterable  v-model="queryParams.periodId" placeholder="请选择营期"  clearable size="small" @change="handlePeriodChange" :disabled="!queryParams.courseId">
           <el-option
             v-for="dict in periodList"
@@ -68,8 +69,10 @@
           />
         </el-select>
       </el-form-item>
+      <!-- 小节:会员方式依赖营期,企微方式依赖课程 -->
       <el-form-item label="小节" prop="videoId">
-        <el-select filterable  v-model="queryParams.videoId" placeholder="请选择小节"  clearable size="small" :disabled="!queryParams.periodId">
+        <el-select filterable  v-model="queryParams.videoId" placeholder="请选择小节"  clearable size="small" 
+          :disabled="queryParams.sendType == 1 ? !queryParams.periodId : !queryParams.courseId">
           <el-option
             v-for="dict in videoList"
             :key="dict.dictValue"
@@ -683,7 +686,7 @@
 
 <script>
 import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog } from "@/api/course/courseWatchLog";
-import {courseList, listCourseRedPacketLog, videoList, periodList} from '@/api/course/courseRedPacketLog'
+import {courseList, qwCourseList, listCourseRedPacketLog, videoList, qwVideoList, periodList} from '@/api/course/courseRedPacketLog'
 import {listLogs} from "@/api/course/courseAnswerlogs";
 import {allListTagGroup} from "../../../api/qw/tagGroup";
 import {searchTags} from "../../../api/qw/tag";
@@ -903,9 +906,8 @@ export default {
     };
   },
   created() {
-    courseList().then(response => {
-      this.courseLists = response.list;
-    });
+    // 初始化时根据默认的sendType加载课程列表
+    this.loadCourseList();
     this.getList();
     this.getDicts("sys_course_watch_log_type_new").then(response => {
       this.logTypeOptions = response.data;
@@ -1086,7 +1088,8 @@ export default {
     },
     /**
      * 课程变更处理
-     * 当课程改变时,清空营期和小节的选择和列表
+     * sendType=1(会员): 加载营期列表,清空营期和小节
+     * sendType=2(企微): 直接加载小节列表,清空小节
      */
     handleCourseChange(courseId) {
       // 清空下级选择和列表
@@ -1095,9 +1098,15 @@ export default {
       this.periodList = [];
       this.videoList = [];
 
-      // 如果选择了课程,加载营期列表
       if (courseId) {
-        this.loadPeriodList(courseId);
+        if (this.queryParams.sendType == 1) {
+          // 会员方式:加载营期列表(三级联动:课程->营期->小节)
+          this.loadPeriodList(courseId);
+        } else if (this.queryParams.sendType == 2) {
+          // 企微方式:直接加载小节列表(二级联动:课程->小节)
+          // 调用 /course/courseRedPacketLog/qwvideoList/{courseId}
+          this.loadQwVideoList(courseId);
+        }
       }
     },
 
@@ -1131,7 +1140,7 @@ export default {
     },
 
     /**
-     * 加载视频列表
+     * 加载视频列表(通过营期ID)
      * @param {Number} periodId - 营期ID
      */
     loadVideoList(periodId) {
@@ -1144,6 +1153,46 @@ export default {
       });
     },
 
+    /**
+     * 加载视频列表(通过课程ID)- 企微方式使用
+     * @param {Number} courseId - 课程ID
+     */
+    loadQwVideoList(courseId) {
+      qwVideoList(courseId).then(response => {
+        this.videoList = response.list || [];
+      }).catch(error => {
+        console.error('加载视频列表失败:', error);
+        this.$message.error('加载视频列表失败');
+        this.videoList = [];
+      });
+    },
+    
+    /**
+     * 加载课程列表
+     * 根据sendType加载不同的课程列表
+     */
+    loadCourseList() {
+      if (this.queryParams.sendType == 2) {
+        // 企微方式:调用qwCourseList
+        qwCourseList().then(response => {
+          this.courseLists = response.list || [];
+        }).catch(error => {
+          console.error('加载企微课程列表失败:', error);
+          this.$message.error('加载课程列表失败');
+          this.courseLists = [];
+        });
+      } else {
+        // 会员方式:调用courseList
+        courseList().then(response => {
+          this.courseLists = response.list || [];
+        }).catch(error => {
+          console.error('加载课程列表失败:', error);
+          this.$message.error('加载课程列表失败');
+          this.courseLists = [];
+        });
+      }
+    },
+
     // 营期时间
     handleScheduleTimeChange(scheduleTime) {
       if (scheduleTime && scheduleTime.length >= 2) {
@@ -1482,6 +1531,17 @@ export default {
     },
 
     handleSendTypeChange() {
+      // 清空课程、营期、小节相关数据
+      this.queryParams.courseId = null;
+      this.queryParams.periodId = null;
+      this.queryParams.videoId = null;
+      this.periodList = [];
+      this.videoList = [];
+      this.courseLists = [];
+      
+      // 重新加载课程列表
+      this.loadCourseList();
+      
       this.handleQuery(); // 重新查询列表
     },
 

+ 64 - 6
src/views/course/courseWatchLog/watchLog.vue

@@ -669,7 +669,7 @@ import {
   myListCourseWatchLog,
   updateCourseWatchLog
 } from "@/api/course/courseWatchLog";
-import {courseList, myListCourseRedPacketLog, videoList} from '@/api/course/courseRedPacketLog'
+import {courseList, qwCourseList, myListCourseRedPacketLog, videoList, qwVideoList} from '@/api/course/courseRedPacketLog'
 import {myListLogs} from "@/api/course/courseAnswerlogs";
 import {getMyQwUserList} from "@/api/qw/user";
 import {searchTags} from "../../../api/qw/tag";
@@ -861,9 +861,8 @@ export default {
     };
   },
   created() {
-    courseList().then(response => {
-      this.courseLists = response.list;
-    });
+    // 初始化时根据默认的sendType加载课程列表
+    this.loadCourseList();
 
     this.getDicts("sys_course_watch_log_type_new").then(response => {
       this.logTypeOptions = response.data;
@@ -909,6 +908,13 @@ export default {
       this.queryParams.courseId = null;
       this.queryParams.videoId = null;
 
+      // 清空课程和视频列表
+      this.courseLists = [];
+      this.videoList = [];
+
+      // 重新加载课程列表
+      this.loadCourseList();
+
       // 重置选择
       this.ids = [];
       this.courseWatchLogList = []; // 清空表格数据
@@ -953,8 +959,60 @@ export default {
         this.videoList = [];
         return
       }
-      videoList(row).then(response => {
-        this.videoList = response.list
+      
+      // 根据sendType调用不同的接口
+      if (this.queryParams.sendType == 2) {
+        // 企微方式:调用qwVideoList
+        this.loadQwVideoList(row);
+      } else {
+        // 会员方式:调用videoList
+        videoList(row).then(response => {
+          this.videoList = response.list || [];
+        }).catch(error => {
+          console.error('加载视频列表失败:', error);
+          this.$message.error('加载视频列表失败');
+          this.videoList = [];
+        });
+      }
+    },
+
+    /**
+     * 加载课程列表
+     * 根据sendType加载不同的课程列表
+     */
+    loadCourseList() {
+      if (this.queryParams.sendType == 2) {
+        // 企微方式:调用qwCourseList
+        qwCourseList().then(response => {
+          this.courseLists = response.list || [];
+        }).catch(error => {
+          console.error('加载企微课程列表失败:', error);
+          this.$message.error('加载课程列表失败');
+          this.courseLists = [];
+        });
+      } else {
+        // 会员方式:调用courseList
+        courseList().then(response => {
+          this.courseLists = response.list || [];
+        }).catch(error => {
+          console.error('加载课程列表失败:', error);
+          this.$message.error('加载课程列表失败');
+          this.courseLists = [];
+        });
+      }
+    },
+
+    /**
+     * 加载视频列表(通过课程ID)- 企微方式使用
+     * @param {Number} courseId - 课程ID
+     */
+    loadQwVideoList(courseId) {
+      qwVideoList(courseId).then(response => {
+        this.videoList = response.list || [];
+      }).catch(error => {
+        console.error('加载视频列表失败:', error);
+        this.$message.error('加载视频列表失败');
+        this.videoList = [];
       });
     },
     updateQwuser() {