wangxy пре 1 недеља
родитељ
комит
95c375fe59

+ 8 - 0
src/api/his/packageOrder.js

@@ -115,3 +115,11 @@ export function courseReport(query) {
     params: query
   })
 }
+
+export function userReport(query) {
+  return request({
+    url: '/company/statistics/userReport',
+    method: 'get',
+    params: query
+  })
+}

+ 140 - 52
src/views/his/statistics/courseReport.vue

@@ -56,7 +56,7 @@
     <!--      <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="tableDataWithTotal">
+    <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" />
@@ -71,6 +71,26 @@
       <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>
+    </div>
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
   </div>
 </template>
 
@@ -109,6 +129,19 @@ export default {
           children: node.children
         }
       },
+      // 添加用于存储计算总和的数据
+      calculatedTotalData: {
+        accessCount: 0,
+        pendingCount: 0,
+        watchingCount: 0,
+        watchRate: '0%',
+        finishedCount: 0,
+        interruptedCount: 0,
+        finishRate: '0%',
+        answerUserCount: 0,
+        packetUserCount: 0,
+        packetAmount: 0
+      },
       showTrainingCampColumn:false,
       showPeriodColumn:false,
       totalData: {},
@@ -157,6 +190,8 @@ export default {
       deliveryStatusOptions: [],
       // 查询参数
       queryParams: {
+        pageNum: 1,
+        pageSize: 10,
         orderSn: null,
         userId: null,
         doctorId: null,
@@ -191,26 +226,6 @@ export default {
     };
   },
   computed: {
-    tableDataWithTotal() {
-      if (this.packageOrderList && this.packageOrderList.length > 0) {
-        // 总是添加一个总计行
-        const totalRow = {
-          companyName: '总计',
-          accessCount: this.totalData?.accessCount || 0,
-          pendingCount: this.totalData?.pendingCount || 0,
-          watchingCount: this.totalData?.watchingCount || 0,
-          watchRate: this.totalData?.watchRate || 0,
-          finishedCount: this.totalData?.finishedCount || 0,
-          interruptedCount: this.totalData?.interruptedCount || 0,
-          finishRate: this.totalData?.finishRate || 0,
-          answerUserCount: this.totalData?.answerUserCount || 0,
-          packetUserCount: this.totalData?.packetUserCount || 0,
-          packetAmount: this.totalData?.packetAmount || 0
-        };
-        return [...this.packageOrderList, totalRow];
-      }
-      return this.packageOrderList;
-    }
   },
   created() {
     getCampList().then(response => {
@@ -228,14 +243,6 @@ export default {
       this.companys.push({companyId: "-1", companyName: "无"})
     });
     this.getList();
-    this.totalData = {
-      inquiryOrderCount: 0,
-      inquiryOrderAmount: 0,
-      integralOrderCount: 0,
-      integralOrderAmount: 0,
-      packageOrderCount: 0,
-      packageOrderAmount: 0
-    };
     this.getDicts("sys_company_or").then(response => {
       this.isPayOptions = response.data;
     });
@@ -266,13 +273,14 @@ export default {
     getList() {
       this.loading = true;
       courseReport(this.queryParams).then(response => {
-        this.packageOrderList = response.data.data;
-        this.totalData = response.data.total || {};
+        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);
+        this.calculateTotals();
         this.loading = false;
         // 延迟强制更新以确保DOM完全渲染
         setTimeout(() => {
@@ -280,6 +288,44 @@ export default {
         }, 100);
       });
     },
+    calculateTotals() {
+      // 重置总计数据
+      this.calculatedTotalData = {
+        accessCount: 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.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;
+
+        // 看课率和完成率直接累加(求总和)
+        this.calculatedTotalData.watchRate += Number(item.watchRate) || 0;
+        this.calculatedTotalData.finishRate += Number(item.finishRate) || 0;
+      });
+
+      // 格式化率值为百分比形式
+      this.calculatedTotalData.watchRate = this.calculatedTotalData.watchRate.toFixed(2) + '%';
+      this.calculatedTotalData.finishRate = this.calculatedTotalData.finishRate.toFixed(2) + '%';
+
+      // 金额格式化
+      this.calculatedTotalData.packetAmount = this.calculatedTotalData.packetAmount.toFixed(2);
+    },
     /** 训练营变更处理 */
     handleCampChange(val) {
       this.queryParams.trainingCampId = val;
@@ -314,27 +360,6 @@ export default {
       return this.packageOrderList &&
         this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
     },
-    getSummaries(param) {
-      const { columns } = param;
-      const sums = [];
-      columns.forEach((column, index) => {
-        if (index === 0) {
-          sums[index] = '总计';
-          return;
-        }
-        // 增强数据检查
-        if (this.totalData && Object.keys(this.totalData).length > 0 &&
-          this.totalData[column.property] !== undefined) {
-          sums[index] = this.totalData[column.property];
-          if (column.property.includes('Amount') && typeof sums[index] === 'number') {
-            sums[index] = parseFloat(sums[index]).toFixed(2);
-          }
-        } else {
-          sums[index] = column.property.includes('Amount') ? '0.00' : 0;
-        }
-      });
-      return sums;
-    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -434,3 +459,66 @@ export default {
   }
 };
 </script>
+
+<style scoped>
+.total-summary {
+  margin-top: 15px;
+  padding: 15px 20px;
+  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7f4 100%);
+  border: 1px solid #dcdfe6;
+  border-radius: 4px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+}
+
+.total-title {
+  font-weight: bold;
+  font-size: 16px;
+  color: #303133;
+  margin-right: 20px;
+  flex-shrink: 0;
+}
+
+.total-item {
+  margin-right: 25px;
+  padding: 5px 10px;
+  background: white;
+  border-radius: 3px;
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
+  display: inline-block;
+  margin-bottom: 5px;
+  font-size: 13px;
+  color: #606266;
+}
+
+.total-item::before {
+  content: "";
+  display: inline-block;
+  width: 3px;
+  height: 3px;
+  background: #409eff;
+  border-radius: 50%;
+  margin-right: 5px;
+  vertical-align: middle;
+}
+
+/* 响应式处理 */
+@media (max-width: 768px) {
+  .total-summary {
+    flex-direction: column;
+    align-items: flex-start;
+  }
+
+  .total-title {
+    margin-bottom: 10px;
+  }
+
+  .total-item {
+    margin-right: 10px;
+    margin-bottom: 8px;
+  }
+}
+
+</style>

+ 120 - 49
src/views/his/statistics/orderReport.vue

@@ -45,7 +45,7 @@
     <!--      <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="tableDataWithTotal">
+    <el-table height="500" v-loading="loading" border :data="packageOrderList">
       <el-table-column label="销售公司" align="center" prop="companyName" v-if="hasCompanyNameField()" width="120px"/>
       <el-table-column label="销售部门" align="center" prop="deptName" v-if="hasDeptNameField()"/>
       <el-table-column label="问诊订单数" align="center" prop="inquiryOrderCount"/>
@@ -56,6 +56,23 @@
       <el-table-column label="套餐包定金金额" align="center" prop="packageOrderAmount"/>
 <!--      <el-table-column label="总计" align="center" prop="totals"/>-->
     </el-table>
+    <div class="total-summary">
+      <span class="total-title">总计:</span>
+      <span class="total-item">问诊订单数: {{ calculatedTotalData.inquiryOrderCount }}</span>
+      <span class="total-item">问诊订单金额: {{ calculatedTotalData.inquiryOrderAmount }}</span>
+      <span class="total-item">积分商品订单数: {{ calculatedTotalData.integralOrderCount }}</span>
+      <span class="total-item">积分商品订单金额: {{ calculatedTotalData.integralOrderAmount}}</span>
+      <span class="total-item">套餐包订单数: {{ calculatedTotalData.packageOrderCount}}</span>
+      <span class="total-item">套餐包定金金额: {{ calculatedTotalData.packageOrderAmount }}</span>
+    </div>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
   </div>
 </template>
 
@@ -86,6 +103,14 @@ export default {
   components: {packageOrderDetails, Treeselect},
   data() {
     return {
+      calculatedTotalData: {
+        inquiryOrderCount: 0,
+        inquiryOrderAmount: 0,
+        integralOrderCount: 0,
+        integralOrderAmount: 0,
+        packageOrderCount: 0,
+        packageOrderAmount: 0
+      },
       totalData: {},
       companys: [],
       deptOptions: [],
@@ -130,6 +155,8 @@ export default {
       deliveryStatusOptions: [],
       // 查询参数
       queryParams: {
+        pageNum: 1,
+        pageSize: 10,
         orderSn: null,
         userId: null,
         doctorId: null,
@@ -162,23 +189,6 @@ export default {
     };
   },
   computed: {
-    tableDataWithTotal() {
-      if (this.packageOrderList && this.packageOrderList.length > 0) {
-        // 总是添加一个总计行
-        const totalRow = {
-          companyName: '总计',
-          deptName: '总计',
-          inquiryOrderCount: this.totalData?.inquiryOrderCount || 0,
-          inquiryOrderAmount: this.totalData?.inquiryOrderAmount || 0,
-          integralOrderCount: this.totalData?.integralOrderCount || 0,
-          integralOrderAmount: this.totalData?.integralOrderAmount || 0,
-          packageOrderCount: this.totalData?.packageOrderCount || 0,
-          packageOrderAmount: this.totalData?.packageOrderAmount || 0
-        };
-        return [...this.packageOrderList, totalRow];
-      }
-      return this.packageOrderList;
-    }
   },
   created() {
     getCompanyList().then(response => {
@@ -190,14 +200,6 @@ export default {
       this.companys.push({companyId: "-1", companyName: "无"})
     });
     this.getList();
-    this.totalData = {
-      inquiryOrderCount: 0,
-      inquiryOrderAmount: 0,
-      integralOrderCount: 0,
-      integralOrderAmount: 0,
-      packageOrderCount: 0,
-      packageOrderAmount: 0
-    };
     this.getDicts("sys_company_or").then(response => {
       this.isPayOptions = response.data;
     });
@@ -228,8 +230,9 @@ export default {
     getList() {
       this.loading = true;
       orderReport(this.queryParams).then(response => {
-        this.packageOrderList = response.data.data;
-        this.totalData = response.data.total || {};
+        this.packageOrderList = response.rows ;
+        this.total = response.total;
+        this.calculateTotals();
         this.loading = false;
         // 延迟强制更新以确保DOM完全渲染
         setTimeout(() => {
@@ -237,6 +240,32 @@ export default {
         }, 100);
       });
     },
+    calculateTotals() {
+      // 重置总计数据
+      this.calculatedTotalData = {
+        inquiryOrderCount: 0,
+        inquiryOrderAmount: 0,
+        integralOrderCount: 0,
+        integralOrderAmount: 0,
+        packageOrderCount: 0,
+        packageOrderAmount: 0
+      };
+
+      // 遍历当前页数据计算总和
+      this.packageOrderList.forEach(item => {
+        this.calculatedTotalData.inquiryOrderCount += Number(item.inquiryOrderCount) || 0;
+        this.calculatedTotalData.inquiryOrderAmount += Number(item.inquiryOrderAmount) || 0;
+        this.calculatedTotalData.integralOrderCount += Number(item.integralOrderCount) || 0;
+        this.calculatedTotalData.integralOrderAmount += Number(item.integralOrderAmount) || 0;
+        this.calculatedTotalData.packageOrderCount += Number(item.packageOrderCount) || 0;
+        this.calculatedTotalData.packageOrderAmount += Number(item.packageOrderAmount) || 0;
+      });
+
+      // 金额格式化
+      this.calculatedTotalData.inquiryOrderAmount = this.calculatedTotalData.inquiryOrderAmount.toFixed(2);
+      this.calculatedTotalData.integralOrderAmount = this.calculatedTotalData.integralOrderAmount.toFixed(2);
+      this.calculatedTotalData.packageOrderAmount = this.calculatedTotalData.packageOrderAmount.toFixed(2);
+    },
     hasDeptNameField() {
       return this.packageOrderList &&
         this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
@@ -246,27 +275,6 @@ export default {
       return this.packageOrderList &&
         !this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
     },
-    getSummaries(param) {
-      const { columns } = param;
-      const sums = [];
-      columns.forEach((column, index) => {
-        if (index === 0) {
-          sums[index] = '总计';
-          return;
-        }
-        // 增强数据检查
-        if (this.totalData && Object.keys(this.totalData).length > 0 &&
-          this.totalData[column.property] !== undefined) {
-          sums[index] = this.totalData[column.property];
-          if (column.property.includes('Amount') && typeof sums[index] === 'number') {
-            sums[index] = parseFloat(sums[index]).toFixed(2);
-          }
-        } else {
-          sums[index] = column.property.includes('Amount') ? '0.00' : 0;
-        }
-      });
-      return sums;
-    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -390,3 +398,66 @@ export default {
   }
 };
 </script>
+
+<style scoped>
+.total-summary {
+  margin-top: 15px;
+  padding: 15px 20px;
+  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7f4 100%);
+  border: 1px solid #dcdfe6;
+  border-radius: 4px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+}
+
+.total-title {
+  font-weight: bold;
+  font-size: 16px;
+  color: #303133;
+  margin-right: 20px;
+  flex-shrink: 0;
+}
+
+.total-item {
+  margin-right: 25px;
+  padding: 5px 10px;
+  background: white;
+  border-radius: 3px;
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
+  display: inline-block;
+  margin-bottom: 5px;
+  font-size: 13px;
+  color: #606266;
+}
+
+.total-item::before {
+  content: "";
+  display: inline-block;
+  width: 3px;
+  height: 3px;
+  background: #409eff;
+  border-radius: 50%;
+  margin-right: 5px;
+  vertical-align: middle;
+}
+
+/* 响应式处理 */
+@media (max-width: 768px) {
+  .total-summary {
+    flex-direction: column;
+    align-items: flex-start;
+  }
+
+  .total-title {
+    margin-bottom: 10px;
+  }
+
+  .total-item {
+    margin-right: 10px;
+    margin-bottom: 8px;
+  }
+}
+
+</style>

+ 127 - 18
src/views/his/statistics/packageOrderReport.vue

@@ -45,7 +45,7 @@
     <!--      <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="tableDataWithTotal"
+    <el-table height="500" v-loading="loading" border :data="packageOrderList"
               v-hasPermi="['his:packageOrder:report']">
       <el-table-column label="销售公司" align="center" prop="companyName" v-if="hasCompanyNameField()" width="120px"/>
       <el-table-column label="销售部门" align="center" prop="deptName" v-if="hasDeptNameField()"/>
@@ -55,6 +55,20 @@
       <el-table-column label="确认收货定金金额" align="center" prop="receiptMoney"/>
 <!--      <el-table-column label="总计" align="center" prop="totals"/>-->
     </el-table>
+    <div class="total-summary">
+      <span class="total-title">总计:</span>
+      <span class="total-item">总订单数: {{ calculatedTotalData.orderNum }}</span>
+      <span class="total-item">定金金额: {{ calculatedTotalData.money }}</span>
+      <span class="total-item">确认收货订单数: {{ calculatedTotalData.receiptOrder }}</span>
+      <span class="total-item">确认收货定金金额: {{ calculatedTotalData.receiptMoney}}</span>
+    </div>
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
   </div>
 </template>
 
@@ -79,6 +93,12 @@ export default {
   components: {packageOrderDetails, Treeselect},
   data() {
     return {
+      calculatedTotalData: {
+        orderNum: 0,
+        money: 0,
+        receiptOrder: 0,
+        receiptMoney: 0
+      },
       companys: [],
       deptOptions: [],
       companyId: undefined,
@@ -122,6 +142,8 @@ export default {
       deliveryStatusOptions: [],
       // 查询参数
       queryParams: {
+        pageNum: 1,
+        pageSize: 10,
         orderSn: null,
         userId: null,
         doctorId: null,
@@ -154,21 +176,21 @@ export default {
     };
   },
   computed: {
-    tableDataWithTotal() {
-      if (this.packageOrderList && this.packageOrderList.length > 0) {
-        // 总是添加一个总计行
-        const totalRow = {
-          companyName: '总计',
-          deptName: '总计',
-          money: this.totalData?.money || 0,
-          orderNum: this.totalData?.orderNum || 0,
-          receiptMoney: this.totalData?.receiptMoney || 0,
-          receiptOrder: this.totalData?.receiptOrder || 0
-        };
-        return [...this.packageOrderList, totalRow];
-      }
-      return this.packageOrderList;
-    }
+    // tableDataWithTotal() {
+    //   if (this.packageOrderList && this.packageOrderList.length > 0) {
+    //     // 总是添加一个总计行
+    //     const totalRow = {
+    //       companyName: '总计',
+    //       deptName: '总计',
+    //       money: this.totalData?.money || 0,
+    //       orderNum: this.totalData?.orderNum || 0,
+    //       receiptMoney: this.totalData?.receiptMoney || 0,
+    //       receiptOrder: this.totalData?.receiptOrder || 0
+    //     };
+    //     return [...this.packageOrderList, totalRow];
+    //   }
+    //   return this.packageOrderList;
+    // }
   },
   created() {
     getCompanyList().then(response => {
@@ -210,8 +232,9 @@ export default {
     getList() {
       this.loading = true;
       PackageOrderReport(this.queryParams).then(response => {
-        this.packageOrderList = response.data.dataList;
-        this.totalData = response.data.total || {};
+        this.packageOrderList = response.rows ;
+        this.total = response.total;
+        this.calculateTotals();
         this.loading = false;
         // 延迟强制更新以确保DOM完全渲染
         setTimeout(() => {
@@ -219,6 +242,27 @@ export default {
         }, 100);
       });
     },
+    calculateTotals() {
+      // 重置总计数据
+      this.calculatedTotalData = {
+        orderNum: 0,
+        money: 0,
+        receiptOrder: 0,
+        receiptMoney: 0
+      };
+
+      // 遍历当前页数据计算总和
+      this.packageOrderList.forEach(item => {
+        this.calculatedTotalData.orderNum += Number(item.orderNum) || 0;
+        this.calculatedTotalData.money += Number(item.money) || 0;
+        this.calculatedTotalData.receiptOrder += Number(item.receiptOrder) || 0;
+        this.calculatedTotalData.receiptMoney += Number(item.receiptMoney) || 0;
+      });
+
+      // 金额格式化
+      this.calculatedTotalData.money = this.calculatedTotalData.money.toFixed(2);
+      this.calculatedTotalData.receiptMoney = this.calculatedTotalData.receiptMoney.toFixed(2);
+    },
     hasDeptNameField() {
       return this.packageOrderList &&
         this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
@@ -299,6 +343,8 @@ export default {
       this.queryParams.endEndTime = null;
       this.queryParams.companyId = null;
       this.queryParams.deptId = null;
+      this.queryParams.pageSize=null;
+      this.queryParams.pageNum=null;
       this.handleQuery();
     },
     xdChange() {
@@ -342,3 +388,66 @@ export default {
   }
 };
 </script>
+
+<style scoped>
+.total-summary {
+  margin-top: 15px;
+  padding: 15px 20px;
+  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7f4 100%);
+  border: 1px solid #dcdfe6;
+  border-radius: 4px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+}
+
+.total-title {
+  font-weight: bold;
+  font-size: 16px;
+  color: #303133;
+  margin-right: 20px;
+  flex-shrink: 0;
+}
+
+.total-item {
+  margin-right: 25px;
+  padding: 5px 10px;
+  background: white;
+  border-radius: 3px;
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
+  display: inline-block;
+  margin-bottom: 5px;
+  font-size: 13px;
+  color: #606266;
+}
+
+.total-item::before {
+  content: "";
+  display: inline-block;
+  width: 3px;
+  height: 3px;
+  background: #409eff;
+  border-radius: 50%;
+  margin-right: 5px;
+  vertical-align: middle;
+}
+
+/* 响应式处理 */
+@media (max-width: 768px) {
+  .total-summary {
+    flex-direction: column;
+    align-items: flex-start;
+  }
+
+  .total-title {
+    margin-bottom: 10px;
+  }
+
+  .total-item {
+    margin-right: 10px;
+    margin-bottom: 8px;
+  }
+}
+
+</style>

+ 535 - 0
src/views/his/statistics/userReport.vue

@@ -0,0 +1,535 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="85px">
+      <el-form-item label="公司名" prop="companyId">
+        <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名"
+                   clearable size="small">
+          <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="project">
+        <el-select filterable v-model="queryParams.project" placeholder="请选择项目"
+                   clearable size="small">
+          <el-option
+            v-for="item in projectList"
+            :key="item.dictCode"
+            :label="item.dictLabel"
+            :value="item.dictCode"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="训练营" prop="trainingCampId">
+        <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" />
+      </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-form-item>
+      <el-form-item label="会员ID" prop="userId">
+        <el-input v-model="queryParams.userId" placeholder="请输入会员ID" clearable size="small" />
+      </el-form-item>
+      <el-form-item label="会员手机号" prop="userPhone">
+        <el-input v-model="queryParams.userPhone" placeholder="请输入会员手机号" clearable size="small" />
+      </el-form-item>
+      <el-form-item label="会员昵称" prop="nickName">
+        <el-input v-model="queryParams.nickName" placeholder="请输入会员昵称" clearable size="small" />
+      </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>
+    <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="['his:packageOrder:export']"-->
+      <!--        >导出</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="会员id" align="center" prop="userId" width="120px"/>
+      <el-table-column label="用户昵称" align="center" prop="nickName" />
+      <el-table-column label="用户状态" align="center" prop="status" />
+      <el-table-column label="用户积分" align="center" prop="Integral"/>
+      <el-table-column label="所属销售" align="center" prop="companyUserName"/>
+      <el-table-column label="所属销售公司" align="center" prop="companyName"/>
+      <el-table-column label="注册时间" align="center" prop="registerDate"/>
+      <el-table-column label="最近看课时间" align="center" prop="lastWatchTime"/>
+      <el-table-column label="看课数" align="center" prop="watchCount"/>
+      <el-table-column label="缺课数" align="center" prop="absentCount"/>
+      <el-table-column label="参与营期数量" align="center" prop="periodCount"/>
+      <el-table-column label="看课状态" align="center" prop="watchStatus"/>
+      <el-table-column label="已消耗积分" align="center" prop="consumedIntegral"/>
+      <el-table-column label="已领红包金额" align="center" prop="receivedAmount"/>
+      <el-table-column label="已产生订单金额" align="center" prop="orderAmount"/>
+    </el-table>
+    <div class="total-summary">
+      <span class="total-title">总计:</span>
+      <span class="total-item">看课数: {{ calculatedTotalData.watchCount }}</span>
+      <span class="total-item">缺课数: {{ calculatedTotalData.absentCount }}</span>
+      <span class="total-item">参与营期数量: {{ calculatedTotalData.periodCount }}</span>
+      <span class="total-item">已消耗积分: {{ calculatedTotalData.consumedIntegral }}</span>
+      <span class="total-item">用户积分: {{ calculatedTotalData.Integral }}</span>
+      <span class="total-item">红包金额: {{ calculatedTotalData.receivedAmount.toFixed(2) }}</span>
+      <span class="total-item">订单金额: {{ calculatedTotalData.orderAmount.toFixed(2) }}</span>
+    </div>
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import {
+  listPackageOrder, getPackageOrder, delPackageOrder, addPackageOrder, updatePackageOrder, exportPackageOrder,
+  PackageOrderReport, orderReport, courseReport, userReport
+} from "@/api/his/packageOrder";
+import {getCompanyList} from "@/api/company/company";
+import packageOrderDetails from '../../components/his/packageOrderDetails.vue';
+import {treeselect} from "@/api/company/companyDept";
+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 {getDicts} from "@/api/system/dict/data";
+
+export default {
+  watch: {
+    'queryParams.deptId': function(newVal, oldVal) {
+      // 避免初始化时的触发
+      if (oldVal !== undefined) {
+        this.handleQuery();
+      }
+    },
+    // 监听deptId
+    'deptId': 'currDeptChange'
+  },
+  name: "PackageOrder",
+  components: {packageOrderDetails, Treeselect},
+  data() {
+    return {
+      normalizer: function(node) {
+        return {
+          id: node.id || node.dictValue,
+          label: node.label || node.dictLabel,
+          children: node.children
+        }
+      },
+      showTrainingCampColumn:false,
+      showPeriodColumn:false,
+      totalData: {},
+      companys: [],
+      camps: [],
+      projectList: [],
+      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: [],
+      // 添加用于存储计算总和的数据
+      calculatedTotalData: {
+        watchCount: 0,
+        absentCount: 0,
+        periodCount: 0,
+        consumedIntegral: 0,
+        Integral: 0,
+        receivedAmount: 0,
+        orderAmount: 0
+      },
+      // 弹出层标题
+      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,
+        finishTime: 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,
+        project:null,
+        userPhone: null,     // 会员手机号
+        nickName: null
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {}
+    };
+  },
+  computed: {
+  },
+  created() {
+    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: "无"})
+    });
+    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.getDicts("sys_course_project").then(e => {
+      this.projectList = e.data;
+    })
+  },
+  methods: {
+    calculateTotals() {
+      // 重置总计数据
+      this.calculatedTotalData = {
+        watchCount: 0,
+        absentCount: 0,
+        periodCount: 0,
+        consumedIntegral: 0,
+        Integral: 0,
+        receivedAmount: 0,
+        orderAmount: 0
+      };
+
+      // 遍历当前页数据计算总和
+      this.packageOrderList.forEach(item => {
+        this.calculatedTotalData.watchCount += Number(item.watchCount) || 0;
+        this.calculatedTotalData.absentCount += Number(item.absentCount) || 0;
+        this.calculatedTotalData.periodCount += Number(item.periodCount) || 0;
+        this.calculatedTotalData.consumedIntegral += Number(item.consumedIntegral) || 0;
+        this.calculatedTotalData.Integral += Number(item.Integral) || 0;
+        this.calculatedTotalData.receivedAmount += Number(item.receivedAmount) || 0;
+        this.calculatedTotalData.orderAmount += Number(item.orderAmount) || 0;
+      });
+    },
+    /** 查询套餐订单列表 */
+    getList() {
+      this.loading = true;
+      userReport(this.queryParams).then(response => {
+        this.packageOrderList = response.rows ;
+        this.total = response.total;
+        // 计算当前页数据的总和
+        this.calculateTotals();
+        this.loading = false;
+        // 延迟强制更新以确保DOM完全渲染
+        setTimeout(() => {
+          this.$forceUpdate();
+        }, 100);
+      });
+    },
+    /** 训练营变更处理 */
+    handleCampChange(val) {
+      this.queryParams.trainingCampId = val;
+      this.queryParams.periodId = null; // 清空已选择的营期
+
+      if (val) {
+        // 获取对应的营期数据
+        this.getPeriodByCamp(val);
+      } else {
+        // 如果清空训练营,也清空营期选项
+        this.deptOptions = [];
+      }
+
+      // 触发查询
+      this.handleQuery();
+    },
+
+    /** 根据训练营获取营期数据 */
+    getPeriodByCamp(campId) {
+      const param = { campId: campId };
+      getPeriodList(param).then((response) => {
+        console.log('接口返回数据:', response);
+        console.log('营期列表数据:', response.data.list);
+        this.deptOptions = response.data.list || [];
+        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,
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: 0,
+        startTime: null,
+        finishTime: null,
+        createTime: null
+      };
+      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,
+        companyId: null,
+        deptId: null,
+        source: null,
+        trainingCampId: null,
+        periodId: null,
+        project: null,
+        userPhone: null,     // 会员手机号
+        nickName: null       // 会员昵称
+      };
+
+      // 立即执行查询
+      this.handleQuery();
+    },
+    xdChange() {
+      if (this.createTime != null) {
+        this.queryParams.sTime = this.createTime[0];
+        this.queryParams.eTime = this.createTime[1];
+      } else {
+        this.queryParams.sTime = null;
+        this.queryParams.eTime = null;
+      }
+    },
+    endChange() {
+      if (this.endTime != null) {
+        this.queryParams.endStartTime = this.endTime[0];
+        this.queryParams.endEndTime = this.endTime[1];
+      } else {
+        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>
+
+<style scoped>
+.total-summary {
+  margin-top: 15px;
+  padding: 15px 20px;
+  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7f4 100%);
+  border: 1px solid #dcdfe6;
+  border-radius: 4px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+}
+
+.total-title {
+  font-weight: bold;
+  font-size: 16px;
+  color: #303133;
+  margin-right: 20px;
+  flex-shrink: 0;
+}
+
+.total-item {
+  margin-right: 25px;
+  padding: 5px 10px;
+  background: white;
+  border-radius: 3px;
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
+  display: inline-block;
+  margin-bottom: 5px;
+  font-size: 13px;
+  color: #606266;
+}
+
+.total-item::before {
+  content: "";
+  display: inline-block;
+  width: 3px;
+  height: 3px;
+  background: #409eff;
+  border-radius: 50%;
+  margin-right: 5px;
+  vertical-align: middle;
+}
+
+/* 响应式处理 */
+@media (max-width: 768px) {
+  .total-summary {
+    flex-direction: column;
+    align-items: flex-start;
+  }
+
+  .total-title {
+    margin-bottom: 10px;
+  }
+
+  .total-item {
+    margin-right: 10px;
+    margin-bottom: 8px;
+  }
+}
+
+</style>