Explorar el Código

看客记录添加创建时间必传,sql数据量太大必传时间字段 我的看客记录

xgb hace 6 días
padre
commit
f1a0776764
Se han modificado 1 ficheros con 44 adiciones y 1 borrados
  1. 44 1
      src/views/course/courseWatchLog/deptWatchLog.vue

+ 44 - 1
src/views/course/courseWatchLog/deptWatchLog.vue

@@ -628,13 +628,30 @@ export default {
     courseList().then(response => {
       this.courseLists = response.list;
     });
-    this.getList();
+
     this.getDicts("sys_course_watch_log_type").then(response => {
       this.logTypeOptions = response.data;
     });
+
+    // 设置默认当天时间 xgb 防止频繁查询大量数据
+    this.setToday();
+
+    this.getList();
     this.getCompanyUserListLikeName(true);
+    this.loading=false;
   },
   methods: {
+    setToday(){
+      const today = new Date();
+      const todayStart = new Date(today);
+      todayStart.setHours(0, 0, 0, 0);
+      const todayEnd = new Date(today);
+      todayEnd.setHours(23, 59, 59, 999);
+
+      this.createTimeText = [this.formatDate(todayStart), this.formatDate(todayEnd)];
+      this.queryParams.sTime = this.formatDate(todayStart);
+      this.queryParams.eTime = this.formatDate(todayEnd);
+    },
     handleSendTypeChange() {
       this.handleQuery(); // 重新查询列表
     },
@@ -686,6 +703,12 @@ export default {
     },
     /** 查询短链课程看课记录列表 */
     getList() {
+      // xgb 看课数据量太大必须限制时间
+      if (!this.createTimeText) {
+        this.$message.warning('请选择创建时间');
+        return;
+      }
+
       this.loading = true;
       if(this.queryParams.logType == "10"){
         this.queryParams.logType = null;
@@ -754,6 +777,8 @@ export default {
       // 统一重置日历组件
       this.resetCalendars();
 
+      this.setToday();
+
       this.handleQuery();
     },
     // 多选框选中数据
@@ -814,6 +839,11 @@ export default {
     },
     /** 导出按钮操作 */
     handleExport() {
+      if (!this.createTimeText) {
+        this.$message.warning('请选择创建时间');
+        return;
+      }
+
       const that = this
       const queryParams = this.queryParams;
       this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
@@ -889,6 +919,19 @@ 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('创建时间区间不能超过一个月');
+          this.createTimeText = null;
+          this.queryParams.sTime = null;
+          this.queryParams.eTime = null;
+          return;
+        }
         // this.createTimeText = this.formatDateRange(createTime);
         this.queryParams.sTime = this.formatDate(createTime[0]) || null;
         this.queryParams.eTime = this.formatDate(createTime[1]) || null;