소스 검색

短链课程看课记录导出

yjwang 1 일 전
부모
커밋
1a87a8776f
2개의 변경된 파일86개의 추가작업 그리고 52개의 파일을 삭제
  1. 43 26
      src/views/course/courseRedPacketLog/index.vue
  2. 43 26
      src/views/course/courseRedPacketLog/myCourseRedPacketLog.vue

+ 43 - 26
src/views/course/courseRedPacketLog/index.vue

@@ -62,17 +62,17 @@
     </el-form>
 
     <el-row :gutter="10" class="mb8">
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="warning"-->
-<!--          plain-->
-<!--          icon="el-icon-download"-->
-<!--          size="mini"-->
-<!--          :loading="exportLoading"-->
-<!--          @click="handleExport"-->
-<!--          v-hasPermi="['course:courseRedPacketLog:export']"-->
-<!--        >导出</el-button>-->
-<!--      </el-col>-->
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+          v-hasPermi="['course:courseRedPacketLog:export']"
+        >导出</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
     <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
@@ -160,7 +160,7 @@ export default {
       // 遮罩层
       loading: true,
       // 导出遮罩层
-      // exportLoading: false,
+      exportLoading: false,
       // 选中数组
       ids: [],
       // 非单个禁用
@@ -353,20 +353,37 @@ export default {
 	  });
 	},
     /** 导出按钮操作 */
-    // handleExport() {
-    //   const queryParams = this.queryParams;
-    //   this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
-    //       confirmButtonText: "确定",
-    //       cancelButtonText: "取消",
-    //       type: "warning"
-    //     }).then(() => {
-    //       this.exportLoading = true;
-    //       return exportCourseRedPacketLog(queryParams);
-    //     }).then(response => {
-    //       this.download(response.msg);
-    //       this.exportLoading = false;
-    //     }).catch(() => {});
-    // }
+    handleExport() {
+      const queryParams = this.queryParams;
+
+      // 定义要排除的字段
+      const excludeFields = ['pageNum', 'pageSize']
+
+      // 检查除排除字段外是否有非null值
+      const hasQueryParams = Object.keys(queryParams).some(key => {
+        return !excludeFields.includes(key) && queryParams[key] !== null &&
+          queryParams[key] !== ''
+      })
+
+      if (!hasQueryParams) {
+        return this.$message.warning({
+          message: '导出失败,请选择至少一个查询条件再试!',
+          duration: 3000
+        })
+      }
+
+      this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          this.exportLoading = true;
+          return exportCourseRedPacketLog(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+          this.exportLoading = false;
+        }).catch(() => {});
+    }
   }
 };
 </script>

+ 43 - 26
src/views/course/courseRedPacketLog/myCourseRedPacketLog.vue

@@ -52,17 +52,17 @@
     </el-form>
 
     <el-row :gutter="10" class="mb8">
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="warning"-->
-<!--          plain-->
-<!--          icon="el-icon-download"-->
-<!--          size="mini"-->
-<!--          :loading="exportLoading"-->
-<!--          @click="handleExport"-->
-<!--          v-hasPermi="['course:courseRedPacketLog:export']"-->
-<!--        >导出</el-button>-->
-<!--      </el-col>-->
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+          v-hasPermi="['course:courseRedPacketLog:export']"
+        >导出</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
     <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
@@ -149,7 +149,7 @@ export default {
       // 遮罩层
       loading: true,
       // 导出遮罩层
-      // exportLoading: false,
+      exportLoading: false,
       // 选中数组
       ids: [],
       // 非单个禁用
@@ -355,20 +355,37 @@ export default {
 	  });
 	},
     /** 导出按钮操作 */
-    // handleExport() {
-    //   const queryParams = this.queryParams;
-    //   this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
-    //       confirmButtonText: "确定",
-    //       cancelButtonText: "取消",
-    //       type: "warning"
-    //     }).then(() => {
-    //       this.exportLoading = true;
-    //       return exportCourseRedPacketLog(queryParams);
-    //     }).then(response => {
-    //       this.download(response.msg);
-    //       this.exportLoading = false;
-    //     }).catch(() => {});
-    // }
+    handleExport() {
+      const queryParams = this.queryParams;
+
+      // 定义要排除的字段
+      const excludeFields = ['pageNum', 'pageSize']
+
+      // 检查除排除字段外是否有非null值
+      const hasQueryParams = Object.keys(queryParams).some(key => {
+        return !excludeFields.includes(key) && queryParams[key] !== null &&
+          queryParams[key] !== ''
+      })
+
+      if (!hasQueryParams) {
+        return this.$message.warning({
+          message: '导出失败,请选择至少一个查询条件再试!',
+          duration: 3000
+        })
+      }
+
+      this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          this.exportLoading = true;
+          return exportCourseRedPacketLog(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+          this.exportLoading = false;
+        }).catch(() => {});
+    }
   }
 };
 </script>