1
0

3 Коммиты 6d2956db0e ... 9213ca8193

Автор SHA1 Сообщение Дата
  wangxy 9213ca8193 看课打卡管理,app看课统计 2 недель назад
  wangxy 0c5588101c Merge remote-tracking branch 'origin/红德堂' into 红德堂 3 недель назад
  wangxy 105556ba99 app需求 3 недель назад

+ 9 - 0
src/api/his/user.js

@@ -191,3 +191,12 @@ export function clearUserWatchRecord(data) {
     data: data
   })
 }
+
+
+// 获取 app 总会员数量
+export function getAppUserCount() {
+  return request({
+    url: '/his/user/appUserCount',
+    method: 'get'
+  })
+}

+ 467 - 0
src/views/his/courseCheckIn/index.vue

@@ -0,0 +1,467 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="85px" @submit.native.prevent>
+      <el-form-item label="活动名称" prop="activityName">
+        <el-input v-model="queryParams.activityName"
+                  placeholder="请输入活动名称"
+                  clearable
+                  size="small"
+                  @keyup.enter.native="handleQuery" />
+      </el-form-item>
+      <el-form-item label="活动状态" prop="status">
+        <el-select v-model="queryParams.status" placeholder="请选择活动状态" clearable size="small">
+          <el-option label="未开始" :value="0" />
+          <el-option label="进行中" :value="1" />
+          <el-option label="已结束" :value="2" />
+          <el-option label="已停用" :value="3" />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button type="primary"
+                   icon="el-icon-plus"
+                   size="mini"
+                   @click="handleAdd"
+                   v-has-permi="['course:checkinActivity:add']">活动配置</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="list" border style="width: 100%">
+      <el-table-column label="活动ID" align="center" prop="activityId" min-width="80" />
+      <el-table-column label="活动名称" align="center" prop="activityName" min-width="150" show-overflow-tooltip />
+      <el-table-column label="活动时间" align="center" min-width="200">
+        <template slot-scope="scope">
+          <span>{{ scope.row.startTime }} 至 {{ scope.row.endTime }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="需要打卡天数" align="center" prop="checkinDays" min-width="100" />
+      <el-table-column label="参与公司" align="center" prop="companyNames" min-width="150" show-overflow-tooltip />
+      <el-table-column label="参与项目" align="center" prop="projectNames" min-width="150" show-overflow-tooltip />
+      <el-table-column label="活动状态" align="center" prop="status" min-width="100">
+        <template slot-scope="scope">
+          <el-tag v-if="scope.row.status === 0" type="info">未开始</el-tag>
+          <el-tag v-else-if="scope.row.status === 1" type="success">进行中</el-tag>
+          <el-tag v-else-if="scope.row.status === 2" type="danger">已结束</el-tag>
+          <el-tag v-else-if="scope.row.status === 3" type="warning">已停用</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="创建时间" align="center" prop="createTime" min-width="160" />
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="150" fixed="right">
+        <template slot-scope="scope">
+          <el-button size="mini"
+                     type="text"
+                     icon="el-icon-edit"
+                     @click="handleUpdate(scope.row)"
+                     v-has-permi="['course:checkinActivity:edit']">修改</el-button>
+          <el-button size="mini"
+                     type="text"
+                     icon="el-icon-delete"
+                     @click="handleDelete(scope.row)"
+                     v-has-permi="['course:checkinActivity:remove']">删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改活动配置对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
+      <el-form :model="form" ref="form" :rules="rules" label-width="120px">
+        <el-form-item label="活动名称" prop="activityName">
+          <el-input v-model="form.activityName" placeholder="请输入活动名称" clearable size="small" />
+        </el-form-item>
+
+        <el-form-item label="活动时间" prop="timeRange">
+          <el-date-picker
+            v-model="form.timeRange"
+            type="datetimerange"
+            range-separator="至"
+            start-placeholder="开始时间"
+            end-placeholder="结束时间"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            size="small"
+            style="width: 100%">
+          </el-date-picker>
+        </el-form-item>
+
+        <el-form-item label="参与公司" prop="companyIds">
+          <el-select filterable multiple v-model="form.companyIds" placeholder="请选择参与公司" size="small" style="width: 100%">
+            <el-option
+              v-for="item in companys"
+              :key="item.companyId"
+              :label="item.companyName"
+              :value="item.companyId"
+            />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="参与项目" prop="projectIds">
+          <el-select filterable multiple v-model="form.projectIds" placeholder="请选择参与项目" size="small" style="width: 100%">
+            <el-option
+              v-for="item in projects"
+              :key="item.dictValue"
+              :label="item.dictLabel"
+              :value="item.dictValue"
+            />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="通知模板" prop="notifyTemplate">
+          <el-input
+            v-model="form.notifyTemplate"
+            type="textarea"
+            :rows="3"
+            placeholder="请输入通知模板"
+            size="small" />
+        </el-form-item>
+
+        <el-form-item label="活动状态" prop="status">
+          <el-select v-model="form.status" placeholder="请选择活动状态" size="small" style="width: 200px">
+            <el-option label="未开始" :value="0" />
+            <el-option label="进行中" :value="1" />
+            <el-option label="已结束" :value="2" />
+            <el-option label="已停用" :value="3" />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="奖品类型" prop="prizeType">
+          <el-select v-model="form.prizeType" placeholder="请选择奖品类型" size="small" style="width: 200px">
+            <el-option :label="'红包'" :value="1" />
+            <el-option :label="'积分商品'" :value="2" />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item v-if="form.prizeType === 1" label="红包金额" prop="redpacketAmount"
+          :rules="{ required: true, message: '红包金额不能为空', trigger: 'blur' }">
+          <el-input-number v-model="form.redpacketAmount" :min="0.01" :precision="2" :step="0.1" size="small" style="width: 200px" />
+          <span style="margin-left: 10px; color: #999;">元</span>
+        </el-form-item>
+
+        <el-form-item v-if="form.prizeType === 2" label="积分商品" prop="prizeGoodsId"
+          :rules="{ required: true, message: '积分商品不能为空', trigger: 'change' }">
+          <el-select filterable v-model="form.prizeGoodsId" placeholder="请选择积分商品" clearable size="small" style="width: 100%" @change="handlePrizeGoodsChange">
+            <el-option
+              v-for="item in integralGoodsList"
+              :key="item.goodsId"
+              :label="item.goodsName"
+              :value="item.goodsId"
+            />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item v-if="form.prizeType === 2 && form.prizeGoodsName" label="已选商品">
+          <el-tag type="success">{{ form.prizeGoodsName }}</el-tag>
+        </el-form-item>
+
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注" size="small" />
+        </el-form-item>
+      </el-form>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="cancel">取 消</el-button>
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { getCompanyList } from "@/api/company/company";
+import request from '@/utils/request'
+
+export default {
+  name: "CourseCheckIn",
+  data() {
+    return {
+      loading: true,
+      showSearch: true,
+      total: 0,
+      list: [],
+      companys: [],
+      projects: [],
+      integralGoodsList: [],
+      open: false,
+      title: "",
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        activityName: null,
+        status: null
+      },
+      form: {
+        activityId: null,
+        activityName: null,
+        timeRange: [],
+        startTime: null,
+        endTime: null,
+        companyIds: [],
+        projectIds: [],
+        notifyTemplate: null,
+        status: 0,
+        prizeType: 1,
+        redpacketAmount: null,
+        prizeGoodsId: null,
+        prizeGoodsName: null,
+        prizeList: [],
+        remark: null
+      },
+      rules: {
+        activityName: [
+          { required: true, message: "活动名称不能为空", trigger: "blur" }
+        ],
+        timeRange: [
+          { required: true, message: "活动时间不能为空", trigger: "change" }
+        ],
+        companyIds: [
+          { required: true, message: "参与公司不能为空", trigger: "change" }
+        ],
+        projectIds: [
+          { required: true, message: "参与项目不能为空", trigger: "change" }
+        ],
+
+      }
+    };
+  },
+  created() {
+    this.getCompanyList();
+    this.getProjectList();
+    this.getIntegralGoodsList();
+    this.getList();
+  },
+  methods: {
+    getList() {
+      this.loading = true;
+      request({
+        url: '/course/checkinActivity/list',
+        method: 'get',
+        params: this.queryParams
+      }).then(response => {
+        this.list = response.rows || [];
+        this.total = response.total || 0;
+        this.loading = false;
+      }).catch(() => {
+        this.loading = false;
+      });
+    },
+    getCompanyList() {
+      getCompanyList().then(response => {
+        this.companys = response.data || [];
+      });
+    },
+    getProjectList() {
+      this.getDicts("sys_course_project").then(response => {
+        this.projects = response.data || [];
+      });
+    },
+    getIntegralGoodsList() {
+      request({
+        url: '/his/integralGoods/list',
+        method: 'get',
+        params: { pageNum: 1, pageSize: 1000 }
+      }).then(response => {
+        this.integralGoodsList = response.rows || [];
+      });
+    },
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.queryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        activityName: null,
+        status: null
+      };
+      this.handleQuery();
+    },
+    reset() {
+      this.form = {
+        activityId: null,
+        activityName: null,
+        timeRange: [],
+        startTime: null,
+        endTime: null,
+        companyIds: [],
+        projectIds: [],
+        notifyTemplate: null,
+        status: 0,
+        prizeType: 1,
+        redpacketAmount: null,
+        prizeGoodsId: null,
+        prizeGoodsName: null,
+        prizeList: [],
+        remark: null
+      };
+    },
+    handlePrizeGoodsChange(goodsId) {
+      if (goodsId) {
+        const goods = this.integralGoodsList.find(item => item.goodsId === goodsId);
+        this.form.prizeGoodsName = goods ? goods.goodsName : null;
+      } else {
+        this.form.prizeGoodsName = null;
+      }
+    },
+    handlePrizeTypeChange(prizeType) {
+      // 切换类型时清空相关字段
+      this.form.redpacketAmount = null;
+      this.form.prizeGoodsId = null;
+      this.form.prizeGoodsName = null;
+    },
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加打卡活动";
+      // 等待对话框打开后再重置表单验证
+      this.$nextTick(() => {
+        this.resetForm("form");
+      });
+    },
+    handleUpdate(row) {
+      const activityId = row.activityId;
+      request({
+        url: '/course/checkinActivity/' + activityId,
+        method: 'get'
+      }).then(response => {
+        // 先重置表单
+        this.reset();
+        // 使用 Object.assign 合并数据,保持响应式
+        Object.assign(this.form, response.data);
+        this.$set(this.form, 'timeRange', [this.form.startTime, this.form.endTime]);
+        // 将逗号分隔的字符串转为数组
+        if (this.form.companyIds) {
+          this.$set(this.form, 'companyIds', this.form.companyIds.split(',').map(id => parseInt(id)));
+        } else {
+          this.$set(this.form, 'companyIds', []);
+        }
+        if (this.form.projectIds) {
+          this.$set(this.form, 'projectIds', this.form.projectIds.split(','));
+        } else {
+          this.$set(this.form, 'projectIds', []);
+        }
+        // 处理奖品数据 - 从prizeList解析单个奖品
+        if (this.form.prizeList && this.form.prizeList.length > 0) {
+          const prize = this.form.prizeList[0];
+          this.$set(this.form, 'prizeType', Number(prize.prizeType));
+          if (this.form.prizeType === 1) {
+            this.$set(this.form, 'redpacketAmount', prize.redpacketAmount);
+          } else if (this.form.prizeType === 2) {
+            this.$set(this.form, 'prizeGoodsId', prize.goodsId);
+            this.handlePrizeGoodsChange(prize.goodsId);
+          }
+        }
+        this.open = true;
+        this.title = "修改打卡活动";
+        // 等待对话框打开后再清除验证状态
+        this.$nextTick(() => {
+          if (this.$refs.form) {
+            this.$refs.form.clearValidate();
+          }
+        });
+      });
+    },
+    handleDelete(row) {
+      const activityIds = row.activityId;
+      this.$confirm('是否确认删除该打卡活动?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        return request({
+          url: '/course/checkinActivity/' + activityIds,
+          method: 'delete'
+        });
+      }).then(() => {
+        this.getList();
+        this.msgSuccess("删除成功");
+      }).catch(() => {});
+    },
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          const prizeList = [];
+          if (this.form.prizeType === 1) {
+            prizeList.push({
+              prizeType: 1,
+              redpacketAmount: this.form.redpacketAmount
+            });
+          } else if (this.form.prizeType === 2) {
+            prizeList.push({
+              prizeType: 2,
+              goodsId: this.form.prizeGoodsId
+            });
+          }
+
+          const submitData = {
+            activityId: this.form.activityId,
+            activityName: this.form.activityName,
+            startTime: this.form.timeRange[0],
+            endTime: this.form.timeRange[1],
+            companyIds: this.form.companyIds.join(','),
+            projectIds: this.form.projectIds.join(','),
+            notifyTemplate: this.form.notifyTemplate,
+            status: this.form.status,
+            prizeList: prizeList,
+            remark: this.form.remark
+          };
+
+          if (this.form.activityId != null) {
+            request({
+              url: '/course/checkinActivity/edit',
+              method: 'put',
+              data: submitData
+            }).then(() => {
+              this.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            request({
+              url: '/course/checkinActivity/add',
+              method: 'post',
+              data: submitData
+            }).then(() => {
+              this.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    }
+  }
+};
+</script>
+
+<style scoped>
+.prize-item {
+  margin-bottom: 10px;
+}
+.clearfix:before,
+.clearfix:after {
+  display: table;
+  content: "";
+}
+.clearfix:after {
+  clear: both;
+}
+</style>

+ 79 - 249
src/views/his/statistics/courseAppReport.vue

@@ -1,10 +1,6 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="85px">
-      <el-radio-group v-model="queryParams.dimension" @change="handleDimensionChange">
-        <el-radio-button label="company">销售公司</el-radio-button>
-        <el-radio-button label="camp">训练营</el-radio-button>
-      </el-radio-group>
       <el-form-item label="公司名" prop="companyId">
         <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名"
                    clearable size="small">
@@ -16,28 +12,12 @@
           />
         </el-select>
       </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">
-          <el-option
-            v-for="item in camps"
-            :key="item.dictValue"
-            :label="item.dictLabel"
-            :value="item.dictValue"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item>
-        <treeselect style="width: 220px" v-model="queryParams.periodId" :options="deptOptions"
-                    clearable :show-count="true" placeholder="请选择归属营期" value-consists-of="LEAF_PRIORITY"
-                    :normalizer="normalizer" v-if="queryParams.dimension === 'camp'" />
+      <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="xdChange"></el-date-picker>
       </el-form-item>
       <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="xdChange"></el-date-picker>
-        </el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
       </el-form-item>
@@ -57,31 +37,27 @@
     </el-row>
     <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="accessCount"/>
-      <el-table-column label="待看课人数" align="center" prop="pendingCount"/>
-      <el-table-column label="看课中人数" align="center" prop="watchingCount"/>
-      <el-table-column label="看课率" align="center" prop="watchRate"/>
-      <el-table-column label="完课人数" align="center" prop="finishedCount"/>
-      <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="appUserCount"/>
+      <el-table-column label="APP活跃人数" align="center" prop="activeAppUserCount"/>
+      <el-table-column label="私域课待看课人次" align="center" prop="pendingCount"/>
+      <el-table-column label="私域课看课中人次" align="center" prop="watchingCount"/>
+      <el-table-column label="私域课看课率" align="center" prop="watchRate"/>
+      <el-table-column label="私域课完课人次" align="center" prop="finishedCount"/>
+      <el-table-column label="答题人次" align="center" prop="answerUserCount"/>
+      <el-table-column label="红包领取人次" align="center" prop="packetUserCount"/>
       <el-table-column label="红包金额" align="center" prop="packetAmount"/>
     </el-table>
     <div class="total-summary">
       <span class="total-title">总计:</span>
-      <span class="total-item">进线人数: {{ calculatedTotalData.accessCount }}</span>
-      <span class="total-item">待看课人数: {{ calculatedTotalData.pendingCount }}</span>
-      <span class="total-item">看课中人数: {{ calculatedTotalData.watchingCount }}</span>
-      <span class="total-item">看课率: {{ calculatedTotalData.watchRate}}</span>
-      <span class="total-item">完课人数: {{ calculatedTotalData.finishedCount }}</span>
-      <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.packetAmount }}</span>
+      <span class="total-item">新增注册人数:{{ calculatedTotalData.appUserCount }}</span>
+      <span class="total-item">APP 活跃人数:{{ calculatedTotalData.activeAppUserCount }}</span>
+      <span class="total-item">私域课待看课人次:{{ calculatedTotalData.pendingCount }}</span>
+      <span class="total-item">私域课看课中人次:{{ calculatedTotalData.watchingCount }}</span>
+      <span class="total-item">私域课看课率:{{ calculatedTotalData.watchRate}}</span>
+      <span class="total-item">私域课完课人次:{{ calculatedTotalData.finishedCount }}</span>
+      <span class="total-item">答题人次:{{ calculatedTotalData.answerUserCount }}</span>
+      <span class="total-item">红包领取人次:{{ calculatedTotalData.packetUserCount}}</span>
+      <span class="total-item">红包金额:{{ calculatedTotalData.packetAmount }}</span>
     </div>
     <pagination
       v-show="total>0"
@@ -94,21 +70,15 @@
 </template>
 
 <script>
-import {
-  listPackageOrder, getPackageOrder, delPackageOrder, addPackageOrder, updatePackageOrder, exportPackageOrder,
-  PackageOrderReport, orderReport, courseReport, exportOrderReport, exportCourseReport
-} from "@/api/his/packageOrder";
-import {getCompanyList} from "@/api/company/company";
-import packageOrderDetails from '../../components/his/packageOrderDetails.vue';
-import {treeselect} from "@/api/company/companyDept";
+import { getCompanyList } from "@/api/company/company";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
-import {getTask} from "@/api/common";
-import {getCampList, getPeriodList} from "@/api/course/userWatchCourseStatistics";
+import { getTask } from "@/api/common";
+import request from '@/utils/request'
 
 export default {
-  name: "PackageOrder",
-  components: {packageOrderDetails, Treeselect},
+  name: "AppCourseReport",
+  components: { Treeselect },
   data() {
     return {
       normalizer: function(node) {
@@ -118,264 +88,134 @@ export default {
           children: node.children
         }
       },
-      // 添加用于存储计算总和的数据
       calculatedTotalData: {
-        accessCount: 0,
+        appUserCount: 0,
+        activeAppUserCount: 0,
         pendingCount: 0,
         watchingCount: 0,
         watchRate: '0%',
         finishedCount: 0,
-        interruptedCount: 0,
-        finishRate: '0%',
         answerUserCount: 0,
         packetUserCount: 0,
         packetAmount: 0
       },
-      showTrainingCampColumn: false,
-      showPeriodColumn: false,
-      totalData: {},
       companys: [],
-      camps: [],
       deptOptions: [],
       companyId: undefined,
-      campId: undefined,
-      deptId: undefined,
       show: {
         open: false,
       },
-      sourceOptions: [],
       actName: "2",
-      // 遮罩层
       loading: true,
       startTime: null,
-      // 导出遮罩层
       exportLoading: false,
-      // 选中数组
       ids: [],
       createTime: null,
-      // 非单个禁用
       single: true,
-      // 非多个禁用
       multiple: true,
-      // 显示搜索条件
       showSearch: true,
       endTime: null,
-      // 总条数
       total: 0,
-      // 套餐订单表格数据
       packageOrderList: [],
-      // 弹出层标题
       title: "",
-      // 是否显示弹出层
       open: false,
-      // 是否支付字典
       isPayOptions: [],
-      // 状态字典
       statusOptions: [],
       refundStatusOptions: [],
       packageSubTypeOptions: [],
       payTypeOptions: [],
       deliveryPayStatusOptions: [],
       deliveryStatusOptions: [],
-      // 查询参数
       queryParams: {
         pageNum: 1,
         pageSize: 10,
-        orderSn: null,
-        userId: null,
-        doctorId: null,
-        doctorName: null,
-        phone: null,
-        phoneMk: null,
-        packageId: null,
-        packageName: null,
-        payMoney: null,
-        isPay: null,
-        days: null,
-        status: null,
-        startTime: null,
-        startDate: null,
-        endDate:null,
-        finishTime: null,
+        companyId: null,
         sTime: null,
-        eTime: null,
-        stTime: null,
-        endTime: null,
-        endStartTime: null,
-        endEndTime: null,
-        companyUserName: null,
-        companyName: null,
-        deptId: null,
-        source: null,
-        trainingCampId: null,
-        periodId: null,
-        dimension: 'camp',
-        watchType: 1
+        eTime: null
       },
-      // 表单参数
       form: {},
-      // 表单校验
       rules: {}
     };
   },
   created() {
-    // 设置默认时间为前一天
-    const yesterday = new Date();
-    yesterday.setDate(yesterday.getDate() - 1);
+    // 默认查询当天
+    const today = new Date();
     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) {
-        this.companyId = this.camps[0].dictValue;
-      }
-      this.camps.push({companyId: "-1", companyName: "无"})
-    });
+    const todayStr = formatDate(today);
+    this.createTime = [todayStr, todayStr];
+    this.queryParams.sTime = todayStr;
+    this.queryParams.eTime = todayStr;
+
     getCompanyList().then(response => {
       this.companys = response.data;
       if (this.companys != null && this.companys.length > 0) {
         this.companyId = this.companys[0].companyId;
       }
       this.companys.push({companyId: "-1", companyName: "无"})
-    });
-    this.getList();
-    this.getDicts("sys_company_or").then(response => {
-      this.isPayOptions = response.data;
-    });
-    this.getDicts("sys_package_order_status").then(response => {
-      this.statusOptions = response.data;
-    });
-    this.getDicts("sys_refund_status").then(response => {
-      this.refundStatusOptions = response.data;
-    });
-    this.getDicts("sys_order_source").then(response => {
-      this.sourceOptions = response.data;
-    });
-    this.getDicts("sys_package_pay_type").then(response => {
-      this.payTypeOptions = response.data;
-    });
-    this.getDicts("sys_store_delivery_pay_status").then(response => {
-      this.deliveryPayStatusOptions = response.data;
-    });
-    this.getDicts("sys_store_order_delivery_status").then(response => {
-      this.deliveryStatusOptions = response.data;
-    });
-    this.getDicts("sys_package_sub_type").then(response => {
-      this.packageSubTypeOptions = response.data;
+      // 获取公司列表后自动查询
+      this.getList();
     });
   },
   methods: {
-    handleDimensionChange: function(val) {
-      console.log('维度切换到:', val);
-      // 重置分页
-      this.queryParams.pageNum = 1;
-      // 重新获取数据
-      this.getList();
-    },
-    /** 查询套餐订单列表 */
     getList() {
       this.loading = true;
-      courseReport(this.queryParams).then(response => {
-        this.packageOrderList = response.rows;
-        this.total = response.total;
-        // 判断是否需要显示训练营和营期列
-        this.showTrainingCampColumn = this.packageOrderList &&
-          this.packageOrderList.some(item => item.trainingCampName);
-        this.showPeriodColumn = this.packageOrderList &&
-          this.packageOrderList.some(item => item.periodName);
+      return request({
+        url: '/company/statistics/appCourseReport',
+        method: 'get',
+        params: this.queryParams
+      }).then(response => {
+        this.packageOrderList = response.rows || response.data;
+        this.total = response.total || 0;
         this.calculateTotals();
         this.loading = false;
-        // 延迟强制更新以确保DOM完全渲染
         setTimeout(() => {
           this.$forceUpdate();
         }, 100);
+      }).catch(() => {
+        this.loading = false;
       });
     },
     calculateTotals() {
-      // 重置总计数据
       this.calculatedTotalData = {
-        accessCount: 0,
+        appUserCount: 0,
+        activeAppUserCount: 0,
         pendingCount: 0,
         watchingCount: 0,
         watchRate: 0,
         finishedCount: 0,
-        interruptedCount: 0,
-        finishRate: 0,
         answerUserCount: 0,
         packetUserCount: 0,
         packetAmount: 0
       };
 
-      // 遍历当前页数据计算总和
       this.packageOrderList.forEach(item => {
-        this.calculatedTotalData.accessCount += Number(item.accessCount) || 0;
+        this.calculatedTotalData.appUserCount += Number(item.appUserCount) || 0;
+        this.calculatedTotalData.activeAppUserCount += Number(item.activeAppUserCount) || 0;
         this.calculatedTotalData.pendingCount += Number(item.pendingCount) || 0;
         this.calculatedTotalData.watchingCount += Number(item.watchingCount) || 0;
         this.calculatedTotalData.finishedCount += Number(item.finishedCount) || 0;
-        this.calculatedTotalData.interruptedCount += Number(item.interruptedCount) || 0;
         this.calculatedTotalData.answerUserCount += Number(item.answerUserCount) || 0;
         this.calculatedTotalData.packetUserCount += Number(item.packetUserCount) || 0;
         this.calculatedTotalData.packetAmount += Number(item.packetAmount) || 0;
       });
 
-      if (this.calculatedTotalData.accessCount > 0) {
-        // 看课率 = 看课中人数 / 进线人数
-        this.calculatedTotalData.watchRate = ((this.calculatedTotalData.watchingCount / this.calculatedTotalData.accessCount) * 100).toFixed(2) + '%';
-        // 完课率 = 完课人数 / 进线人数
-        this.calculatedTotalData.finishRate = ((this.calculatedTotalData.finishedCount / this.calculatedTotalData.accessCount) * 100).toFixed(2) + '%';
+      if (this.calculatedTotalData.pendingCount > 0) {
+        this.calculatedTotalData.watchRate = ((this.calculatedTotalData.watchingCount / this.calculatedTotalData.pendingCount) * 100).toFixed(2) + '%';
       } else {
         this.calculatedTotalData.watchRate = '0.00%';
-        this.calculatedTotalData.finishRate = '0.00%';
       }
 
-      // 金额格式化
       this.calculatedTotalData.packetAmount = this.calculatedTotalData.packetAmount.toFixed(2);
     },
-    /** 训练营变更处理 */
-    handleCampChange(val) {
-      this.queryParams.trainingCampId = val;
-      this.queryParams.periodId = null; // 清空已选择的营期
-
-      if (val) {
-        // 获取对应的营期数据
-        this.getPeriodByCamp(val);
-      } else {
-        // 如果清空训练营,也清空营期选项
-        this.deptOptions = [];
-      }
-      // 移除了自动搜索的逻辑,只在点击搜索按钮时触发
-    },
-
-    /** 根据训练营获取营期数据 */
-    getPeriodByCamp(campId) {
-      const param = {campId: campId};
-      getPeriodList(param).then((response) => {
-        console.log('接口返回数据:', response);
-        console.log('营期列表数据:', response.data);
-        this.deptOptions = response.data || [];
-        console.log('deptOptions 已赋值:', this.deptOptions);
-      }).catch(error => {
-        console.error('获取营期数据失败:', error);
-        this.deptOptions = [];
-      });
-    },
-    hasDeptNameField() {
-      return this.packageOrderList &&
-        this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
-    },
-    // 取消按钮
     cancel() {
       this.open = false;
       this.reset();
     },
-    // 表单重置
     reset() {
       this.form = {
         orderId: null,
@@ -394,50 +234,23 @@ export default {
       };
       this.resetForm("form");
     },
-    /** 搜索按钮操作 */
     handleQuery() {
       this.getList();
     },
-    /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm");
-      // 清空所有时间相关变量
       this.createTime = null;
       this.startTime = null;
       this.endTime = null;
 
-      // 重置所有查询参数
       this.queryParams = {
-        pageNum: null,
-        pageSize: null,
-        orderSn: null,
-        userId: null,
-        doctorId: null,
-        doctorName: null,
-        phone: null,
-        phoneMk: null,
-        packageId: null,
-        packageName: null,
-        payMoney: null,
-        isPay: null,
-        days: null,
-        status: null,
-        startTime: null,
-        finishTime: null,
-        sTime: null,
-        eTime: null,
-        stTime: null,
-        endTime: null,
-        endStartTime: null,
-        endEndTime: null,
-        companyUserName: null,
-        companyName: null,
+        pageNum: 1,
+        pageSize: 10,
         companyId: null,
-        deptId: null,
-        source: null,
+        sTime: null,
+        eTime: null
       };
 
-      // 立即执行查询
       this.handleQuery();
     },
     xdChange() {
@@ -450,18 +263,36 @@ export default {
       }
     },
     handleExport() {
-      const queryParams = this.queryParams;
-      this.$confirm('是否确认导出会员看课报表', "警告", {
+      const now = new Date();
+      const year = now.getFullYear();
+      const month = String(now.getMonth() + 1).padStart(2, '0');
+      const firstDay = `${year}-${month}-01`;
+      const lastDay = new Date(year, now.getMonth() + 1, 0);
+      const lastDayStr = `${year}-${month}-${String(lastDay.getDate()).padStart(2, '0')}`;
+
+      const { watchType, ...paramsWithoutWatchType } = this.queryParams;
+      const exportParams = {
+        ...paramsWithoutWatchType,
+        sTime: this.queryParams.sTime || firstDay,
+        eTime: this.queryParams.eTime || lastDayStr
+      };
+
+      this.$confirm('是否确认导出 APP 看课报表', "警告", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"
       }).then(() => {
         this.exportLoading = true;
-        return exportCourseReport(queryParams);
+        return request({
+          url: '/company/statistics/exportAppCourseReport',
+          method: 'get',
+          params: exportParams
+        });
       }).then(response => {
         this.download(response.msg);
         this.exportLoading = false;
       }).catch(() => {
+        this.exportLoading = false;
       });
     },
     endChange() {
@@ -521,7 +352,6 @@ export default {
   vertical-align: middle;
 }
 
-/* 响应式处理 */
 @media (max-width: 768px) {
   .total-summary {
     flex-direction: column;

+ 31 - 1
src/views/index.vue

@@ -66,6 +66,24 @@
                   <span class="card-panel-num companynumber">{{ padTotalNum }}</span>
                 </template>
               </div>
+              <div class="companycard cardafter">
+                <div class="card-title1" style="white-space: nowrap;">
+                  <img src="../assets/images/member.png" alt="" class="icon-img">
+                  APP总会员
+                </div>
+                <div class="card-value highlight1">
+                  <count-to :start-val="0" :end-val="appTotalUser" :duration="3600" class="card-panel-num companynumber" />
+                </div>
+              </div>
+              <div class="companycard cardafter">
+                <div class="card-title1" style="white-space: nowrap;">
+                  <img src="../assets/images/member.png" alt="" class="icon-img">
+                  APP新增用户
+                </div>
+                <div class="card-value highlight1">
+                  <count-to :start-val="0" :end-val="appNewUser" :duration="3600" class="card-panel-num companynumber" />
+                </div>
+              </div>
             </div>
           </div>
         </el-col>
@@ -578,6 +596,7 @@ import {
 import dayjs from 'dayjs';
 import { listDept } from '@/api/system/dept'
 import { listCompany } from '@/api/his/company'
+import { getAppUserCount } from '@/api/his/user'
 
 
 const viewCharOption = {
@@ -1051,7 +1070,11 @@ export default {
       // 商品总数
       goodsTotalNum: 0,
       // 今日商品总数
-      todayGoodsNum: 0
+      todayGoodsNum: 0,
+      // APP 总会员数
+      appTotalUser: 0,
+      // APP 新增用户数
+      appNewUser: 0
     }
   },
   mounted() {
@@ -1363,6 +1386,13 @@ export default {
       this.handleThisMonthRecvCount();
       this.handleThisMonthOrderCount();
 
+      // 获取 APP 总会员数
+      getAppUserCount().then(res => {
+        if (res.code === 200) {
+          this.appTotalUser = res.data.appTotalUser ?? 0;
+          this.appNewUser = res.data.appNewUser ?? 0;
+        }
+      });
     },
     /**
      * 将数字添加千位分隔符