فهرست منبع

Merge remote-tracking branch 'origin/master'

xgb 3 روز پیش
والد
کامیت
e2586cecc4

+ 2 - 2
.env.prod-bjzm

@@ -21,9 +21,9 @@ VUE_APP_OBS_BUCKET = bjzm
 # 存储桶配置
 VUE_APP_COS_BUCKET = bjzmky-1323137866
 # 存储桶配置
-VUE_APP_COS_REGION = ap-guangzhou
+VUE_APP_COS_REGION = ap-chongqing
 # 线路一地址
-VUE_APP_VIDEO_LINE_1 = https://bjzmky-1323137866.cos.ap-guangzhou.myqcloud.com
+VUE_APP_VIDEO_LINE_1 = https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com
 # 线路二地址
 VUE_APP_VIDEO_LINE_2 = https://bjzmobs.ylrztop.com
 

+ 53 - 0
src/api/his/storeActivity.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 查询活动列表
+export function listStoreActivity(query) {
+  return request({
+    url: '/his/storeActivity/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询活动详细
+export function getStoreActivity(activityId) {
+  return request({
+    url: '/his/storeActivity/' + activityId,
+    method: 'get'
+  })
+}
+
+// 新增活动
+export function addStoreActivity(data) {
+  return request({
+    url: '/his/storeActivity',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改活动
+export function updateStoreActivity(data) {
+  return request({
+    url: '/his/storeActivity',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除活动
+export function delStoreActivity(activityId) {
+  return request({
+    url: '/his/storeActivity/' + activityId,
+    method: 'delete'
+  })
+}
+
+// 导出活动
+export function exportStoreActivity(query) {
+  return request({
+    url: '/his/storeActivity/export',
+    method: 'get',
+    params: query
+  })
+}

+ 18 - 0
src/api/live/liveOrder.js

@@ -9,6 +9,15 @@ export function listLiveOrder(query) {
   })
 }
 
+// 查询订单列表
+export function listLiveOrderZm(query) {
+  return request({
+    url: '/live/liveOrder/listZm',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询订单详细
 export function getLiveOrder(orderId) {
   return request({
@@ -68,6 +77,15 @@ export function exportLiveOrder(query) {
   })
 }
 
+// 导出订单
+export function exportLiveOrderZm(query) {
+  return request({
+    url: '/live/liveOrder/exportZm',
+    method: 'get',
+    params: query
+  })
+}
+
 export function getExpress(data) {
   return request({
     url: '/live/liveOrder/getExpressByDeliverId',

+ 17 - 4
src/api/statistics/statistics.js

@@ -325,7 +325,7 @@ export function thisMonthRecvCount(param){
 }
 
 /**
- * 综合统计
+ * 综合统计(需要按照时间分组)
  * @returns {*}
  */
 export function getStatisticsData(data) {
@@ -337,7 +337,7 @@ export function getStatisticsData(data) {
 }
 
 /**
- * 获取下拉
+ * 获取公司下拉
  * @returns {*}
  */
 export function getSearchCompanyInfo(param){
@@ -349,7 +349,7 @@ export function getSearchCompanyInfo(param){
 }
 
 /**
- * 获取下拉
+ * 获取部门下拉
  * @returns {*}
  */
 export function getSearchDeptInfo(param){
@@ -361,7 +361,7 @@ export function getSearchDeptInfo(param){
 }
 
 /**
- * 获取下拉
+ * 获取用户下拉
  * @returns {*}
  */
 export function getSearchUserInfo(param){
@@ -372,6 +372,19 @@ export function getSearchUserInfo(param){
   })
 }
 
+/**
+ * 综合统计(不按照时间分组)
+ * @returns {*}
+ */
+export function getStatisticsDataN(data) {
+  return request({
+    url: '/crm/ComprehensiveStatistics/statisticMainN',
+    method: 'post',
+    data: data  // 使用 data 而不是 params
+  })
+}
+
+
 
 
 

+ 75 - 29
src/components/LiveVideoUpload/single.vue

@@ -2,34 +2,34 @@
   <div>
     <el-form-item label="">
       <div class="upload_video" id="upload_video">
-        <el-upload
-          class="upload-demo"
-          ref="upload"
-          action="#"
-          :http-request="uploadVideoToTxPcdn"
-          accept=".mp4"
-          :limit="1"
-          :on-remove="handleRemove"
-          :on-change="handleChange"
-          :auto-upload="false"
-          :key="uploadKey"
-        >
-          <el-button slot="trigger" size="small" type="primary" >选取视频</el-button>
-          <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">点击上传</el-button>
+<!--        <el-upload-->
+<!--          class="upload-demo"-->
+<!--          ref="upload"-->
+<!--          action="#"-->
+<!--          :http-request="uploadVideoToTxPcdn"-->
+<!--          accept=".mp4"-->
+<!--          :limit="1"-->
+<!--          :on-remove="handleRemove"-->
+<!--          :on-change="handleChange"-->
+<!--          :auto-upload="false"-->
+<!--          :key="uploadKey"-->
+<!--        >-->
+<!--          <el-button slot="trigger" size="small" type="primary" >选取视频</el-button>-->
+<!--          <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">点击上传</el-button>-->
           <!-- 仅当showControl为true时显示视频库选取按钮 -->
           <el-button v-if="showControl" style="margin-left: 10px;" size="small" type="success" @click="openVideoLibrary">视频库选取</el-button>
-          <!-- 线路一 -->
-          <div class="progress-container">
-            <span class="progress-label">线路一</span>
-            <el-progress
-              style="margin-top: 5px;"
-              class="progress"
-              :text-inside="true"
-              :stroke-width="18"
-              :percentage="txProgress"
-              status="success">
-            </el-progress>
-          </div>
+<!--          &lt;!&ndash; 线路一 &ndash;&gt;-->
+<!--          <div class="progress-container">-->
+<!--            <span class="progress-label">线路一</span>-->
+<!--            <el-progress-->
+<!--              style="margin-top: 5px;"-->
+<!--              class="progress"-->
+<!--              :text-inside="true"-->
+<!--              :stroke-width="18"-->
+<!--              :percentage="txProgress"-->
+<!--              status="success">-->
+<!--            </el-progress>-->
+<!--          </div>-->
 
           <!-- 线路二 -->
 <!--          <div class="progress-container">-->
@@ -44,7 +44,7 @@
 <!--            </el-progress>-->
 <!--          </div>-->
           <div slot="tip" class="el-upload__tip">只能上传mp4文件,且不超过500M</div>
-        </el-upload>
+<!--        </el-upload>-->
       </div>
     </el-form-item>
     <el-form-item label="视频播放">
@@ -125,6 +125,7 @@ import { uploadObject } from "@/utils/cos.js";
 import Pagination from "@/components/Pagination";
 // import { listVideoResource } from '@/api/course/videoResource';
 import { listLiveVideo, getLiveVideo, delLiveVideo, addLiveVideo, updateLiveVideo, exportLiveVideo } from "@/api/live/liveVideo";
+import Hls from 'hls.js';
 
 export default {
   components: {
@@ -182,6 +183,9 @@ export default {
       default: true,
     }
   },
+  destroyed() {
+    this.hls?.destroy();
+  },
   data() {
     return {
       videoName:'',
@@ -206,6 +210,7 @@ export default {
       libraryTotal: 0,
       libraryList: [],
       selectedVideo: null,
+      hls:null,
       libraryQueryParams: {
         pageNum: 1,
         pageSize: 10,
@@ -230,13 +235,50 @@ export default {
   },
   mounted() {
     this.reset();
+    if (this.videoUrl.endsWith(".m3u8")) {
+      this.$nextTick(() => {
+        this.initPlayer()
+      })
+    }
   },
   watch: {
+    videoUrl(newVal,oldVal){
+      console.log("触发数据改变")
+      if (this.videoUrl.endsWith(".m3u8")) {
+        this.$nextTick(() => {
+          this.initPlayer()
+        })
+      }
+    },
     uploadType(newType) {
       this.localUploadType = newType;
     },
+
   },
   methods: {
+    initPlayer() {
+      this.hls?.destroy();
+      if (Hls.isSupported()) {
+        const videoElement = this.$refs.myM3u8Video
+        if (!videoElement) {
+          console.error('找不到 video 元素')
+          return
+        }
+        this.hls = new Hls();
+        this.hls.attachMedia(videoElement);
+        this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
+          this.hls.loadSource(this.videoUrl);
+          this.hls.on(Hls.Events.STREAM_LOADED, (event, data) => {
+            videoElement.play();
+          });
+        });
+        this.hls.on(Hls.Events.ERROR, (event, data) => {
+          console.error('HLS 错误:', data);
+        });
+      } else {
+        console.error('浏览器不支持 HLS')
+      }
+    },
     /** 查询直播视频列表 */
     getList() {
       this.libraryLoading = true;
@@ -348,7 +390,7 @@ export default {
       // 重置内部状态
       this.txProgress = 0;
       this.fileList = [];
-      this.$refs.upload.clearFiles();
+      // this.$refs.upload.clearFiles();
       this.uploadKey++;
     },
     /** 查询视频库列表 */
@@ -412,7 +454,11 @@ export default {
       this.$emit("update:videoUrl", this.selectedVideo.videoUrl);
       this.$emit("change", this.selectedVideo.videoUrl,this.selectedVideo.lineOne);
 
-
+      if (this.videoUrl.endsWith(".m3u8")) {
+        this.$nextTick(() => {
+          this.initPlayer()
+        })
+      }
       this.libraryOpen = false;
     },
     /** 取消视频选择 */

+ 2 - 2
src/views/company/companyMoneyLogs/index.vue

@@ -106,8 +106,8 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="ID" align="center" prop="logsId" />
       <el-table-column label="企业" align="center" prop="companyName" />
-      <el-table-column label="红包金额" align="center" prop="money" />
-      <el-table-column label="红包余额" align="center" prop="balance" />
+      <el-table-column label="金额" align="center" prop="money" />
+      <el-table-column label="余额" align="center" prop="balance" />
 
       <el-table-column label="商城订单号" align="center" prop="orderCode"  v-if="queryParams.logsType==3 || queryParams.logsType==4 ||queryParams.logsType==5 || queryParams.logsType==6"  />
       <el-table-column label="支付类型" align="center" prop="payTypeCode"  v-if="queryParams.logsType==3 || queryParams.logsType==4 ||queryParams.logsType==5 || queryParams.logsType==6 " />

+ 1 - 1
src/views/course/courseTrafficLog/statistics.vue

@@ -43,7 +43,7 @@
           size="mini"
           :loading="exportLoading"
           @click="handleExport"
-          v-hasPermi="['course:courseRedPacketLog:export']"
+          v-hasPermi="['course:courseTrafficLog:statisticsExport']"
         >导出</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>

+ 3 - 0
src/views/his/adv/index.vue

@@ -212,6 +212,9 @@
             ></el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="排序">
+          <el-input-number v-model="form.sort"  label="排序"></el-input-number>
+        </el-form-item>
         <el-form-item label="状态">
           <el-radio-group v-model="form.status">
              <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>

+ 1 - 1
src/views/his/coupon/index.vue

@@ -120,7 +120,7 @@
                type="text"
                @click="handledetails(scope.row)"
            >详情
-           
+
           </el-button>
           <el-button
             size="mini"

+ 356 - 166
src/views/his/statistics/comprehensiveStatistics.vue

@@ -1,107 +1,135 @@
 <template>
   <div class="app-container">
     <div class="app-content">
-      <div class="title">综合统计看板</div>
+      <div class="title">综合统计看板</div>
 
       <el-form class="search-form" :inline="true" label-width="90px">
-
-        <!-- 时间范围选择 -->
-        <el-form-item label="时间范围">
-          <el-date-picker
-            v-model="dateRange"
-            type="daterange"
-            range-separator="至"
-            start-placeholder="开始日期"
-            end-placeholder="结束日期"
-            value-format="yyyy-MM-dd"
-            :picker-options="pickerOptions">
-          </el-date-picker>
-        </el-form-item>
-
-        <!-- 统计维度选择 -->
-        <el-form-item label="统计维度">
-          <el-select v-model="queryParams.dimension" placeholder="请选择统计维度" @change="handleDimensionChange" clearable>
-            <el-option label="个人" :value="1"></el-option>
-            <el-option label="公司" :value="2"></el-option>
-            <el-option label="部门" :value="3"></el-option>
-          </el-select>
-        </el-form-item>
-
-        <!-- 公司选择 -->
-        <el-form-item label="选择公司" v-if="queryParams.dimension">
-          <el-select
-            v-model="queryParams.companyId"
-            placeholder="请选择公司"
-            @change="handleCompanyChange"
-            clearable
-            :disabled="!queryParams.dimension">
-            <el-option
-              v-for="company in companyList"
-              :key="company.companyId"
-              :label="company.companyName"
-              :value="company.companyId">
-            </el-option>
-          </el-select>
-        </el-form-item>
-
-        <!-- 部门选择 -->
-        <el-form-item label="选择部门" v-if="showDepartmentSelect">
-          <el-select
-            v-model="queryParams.deptId"
-            placeholder="请选择部门"
-            @change="handleDeptChange"
-            clearable
-            :disabled="!queryParams.companyId">
-            <el-option
-              v-for="dept in deptList"
-              :key="dept.deptId"
-              :label="dept.deptName"
-              :value="dept.deptId">
-            </el-option>
-          </el-select>
-        </el-form-item>
-
-        <!-- 人员选择 -->
-        <el-form-item label="选择人员" v-if="showUserSelect">
-          <el-select
-            v-model="queryParams.userId"
-            placeholder="请选择人员"
-            clearable
-            :disabled="!queryParams.deptId">
-            <el-option
-              v-for="user in userList"
-              :key="user.userId"
-              :label="user.nickName"
-              :value="user.userId">
-            </el-option>
-          </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-row :gutter="10">
+          <!-- 时间范围选择 -->
+          <el-col :span="6">
+            <el-form-item label="时间范围">
+              <el-date-picker
+                v-model="dateRange"
+                type="daterange"
+                range-separator="至"
+                start-placeholder="开始日期"
+                end-placeholder="结束日期"
+                value-format="yyyy-MM-dd"
+                :picker-options="pickerOptions"
+                style="width: 100%">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+
+          <!-- 统计维度选择 -->
+          <el-col :span="4">
+            <el-form-item label="统计维度">
+              <el-select
+                v-model="queryParams.dimension"
+                placeholder="请选择统计维度"
+                @change="handleDimensionChange"
+                clearable
+                style="width: 100%">
+                <el-option label="个人" :value="1"></el-option>
+                <el-option label="公司" :value="2"></el-option>
+                <el-option label="部门" :value="3"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+
+          <!-- 公司选择 -->
+          <el-col :span="4" v-if="showCompanySelect">
+            <el-form-item label="选择公司">
+              <el-select
+                v-model="queryParams.companyId"
+                placeholder="请选择公司"
+                @change="handleCompanyChange"
+                clearable
+                :disabled="!queryParams.dimension"
+                style="width: 100%">
+                <el-option
+                  v-for="company in companyList"
+                  :key="company.companyId"
+                  :label="company.companyName"
+                  :value="company.companyId">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+
+          <!-- 部门选择 -->
+          <el-col :span="4" v-if="showDepartmentSelect">
+            <el-form-item label="选择部门">
+              <el-cascader
+                v-model="selectedDeptIds"
+                :options="deptTreeData"
+                :props="deptCascaderProps"
+                placeholder="请选择部门"
+                clearable
+                style="width: 100%"
+                @change="handleDeptChange">
+              </el-cascader>
+            </el-form-item>
+          </el-col>
+
+          <!-- 操作按钮 -->
+          <el-col :span="6">
+            <el-form-item label-width="0" style="padding-top: 35px;">
+              <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-button type="success" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading">导出</el-button>
+            </el-form-item>
+          </el-col>
+        </el-row>
       </el-form>
     </div>
 
     <!-- 数据表格 -->
     <div class="table-section">
-      <el-table :data="paginatedTableData" border style="width: 100%" height="600">
+      <el-table v-loading="loading" :data="paginatedTableData" border style="width: 100%" height="600">
         <!-- 添加时间列 -->
-        <el-table-column prop="statisticsTime" label="统计时间" width="180">
+        <el-table-column prop="companyName" label="公司名称"/>
+        <el-table-column prop="deptName" label="部门名称" v-if="showDeptNameColumn" />
+        <!-- 根据维度决定是否显示人员姓名 -->
+        <el-table-column prop="companyUserName" label="人员名称" v-if="showUserNameColumn" />
+        <!-- 更新以下列为新的字段名 -->
+        <el-table-column prop="sendCount" label="发课数">
           <template slot-scope="scope">
-            {{ formatDateTime(scope.row.statisticsTime) }}
+            {{ scope.row.sendCount || 0 }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="completeNum" label="完课数">
+          <template slot-scope="scope">
+            {{ scope.row.completeNum || 0 }}
+          </template>
+        </el-table-column>
+        <!-- 完播率 -->
+        <el-table-column prop="completeRate" label="完播率" width="100">
+          <template slot-scope="scope">
+            {{ calculateCompleteRate(scope.row) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="answerNum" label="答题数">
+          <template slot-scope="scope">
+            {{ scope.row.answerNum || 0 }}
+          </template>
+        </el-table-column>
+        <!-- 答题率 -->
+        <el-table-column prop="answerRate" label="答题率" width="100">
+          <template slot-scope="scope">
+            {{ calculateAnswerRate(scope.row) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="redPacketNum" label="红包领取数">
+          <template slot-scope="scope">
+            {{ scope.row.redPacketNum || 0 }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="redPacketAmount" label="红包金额(元)">
+          <template slot-scope="scope">
+            {{ scope.row.redPacketAmount || 0 }}
           </template>
         </el-table-column>
-        <el-table-column prop="companyName" label="公司名称" />
-        <el-table-column prop="deptName" label="部门名称" />
-        <!-- 根据维度决定是否显示人员姓名 -->
-        <el-table-column prop="companyUserName" label="人员姓名" v-if="showUserNameColumn" />
-        <!-- 更新以下列为新的字段名 -->
-        <el-table-column prop="sendCount" label="发送数" />
-        <el-table-column prop="answerNum" label="答题数" />
-        <el-table-column prop="redPacketNum" label="红包领取数" />
-        <el-table-column prop="redPacketAmount" label="红包金额(元)" />
       </el-table>
 
       <el-pagination
@@ -119,13 +147,18 @@
 </template>
 
 <script>
-import { getStatisticsData, getSearchUserInfo, getSearchCompanyInfo, getSearchDeptInfo } from "@/api/statistics/statistics";
+import { getStatisticsDataN, getSearchUserInfo, getSearchCompanyInfo, getSearchDeptInfo } from "@/api/statistics/statistics";
 
 export default {
   data() {
     return {
+      exportLoading: false, // 添加导出加载状态
+      loading: false,
+      lastQueryDimension: null, // 记录上次查询的维度
       companyList: [],
-      deptList: [],
+      deptList: [], // 原始部门数据
+      deptTreeData: [], // 树形部门数据
+      selectedDeptIds: [], // 选中的部门ID路径
       userList: [],
       rawData: [],
       tableData: [],
@@ -159,6 +192,14 @@ export default {
           }
         }]
       },
+      deptCascaderProps: {
+        value: 'deptId',
+        label: 'deptName',
+        children: 'children',
+        expandTrigger: 'hover',
+        checkStrictly: true, // 允许选择任意一级
+        emitPath: false // 只返回选中节点的值,而不是整个路径
+      },
       queryParams: {
         dimension: null,
         companyId: null,
@@ -175,22 +216,28 @@ export default {
       return this.tableData.slice(start, end);
     },
 
+    showCompanySelect() {
+      // 公司维度不需要显示公司选择,其他维度都需要
+      return this.queryParams.dimension && this.queryParams.dimension !== 2;
+    },
+
     showDepartmentSelect() {
-      return this.queryParams.dimension &&
-        (this.queryParams.dimension === 3 || this.queryParams.dimension === 1) &&
-        this.queryParams.companyId;
+      // 部门维度不需要显示部门选择,个人维度需要显示
+      return this.queryParams.dimension === 1 && this.queryParams.companyId;
     },
 
-    showUserSelect() {
-      return this.queryParams.dimension === 1 &&
-        this.queryParams.companyId &&
-        this.queryParams.deptId;
+
+
+    // 控制部门名称列显示
+    showDeptNameColumn() {
+      // 基于上次查询的维度来决定是否显示部门名称列
+      return this.lastQueryDimension && this.lastQueryDimension !== 2;
     },
 
-    // 添加计算属性控制人员姓名列显示
+    // 控制人员姓名列显示
     showUserNameColumn() {
-      // 当维度为个人时显示人员姓名列,公司维度时不显示
-      return this.queryParams.dimension === 1 || this.queryParams.dimension === 3;
+      // 只有个人维度显示人员姓名列
+      return this.lastQueryDimension === 1;
     }
   },
 
@@ -201,23 +248,26 @@ export default {
     // 默认设置统计维度为公司
     this.queryParams.dimension = 2;
     this.loadData();
+    // 页面初始化时查询一次数据
+    this.fetchStatisticsData();
   },
 
   methods: {
+    // 在 loadData 方法中也移除自动查询
     loadData() {
       // 使用 getSearchCompanyInfo 获取公司下拉数据
       getSearchCompanyInfo().then(response => {
         this.companyList = response.data || [];
 
         // 默认选择第一个公司(如果存在)
-        if (this.companyList.length > 0) {
+        if (this.companyList.length > 0 && this.queryParams.dimension !== 2) {
           this.queryParams.companyId = this.companyList[0].companyId;
           // 加载该公司的部门数据
           return this.loadDeptData(this.queryParams.companyId);
         }
       }).then(() => {
-        // 在公司和部门默认选择完成后,请求统计数据
-        return this.fetchStatisticsData();
+        // 移除自动查询调用,只保留初始加载
+        // return this.fetchStatisticsData();
       }).catch(error => {
         console.error('数据加载失败:', error);
         this.$message.error('数据加载失败');
@@ -225,12 +275,26 @@ export default {
     },
 
     loadDeptData(companyId) {
+      if (!companyId) return Promise.resolve();
+
       return getSearchDeptInfo({ id: companyId }).then(response => {
-        this.deptList = response.data || [];
+        const deptData = response.data || [];
+        this.deptList = deptData;
+
+        // 如果后端直接返回树形结构(第一层数据有children),直接使用
+        // 否则通过buildDeptTree构建树形结构
+        const hasTreeStructure = deptData.some(dept => dept.children && dept.children.length > 0);
+        if (hasTreeStructure) {
+          this.deptTreeData = deptData.filter(dept => dept.parentId === 0 || dept.parentId === null);
+        } else {
+          this.deptTreeData = this.buildDeptTree(deptData);
+        }
 
         // 默认选择第一个部门(如果存在)
-        if (this.deptList.length > 0) {
-          this.queryParams.deptId = this.deptList[0].deptId;
+        if (this.deptTreeData.length > 0 && this.queryParams.dimension === 1) {
+          // 选择第一个顶级部门
+          this.queryParams.deptId = this.deptTreeData[0].deptId;
+          this.selectedDeptIds = [this.queryParams.deptId];
         }
       }).catch(error => {
         console.error('部门数据加载失败:', error);
@@ -238,6 +302,50 @@ export default {
       });
     },
 
+    // 构建部门树形结构
+    buildDeptTree(deptList) {
+      if (!deptList || deptList.length === 0) return [];
+
+      // 创建部门映射
+      const deptMap = {};
+      deptList.forEach(dept => {
+        // 如果后端返回的数据中已经有children字段且有值,则使用后端的children
+        // 否则初始化为空数组
+        deptMap[dept.deptId] = {
+          ...dept,
+          children: (dept.children && dept.children.length > 0) ? dept.children : []
+        };
+      });
+
+      // 构建树形结构
+      const tree = [];
+      deptList.forEach(dept => {
+        if (dept.parentId === 0 || dept.parentId === null) {
+          // 顶级部门
+          tree.push(deptMap[dept.deptId]);
+        } else {
+          // 子部门 - 只有在后端没有返回children的情况下才手动构建
+          if (deptMap[dept.parentId] && (!dept.children || dept.children.length === 0)) {
+            deptMap[dept.parentId].children.push(deptMap[dept.deptId]);
+          }
+        }
+      });
+
+      // 清理空的children数组,保持数据结构整洁
+      const cleanEmptyChildren = (nodes) => {
+        nodes.forEach(node => {
+          if (node.children && node.children.length === 0) {
+            delete node.children;
+          } else if (node.children && node.children.length > 0) {
+            cleanEmptyChildren(node.children);
+          }
+        });
+      };
+      cleanEmptyChildren(tree);
+
+      return tree;
+    },
+
     // 添加时间格式化方法
     formatDateTime(dateString) {
       if (!dateString) return '';
@@ -259,6 +367,7 @@ export default {
     },
 
     fetchStatisticsData() {
+      this.loading = true; // 开始请求时设置 loading 为 true
       // 构造请求参数对象
       const params = {
         dimension: this.queryParams.dimension,
@@ -266,93 +375,74 @@ export default {
         endTime: this.formatDate(this.dateRange[1])
       };
 
-      // 根据维度设置id参数
-      if (this.queryParams.dimension === 1 && this.queryParams.userId) {
-        params.id = this.queryParams.userId;
-      } else if (this.queryParams.dimension === 2 && this.queryParams.companyId) {
-        params.id = this.queryParams.companyId;
-      } else if (this.queryParams.dimension === 3 && this.queryParams.deptId) {
+      // 根据新规则设置id参数
+      if (this.queryParams.dimension === 1 && this.queryParams.deptId) {
+        // 个人维度传递部门ID
         params.id = this.queryParams.deptId;
+      } else if (this.queryParams.dimension === 3 && this.queryParams.companyId) {
+        // 部门维度传递公司ID
+        params.id = this.queryParams.companyId;
       }
+      // 公司维度不传递ID参数
 
       // 以POST方式发送请求体
-      return getStatisticsData(params).then(response => {
+      return getStatisticsDataN(params).then(response => {
         this.rawData = response.data || [];
         this.tableData = [...this.rawData];
         this.currentPage = 1;
       }).catch(error => {
         console.error('统计数据加载失败:', error);
         this.$message.error('统计数据加载失败');
+      }).finally(() => {
+        this.loading = false; // 请求完成后设置 loading 为 false
       });
     },
 
     handleCompanyChange(companyId) {
       this.queryParams.deptId = null;
+      this.selectedDeptIds = [];
       this.queryParams.userId = null;
       this.deptList = [];
+      this.deptTreeData = [];
       this.userList = [];
 
       if (!companyId) return;
 
       // 使用 getSearchDeptInfo 获取部门下拉数据
       getSearchDeptInfo({ id: companyId }).then(response => {
-        this.deptList = response.data || [];
+        const deptData = response.data || [];
+        this.deptList = deptData;
+
+        // 如果后端直接返回树形结构(第一层数据有children),直接使用
+        // 否则通过buildDeptTree构建树形结构
+        const hasTreeStructure = deptData.some(dept => dept.children && dept.children.length > 0);
+        if (hasTreeStructure) {
+          this.deptTreeData = deptData.filter(dept => dept.parentId === 0 || dept.parentId === null);
+        } else {
+          this.deptTreeData = this.buildDeptTree(deptData);
+        }
 
         // 默认选择第一个部门(如果存在)
-        // 仅在部门维度或个人维度下默认选择第一个部门
-        if (this.deptList.length > 0 &&
-          (this.queryParams.dimension === 3 || this.queryParams.dimension === 1)) {
-          this.queryParams.deptId = this.deptList[0].deptId;
-
-          // 如果是个人维度,还需要加载用户数据
-          if (this.queryParams.dimension === 1 && this.queryParams.deptId) {
-            this.loadUserData(this.queryParams.deptId);
-          }
+        // 仅在个人维度下默认选择第一个部门
+        if (this.deptTreeData.length > 0 && this.queryParams.dimension === 1) {
+          // 选择第一个顶级部门
+          this.queryParams.deptId = this.deptTreeData[0].deptId;
+          this.selectedDeptIds = [this.queryParams.deptId];
         }
       }).catch(error => {
         console.error('部门数据加载失败:', error);
         this.$message.error('部门数据加载失败');
       });
+      // 移除.then()后面的自动查询调用
     },
-
-    // 新增加载用户数据的方法
-    loadUserData(deptId) {
-      if (!deptId) return;
-
-      getSearchUserInfo({ id: deptId }).then(response => {
-        this.userList = response.data || [];
-
-        // 可以选择默认选中第一个用户
-        if (this.userList.length > 0) {
-          // this.queryParams.userId = this.userList[0].userId;
-        }
-      }).catch(error => {
-        console.error('人员数据加载失败:', error);
-        this.$message.error('人员数据加载失败');
-      });
-    },
-
-    handleDeptChange(deptId) {
-      this.queryParams.userId = null;
-      this.userList = [];
-
-      if (!deptId) return;
-
-      // 使用 getSearchUserInfo 获取人员下拉数据
-      getSearchUserInfo({ id: deptId }).then(response => {
-        this.userList = response.data || [];
-
-        // 在个人维度下,默认选择第一个用户(可选)
-        if (this.userList.length > 0 && this.queryParams.dimension === 1) {
-          // this.queryParams.userId = this.userList[0].userId;
-        }
-      }).catch(error => {
-        console.error('人员数据加载失败:', error);
-        this.$message.error('人员数据加载失败');
-      });
+    handleDeptChange(selectedDeptId) {
+      // 更新选中的部门ID
+      this.queryParams.deptId = selectedDeptId;
     },
 
     handleQuery() {
+      // 记录当前查询的维度
+      this.lastQueryDimension = this.queryParams.dimension;
       // 触发统计数据请求
       this.fetchStatisticsData();
     },
@@ -361,25 +451,32 @@ export default {
       // 重置后续选择项
       this.queryParams.companyId = null;
       this.queryParams.deptId = null;
+      this.selectedDeptIds = [];
       this.queryParams.userId = null;
       this.deptList = [];
+      this.deptTreeData = [];
       this.userList = [];
     },
 
     resetQuery() {
       this.queryParams = {
-        dimension: null,
+        dimension: 2, // 重置为公司维度
         companyId: null,
         deptId: null,
         userId: null
       };
+      this.selectedDeptIds = []; // 重置部门选择
       // 重置时间为当天
       const today = new Date();
       this.dateRange = [today, today];
       this.deptList = [];
+      this.deptTreeData = [];
       this.userList = [];
       this.tableData = [...this.rawData];
       this.currentPage = 1;
+      // 重置后立即发送请求
+      this.lastQueryDimension = 2; // 同时更新lastQueryDimension
+      this.fetchStatisticsData();
     },
 
     handleSizeChange(val) {
@@ -389,6 +486,95 @@ export default {
 
     handleCurrentChange(val) {
       this.currentPage = val;
+    },
+
+    // 计算完播率:完课数 / 发送数
+    calculateCompleteRate(row) {
+      const sendCount = row.sendCount || 0;
+      const completeNum = row.completeNum || 0;
+
+      if (sendCount === 0) {
+        return '0%';
+      }
+
+      const rate = (completeNum / sendCount * 100).toFixed(2);
+      return rate + '%';
+    },
+
+    // 计算答题率:答题数 / 完课数
+    calculateAnswerRate(row) {
+      const completeNum = row.completeNum || 0;
+      const answerNum = row.answerNum || 0;
+
+      if (completeNum === 0) {
+        return '0%';
+      }
+
+      const rate = (answerNum / completeNum * 100).toFixed(2);
+      return rate + '%';
+    },
+    // 添加导出方法
+    handleExport() {
+      if (this.tableData.length === 0) {
+        this.$message.warning('没有可导出的数据');
+        return;
+      }
+
+      this.exportLoading = true;
+
+      try {
+        // 创建 CSV 内容
+        const headers = [
+         '公司名称', '部门名称', '人员名称',
+          '发课数', '完课数', '完播率', '答题数', '答题率',
+          '红包领取数', '红包金额(元)'
+        ];
+
+        const csvContent = [
+          headers.join(','),
+          ...this.tableData.map(row => [
+            row.companyName || '',
+            row.deptName || '',
+            row.companyUserName || '',
+            row.sendCount || 0,
+            row.completeNum || 0,
+            this.calculateCompleteRate(row),
+            row.answerNum || 0,
+            this.calculateAnswerRate(row),
+            row.redPacketNum || 0,
+            row.redPacketAmount || 0
+          ].map(field => `"${field}"`).join(','))
+        ].join('\n');
+
+        // 创建下载链接
+        const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
+        const link = document.createElement('a');
+        const url = URL.createObjectURL(blob);
+
+        link.setAttribute('href', url);
+
+        // link.setAttribute('download', `综合统计看板_${new Date().toISOString().slice(0, 10)}.csv`);
+        // 修改为:
+        const now = new Date();
+        const timestamp = now.getFullYear() +
+          String(now.getMonth() + 1).padStart(2, '0') +
+          String(now.getDate()).padStart(2, '0') +
+          String(now.getHours()).padStart(2, '0') +
+          String(now.getMinutes()).padStart(2, '0') +
+          String(now.getSeconds()).padStart(2, '0');
+        link.setAttribute('download', `综合统计看板_${timestamp}.csv`);
+        link.style.visibility = 'hidden';
+        document.body.appendChild(link);
+        link.click();
+        document.body.removeChild(link);
+
+        this.$message.success('导出成功');
+      } catch (error) {
+        console.error('导出失败:', error);
+        this.$message.error('导出失败');
+      } finally {
+        this.exportLoading = false;
+      }
     }
   }
 };
@@ -417,13 +603,17 @@ export default {
 }
 
 .search-form {
-  display: flex;
-  justify-content: center;
-  flex-wrap: wrap;
+  margin-bottom: 0;
 }
 
 .search-form .el-form-item {
-  margin-bottom: 10px;
+  margin-bottom: 18px;
+  width: 100%;
+}
+
+.search-form .el-row {
+  margin-left: 0 !important;
+  margin-right: 0 !important;
 }
 
 .table-section {

+ 640 - 0
src/views/his/statistics/dayComprehensiveStatistics.vue

@@ -0,0 +1,640 @@
+<template>
+  <div class="app-container">
+    <div class="app-content">
+      <div class="title">综合统计看板</div>
+
+      <el-form class="search-form" :inline="true" label-width="90px">
+        <el-row :gutter="10">
+          <!-- 时间范围选择 -->
+          <el-col :span="6">
+            <el-form-item label="时间范围">
+              <el-date-picker
+                v-model="dateRange"
+                type="daterange"
+                range-separator="至"
+                start-placeholder="开始日期"
+                end-placeholder="结束日期"
+                value-format="yyyy-MM-dd"
+                :picker-options="pickerOptions"
+                style="width: 100%">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+
+          <!-- 统计维度选择 -->
+          <el-col :span="4">
+            <el-form-item label="统计维度">
+              <el-select
+                v-model="queryParams.dimension"
+                placeholder="请选择统计维度"
+                @change="handleDimensionChange"
+                clearable
+                style="width: 100%">
+                <el-option label="个人" :value="1"></el-option>
+                <el-option label="公司" :value="2"></el-option>
+                <el-option label="部门" :value="3"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+
+          <!-- 公司选择 -->
+          <el-col :span="4" v-if="showCompanySelect">
+            <el-form-item label="选择公司">
+              <el-select
+                v-model="queryParams.companyId"
+                placeholder="请选择公司"
+                @change="handleCompanyChange"
+                clearable
+                :disabled="!queryParams.dimension"
+                style="width: 100%">
+                <el-option
+                  v-for="company in companyList"
+                  :key="company.companyId"
+                  :label="company.companyName"
+                  :value="company.companyId">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+
+          <!-- 部门选择 -->
+          <el-col :span="4" v-if="showDepartmentSelect">
+            <el-form-item label="选择部门">
+              <el-cascader
+                v-model="selectedDeptIds"
+                :options="deptTreeData"
+                :props="deptCascaderProps"
+                placeholder="请选择部门"
+                clearable
+                style="width: 100%"
+                @change="handleDeptChange">
+              </el-cascader>
+            </el-form-item>
+          </el-col>
+
+          <!-- 操作按钮 -->
+          <el-col :span="6">
+            <el-form-item label-width="0" style="padding-top: 35px;">
+              <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-button type="success" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading">导出</el-button>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+
+    <!-- 数据表格 -->
+    <div class="table-section">
+      <el-table v-loading="loading" :data="paginatedTableData" border style="width: 100%" height="600">
+        <!-- 添加时间列 -->
+        <el-table-column prop="statisticsTime" label="统计时间" width="180">
+          <template slot-scope="scope">
+            {{ formatDateTime(scope.row.statisticsTime) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="companyName" label="公司名称"/>
+        <el-table-column prop="deptName" label="部门名称" v-if="showDeptNameColumn" />
+        <!-- 根据维度决定是否显示人员姓名 -->
+        <el-table-column prop="companyUserName" label="人员名称" v-if="showUserNameColumn" />
+        <!-- 更新以下列为新的字段名 -->
+        <el-table-column prop="sendCount" label="发课数">
+          <template slot-scope="scope">
+            {{ scope.row.sendCount || 0 }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="completeNum" label="完课数">
+          <template slot-scope="scope">
+            {{ scope.row.completeNum || 0 }}
+          </template>
+        </el-table-column>
+        <!-- 完播率 -->
+        <el-table-column prop="completeRate" label="完播率" width="100">
+          <template slot-scope="scope">
+            {{ calculateCompleteRate(scope.row) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="answerNum" label="答题数">
+          <template slot-scope="scope">
+            {{ scope.row.answerNum || 0 }}
+          </template>
+        </el-table-column>
+        <!-- 答题率 -->
+        <el-table-column prop="answerRate" label="答题率" width="100">
+          <template slot-scope="scope">
+            {{ calculateAnswerRate(scope.row) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="redPacketNum" label="红包领取数">
+          <template slot-scope="scope">
+            {{ scope.row.redPacketNum || 0 }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="redPacketAmount" label="红包金额(元)">
+          <template slot-scope="scope">
+            {{ scope.row.redPacketAmount || 0 }}
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <el-pagination
+        @size-change="handleSizeChange"
+        @current-change="handleCurrentChange"
+        :current-page="currentPage"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="tableData.length"        style="margin-top: 20px; text-align: right;">
+      </el-pagination>
+    </div>
+
+  </div>
+</template>
+
+<script>
+import { getStatisticsData, getSearchUserInfo, getSearchCompanyInfo, getSearchDeptInfo } from "@/api/statistics/statistics";
+
+export default {
+  data() {
+    return {
+      exportLoading: false, // 添加导出加载状态
+      loading: false,
+      lastQueryDimension: null, // 记录上次查询的维度
+      companyList: [],
+      deptList: [], // 原始部门数据
+      deptTreeData: [], // 树形部门数据
+      selectedDeptIds: [], // 选中的部门ID路径
+      userList: [],
+      rawData: [],
+      tableData: [],
+      currentPage: 1,
+      pageSize: 20,
+      dateRange: [],
+      pickerOptions: {
+        shortcuts: [{
+          text: '最近一周',
+          onClick(picker) {
+            const end = new Date();
+            const start = new Date();
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+            picker.$emit('pick', [start, end]);
+          }
+        }, {
+          text: '最近一个月',
+          onClick(picker) {
+            const end = new Date();
+            const start = new Date();
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+            picker.$emit('pick', [start, end]);
+          }
+        }, {
+          text: '最近三个月',
+          onClick(picker) {
+            const end = new Date();
+            const start = new Date();
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+            picker.$emit('pick', [start, end]);
+          }
+        }]
+      },
+      deptCascaderProps: {
+        value: 'deptId',
+        label: 'deptName',
+        children: 'children',
+        expandTrigger: 'hover',
+        checkStrictly: true, // 允许选择任意一级
+        emitPath: false // 只返回选中节点的值,而不是整个路径
+      },
+      queryParams: {
+        dimension: null,
+        companyId: null,
+        deptId: null,
+        userId: null
+      }
+    };
+  },
+
+  computed: {
+    paginatedTableData() {
+      const start = (this.currentPage - 1) * this.pageSize;
+      const end = start + this.pageSize;
+      return this.tableData.slice(start, end);
+    },
+
+    showCompanySelect() {
+      // 公司维度不需要显示公司选择,其他维度都需要
+      return this.queryParams.dimension && this.queryParams.dimension !== 2;
+    },
+
+    showDepartmentSelect() {
+      // 部门维度不需要显示部门选择,个人维度需要显示
+      return this.queryParams.dimension === 1 && this.queryParams.companyId;
+    },
+
+
+
+    // 控制部门名称列显示
+    showDeptNameColumn() {
+      // 基于上次查询的维度来决定是否显示部门名称列
+      return this.lastQueryDimension && this.lastQueryDimension !== 2;
+    },
+
+    // 控制人员姓名列显示
+    showUserNameColumn() {
+      // 只有个人维度显示人员姓名列
+      return this.lastQueryDimension === 1;
+    }
+  },
+
+  mounted() {
+    // 设置默认时间为当天
+    const today = new Date();
+    this.dateRange = [today, today];
+    // 默认设置统计维度为公司
+    this.queryParams.dimension = 2;
+    this.loadData();
+    // 页面初始化时查询一次数据
+    this.fetchStatisticsData();
+  },
+
+  methods: {
+    // 在 loadData 方法中也移除自动查询
+    loadData() {
+      // 使用 getSearchCompanyInfo 获取公司下拉数据
+      getSearchCompanyInfo().then(response => {
+        this.companyList = response.data || [];
+
+        // 默认选择第一个公司(如果存在)
+        if (this.companyList.length > 0 && this.queryParams.dimension !== 2) {
+          this.queryParams.companyId = this.companyList[0].companyId;
+          // 加载该公司的部门数据
+          return this.loadDeptData(this.queryParams.companyId);
+        }
+      }).then(() => {
+        // 移除自动查询调用,只保留初始加载
+        // return this.fetchStatisticsData();
+      }).catch(error => {
+        console.error('数据加载失败:', error);
+        this.$message.error('数据加载失败');
+      });
+    },
+
+    loadDeptData(companyId) {
+      if (!companyId) return Promise.resolve();
+
+      return getSearchDeptInfo({ id: companyId }).then(response => {
+        const deptData = response.data || [];
+        this.deptList = deptData;
+
+        // 如果后端直接返回树形结构(第一层数据有children),直接使用
+        // 否则通过buildDeptTree构建树形结构
+        const hasTreeStructure = deptData.some(dept => dept.children && dept.children.length > 0);
+        if (hasTreeStructure) {
+          this.deptTreeData = deptData.filter(dept => dept.parentId === 0 || dept.parentId === null);
+        } else {
+          this.deptTreeData = this.buildDeptTree(deptData);
+        }
+
+        // 默认选择第一个部门(如果存在)
+        if (this.deptTreeData.length > 0 && this.queryParams.dimension === 1) {
+          // 选择第一个顶级部门
+          this.queryParams.deptId = this.deptTreeData[0].deptId;
+          this.selectedDeptIds = [this.queryParams.deptId];
+        }
+      }).catch(error => {
+        console.error('部门数据加载失败:', error);
+        this.$message.error('部门数据加载失败');
+      });
+    },
+
+    // 构建部门树形结构
+    buildDeptTree(deptList) {
+      if (!deptList || deptList.length === 0) return [];
+
+      // 创建部门映射
+      const deptMap = {};
+      deptList.forEach(dept => {
+        // 如果后端返回的数据中已经有children字段且有值,则使用后端的children
+        // 否则初始化为空数组
+        deptMap[dept.deptId] = {
+          ...dept,
+          children: (dept.children && dept.children.length > 0) ? dept.children : []
+        };
+      });
+
+      // 构建树形结构
+      const tree = [];
+      deptList.forEach(dept => {
+        if (dept.parentId === 0 || dept.parentId === null) {
+          // 顶级部门
+          tree.push(deptMap[dept.deptId]);
+        } else {
+          // 子部门 - 只有在后端没有返回children的情况下才手动构建
+          if (deptMap[dept.parentId] && (!dept.children || dept.children.length === 0)) {
+            deptMap[dept.parentId].children.push(deptMap[dept.deptId]);
+          }
+        }
+      });
+
+      // 清理空的children数组,保持数据结构整洁
+      const cleanEmptyChildren = (nodes) => {
+        nodes.forEach(node => {
+          if (node.children && node.children.length === 0) {
+            delete node.children;
+          } else if (node.children && node.children.length > 0) {
+            cleanEmptyChildren(node.children);
+          }
+        });
+      };
+      cleanEmptyChildren(tree);
+
+      return tree;
+    },
+
+    // 添加时间格式化方法
+    formatDateTime(dateString) {
+      if (!dateString) return '';
+      // 移除时区信息并格式化日期时间
+      const date = new Date(dateString.replace(/\.\d{3}\+\d{4}$/, ''));
+      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}`;
+    },
+
+    formatDate(date) {
+      if (!date) return '';
+      const d = new Date(date);
+      const year = d.getFullYear();
+      const month = String(d.getMonth() + 1).padStart(2, '0');
+      const day = String(d.getDate()).padStart(2, '0');
+      return `${year}-${month}-${day}`;
+    },
+
+    fetchStatisticsData() {
+      this.loading = true; // 开始请求时设置 loading 为 true
+      // 构造请求参数对象
+      const params = {
+        dimension: this.queryParams.dimension,
+        startTime: this.formatDate(this.dateRange[0]),
+        endTime: this.formatDate(this.dateRange[1])
+      };
+
+      // 根据新规则设置id参数
+      if (this.queryParams.dimension === 1 && this.queryParams.deptId) {
+        // 个人维度传递部门ID
+        params.id = this.queryParams.deptId;
+      } else if (this.queryParams.dimension === 3 && this.queryParams.companyId) {
+        // 部门维度传递公司ID
+        params.id = this.queryParams.companyId;
+      }
+      // 公司维度不传递ID参数
+
+      // 以POST方式发送请求体
+      return getStatisticsData(params).then(response => {
+        this.rawData = response.data || [];
+        this.tableData = [...this.rawData];
+        this.currentPage = 1;
+      }).catch(error => {
+        console.error('统计数据加载失败:', error);
+        this.$message.error('统计数据加载失败');
+      }).finally(() => {
+        this.loading = false; // 请求完成后设置 loading 为 false
+      });
+    },
+
+    handleCompanyChange(companyId) {
+      this.queryParams.deptId = null;
+      this.selectedDeptIds = [];
+      this.queryParams.userId = null;
+      this.deptList = [];
+      this.deptTreeData = [];
+      this.userList = [];
+
+      if (!companyId) return;
+
+      // 使用 getSearchDeptInfo 获取部门下拉数据
+      getSearchDeptInfo({ id: companyId }).then(response => {
+        const deptData = response.data || [];
+        this.deptList = deptData;
+
+        // 如果后端直接返回树形结构(第一层数据有children),直接使用
+        // 否则通过buildDeptTree构建树形结构
+        const hasTreeStructure = deptData.some(dept => dept.children && dept.children.length > 0);
+        if (hasTreeStructure) {
+          this.deptTreeData = deptData.filter(dept => dept.parentId === 0 || dept.parentId === null);
+        } else {
+          this.deptTreeData = this.buildDeptTree(deptData);
+        }
+
+        // 默认选择第一个部门(如果存在)
+        // 仅在个人维度下默认选择第一个部门
+        if (this.deptTreeData.length > 0 && this.queryParams.dimension === 1) {
+          // 选择第一个顶级部门
+          this.queryParams.deptId = this.deptTreeData[0].deptId;
+          this.selectedDeptIds = [this.queryParams.deptId];
+        }
+      }).catch(error => {
+        console.error('部门数据加载失败:', error);
+        this.$message.error('部门数据加载失败');
+      });
+      // 移除.then()后面的自动查询调用
+    },
+
+    handleDeptChange(selectedDeptId) {
+      // 更新选中的部门ID
+      this.queryParams.deptId = selectedDeptId;
+    },
+
+    handleQuery() {
+      // 记录当前查询的维度
+      this.lastQueryDimension = this.queryParams.dimension;
+      // 触发统计数据请求
+      this.fetchStatisticsData();
+    },
+
+    handleDimensionChange() {
+      // 重置后续选择项
+      this.queryParams.companyId = null;
+      this.queryParams.deptId = null;
+      this.selectedDeptIds = [];
+      this.queryParams.userId = null;
+      this.deptList = [];
+      this.deptTreeData = [];
+      this.userList = [];
+    },
+
+    resetQuery() {
+      this.queryParams = {
+        dimension: 2, // 重置为公司维度
+        companyId: null,
+        deptId: null,
+        userId: null
+      };
+      this.selectedDeptIds = []; // 重置部门选择
+      // 重置时间为当天
+      const today = new Date();
+      this.dateRange = [today, today];
+      this.deptList = [];
+      this.deptTreeData = [];
+      this.userList = [];
+      this.tableData = [...this.rawData];
+      this.currentPage = 1;
+      // 重置后立即发送请求
+      this.lastQueryDimension = 2; // 同时更新lastQueryDimension
+      this.fetchStatisticsData();
+    },
+
+    handleSizeChange(val) {
+      this.pageSize = val;
+      this.currentPage = 1;
+    },
+
+    handleCurrentChange(val) {
+      this.currentPage = val;
+    },
+
+    // 计算完播率:完课数 / 发送数
+    calculateCompleteRate(row) {
+      const sendCount = row.sendCount || 0;
+      const completeNum = row.completeNum || 0;
+
+      if (sendCount === 0) {
+        return '0%';
+      }
+
+      const rate = (completeNum / sendCount * 100).toFixed(2);
+      return rate + '%';
+    },
+
+    // 计算答题率:答题数 / 完课数
+    calculateAnswerRate(row) {
+      const completeNum = row.completeNum || 0;
+      const answerNum = row.answerNum || 0;
+
+      if (completeNum === 0) {
+        return '0%';
+      }
+
+      const rate = (answerNum / completeNum * 100).toFixed(2);
+      return rate + '%';
+    },
+    // 添加导出方法
+    handleExport() {
+      if (this.tableData.length === 0) {
+        this.$message.warning('没有可导出的数据');
+        return;
+      }
+
+      this.exportLoading = true;
+
+      try {
+        // 创建 CSV 内容
+        const headers = [
+          '公司名称', '部门名称', '人员名称',
+          '发课数', '完课数', '完播率', '答题数', '答题率',
+          '红包领取数', '红包金额(元)'
+        ];
+
+        const csvContent = [
+          headers.join(','),
+          ...this.tableData.map(row => [
+            row.companyName || '',
+            row.deptName || '',
+            row.companyUserName || '',
+            row.sendCount || 0,
+            row.completeNum || 0,
+            this.calculateCompleteRate(row),
+            row.answerNum || 0,
+            this.calculateAnswerRate(row),
+            row.redPacketNum || 0,
+            row.redPacketAmount || 0
+          ].map(field => `"${field}"`).join(','))
+        ].join('\n');
+
+        // 创建下载链接
+        const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
+        const link = document.createElement('a');
+        const url = URL.createObjectURL(blob);
+
+        link.setAttribute('href', url);
+
+        // link.setAttribute('download', `综合统计看板_${new Date().toISOString().slice(0, 10)}.csv`);
+        // 修改为:
+        const now = new Date();
+        const timestamp = now.getFullYear() +
+          String(now.getMonth() + 1).padStart(2, '0') +
+          String(now.getDate()).padStart(2, '0') +
+          String(now.getHours()).padStart(2, '0') +
+          String(now.getMinutes()).padStart(2, '0') +
+          String(now.getSeconds()).padStart(2, '0');
+        link.setAttribute('download', `综合统计看板_${timestamp}.csv`);
+        link.style.visibility = 'hidden';
+        document.body.appendChild(link);
+        link.click();
+        document.body.removeChild(link);
+
+        this.$message.success('导出成功');
+      } catch (error) {
+        console.error('导出失败:', error);
+        this.$message.error('导出失败');
+      } finally {
+        this.exportLoading = false;
+      }
+    }
+  }
+};
+</script>
+
+<style scoped>
+.app-container {
+  border: 1px solid #e6e6e6;
+  padding: 12px;
+  background-color: #f5f7fa;
+}
+
+.app-content {
+  background-color: white;
+  padding: 20px;
+  border-radius: 4px;
+  margin-bottom: 20px;
+}
+
+.title {
+  text-align: center;
+  font-size: 24px;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 20px;
+}
+
+.search-form {
+  margin-bottom: 0;
+}
+
+.search-form .el-form-item {
+  margin-bottom: 18px;
+  width: 100%;
+}
+
+.search-form .el-row {
+  margin-left: 0 !important;
+  margin-right: 0 !important;
+}
+
+.table-section {
+  background-color: white;
+  padding: 20px;
+  border-radius: 4px;
+}
+
+.table-section .el-table {
+  width: 100% !important;
+}
+
+@media (min-width: 1200px) {
+  .table-section {
+    padding: 20px 50px;
+  }
+}
+</style>

+ 435 - 0
src/views/his/storeActivity/index.vue

@@ -0,0 +1,435 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="活动标题" prop="title">
+        <el-input
+          v-model="queryParams.title"
+          placeholder="请输入活动标题"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="cyan" 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-hasPermi="['store:storeActivity:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['store:storeActivity:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['store:storeActivity:remove']"
+        >删除</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">
+      <el-tab-pane label="正常" name="1"></el-tab-pane>
+      <el-tab-pane label="关闭" name="0"></el-tab-pane>
+    </el-tabs>
+
+    <el-table  height="500" border v-loading="loading" :data="storeActivityList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="ID" align="center" prop="activityId" />
+      <el-table-column label="活动标题" align="center" prop="title" />
+      <!-- <el-table-column label="描述" show-overflow-tooltip align="center" prop="descs" /> -->
+
+      <el-table-column label="弹框广告图" align="center" width="120">
+        <template slot-scope="scope">
+          <el-popover
+            placement="right"
+            title=""
+            trigger="hover"
+          >
+            <img slot="reference" :src="scope.row.logoUrl" width="100">
+            <img :src="scope.row.logoUrl" style="max-width: 150px;">
+          </el-popover>
+        </template>
+      </el-table-column>
+      <el-table-column label="分享数" align="center" prop="shareNumber" />
+      <el-table-column label="状态" align="center" prop="status" >
+          <template slot-scope="scope">
+              <el-tag prop="status" v-for="(item, index) in statusOptions"    v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
+          </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['store:storeActivity:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['store:storeActivity: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="800px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="标题" prop="title">
+          <el-input v-model="form.title" placeholder="请输入标题" />
+        </el-form-item>
+        <!-- <el-form-item label="描述" prop="descs">
+          <el-input v-model="form.descs" type="textarea" placeholder="请输入内容" />
+        </el-form-item> -->
+        <el-form-item label="弹框广告图" prop="logoUrl">
+          <Material v-model="imageArr" type="image" :num="1" :width="150" :height="150" />
+        </el-form-item>
+        <el-form-item label="BANNER图" prop="images">
+          <Material v-model="photoArr" type="image" :num="10" :width="150" :height="150" />
+        </el-form-item>
+        <el-form-item label="活动疗法" prop="productIds"  >
+              <el-row  >
+                <el-col >
+                      <el-button plain  type="primary" icon="el-icon-plus" @click="handleAddPackage">添加疗法</el-button>
+                </el-col>
+              </el-row>
+              <el-table border width="100%" style="margin-top:5px;"  :data="packages">
+                <el-table-column label="疗法ID" align="center" prop="packageId" />
+                <el-table-column label="疗法图片" align="center" width="100">
+                  <template slot-scope="scope">
+                    <el-popover
+                      placement="right"
+                      title=""
+                      trigger="hover"
+                    >
+                      <img slot="reference" :src="scope.row.imgUrl" width="50">
+                      <img :src="scope.row.imgUrl" style="max-width: 50px;">
+                    </el-popover>
+                  </template>
+                </el-table-column>
+                <el-table-column label="疗法名称" show-overflow-tooltip align="center" prop="packageName" />
+                <el-table-column label="售价" align="center"  prop="price"  >
+                   <template slot-scope="scope">
+                    <div v-if="scope.row.totalPrice!=null">
+                         {{scope.row.totalPrice.toFixed(2)}}
+                    </div>
+                  </template>
+                </el-table-column>
+                <el-table-column label="操作" align="center" width="100px" >
+                  <template slot-scope="scope">
+                    <el-button
+                      size="mini"
+                      type="text"
+                      icon="el-icon-delete"
+                      @click="handlePackageDelete(scope.row)"
+                    >删除</el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+        </el-form-item>
+        <el-form-item label="活动内容">
+          <editor ref="myeditor"   @on-text-change="updateText" />
+        </el-form-item>
+        <el-form-item label="状态">
+          <el-radio-group v-model="form.status">
+            <el-radio label="1">正常</el-radio>
+            <el-radio label="0">关闭</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+    <el-dialog :title="package.title" v-if="package.open"  :visible.sync="package.open" width="1000px" append-to-body>
+        <package-select  ref="package"  @selectPackage="selectPackage" />
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listStoreActivity, getStoreActivity, delStoreActivity, addStoreActivity, updateStoreActivity, exportStoreActivity } from "@/api/his/storeActivity";
+import Material from '@/components/Material'
+import singleImg from '@/components/Material/single'
+import Editor from '@/components/Editor/wang';
+
+import packageSelect from "./packageSelect";
+
+export default {
+  name: "StoreActivity",
+  components: {
+    packageSelect,
+    Editor,
+    Material,
+    singleImg,
+  },
+  watch: {
+    imageArr: function(val) {
+      this.form.logoUrl = val.join(',')
+    },
+    photoArr: function(val) {
+      this.form.images = val.join(',')
+    },
+  },
+  data() {
+    return {
+      photoArr:[],
+      packages:[],
+      package:{
+        open:false,
+        title:"疗法选择"
+      },
+      statusOptions:[],
+      imageArr:[],
+      activeName:"1",
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 活动表格数据
+      storeActivityList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        title: null,
+        descs: null,
+        logoUrl: null,
+        images: null,
+        productIds: null,
+        content: null,
+        status: null
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+      }
+    };
+  },
+  created() {
+    this.getDicts("common_status").then((response) => {
+      this.statusOptions = response.data;
+    });
+
+    this.getList();
+  },
+  methods: {
+    selectPackage(row){
+      for(var i=0;i<this.packages.length;i++){
+        this.$message.warning('该疗法已存在,无需重复添加!');
+        if(this.packages[i].packageId==row.packageId){
+          return;
+        }
+      }
+      this.packages.push(row);
+      this.$message.success('疗法'+row.packageName+'添加成功!');
+    },
+    handleAddPackage(){
+      this.package.open=true;
+    },
+    handlePackageDelete(row){
+       this.packages.splice(this.packages.findIndex(item => item.packageId === row.packageId), 1)
+    },
+    updateText(text){
+      this.form.content=text
+    },
+    handleClick(tab, event) {
+      this.queryParams.status=tab.name;
+      this.getList();
+    },
+    /** 查询活动列表 */
+    getList() {
+      this.loading = true;
+      listStoreActivity(this.queryParams).then(response => {
+        this.storeActivityList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        activityId: null,
+        title: null,
+        descs: null,
+        logoUrl: null,
+        images: null,
+        packageIds: null,
+        productIds: null,
+        content: null,
+        createTime: null,
+        status: "1"
+      };
+      this.imageArr=[];
+      this.photoArr=[];
+      this.packages=[];
+      this.packages=[];
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.activityId)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加活动";
+      setTimeout(() => {
+        this.$refs.myeditor.setText("");
+      }, 200);
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const activityId = row.activityId || this.ids
+      getStoreActivity(activityId).then(response => {
+        this.form = response.activity;
+        this.form.status=this.form.status.toString();
+        if(this.form.logoUrl!=null){
+          this.imageArr=this.form.logoUrl.split(',');
+        }
+        if(this.form.images!=null){
+          this.photoArr=this.form.images.split(',');
+        }
+        this.packages=response.packages;
+        this.open = true;
+        this.title = "修改活动";
+        setTimeout(() => {
+          if(this.form.content==null){
+            this.$refs.myeditor.setText("");
+          }
+          else{
+            this.$refs.myeditor.setText(this.form.content);
+          }
+        }, 200);
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          var packageIds=[];
+          if (this.packages && this.packages.length>0) {
+            this.packages.forEach(element => {
+              packageIds.push(element.packageId);
+            });
+            // this.form.packageIds=packageIds.toString();
+            this.form.productIds = packageIds.toString();
+          } else {
+            this.form.productIds = "";
+          }
+          if (this.form.activityId != null) {
+            updateStoreActivity(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          } else {
+            addStoreActivity(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("新增成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const activityIds = row.activityId || this.ids;
+      this.$confirm('是否确认删除活动编号为"' + activityIds + '"的数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return delStoreActivity(activityIds);
+        }).then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        }).catch(function() {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm('是否确认导出所有活动数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return exportStoreActivity(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+        }).catch(function() {});
+    }
+  }
+};
+</script>

+ 119 - 0
src/views/his/storeActivity/packageSelect.vue

@@ -0,0 +1,119 @@
+<template>
+  <div class="product-select" >
+    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
+      <el-form-item label="商品名称" prop="productName">
+        <el-input
+          style="width:200px"
+          v-model="queryParams.packageName"
+          placeholder="请输入商品名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+      </el-form-item>
+    </el-form>
+    <el-table height="600" v-loading="loading" border :data="list" >
+      <el-table-column label="ID" align="center" prop="packageId" />
+      <el-table-column label="套餐包名称" align="center" prop="packageName" />
+      <el-table-column label="疗法图片" align="center" prop="imgUrl">
+        <template slot-scope="scope">
+            <img :src="scope.row.imgUrl" style="height: 80px;">
+        </template>
+      </el-table-column>
+      <el-table-column label="别名" align="center" prop="secondName" />
+      <el-table-column label="类型" align="center" prop="packageType">
+        <template slot-scope="scope">
+          <dict-tag :options="packageTypeOptions" :value="scope.row.packageType"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="子类型" align="center" prop="packageSubType">
+        <template slot-scope="scope">
+          <dict-tag :options="packageSubTypeOptions" :value="scope.row.packageSubType"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            @click="handleSelect(scope.row)"
+          >选择
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <pagination
+      style="padding-bottom:10px;"
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+// import { listPackage } from "@/api/his/package";
+import { listPackage } from '../../../api/his/package'
+
+export default {
+  name: "selectPackage",
+  data() {
+    return {
+      loading: true,
+      list:[],
+      packageTypeOptions:[],
+      packageSubTypeOptions:[],
+      total: 0,
+      queryParams: {
+        packageName:"",
+        secondName:"",
+        status:1,
+        isShow:1,
+        pageNum: 1,
+        pageSize: 10,
+      }
+    };
+  },
+  created() {
+    this.getList();
+    this.getDicts("sys_package_type").then(response => {
+      this.packageTypeOptions = response.data;
+    });
+    this.getDicts("sys_package_sub_type").then(response => {
+      this.packageSubTypeOptions = response.data;
+    });
+  },
+  methods: {
+    handleSelect(row){
+      this.$emit('selectPackage',row);
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    getDetails(){
+      this.getList();
+    },
+    getList(){
+      this.loading = true;
+      listPackage(this.queryParams).then(response => {
+        this.list = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    }
+  }
+};
+</script>
+<style scoped>
+
+.product-select{
+  padding-bottom: 15px;
+}
+</style>

+ 1 - 0
src/views/his/user/index.vue

@@ -499,6 +499,7 @@ export default {
         this.title = "修改用户";
         this.form.status = String(this.form.status)
         this.form.level = String(this.form.level)
+        this.form.isPromoter = String(this.form.isPromoter)
 
       });
     },

+ 1 - 1
src/views/hisStore/components/productAfterSalesOrder.vue

@@ -336,7 +336,7 @@ export default {
     handleRefund(){
         this.audit.open=true;
         this.form.salesId=this.afterSales.id;
-        this.form.refundAmount=this.afterSales.refundAmount;
+        this.form.refundAmount=this.order.payMoney;
     },
     submitAuditForm() {
       this.$refs["form"].validate(valid => {

+ 2 - 2
src/views/live/live/index.vue

@@ -305,7 +305,7 @@
         </el-form-item>
         <el-form-item label="直播类型" prop="liveType">
           <el-radio-group v-model="form.liveType">
-            <el-radio :label="1">直播</el-radio>
+<!--            <el-radio :label="1">直播</el-radio>-->
             <el-radio :label="2">录播</el-radio>
           </el-radio-group>
         </el-form-item>
@@ -432,7 +432,7 @@ import {
 } from "@/api/live/live";
 import Editor from '@/components/Editor/wang';
 import user from '@/store/modules/user';
-import VideoUpload from "@/components/VideoUpload/index.vue";
+import VideoUpload from "@/components/LiveVideoUpload/single.vue";
 
 export default {
   name: "Live",

+ 17 - 0
src/views/live/liveConfig/index.vue

@@ -133,7 +133,9 @@ export default {
       activeTab: 'watchReward',
       liveId: null,
       liveInfo: {},
+      socket:null,
       currentComponent: WatchReward,
+      liveWsUrl: process.env.VUE_APP_LIVE_WS_URL + '/app/webSocket',
       menuList:[
         { name: '观看奖励', label: '观看奖励', index: 'watchReward'},
         { name: '直播预告', label: '直播预告', index: 'preview'},
@@ -154,8 +156,23 @@ export default {
   created() {
     this.liveId = this.$route.params.liveId
     this.getLiving()
+    this.connectWebSocket()
+  },
+  computed: {
+    userId() {
+      return this.$store.state.user.user.userId
+    },
   },
   methods: {
+    connectWebSocket() {
+      this.$store.dispatch('initLiveWs', {
+        liveWsUrl: this.liveWsUrl,
+        liveId: this.liveId,
+        userId: this.userId
+      })
+      this.socket = this.$store.state.liveWs[this.liveId]
+      this.socket.onmessage = (event) => this.handleWsMessage(event)
+    },
     handleSelect(index){
       this.currentComponent = index; // 切换当前显示的组件
     },

+ 25 - 0
src/views/live/liveConfig/liveCoupon.vue

@@ -45,6 +45,16 @@
         prop="couponTime"
         label="优惠券有效时间"
       ></el-table-column>
+
+      <el-table-column
+        prop="type"
+        label="优惠券类型"
+      >
+        <template slot-scope="scope">
+          <dict-tag :options="couponTypeOptions" :value="scope.row.type"/>
+        </template>
+      </el-table-column>
+
       <el-table-column
         prop="productName"
         label="绑定直播商品"
@@ -150,6 +160,15 @@
             label="优惠券有效时间"
             class-name="clickable-column"
           ></el-table-column>
+          <el-table-column
+            prop="type"
+            label="优惠券类型"
+            class-name="clickable-column"
+          >
+            <template slot-scope="scope">
+              <dict-tag :options="couponTypeOptions" :value="scope.row.type"/>
+            </template>
+          </el-table-column>
         </el-table>
 
         <pagination
@@ -236,6 +255,7 @@ export default {
       },
       couponLiveList: [],
       couponLiveTotal: 0,
+      couponTypeOptions: [],
       couponParams: {
         pageNum: 1,
         pageSize: 10,
@@ -305,6 +325,11 @@ export default {
     // this.goodsParams.liveId = this.liveId
     // this.getLiveGoodsList();
     // this.socket = this.$store.state.liveWs[this.liveId]
+
+    // 获取优惠券类型字典
+    this.getDicts("store_coupon_type").then((response) => {
+      this.couponTypeOptions = response.data;
+    });
   },
   methods: {
     handleGoodsChange(row){

+ 55 - 0
src/views/live/liveConfig/task.vue

@@ -209,6 +209,26 @@
             </div>
           </el-select>
         </el-form-item>
+        <el-form-item label="商品选择" prop="goodsId" v-if="form.taskType == 6">
+          <el-select v-model="form.goodsId" placeholder="请选择商品" ref="selectGoods" >
+            <el-option v-for="i in productOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            <!-- 加载载中状态 -->
+            <div v-if="isLoading" class="loading-indicator">
+              <i class="el-icon-loading"></i>
+              <span>加载中...</span>
+            </div>
+
+            <!-- 没有更多数据 -->
+            <div v-if="!hasMore && !isLoading" class="no-more">
+              没有更多数据了
+            </div>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="上下架状态" prop="goodsStatus" v-if="form.taskType == 6">
+          <el-select v-model="form.goodsStatus" placeholder="请选择上下架状态">
+            <el-option v-for="i in goodsStatusOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="触发时间" prop="content">
           <el-time-picker
             default-value="2025-01-01 00:00:00"
@@ -273,6 +293,10 @@ export default {
         {
           value: 5,
           label: "定时优惠券"
+        },
+        {
+          value: 6,
+          label: "定时商品上下架"
         }
       ],
       statusOptions:[{
@@ -284,6 +308,15 @@ export default {
           label: "启用"
         }
       ],
+      goodsStatusOptions:[{
+        value: 0,
+        label: "下架"
+      },
+        {
+          value: 1,
+          label: "上架"
+        }
+      ],
       haveData:{
         goods:false,
         red:false,
@@ -420,6 +453,8 @@ export default {
           return "定时抽奖";
         case 5:
           return "定时优惠券";
+        case 6:
+          return "定时商品上下架";
         default:
           return "--";
       }
@@ -492,6 +527,8 @@ export default {
           await this.addLotteryList();
         }else if(this.form.taskType == 5){
           await this.addCouponList();
+        }else if(this.form.taskType == 6){
+          await this.addGoodsList();
         }
       }catch ( err){
         console.error('加载数据失败:', err);
@@ -629,6 +666,8 @@ export default {
         triggerType: null,
         triggerValue: null,
         content: null,
+        goodsId: null,
+        goodsStatus: null,
         status: 1,
         createdTime: null,
         updatedTime: null
@@ -674,6 +713,8 @@ export default {
         await this.addLotteryList();
       }else if(row.taskType == 5) {
         await this.addCouponList();
+      }else if(row.taskType == 6) {
+        await this.addGoodsList();
       }
       const id = row.id || this.ids
       getTask(id).then(response => {
@@ -687,6 +728,9 @@ export default {
           this.form.content = content.desc;
         }else if(this.form.taskType == 5){
           this.form.content = content.couponId;
+        }else if(this.form.taskType == 6){
+          this.form.goodsId = content.goodsId;
+          this.form.goodsStatus = content.status;
         }
         this.open = true;
         this.title = "修改直播间自动化任务配置";
@@ -699,6 +743,17 @@ export default {
         this.msgError("请选择直播间");
         return;
       }
+      if(this.form.taskType == 6){
+        if(this.form.goodsId == null) {
+          this.msgError("请选择商品");
+          return;
+        }
+        this.form.content = JSON.stringify({
+          goodsId: this.form.goodsId,
+          status: this.form.goodsStatus
+        })
+
+      }
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.id != null) {

+ 68 - 0
src/views/live/liveConsole/LiveConsole.vue

@@ -169,6 +169,7 @@
         <div class="message-actions">
           <button @click="sendMessage">发送消息</button>
           <button @click="sendPopMessage">弹窗消息</button>
+          <button @click="showTopMsgDialog">顶部消息</button>
         </div>
       </div>
     </div>
@@ -214,6 +215,33 @@
       </div>
     </div>
 
+    <!-- 顶部消息对话框 -->
+    <el-dialog title="发送顶部消息" :visible.sync="topMsgDialogVisible" width="500px">
+      <el-form :model="topMsgForm" label-width="100px">
+        <el-form-item label="消息内容">
+          <el-input
+            type="textarea"
+            v-model="topMsgForm.msg"
+            placeholder="请输入消息内容"
+            :rows="3"
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="显示时长">
+          <el-input-number
+            v-model="topMsgForm.duration"
+            :min="1"
+            :max="60"
+            placeholder="请输入显示时长(分钟)"
+          ></el-input-number>
+          <span style="margin-left: 10px;">分钟</span>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="topMsgDialogVisible = false">取 消</el-button>
+        <el-button type="primary" @click="sendTopMessage">确 定</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -357,6 +385,11 @@ export default {
       newMsg:'',
       autoMsgTimer: null,
       checkInterval: 2000, // 检查间隔(1分钟,可根据需求调整)
+      topMsgDialogVisible: false,
+      topMsgForm: {
+        msg: '',
+        duration: 5
+      }
     };
   },
   computed: {
@@ -494,6 +527,41 @@ export default {
 
       this.newMsg = '';
     },
+    // 显示顶部消息对话框
+    showTopMsgDialog() {
+      this.topMsgForm.msg = '';
+      this.topMsgForm.duration = 5;
+      this.topMsgDialogVisible = true;
+    },
+    // 发送顶部消息
+    sendTopMessage() {
+      // 发送前简单校验
+      if (this.topMsgForm.msg.trim() === '') {
+        this.$message.warning('请输入消息内容');
+        return;
+      }
+
+      if (!this.topMsgForm.duration || this.topMsgForm.duration < 1) {
+        this.$message.warning('请输入有效的显示时长');
+        return;
+      }
+
+      let msg = {
+        msg: this.topMsgForm.msg,
+        duration: this.topMsgForm.duration,
+        liveId: this.liveId,
+        userId: this.userId,
+        userType: 1,
+        cmd: 'sendTopMsg',
+        avatar: this.$store.state.user.user.avatar,
+        nickName: this.$store.state.user.user.nickName,
+      }
+
+      this.socket.send(JSON.stringify(msg))
+
+      this.topMsgDialogVisible = false;
+      this.$message.success('顶部消息发送成功');
+    },
     sendMessage() {
       // 发送前简单校验
       if (this.newMsg.trim() === '') {

+ 108 - 19
src/views/live/liveConsole/LiveDashboard.vue

@@ -7,6 +7,10 @@
         <div class="card" v-for="item in dataCards" :key="item.title">
           <h3>{{ item.title }}</h3>
           <p class="value">{{ item.value }}</p>
+          <div class="sub-values" v-if="item.subValues">
+            <span class="sub-item">直播: {{ item.subValues.live }}</span>
+            <span class="sub-item">回放: {{ item.subValues.replay }}</span>
+          </div>
         </div>
       </div>
 
@@ -15,12 +19,12 @@
         <!-- 左侧用户分析区(占50%宽度) -->
         <div class="user-analysis">
           <div class="new-old">
-            <h3>新老用户占比</h3>
-            <EChartsComponent chartId="newOldChart" :option="newOldOption" />
+            <h3>直播新老用户占比</h3>
+            <EChartsComponent chartId="liveNewOldChart" :option="liveNewOldOption" />
           </div>
           <div class="region">
-            <h3>地域访客</h3>
-            <EChartsComponent chartId="regionChart" :option="regionOption" />
+            <h3>回放新老用户占比</h3>
+            <EChartsComponent chartId="replayNewOldChart" :option="replayNewOldOption" />
           </div>
         </div>
 
@@ -69,16 +73,36 @@ export default {
     return {
       // 数据保持不变(与原代码一致)
       dataCards: [
-        { title: '在线人数', value: '2.5k' },
-        { title: '观看人次', value: '15.2k' },
-        { title: '点赞数', value: '12.8k' },
-        { title: '评论数', value: '3.2k' }
+        { title: '在线人数', value: 0 },
+        { 
+          title: '观看人次', 
+          value: 0,
+          subValues: { live: 0, replay: 0 }
+        },
+        { 
+          title: '点赞数', 
+          value: 0,
+          subValues: { live: 0, replay: 0 }
+        },
+        { 
+          title: '评论数', 
+          value: 0,
+          subValues: { live: 0, replay: 0 }
+        }
       ],
-      newOldOption: {
+      liveNewOldOption: {
         tooltip: { trigger: 'item' },
         series: [{
           type: 'pie', radius: '70%',
-          data: [{ value: 65, name: '新用户' }, { value: 35, name: '老用户' }],
+          data: [{ value: 0, name: '新用户' }, { value: 0, name: '老用户' }],
+          itemStyle: { colors: ['#36cfc9', '#722ed1'] }
+        }]
+      },
+      replayNewOldOption: {
+        tooltip: { trigger: 'item' },
+        series: [{
+          type: 'pie', radius: '70%',
+          data: [{ value: 0, name: '新用户' }, { value: 0, name: '老用户' }],
           itemStyle: { colors: ['#36cfc9', '#722ed1'] }
         }]
       },
@@ -202,29 +226,80 @@ export default {
       });
     },
     dealData(data){
+      // 计算总计
+      const totalViewNum = (data.liveViewNum || 0) + (data.replayViewNum || 0);
+      const totalLikeNum = (data.liveLikeNum || 0) + (data.replayLikeNum || 0);
+      const totalCommentNum = (data.liveCommentNum || 0) + (data.replayCommentNum || 0);
+      
       this.dataCards = [
-        { title: '在线人数', value: data.onlineNum },
-        { title: '观看人次', value: data.viewNum },
-        { title: '点赞数', value: data.likeNum },
-        { title: '评论数', value: data.commentNum }
+        { title: '在线人数', value: data.onlineNum || 0 },
+        { 
+          title: '观看人次', 
+          value: totalViewNum,
+          subValues: { 
+            live: data.liveViewNum || 0, 
+            replay: data.replayViewNum || 0 
+          }
+        },
+        { 
+          title: '点赞数', 
+          value: totalLikeNum,
+          subValues: { 
+            live: data.liveLikeNum || 0, 
+            replay: data.replayLikeNum || 0 
+          }
+        },
+        { 
+          title: '评论数', 
+          value: totalCommentNum,
+          subValues: { 
+            live: data.liveCommentNum || 0, 
+            replay: data.replayCommentNum || 0 
+          }
+        }
       ]
-      this.newOldOption= {
+      
+      // 直播新老用户占比
+      this.liveNewOldOption = {
+        tooltip: { trigger: 'item' },
+        series: [{
+          type: 'pie', radius: '70%',
+          data: [
+            { value: data.liveNewUserNum || 0, name: '新用户' }, 
+            { value: data.liveOldUserNum || 0, name: '老用户' }
+          ],
+          itemStyle: { colors: ['#36cfc9', '#722ed1'] }
+        }]
+      }
+      
+      // 回放新老用户占比
+      this.replayNewOldOption = {
         tooltip: { trigger: 'item' },
         series: [{
           type: 'pie', radius: '70%',
-          data: [{ value: data.newUserNum, name: '新用户' }, { value: data.oldUserNum, name: '老用户' }],
+          data: [
+            { value: data.replayNewUserNum || 0, name: '新用户' }, 
+            { value: data.replayOldUserNum || 0, name: '老用户' }
+          ],
           itemStyle: { colors: ['#36cfc9', '#722ed1'] }
         }]
       }
+      
+      // 观众来源
       this.sourceOption = {
         tooltip: { trigger: 'item' },
         series: [{
           type: 'pie', radius: '70%',
-          data: [{ value: data.shareUrlNum, name: '分享链接' }, { value: data.directAccessNum, name: '直接访问' }, { value: 0, name: '其他' }],
-          itemStyle: { colors: ['#3b82f6', '#10b981', '#f59e0b'] }
+          data: [
+            { value: data.shareUrlNum || 0, name: '分享链接' }, 
+            { value: data.directAccessNum || 0, name: '直接访问' }
+          ],
+          itemStyle: { colors: ['#3b82f6', '#10b981'] }
         }]
       }
-      this.rankList = data.inviteUserList;
+      
+      // 邀请用户列表
+      this.rankList = data.inviteUserList || [];
     },
   }
 };
@@ -282,6 +357,20 @@ export default {
   margin: 0;
 }
 
+.card .sub-values {
+  display: flex;
+  justify-content: space-around;
+  margin-top: 10px;
+  font-size: 0.8vw;
+  color: #94a3b8;
+}
+
+.card .sub-item {
+  padding: 3px 8px;
+  background: rgba(54, 207, 201, 0.1);
+  border-radius: 4px;
+}
+
 /* 中间内容区:高度40%,左右分栏 */
 .middle-content {
   width: 100%;

+ 15 - 1
src/views/live/liveCoupon/index.vue

@@ -91,6 +91,12 @@
       <el-table-column label="优惠券面值" align="center" prop="couponPrice" />
       <el-table-column label="最低消费" align="center" prop="useMinPrice" />
       <el-table-column label="优惠券有效期限(天)" align="center" prop="couponTime" />
+      <el-table-column label="是否无门槛" align="center" prop="isNoThreshold">
+        <template slot-scope="scope">
+          <span>{{ scope.row.isNoThreshold == 1 ? '是' : '否' }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="限制领取次数" align="center" prop="limitReceiveCount" />
       <el-table-column label="排序" align="center" prop="sort" />
       <el-table-column label="类型" align="center" prop="type" >
           <template slot-scope="scope">
@@ -171,6 +177,9 @@
             </el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="限制领取次数" prop="limitReceiveCount" v-if=" form.type==3">
+          <el-input-number v-model="form.limitReceiveCount"  :min="1"  label="请输入限制领取次数"></el-input-number>
+        </el-form-item>
         <el-form-item label="状态">
             <el-radio-group v-model="form.status">
               <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
@@ -381,7 +390,9 @@ export default {
         packageCateIds:[],
         createTime: null,
         updateTime: null,
-        isDel: null
+        isDel: null,
+        isNoThreshold: 0,
+        limitReceiveCount: 1,
       };
       this.resetForm("form");
     },
@@ -429,6 +440,9 @@ export default {
           if(this.form.packageCateIds!=null){
             this.form.packageCateIds=this.form.packageCateIds.toString();
           }
+          if(this.form.type==3){
+            this.form.isNoThreshold = 1
+          }
           if (this.form.couponId != null) {
             updateStoreCoupon(this.form).then(response => {
               if (response.code === 200) {

+ 1 - 1
src/views/live/liveCouponIssue/index.vue

@@ -65,7 +65,7 @@
       <el-table-column label="最低消费" align="center" prop="useMinPrice" />
       <el-table-column label="优惠券有效期限(天)" align="center" prop="couponTime" />
       <el-table-column label="总数量" align="center" prop="totalCount" />
-      <el-table-column label="领取数量" align="center" prop="remainCount" />
+      <el-table-column label="领取数量" align="center" prop="remainCount" />
       <el-table-column label="类型" align="center" prop="couponType" >
           <template slot-scope="scope">
               <el-tag prop="couponType" v-for="(item, index) in couponTypeOptions"    v-if="scope.row.couponType==item.dictValue">{{item.dictLabel}}</el-tag>

+ 117 - 136
src/views/live/liveOrder/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
       <el-form-item label="公司名" prop="companyId">
         <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名" @change="companyChange" clearable size="small">
           <el-option
@@ -15,122 +15,98 @@
       <el-form-item>
         <treeselect style="width: 220px" :clearable="false" v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
       </el-form-item>
-      <el-form-item label="订单号" prop="orderCode">
+
+      <el-form-item label="商品名称" prop="productName">
         <el-input
-          v-model="queryParams.orderCode"
-          placeholder="请输入订单号"
+          v-model="queryParams.productName"
+          placeholder="请输入商品名称"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="用户ID" prop="userId">
+
+      <el-form-item label="商品规格" prop="productSpec">
         <el-input
-          v-model="queryParams.userId"
-          placeholder="请输入用户ID"
+          v-model="queryParams.productSpec"
+          placeholder="请输入商品规格"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="收货人" prop="userName">
+
+      <el-form-item label="商品数量" prop="totalNum">
         <el-input
-          v-model="queryParams.userName"
-          placeholder="请输入收货人"
+          v-model="queryParams.totalNum"
+          placeholder="请输入商品数量"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="手机号" prop="userPhone">
+
+      <el-form-item label="销售价格" prop="price">
         <el-input
-          v-model="queryParams.userPhone"
-          placeholder="请输入手机号"
+          v-model="queryParams.price"
+          placeholder="请输入销售价格"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="地址" prop="userAddress">
+
+      <el-form-item label="收货地址" prop="userAddress">
         <el-input
           v-model="queryParams.userAddress"
-          placeholder="请输入地址"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="支付金额" prop="payMoney">
-        <el-input
-          v-model="queryParams.payMoney"
-          placeholder="请输入支付金额"
+          placeholder="请输入收货地址"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="订单金额" prop="totalPrice">
-        <el-input
-          v-model="queryParams.totalPrice"
-          placeholder="请输入订单金额"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="物流编号" prop="deliveryCode">
+
+      <el-form-item label="商品ID" prop="productId">
         <el-input
-          v-model="queryParams.deliveryCode"
-          placeholder="请输入物流编号"
+          v-model="queryParams.productId"
+          placeholder="请输入商品ID"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="物流名称" prop="deliveryName">
+
+      <el-form-item label="成本价格" prop="cost">
         <el-input
-          v-model="queryParams.deliveryName"
-          placeholder="请输入物流名称"
+          v-model="queryParams.cost"
+          placeholder="请输入成本价格"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="物流单号" prop="deliverySn">
+
+      <el-form-item label="供应商" prop="supplierName">
         <el-input
-          v-model="queryParams.deliverySn"
-          placeholder="请输入物流单号"
+          v-model="queryParams.supplierName"
+          placeholder="请输入供应商名称"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
 
-      <!-- 修改支付时间为范围选择 -->
-      <el-form-item label="支付时间" prop="payTimeRange">
+      <!-- 下单时间范围选择 -->
+      <el-form-item label="下单时间" prop="orderTimeRange">
         <el-date-picker
-          v-model="payTimeRange"
+          v-model="orderTimeRange"
           type="daterange"
           range-separator="至"
           start-placeholder="开始日期"
           end-placeholder="结束日期"
           value-format="yyyy-MM-dd"
           size="small"
-          @change="handlePayTimeChange"
-        />
-      </el-form-item>
-
-      <!-- 修改完成时间为范围选择 -->
-      <el-form-item label="完成时间" prop="finishTimeRange">
-        <el-date-picker
-          v-model="finishTimeRange"
-          type="daterange"
-          range-separator="至"
-          start-placeholder="开始日期"
-          end-placeholder="结束日期"
-          value-format="yyyy-MM-dd"
-          size="small"
-          @change="handleFinishTimeChange"
+          @change="handleOrderTimeChange"
         />
       </el-form-item>
 
@@ -162,40 +138,59 @@
 
     <el-table border v-loading="loading" :data="liveOrderList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="订单号" align="center" prop="orderCode" />
-      <el-table-column label="所属公司" align="center" prop="companyName" />
-      <el-table-column label="所属员工" align="center" prop="companyUserName" />
-      <el-table-column label="用户ID" align="center" prop="userId" />
-      <el-table-column label="收货人" align="center" prop="userName" />
-      <el-table-column label="手机号" align="center" prop="userPhone" />
-      <el-table-column label="地址" align="center" prop="userAddress" />
-      <el-table-column label="支付金额" align="center" prop="payMoney" />
-      <el-table-column label="订单金额" align="center" prop="totalPrice" />
-      <el-table-column label="物流编号" align="center" prop="deliveryCode" />
-      <el-table-column label="物流名称" align="center" prop="deliveryName" />
-      <el-table-column label="物流单号" align="center" prop="deliverySn" />
-      <el-table-column label="物流状态" align="center" prop="deliveryStatus">
-        <template slot-scope="item">
-          <dict-tag :options="deliveryStatusOptions" :value="item.row.deliveryStatus"/>
+      <el-table-column label="销售ID" align="center" prop="companyUserId" >
+        <template slot-scope="scope">
+          <span v-if="scope.row.companyUserId > 0" >{{ scope.row.companyUserId }}</span>
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="绑定销售昵称" align="center" prop="companyUserName" />
+      <el-table-column label="客户编码" align="center" prop="userId" />
+      <el-table-column label="会员等级" align="center" prop="userLevel">
+      </el-table-column>
+      <el-table-column label="销售绑定手机号" align="center" prop="companyUserPhone" />
+      <el-table-column label="销售创建时间" align="center" prop="companyUserCreateTime" width="180">
+        <template slot-scope="scope">
+          <span>{{ scope.row.companyUserCreateTime }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="客户ID" align="center" prop="userId" />
+      <el-table-column label="客户昵称" align="center" prop="nickName" />
+      <el-table-column label="客户绑定手机号" align="center" prop="userBindPhone" />
+      <el-table-column label="收货手机号" align="center" prop="userPhone" />
+      <el-table-column label="累计成交笔数" align="center" prop="totalOrderCount" />
+      <el-table-column label="累计成交总额" align="center" prop="totalOrderAmount" />
+      <el-table-column label="最新绑定时间" align="center" prop="latestBindTime" width="180">
+        <template slot-scope="scope">
+          <span>{{ scope.row.latestBindTime }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="物流跟踪状态" align="center" prop="deliveryType">
-        <template slot-scope="item">
-          <dict-tag :options="deliveryTypeOptions" :value="item.row.deliveryType"/>
+      <el-table-column label="客户状态" align="center" prop="customerStatus">
+        <template slot-scope="scope">
+          <dict-tag :options="customerStatusOptions" :value="scope.row.customerStatus"/>
         </template>
       </el-table-column>
-      <el-table-column label="支付时间" align="center" prop="payTime" width="180">
+      <el-table-column label="所属店铺" align="center" prop="storeId" />
+      <el-table-column label="所属店铺名称" align="center" prop="storeName" />
+      <el-table-column label="商品ID" align="center" prop="productId" />
+      <el-table-column label="商品名称" align="center" prop="productName" width="150" />
+      <el-table-column label="商品规格" align="center" prop="productSpec" width="120" />
+      <el-table-column label="商品数量" align="center" prop="totalNum" />
+      <el-table-column label="销售价格" align="center" prop="totalPrice" />
+      <el-table-column label="成本价格" align="center" prop="costPrice" />
+      <el-table-column label="收货地址" align="center" prop="userAddress" width="200" />
+      <el-table-column label="对应供应商" align="center" prop="supplierName" width="120" />
+      <el-table-column label="下单时间" align="center" prop="createTime" width="180">
         <template slot-scope="scope">
-          <span>{{ scope.row.payTime }}</span>
+          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="状态" align="center" prop="status" >
-        <template slot-scope="item">
-          <dict-tag :options="orderStatusOptions" :value="item.row.status"/>
+      <el-table-column label="订单状态" align="center" prop="status">
+        <template slot-scope="scope">
+          <dict-tag :options="orderStatusOptions" :value="scope.row.status"/>
         </template>
       </el-table-column>
-      <el-table-column label="备注" align="center" prop="remark" />
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -226,7 +221,7 @@
 </template>
 
 <script>
-import { listLiveOrder, exportLiveOrder } from "@/api/live/liveOrder";
+import { listLiveOrderZm, exportLiveOrderZm } from "@/api/live/liveOrder";
 import liveOrderDetails from './liveOrderDetails.vue';
 import {getCompanyList} from "@/api/company/company";
 import Treeselect from "@riophae/vue-treeselect";
@@ -241,6 +236,8 @@ export default {
     return {
       // 字典
       orderStatusOptions: [],
+      memberLevelOptions: [],
+      customerStatusOptions: [],
       // 遮罩层
       loading: true,
       // 导出遮罩层
@@ -257,34 +254,32 @@ export default {
       total: 0,
       // 订单表格数据
       liveOrderList: [],
-      deliveryStatusOptions: [],
-      deliveryTypeOptions: [],
+      // 公司列表
+      companys: [],
+      companyId: null,
+      // 部门树选项
+      deptOptions: [],
 
-      // 支付时间范围选择器绑定的值
-      payTimeRange: [],
-      // 完成时间范围选择器绑定的值
-      finishTimeRange: [],
+      // 下单时间范围选择器绑定的值
+      orderTimeRange: [],
 
       // 查询参数
       queryParams: {
         pageNum: 1,
         liveId: null,
         pageSize: 10,
-        orderSn: null,
-        userId: null,
-        userName: null,
-        mobile: null,
-        address: null,
-        payMoney: null,
-        orderMoney: null,
-        deliveryCode: null,
-        deliveryName: null,
-        deliverySn: null,
-        // 移除单个时间字段,改为范围字段
-        payStartTime: null,
-        payEndTime: null,
-        finishTimeStart: null,
-        finishTimeEnd: null,
+        companyId: null,
+        deptId: null,
+        productName: null,
+        productSpec: null,
+        productNum: null,
+        salePrice: null,
+        userAddress: null,
+        productId: null,
+        costPrice: null,
+        supplierName: null,
+        orderStartTime: null,
+        orderEndTime: null,
         status: null,
       },
       orderOptions: [],
@@ -311,35 +306,24 @@ export default {
     this.getDicts("sys_order_status").then(response => {
       this.orderOptions = response.data;
     });
-    this.getDicts("store_order_delivery_status").then(response => {
-      this.deliveryStatusOptions = response.data;
+    this.getDicts("sys_user_level").then(response => {
+      this.memberLevelOptions = response.data;
     });
-    this.getDicts("logistics_status").then(response => {
-      this.deliveryTypeOptions = response.data;
+    this.getDicts("sys_customer_status").then(response => {
+      this.customerStatusOptions = response.data;
     });
   },
   methods: {
     parseTime,
 
-    // 支付时间范围选择变化处理
-    handlePayTimeChange(value) {
-      if (value && value.length === 2) {
-        this.queryParams.payStartTime = value[0] + ' 00:00:00';
-        this.queryParams.payEndTime = value[1] + ' 23:59:59';
-      } else {
-        this.queryParams.payStartTime = null;
-        this.queryParams.payEndTime = null;
-      }
-    },
-
-    // 完成时间范围选择变化处理
-    handleFinishTimeChange(value) {
+    // 下单时间范围选择变化处理
+    handleOrderTimeChange(value) {
       if (value && value.length === 2) {
-        this.queryParams.finishTimeStart = value[0] + ' 00:00:00';
-        this.queryParams.finishTimeEnd = value[1] + ' 23:59:59';
+        this.queryParams.createTimeStart = value[0] + ' 00:00:00';
+        this.queryParams.createTimeEnd = value[1] + ' 23:59:59';
       } else {
-        this.queryParams.finishTimeStart = null;
-        this.queryParams.finishTimeEnd = null;
+        this.queryParams.createTimeStart = null;
+        this.queryParams.createTimeEnd = null;
       }
     },
 
@@ -365,7 +349,7 @@ export default {
     /** 查询订单列表 */
     getList() {
       this.loading = true;
-      listLiveOrder(this.queryParams).then(response => {
+      listLiveOrderZm(this.queryParams).then(response => {
         this.liveOrderList = response.rows;
         this.total = response.total;
         this.loading = false;
@@ -386,13 +370,10 @@ export default {
     resetQuery() {
       this.resetForm("queryForm");
       // 同时清空范围选择器的值
-      this.payTimeRange = [];
-      this.finishTimeRange = [];
+      this.orderTimeRange = [];
       // 清空时间范围参数
-      this.queryParams.payStartTime = null;
-      this.queryParams.payEndTime = null;
-      this.queryParams.finishTimeStart = null;
-      this.queryParams.finishTimeEnd = null;
+      this.queryParams.orderStartTime = null;
+      this.queryParams.orderEndTime = null;
       this.handleQuery();
     },
 
@@ -412,7 +393,7 @@ export default {
         type: "warning"
       }).then(() => {
         this.exportLoading = true;
-        return exportLiveOrder(queryParams);
+        return exportLiveOrderZm(queryParams);
       }).then(response => {
         this.download(response.msg);
         this.exportLoading = false;

+ 1 - 1
src/views/live/liveVideo/index.vue

@@ -250,7 +250,7 @@ export default {
             this.msgError("请上传视频");
             return;
           }
-          this.form.videoUrl.replace(/\.mp4$/, '.m3u8');
+          this.form.videoUrl = this.form.videoUrl.replace('.mp4', '.m3u8');
           addLiveVideo(this.form).then(response => {
             this.msgSuccess("新增成功");
             this.open = false;

+ 40 - 3
src/views/system/user/index.vue

@@ -154,6 +154,26 @@
               <span v-else>-</span>
             </template>
           </el-table-column>
+          <el-table-column
+            label="订单权限"
+            align="center"
+            width="120">
+            <template #header>
+              <span>
+                订单权限
+                <el-tooltip
+                  content="此列显示用户所属公司,决定了用户可以查看和操作哪些订单数据。不同公司对应不同的数据访问范围。"
+                  placement="top">
+                  <i class="el-icon-question" style="margin-left:4px;cursor:pointer;"></i>
+                </el-tooltip>
+              </span>
+            </template>
+
+            <template #default="{ row }">
+              <el-tag v-for="item in companys" v-if="item.companyId == row.companyId" >{{item.companyName}}</el-tag>
+            </template>
+          </el-table-column>
+
           <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
             <template slot-scope="scope">
               <el-switch
@@ -200,7 +220,7 @@
                   <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
                     v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
                     <el-dropdown-item command="handleSetUser" icon="el-icon-warning-outline"
-                    v-hasPermi="['system:user:edit']">用户设置</el-dropdown-item>  
+                    v-hasPermi="['system:user:edit']">用户设置</el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
             </template>
@@ -308,6 +328,18 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="12">
+            <el-form-item label="订单权限">
+              <el-select filterable  v-model="form.companyId" clearable placeholder="请选择公司名" size="small">
+                <el-option
+                  v-for="item in companys"
+                  :key="item.companyId"
+                  :label="item.companyName"
+                  :value="item.companyId"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
         </el-row>
         <el-row>
           <el-col :span="24">
@@ -362,6 +394,7 @@ import { getToken } from "@/utils/auth";
 import { treeselect } from "@/api/system/dept";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { getCompanyList } from '@/api/company/company'
 
 export default {
   name: "User",
@@ -493,8 +526,12 @@ export default {
     this.getConfigKey("sys.user.initPassword").then(response => {
       this.initPassword = response.msg;
     });
+    getCompanyList().then(response => {
+      this.companys = response.data;
+    });
   },
   methods: {
+
     /** 查询用户列表 */
     getList() {
       this.loading = true;
@@ -587,7 +624,7 @@ export default {
           break;
         case "handleSetUser":
           this.handleSetUser(row);
-          break  
+          break
         default:
           break;
       }
@@ -760,4 +797,4 @@ export default {
     }
   }
 };
-</script>
+</script>