Bläddra i källkod

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

xgb 1 vecka sedan
förälder
incheckning
69716f95d8
1 ändrade filer med 53 tillägg och 4 borttagningar
  1. 53 4
      src/views/course/courseWatchLog/index.vue

+ 53 - 4
src/views/course/courseWatchLog/index.vue

@@ -45,7 +45,9 @@
         </el-date-picker>
       </el-form-item>
       <el-form-item label="创建时间" prop="createTime">
-        <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
+        <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"
+                        type="daterange"
+                        :required="true"
                         range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="createChange"></el-date-picker>
       </el-form-item>
       <el-form-item label="最新更新时间" prop="updateTime">
@@ -237,8 +239,13 @@ export default {
       this.userSourceTypeOptions = response.data;
     })
 
+    // 设置默认当天时间 xgb 防止频繁查询大量数据
+    this.setToday();
+
     this.getList();
 
+    this.loading = false;
+
 
   },
   computed: {
@@ -252,6 +259,20 @@ export default {
     }
   },
   methods: {
+
+    setToday(){
+      const today = new Date();
+      const todayStr = this.formatDate(today);
+      this.createTime = [todayStr, todayStr];
+      this.queryParams.sTime = todayStr;
+      this.queryParams.eTime = todayStr;
+    },
+    formatDate(date) {
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0');
+      const day = String(date.getDate()).padStart(2, '0');
+      return `${year}-${month}-${day}`;
+    },
     handleClear(){
       this.queryUserLoading = false;
       this.fsUserList = [];
@@ -292,6 +313,20 @@ export default {
     },
     createChange() {
       if (this.createTime != null) {
+        const startDate = new Date(this.createTime[0]);
+        const endDate = new Date(this.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.createTime = null;
+          this.queryParams.sTime = null;
+          this.queryParams.eTime = null;
+          return;
+        }
+
         this.queryParams.sTime = this.createTime[0];
         this.queryParams.eTime = this.createTime[1];
       } else {
@@ -320,6 +355,12 @@ export default {
     },
     /** 查询短链课程看课记录列表 */
     getList() {
+
+      // xgb 看课数据量太大必须限制时间
+      if (!this.createTime) {
+        this.$message.warning('请选择创建时间');
+        return;
+      }
       this.loading = true;
       if(this.queryParams.logType == "10"){
         this.queryParams.logType = null;
@@ -366,17 +407,21 @@ export default {
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm");
-      this.createTime = null;
+      // this.createTime = null;
       this.scheduleTime = null;
-      this.queryParams.sTime = null;
-      this.queryParams.eTime = null;
+      // this.queryParams.sTime = null;
+      // this.queryParams.eTime = null;
       this.queryParams.upSTime = null;
       this.queryParams.upETime = null;
       this.queryParams.scheduleStartTime = null;
       this.queryParams.scheduleEndTime = null;
       this.scheduleTime=null;
       this.updateTime=null;
+      // 重置时间当天
+      this.setToday();
+
       this.handleQuery();
+
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
@@ -436,6 +481,10 @@ export default {
     },
     /** 导出按钮操作 */
     handleExport() {
+      if (!this.createTime) {
+        this.$message.warning('请选择创建时间');
+        return;
+      }
       const queryParams = this.queryParams;
       this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
           confirmButtonText: "确定",