浏览代码

会员看课分析统计修改

Long 1 周之前
父节点
当前提交
ae6efc34a9
共有 1 个文件被更改,包括 59 次插入12 次删除
  1. 59 12
      src/views/course/courseUserStatistics/statistics.vue

+ 59 - 12
src/views/course/courseUserStatistics/statistics.vue

@@ -31,8 +31,17 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item label="所属公司" prop="companyId">
+        <el-select v-model="queryParams.companyId" placeholder="请选择公司" filterable clearable size="small" @change="handleCompanyChange">
+          <el-option
+            v-for="item in companyList"
+            :key="item.companyId"
+            :label="item.companyName"
+            :value="item.companyId"/>
+        </el-select>
+      </el-form-item>
       <el-form-item label="销售" prop="nickName">
-        <el-select v-model="queryParams.companyUserId" remote placeholder="请选择" filterable clearable  style="width: 100%;" @keyup.enter.native="handleQuery">
+        <el-select v-model="queryParams.companyUserId" placeholder="请选择" filterable clearable size="small">
           <el-option
             v-for="dict in companyUserList"
             :key="`${dict.nickName} - ${dict.userName}`"
@@ -42,7 +51,7 @@
         </el-select>
       </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" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
+        <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :clearable="false" @change="change"></el-date-picker>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -487,7 +496,8 @@
 <script>
 import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog,statisticsList,qwWatchLogStatisticsList,qwWatchLogAllStatisticsList } from "@/api/course/courseWatchLog";
 import { courseList,videoList } from '@/api/course/courseRedPacketLog'
-import {getUserList} from "@/api/company/companyUser";
+import {getUserList, getCompanyList} from "@/api/company/companyUser";
+import {getDicts} from "@/api/system/dict/data";
 export default {
   name: "CourseWatchLog",
   data() {
@@ -518,6 +528,7 @@ export default {
       // 是否显示弹出层
       open: false,
       companyUserList: [],
+      companyList: [],
       projectLists: [],
       // 查询参数
       queryParams: {
@@ -547,14 +558,27 @@ export default {
     };
   },
   created() {
+    const today = new Date();
+    const tomorrow = new Date(today);
+    tomorrow.setDate(tomorrow.getDate() + 1);
+    const formatDate = d => d.toISOString().split('T')[0];
+    this.createTime = [formatDate(today), formatDate(tomorrow)];
+    this.queryParams.sTime = this.createTime[0];
+    this.queryParams.eTime = this.createTime[1];
+
     courseList().then(response => {
       this.courseLists = response.list;
     });
+    getCompanyList().then(res => {
+      if (res.code === 200) {
+        this.companyList = res.data;
+      }
+    });
     this.getList();
-    this.getDicts("sys_course_watch_log_type").then(response => {
+    getDicts("sys_course_watch_log_type").then(response => {
       this.logTypeOptions = response.data;
     });
-    this.getDicts("sys_course_project").then(response => {
+    getDicts("sys_course_project").then(response => {
       this.projectLists = response.data;
     })
     if (this.queryParams.companyId != null) {
@@ -576,8 +600,31 @@ export default {
         this.videoList=response.list
       });
     },
+    handleCompanyChange(val) {
+      this.queryParams.companyUserId = null;
+      if (val) {
+        getUserList(val).then(res => {
+          if (res.code === 200) {
+            this.companyUserList = res.data;
+          }
+        });
+      } else {
+        this.companyUserList = [];
+      }
+    },
     change() {
       if (this.createTime != null) {
+        if (this.createTime[0] === this.createTime[1]) {
+          const today = new Date();
+          const tomorrow = new Date(today);
+          tomorrow.setDate(tomorrow.getDate() + 1);
+          const formatDate = d => d.toISOString().split('T')[0];
+          this.createTime = [formatDate(today), formatDate(tomorrow)];
+          this.queryParams.sTime = this.createTime[0];
+          this.queryParams.eTime = this.createTime[1];
+          this.$message.warning("开始时间和结束时间不能是同一天");
+          return;
+        }
         this.queryParams.sTime = this.createTime[0];
         this.queryParams.eTime = this.createTime[1];
       } else {
@@ -628,20 +675,20 @@ export default {
     },
     /** 搜索按钮操作 */
     handleQuery() {
-      if (!this.queryParams.sTime || !this.queryParams.eTime) {
-        this.$message.warning("请选择添加时间");
-        return;
-      }
       this.queryParams.pageNum = 1;
       this.getList();
     },
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm");
-      this.createTime = null;
+      const today = new Date();
+      const tomorrow = new Date(today);
+      tomorrow.setDate(tomorrow.getDate() + 1);
+      const formatDate = d => d.toISOString().split('T')[0];
+      this.createTime = [formatDate(today), formatDate(tomorrow)];
+      this.queryParams.sTime = this.createTime[0];
+      this.queryParams.eTime = this.createTime[1];
       this.scheduleTime = null;
-      this.queryParams.sTime = null;
-      this.queryParams.eTime = null;
       this.queryParams.scheduleStartTime = null;
       this.queryParams.scheduleEndTime = null;
       this.handleQuery();