Kaynağa Gözat

看课统计添加默认条件

wangxy 1 hafta önce
ebeveyn
işleme
6860b3b6aa
1 değiştirilmiş dosya ile 42 ekleme ve 54 silme
  1. 42 54
      src/views/his/statistics/courseReport.vue

+ 42 - 54
src/views/his/statistics/courseReport.vue

@@ -18,7 +18,7 @@
       </el-form-item>
       <el-form-item label="训练营" prop="trainingCampId" v-if="queryParams.dimension === 'camp'">
         <el-select filterable v-model="queryParams.trainingCampId" placeholder="请选择训练营"
-                   clearable size="small"  @change="handleCampChange">
+                   clearable size="small" @change="handleCampChange">
           <el-option
             v-for="item in camps"
             :key="item.dictValue"
@@ -43,26 +43,22 @@
       </el-form-item>
     </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"
-              >导出</el-button>
-            </el-col>
-            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
-    <!--    <el-tabs type="card" v-model="actName" @tab-click="handleClickX">-->
-    <!--      <el-tab-pane label="全部订单" name="10"></el-tab-pane>-->
-    <!--      <el-tab-pane v-for="(item,index) in statusOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>-->
-    <!--    </el-tabs>-->
     <el-table height="500" v-loading="loading" border :data="packageOrderList">
       <el-table-column label="销售公司" align="center" prop="companyName" width="120px"/>
-      <el-table-column label="训练营" align="center" prop="trainingCampName"  v-if="showTrainingCampColumn"/>
-      <el-table-column label="营期" align="center" prop="periodName"  v-if="showPeriodColumn" />
+      <el-table-column label="训练营" align="center" prop="trainingCampName" v-if="showTrainingCampColumn"/>
+      <el-table-column label="营期" align="center" prop="periodName" v-if="showPeriodColumn"/>
       <el-table-column label="进线人数" align="center" prop="accessCount"/>
       <el-table-column label="待看课人数" align="center" prop="pendingCount"/>
       <el-table-column label="看课中人数" align="center" prop="watchingCount"/>
@@ -71,7 +67,7 @@
       <el-table-column label="看课中断" align="center" prop="interruptedCount"/>
       <el-table-column label="完课率" align="center" prop="finishRate"/>
       <el-table-column label="答题人数" align="center" prop="answerUserCount"/>
-      <el-table-column label="红包领取数" align="center" prop="packetUserCount"/>
+      <el-table-column label="红包领取数" align="center" prop="packetUserCount"/>
       <el-table-column label="红包金额" align="center" prop="packetAmount"/>
     </el-table>
     <div class="total-summary">
@@ -84,7 +80,7 @@
       <span class="total-item">看课中断: {{ calculatedTotalData.interruptedCount }}</span>
       <span class="total-item">完课率: {{ calculatedTotalData.finishRate}}</span>
       <span class="total-item">答题人数: {{ calculatedTotalData.answerUserCount }}</span>
-      <span class="total-item">红包领取数: {{ calculatedTotalData.packetUserCount}}</span>
+      <span class="total-item">红包领取数: {{ calculatedTotalData.packetUserCount}}</span>
       <span class="total-item">红包金额: {{ calculatedTotalData.packetAmount }}</span>
     </div>
     <pagination
@@ -111,16 +107,6 @@ import {getTask} from "@/api/common";
 import {getCampList, getPeriodList} from "@/api/course/userWatchCourseStatistics";
 
 export default {
-  watch: {
-    'queryParams.deptId': function(newVal, oldVal) {
-      // 避免初始化时的触发
-      if (oldVal !== undefined) {
-        this.handleQuery();
-      }
-    },
-    // 监听deptId
-    'deptId': 'currDeptChange'
-  },
   name: "PackageOrder",
   components: {packageOrderDetails, Treeselect},
   data() {
@@ -145,14 +131,14 @@ export default {
         packetUserCount: 0,
         packetAmount: 0
       },
-      showTrainingCampColumn:false,
-      showPeriodColumn:false,
+      showTrainingCampColumn: false,
+      showPeriodColumn: false,
       totalData: {},
       companys: [],
       camps: [],
       deptOptions: [],
       companyId: undefined,
-      campId:undefined ,
+      campId: undefined,
       deptId: undefined,
       show: {
         open: false,
@@ -208,6 +194,8 @@ export default {
         days: null,
         status: null,
         startTime: null,
+        startDate: null,
+        endDate:null,
         finishTime: null,
         sTime: null,
         eTime: null,
@@ -219,9 +207,9 @@ export default {
         companyName: null,
         deptId: null,
         source: null,
-        trainingCampId:null,
-        periodId:null,
-        dimension:'company'
+        trainingCampId: null,
+        periodId: null,
+        dimension: 'camp'
       },
       // 表单参数
       form: {},
@@ -229,9 +217,19 @@ export default {
       rules: {}
     };
   },
-  computed: {
-  },
   created() {
+    // 设置默认时间为前一天
+    const yesterday = new Date();
+    yesterday.setDate(yesterday.getDate() - 1);
+    const 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}`;
+    };
+    this.createTime = [formatDate(yesterday), formatDate(yesterday)];
+    this.queryParams.sTime = this.createTime[0];
+    this.queryParams.eTime = this.createTime[1];
     getCampList().then(response => {
       this.camps = response.data.list
       if (this.camps != null && this.camps.length > 0) {
@@ -284,7 +282,7 @@ export default {
     getList() {
       this.loading = true;
       courseReport(this.queryParams).then(response => {
-        this.packageOrderList = response.rows ;
+        this.packageOrderList = response.rows;
         this.total = response.total;
         // 判断是否需要显示训练营和营期列
         this.showTrainingCampColumn = this.packageOrderList &&
@@ -351,14 +349,12 @@ export default {
         // 如果清空训练营,也清空营期选项
         this.deptOptions = [];
       }
-
-      // 触发查询
-      this.handleQuery();
+      // 移除了自动搜索的逻辑,只在点击搜索按钮时触发
     },
 
     /** 根据训练营获取营期数据 */
     getPeriodByCamp(campId) {
-      const param = { campId: campId };
+      const param = {campId: campId};
       getPeriodList(param).then((response) => {
         console.log('接口返回数据:', response);
         console.log('营期列表数据:', response.data);
@@ -464,7 +460,8 @@ export default {
       }).then(response => {
         this.download(response.msg);
         this.exportLoading = false;
-      }).catch(() => {});
+      }).catch(() => {
+      });
     },
     endChange() {
       if (this.endTime != null) {
@@ -474,15 +471,7 @@ export default {
         this.queryParams.endStartTime = null;
         this.queryParams.endEndTime = null;
       }
-    },
-    handleDeptChange(val) {
-      this.queryParams.deptId = val;
-      this.handleQuery(); // 选择后立即搜索
-    },
-    currDeptChange(val) {
-      this.queryParams.deptId = val;
-      this.this.handleQuery();
-    },
+    }
   }
 };
 </script>
@@ -547,5 +536,4 @@ export default {
     margin-bottom: 8px;
   }
 }
-
 </style>