Quellcode durchsuchen

看课记录查询修改 营期 创建时间 更新时间 任意可以查询

xgb vor 5 Tagen
Ursprung
Commit
397a9002bb

+ 52 - 16
src/views/course/courseWatchLog/deptWatchLog.vue

@@ -703,9 +703,11 @@ export default {
     },
     /** 查询短链课程看课记录列表 */
     getList() {
-      // xgb 看课数据量太大必须限制时间
-      if (!this.createTimeText) {
-        this.$message.warning('请选择创建时间');
+      // xgb 看课数据量太大必须限制时间if (this.isEmptyArray(this.createTimeText) &&
+      if (this.isEmptyArray(this.createTimeText) &&
+        this.isEmptyArray(this.updateTimeText) &&
+        this.isEmptyArray(this.scheduleTimeText)) {
+        this.$message.warning('请选择创建时间或营期时间或最新更新时间');
         return;
       }
 
@@ -717,7 +719,14 @@ export default {
         this.courseWatchLogList = response.rows;
         this.total = response.total;
         this.loading = false;
-      });
+      }).catch(() => {
+          this.loading = false;
+        }
+      );
+    },
+    // 添加辅助方法
+    isEmptyArray(arr) {
+      return !arr || arr.length === 0;
     },
     // 取消按钮
     cancel() {
@@ -839,8 +848,11 @@ export default {
     },
     /** 导出按钮操作 */
     handleExport() {
-      if (!this.createTimeText) {
-        this.$message.warning('请选择创建时间');
+      // xgb 看课数据量太大必须限制时间
+      if (this.isEmptyArray(this.createTimeText) &&
+        this.isEmptyArray(this.updateTimeText) &&
+        this.isEmptyArray(this.scheduleTimeText)) {
+        this.$message.warning('请选择创建时间或营期时间或最新更新时间');
         return;
       }
 
@@ -907,6 +919,12 @@ export default {
     // 营期时间
     handleScheduleTimeChange(scheduleTime) {
       if (scheduleTime && scheduleTime.length >= 2) {
+        if(!this.checkDateRangeLimit(scheduleTime)){
+          this.scheduleTimeText = null;
+          this.queryParams.scheduleStartTime=null;
+          this.queryParams.scheduleStartTime=null;
+          return;
+        }
         // this.scheduleTimeText = this.formatDateRange(scheduleTime);
         this.queryParams.scheduleStartTime = scheduleTime[0] || null;
         this.queryParams.scheduleEndTime = scheduleTime[1] || null;
@@ -916,20 +934,32 @@ export default {
         this.queryParams.scheduleEndTime = null;
       }
     },
+    checkDateRangeLimit(dateRange) {
+      if (dateRange && dateRange.length >= 2) {
+        const startDate = new Date(dateRange[0]);
+        const endDate = new Date(dateRange[1]);
+
+        // 设置时间为当天开始,避免时间部分影响计算
+        startDate.setHours(0, 0, 0, 0);
+        endDate.setHours(0, 0, 0, 0);
+
+        const timeDiff = Math.abs(endDate - startDate);
+        const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
+
+        if (diffDays > 31) { // maxDays-1 因为包含起始日
+          this.$message.warning('时间区间不能超过一个月');
+          return false;
+        }
+      }
+      return true;
+    },
     // 创建时间
     createChange(createTime) {
       if (createTime && createTime.length >= 2) {
-        const startDate = new Date(createTime[0]);
-        const endDate = new Date(createTime[1]);
-        const timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
-        const diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
-
-        // 限制时间区间为一个月
-        if (diffDays > 31) {
-          this.$message.warning('创建时间区间不能超过一个月');
+        if(!this.checkDateRangeLimit(createTime)){
           this.createTimeText = null;
-          this.queryParams.sTime = null;
-          this.queryParams.eTime = null;
+          this.queryParams.sTime=null;
+          this.queryParams.eTime=null;
           return;
         }
         // this.createTimeText = this.formatDateRange(createTime);
@@ -945,6 +975,12 @@ export default {
     // 更新时间
     updateChange(updateTime) {
       if (updateTime && updateTime.length >= 2) {
+        if(!this.checkDateRangeLimit(updateTime)){
+          this.updateTimeText = null;
+          this.queryParams.upSTime=null;
+          this.queryParams.upETime=null;
+          return;
+        }
         this.updateTimeText = this.formatDateRange(updateTime);
         this.queryParams.upSTime = updateTime[0] || null;
         this.queryParams.upETime = updateTime[1] || null;

+ 51 - 15
src/views/course/courseWatchLog/index.vue

@@ -832,6 +832,10 @@ export default {
     this.loading=false;
   },
   methods: {
+    // 添加辅助方法
+    isEmptyArray(arr) {
+      return !arr || arr.length === 0;
+    },
     setToday(){
       const today = new Date();
       const todayStart = new Date(today);
@@ -1019,10 +1023,35 @@ export default {
         this.videoList=response.list
       });
     },
+    checkDateRangeLimit(dateRange) {
+      if (dateRange && dateRange.length >= 2) {
+        const startDate = new Date(dateRange[0]);
+        const endDate = new Date(dateRange[1]);
+
+        // 设置时间为当天开始,避免时间部分影响计算
+        startDate.setHours(0, 0, 0, 0);
+        endDate.setHours(0, 0, 0, 0);
 
+        const timeDiff = Math.abs(endDate - startDate);
+        const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
+
+        if (diffDays > 31) { // maxDays-1 因为包含起始日
+          this.$message.warning('时间区间不能超过一个月');
+          return false;
+        }
+      }
+      return true;
+    },
     // 营期时间
     handleScheduleTimeChange(scheduleTime) {
       if (scheduleTime && scheduleTime.length >= 2) {
+        if(!this.checkDateRangeLimit(scheduleTime)){
+          this.scheduleTimeText = null;
+          this.queryParams.scheduleStartTime=null;
+          this.queryParams.scheduleStartTime=null;
+          return;
+        }
+
         // this.scheduleTimeText = this.formatDateRange(scheduleTime);
         this.queryParams.scheduleStartTime = scheduleTime[0] || null;
         this.queryParams.scheduleEndTime = scheduleTime[1] || null;
@@ -1037,17 +1066,10 @@ export default {
     // 创建时间
     createChange(createTime) {
       if (createTime && createTime.length >= 2) {
-        const startDate = new Date(createTime[0]);
-        const endDate = new Date(createTime[1]);
-        const timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
-        const diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
-
-        // 限制时间区间为一个月
-        if (diffDays > 31) {
-          this.$message.warning('创建时间区间不能超过一个月');
+        if(!this.checkDateRangeLimit(createTime)){
           this.createTimeText = null;
-          this.queryParams.sTime = null;
-          this.queryParams.eTime = null;
+          this.queryParams.sTime=null;
+          this.queryParams.eTime=null;
           return;
         }
 
@@ -1064,6 +1086,12 @@ export default {
     // 更新时间
     updateChange(updateTime) {
       if (updateTime && updateTime.length >= 2) {
+        if(!this.checkDateRangeLimit(updateTime)){
+          this.updateTimeText = null;
+          this.queryParams.upSTime=null;
+          this.queryParams.upETime=null;
+          return;
+        }
         // this.updateTimeText = this.formatDateRange(updateTime);
         this.queryParams.upSTime = updateTime[0] || null;
         this.queryParams.upETime = updateTime[1] || null;
@@ -1189,8 +1217,10 @@ export default {
     /** 查询短链课程看课记录列表 */
     getList() {
       // xgb 看课数据量太大必须限制时间
-      if (!this.createTimeText) {
-        this.$message.warning('请选择创建时间');
+      if (this.isEmptyArray(this.createTimeText) &&
+        this.isEmptyArray(this.updateTimeText) &&
+        this.isEmptyArray(this.scheduleTimeText)) {
+        this.$message.warning('请选择创建时间或营期时间或最新更新时间');
         return;
       }
 
@@ -1203,6 +1233,8 @@ export default {
         this.courseWatchLogList = response.rows;
         this.total = response.total;
         this.loading = false;
+      }).catch(() => {
+        this.loading = false;
       });
     },
     // 取消按钮
@@ -1261,7 +1293,6 @@ export default {
       this.queryParams.scheduleEndTime = null;
       this.queryParams.sopId = null; // 重置SOP ID
 
-      this.setToday();
 
       // 重置SOP搜索
       this.handleSopClear();
@@ -1269,6 +1300,8 @@ export default {
       // 统一重置日历组件
       this.resetCalendars();
 
+      this.setToday();
+
       this.handleQuery();
     },
     // 多选框选中数据
@@ -1329,8 +1362,11 @@ export default {
     },
     /** 导出按钮操作 */
     handleExport() {
-      if (!this.createTimeText) {
-        this.$message.warning('请选择创建时间');
+      // xgb 看课数据量太大必须限制时间
+      if (this.isEmptyArray(this.createTimeText) &&
+        this.isEmptyArray(this.updateTimeText) &&
+        this.isEmptyArray(this.scheduleTimeText)) {
+        this.$message.warning('请选择创建时间或营期时间或最新更新时间');
         return;
       }
       const queryParams = this.queryParams;

+ 57 - 21
src/views/course/courseWatchLog/watchLog.vue

@@ -854,10 +854,10 @@ export default {
       this.qecCreateTime = [];
       this.periodTime = [];
 
-      this.scheduleTimeText = '';
-      this.createTimeText = '';
-      this.updateTimeText = '';
-      this.qecCreateTimeText = '';
+      this.scheduleTimeText = [];
+      this.createTimeText = [];
+      this.updateTimeText = [];
+      this.qecCreateTimeText = [];
       this.periodTimeText = [];
 
       // 强制刷新日历组件
@@ -904,31 +904,48 @@ export default {
     // 营期时间
     handleScheduleTimeChange(scheduleTime) {
       if (scheduleTime && scheduleTime.length >= 2) {
+        if(!this.checkDateRangeLimit(scheduleTime)){
+          this.scheduleTimeText = null;
+          this.queryParams.scheduleStartTime=null;
+          this.queryParams.scheduleStartTime=null;
+          return;
+        }
+
         // this.scheduleTimeText = this.formatDateRange(scheduleTime);
         this.queryParams.scheduleStartTime = scheduleTime[0] || null;
         this.queryParams.scheduleEndTime = scheduleTime[1] || null;
-        console.log(this.queryParams.scheduleStartTime)
-        console.log(this.queryParams.scheduleEndTime)
       } else {
         this.scheduleTimeText = [];
         this.queryParams.scheduleStartTime = null;
         this.queryParams.scheduleEndTime = null;
       }
     },
+    checkDateRangeLimit(dateRange) {
+      if (dateRange && dateRange.length >= 2) {
+        const startDate = new Date(dateRange[0]);
+        const endDate = new Date(dateRange[1]);
+
+        // 设置时间为当天开始,避免时间部分影响计算
+        startDate.setHours(0, 0, 0, 0);
+        endDate.setHours(0, 0, 0, 0);
+
+        const timeDiff = Math.abs(endDate - startDate);
+        const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
+
+        if (diffDays > 31) { // maxDays-1 因为包含起始日
+          this.$message.warning('时间区间不能超过一个月');
+          return false;
+        }
+      }
+      return true;
+    },
     // 创建时间
     createChange(createTime) {
       if (createTime && createTime.length >= 2) {
-        const startDate = new Date(createTime[0]);
-        const endDate = new Date(createTime[1]);
-        const timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
-        const diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
-
-        // 限制时间区间为一个月
-        if (diffDays > 31) {
-          this.$message.warning('创建时间区间不能超过一个月');
+        if(!this.checkDateRangeLimit(createTime)){
           this.createTimeText = null;
-          this.queryParams.sTime = null;
-          this.queryParams.eTime = null;
+          this.queryParams.sTime=null;
+          this.queryParams.eTime=null;
           return;
         }
 
@@ -945,6 +962,13 @@ export default {
     // 更新时间
     updateChange(updateTime) {
       if (updateTime && updateTime.length >= 2) {
+        if(!this.checkDateRangeLimit(updateTime)){
+          this.updateTimeText = null;
+          this.queryParams.upSTime=null;
+          this.queryParams.upETime=null;
+          return;
+        }
+
         // this.updateTimeText = this.formatDateRange(updateTime);
         this.queryParams.upSTime = updateTime[0] || null;
         this.queryParams.upETime = updateTime[1] || null;
@@ -1057,11 +1081,14 @@ export default {
 
     /** 查询短链课程看课记录列表 */
     getList() {
-      // xgb 看课数据量太大必须限制时间
-      if (!this.createTimeText) {
-        this.$message.warning('请选择创建时间');
+      // xgb 看课数据量太大必须限制时间if (this.isEmptyArray(this.createTimeText) &&
+      if (this.isEmptyArray(this.createTimeText) &&
+        this.isEmptyArray(this.updateTimeText) &&
+        this.isEmptyArray(this.scheduleTimeText)) {
+        this.$message.warning('请选择创建时间或营期时间或最新更新时间');
         return;
       }
+
       this.loading = true;
       let param = JSON.parse(JSON.stringify(this.queryParams));
       if (param.logType == "10") {
@@ -1071,6 +1098,8 @@ export default {
         this.courseWatchLogList = response.rows;
         this.total = response.total;
         this.loading = false;
+      }).catch(() => {
+        this.loading = false;
       });
     },
     // 取消按钮
@@ -1196,10 +1225,17 @@ export default {
       }).catch(() => {
       });
     },
+    // 添加辅助方法
+    isEmptyArray(arr) {
+      return !arr || arr.length === 0;
+    },
     /** 导出按钮操作 */
     handleExport() {
-      if (!this.createTimeText) {
-        this.$message.warning('请选择创建时间');
+      // xgb 看课数据量太大必须限制时间
+      if (this.isEmptyArray(this.createTimeText) &&
+        this.isEmptyArray(this.updateTimeText) &&
+        this.isEmptyArray(this.scheduleTimeText)) {
+        this.$message.warning('请选择创建时间或营期时间或最新更新时间');
         return;
       }
       const queryParams = this.queryParams;