Procházet zdrojové kódy

看课查询和销售后端的权限查询

xw před 4 dny
rodič
revize
b40c6628f2

+ 19 - 0
src/api/fastGpt/fastGptPushTokenTotal.js

@@ -0,0 +1,19 @@
+import request from '@/utils/request'
+
+// 查询token消耗统计列表
+export function getFastGptPushTokenTotal(query) {
+  return request({
+    url: '/fastGpt/pushTokenTotal/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 导出token消耗统计
+export function exportFastGptPushTokenTotal(query) {
+  return request({
+    url: '/fastGpt/pushTokenTotal/export',
+    method: 'get',
+    params: query
+  })
+}

+ 196 - 224
src/views/course/courseTrafficLog/index.vue

@@ -1,314 +1,286 @@
 <template>
   <div class="app-container">
+    <!-- Tab 切换 -->
+    <el-tabs v-model="activeTab" @tab-click="handleTabClick">
+      <el-tab-pane label="公司" name="company"></el-tab-pane>
+      <el-tab-pane label="项目" name="project"></el-tab-pane>
+      <el-tab-pane label="课程" name="course"></el-tab-pane>
+      <el-tab-pane label="公开课" name="common"></el-tab-pane>
+    </el-tabs>
+
+    <!-- 查询条件 -->
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
-<!--      <el-form-item label="公司名称" prop="companyId" >-->
-<!--        <el-select v-model="queryParams.companyId" placeholder="请选择所属公司" filterable clearable size="small">-->
-<!--          <el-option v-for="(option, index) in companyList" :key="index" :value="option.dictValue" :label="option.dictLabel"></el-option>-->
-<!--        </el-select>-->
-<!--      </el-form-item>-->
-      <el-form-item label="项目" prop="project">
+      <!-- 公司选择 -->
+      <!-- <el-form-item label="公司" v-if="activeTab === 'all' || activeTab === 'company'">
+        <el-select v-model="queryParams.companyId" placeholder="请选择公司" filterable clearable size="small">
+          <el-option v-for="(option, index) in companyList" :key="index" :value="option.dictValue" :label="option.dictLabel"></el-option>
+        </el-select>
+      </el-form-item> -->
+
+      <!-- 项目选择 -->
+      <el-form-item label="项目" v-if="activeTab === 'all' || activeTab === 'project'">
         <el-select v-model="queryParams.project" placeholder="请选择项目" filterable clearable size="small">
-          <el-option
-            v-for="dict in projectOptions"
-            :key="dict.dictValue"
-            :label="dict.dictLabel"
-            :value="dict.dictValue"
-          />
+          <el-option v-for="dict in projectOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
+        </el-select>
+      </el-form-item>
+
+      <!-- 课程选择 -->
+      <el-form-item label="课程" v-if="activeTab === 'all' || activeTab === 'course'">
+        <el-select v-model="queryParams.courseId" placeholder="请选择课程" filterable clearable size="small">
+          <el-option v-for="dict in courseLists" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
         </el-select>
       </el-form-item>
-      <el-form-item label="课程" prop="courseId">
-        <el-select filterable  v-model="queryParams.courseId" placeholder="请选择课程"  clearable size="small" @change="courseChange(queryParams.courseId)">
-          <el-option
-            v-for="dict in courseLists"
-            :key="dict.dictValue"
-            :label="dict.dictLabel"
-            :value="dict.dictValue"
-          />
+      <el-form-item label="公开课" v-if="activeTab === 'all' || activeTab === 'common'">
+        <el-select v-model="queryParams.courseId" placeholder="请选择课程" filterable clearable size="small">
+          <el-option v-for="dict in courseLists" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
         </el-select>
       </el-form-item>
-      <el-form-item label="年月" prop="time">
+
+      <!-- 时间选择 -->
+      <el-form-item label="年月">
         <el-date-picker
-          v-model="time"
+          v-model="timeRange"
           type="daterange"
           placeholder="选择年月"
-          :picker-options="pickerOptions"
           :value-format="'yyyy-MM-dd'"
+          :picker-options="pickerOptions"
           @change="handleDateData"
         ></el-date-picker>
       </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-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading" @click="handleExport" v-hasPermi="['course:courseTrafficLog:export']" >导出</el-button>
       </el-form-item>
     </el-form>
 
-    <el-row :gutter="10" class="mb8">
-      <el-col :span="1.5">
-        <el-button
-          type="warning"
-          plain
-          icon="el-icon-download"
-          size="mini"
-          :loading="exportLoading"
-          @click="handleExport"
-          v-hasPermi="['course:courseTrafficLog:export']"
-        >导出</el-button>
-      </el-col>
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
-    </el-row>
-
+    <!-- 表格 -->
     <el-table border v-loading="loading" :data="courseTrafficLogList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="公司名称" align="center" prop="companyName" />
-      <el-table-column label="项目" align="center" prop="projectName" />
-      <el-table-column label="课程" align="center" prop="courseName" />
+      <!-- 公司列 -->
+      <el-table-column label="公司" align="center" prop="companyName" v-if="activeTab === 'all' || activeTab === 'company'" />
+      <!-- 项目列 -->
+      <el-table-column label="项目" align="center" prop="projectName" v-if="activeTab === 'all' || activeTab === 'project'" />
+      <!-- 课程列 -->
+      <el-table-column label="课程" align="center" prop="courseName" v-if="activeTab === 'all' || activeTab === 'course'||activeTab === 'common'" />
       <el-table-column label="日期" align="center" prop="month" />
       <el-table-column label="使用流量" align="center">
         <template slot-scope="scope">
           <span>{{ formatTrafficData(scope.row.totalInternetTraffic) }}</span>
         </template>
       </el-table-column>
-<!--      <el-table-column label="费用" align="center">-->
-<!--        <template slot-scope="scope">-->
-<!--          <span>{{ formatTrafficMoney(scope.row.totalInternetTraffic) }}</span>-->
-<!--        </template>-->
-<!--      </el-table-column>-->
+      <el-table-column label="耗费金额(元)" align="center" prop="formattedAmount" />
     </el-table>
 
+    <!-- 分页 -->
     <pagination
-      v-show="total>0"
+      v-show="total > 0"
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
       @pagination="getList"
     />
-
   </div>
 </template>
 
 <script>
-import { listCourseTrafficLog, getCourseTrafficLog, delCourseTrafficLog, addCourseTrafficLog, updateCourseTrafficLog, exportCourseTrafficLog } from "@/api/course/courseTrafficLog";
-import {courseList} from "@/api/course/courseRedPacketLog";
-import {allList}from "@/api/company/company";
+import { listCourseTrafficLog, exportCourseTrafficLog } from "@/api/course/courseTrafficLog";
+import { courseList } from "@/api/course/courseRedPacketLog";
+import { allList } from "@/api/company/company";
+
 export default {
-  name: "CourseTrafficLog",
   data() {
     return {
+      activeTab: "company", // 默认 tab
+      timeRange: null, // 时间范围单独绑定
+      companyList: [],
+      projectOptions: [],
       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]);
+        shortcuts: [
+          {
+            text: '今日',
+            onClick(picker) {
+              const start = new Date();
+              const end = new Date();
+              picker.$emit('pick', [start, end]);
+            }
+          },
+          {
+            text: '昨日',
+            onClick(picker) {
+              const start = new Date();
+              start.setDate(start.getDate() - 1);
+              const end = new Date(start);
+              picker.$emit('pick', [start, end]);
+            }
+          },
+          {
+            text: '本周',
+            onClick(picker) {
+              const now = new Date();
+              const day = now.getDay() || 7;
+              const start = new Date(now);
+              start.setDate(now.getDate() - day + 1);
+              const end = new Date();
+              picker.$emit('pick', [start, end]);
+            }
+          },
+          {
+            text: '本月',
+            onClick(picker) {
+              const start = new Date(new Date().setDate(1));
+              const end = new Date();
+              picker.$emit('pick', [start, end]);
+            }
           }
-        }]
+        ]
       },
-      companyList:[],
-      // 遮罩层
+      courseLists: [],
       loading: false,
-      // 导出遮罩层
       exportLoading: false,
-      // 选中数组
-      ids: [],
-      // 非单个禁用
-      single: true,
-      // 非多个禁用
-      multiple: true,
-      // 显示搜索条件
       showSearch: true,
-      // 总条数
       total: 0,
-      // 短链课程流量记录表格数据
       courseTrafficLogList: [],
-      projectOptions:[],
-      courseLists:[],
-      // 弹出层标题
-      title: "",
-      // 是否显示弹出层
-      open: false,
-      time: null,
-      // 查询参数
       queryParams: {
+        tabType: "", // 当前 tab 类型
         startDate: null,
         endDate: null,
         pageNum: 1,
         pageSize: 10,
-        userId: null,
-        videoId: null,
-        qwExternalContactId: null,
-        internetTraffic: null,
-        qwUserId: null,
-        companyUserId: null,
         companyId: null,
-        courseId: null,
-      },
-      // 表单参数
-      form: {},
-      // 表单校验
-      rules: {
+        project: null,
+        courseId: null
       }
     };
   },
   created() {
-    courseList().then(response => {
-      this.courseLists = response.list;
-    });
-    this.getDicts("sys_course_project").then(response => {
-      this.projectOptions = response.data;
-    });
-    this.getAllCompany();
+    // 初始化为当天日期
+    this.initTodayDate();
 
+    courseList().then(res => this.courseLists = res.list);
+    this.getDicts("sys_course_project").then(res => this.projectOptions = res.data);
+    this.getAllCompany();
+    this.getList();
   },
   methods: {
-    handleDateData(){
-      if (this.time) {
-        this.queryParams.startDate = this.time[0];
-        this.queryParams.endDate = this.time[1];
-      } else {
-        this.queryParams.startDate = null;
-        this.queryParams.endDate = null;
-      }
-    },
-    getAllCompany() {
-      allList().then(response => {
-        this.companyList = response.rows;
-      });
+    // 初始化为前一天(昨天)日期
+    initTodayDate() {
+      const yesterday = new Date();
+      yesterday.setDate(yesterday.getDate() - 1); // 减去1天,得到昨天
+
+      const year = yesterday.getFullYear();
+      const month = String(yesterday.getMonth() + 1).padStart(2, '0');
+      const day = String(yesterday.getDate()).padStart(2, '0');
+      const yesterdayStr = `${year}-${month}-${day}`;
+
+      this.timeRange = [yesterdayStr, yesterdayStr];
+      this.queryParams.startDate = yesterdayStr;
+      this.queryParams.endDate = yesterdayStr;
     },
-    formatTrafficData(traffic) {
 
-        if (traffic < 1024) { // Less than 1 KB
-          return traffic + ' B';
-        } else if (traffic < 1024 * 1024) { // Less than 1 MB
-          return (traffic / 1024).toFixed(2) + ' KB';
-        } else if (traffic < 1024 * 1024 * 1024) { // Less than 1 GB
-          return (traffic / (1024 * 1024)).toFixed(2) + ' MB';
-        } else { // More than 1 GB
-          return (traffic / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
+
+    getSummaries(param) {
+      const { columns, data } = param
+      const sums = []
+
+      columns.forEach((column, index) => {
+        if (index === 0) {
+          // 第一列显示"总计"
+          sums[index] = '总计'
+          return
         }
 
+        // 如果是流量列
+        if (column.property === 'totalInternetTraffic' ||
+          (column.label === '使用流量' && !column.property)) {
+          const values = data.map(item => Number(item.totalInternetTraffic) || 0)
+          if (!values.every(value => isNaN(value))) {
+            const total = values.reduce((prev, curr) => {
+              const value = Number(curr)
+              return prev + (isNaN(value) ? 0 : value)
+            }, 0)
+            sums[index] = this.formatTrafficData(total)
+          } else {
+            sums[index] = 'N/A'
+          }
+        } else {
+          // 其他列留空
+          sums[index] = ''
+        }
+      })
+
+      return sums
     },
-    formatTrafficMoney(traffic){
-      return (traffic / (1024 * 1024 * 1024) * 0.095).toFixed(2) + ' 元'
+
+    handleTabClick(tab) {
+      this.queryParams.tabType = tab.name;
+      this.queryParams.pageNum = 1;
+
+      // 清理互斥参数
+      if (tab.name !== "project") this.queryParams.project = null;
+      if (tab.name !== "course") this.queryParams.courseId = null;
+      if (tab.name !== "company") this.queryParams.companyId = null;
+
+      this.getList();
     },
 
-    handleShortcut() {
-      this.queryParams.time = new Date().toISOString().slice(0, 7);
+    handleDateData() {
+      if (this.timeRange) {
+        this.queryParams.startDate = this.timeRange[0];
+        this.queryParams.endDate = this.timeRange[1];
+      } else {
+        this.queryParams.startDate = null;
+        this.queryParams.endDate = null;
+      }
+    },
+    getAllCompany() {
+      allList().then(res => this.companyList = res.rows);
     },
-    /** 查询短链课程流量记录列表 */
     getList() {
       this.loading = true;
-      listCourseTrafficLog(this.queryParams).then(response => {
-        this.courseTrafficLogList = response.rows;
-        this.total = response.total;
-        this.loading = false;
-      }).finally(()=>{
+      listCourseTrafficLog(this.queryParams).then(res => {
+        this.courseTrafficLogList = res.rows;
+        this.total = res.total;
+      }).finally(() => {
         this.loading = false;
-      })
-    },
-    // 取消按钮
-    cancel() {
-      this.open = false;
-      this.reset();
-    },
-    // 表单重置
-    reset() {
-      this.form = {
-        logId: null,
-        userId: null,
-        videoId: null,
-        createTime: null,
-        qwExternalContactId: null,
-        internetTraffic: null,
-        qwUserId: null,
-        companyUserId: null,
-        companyId: null,
-        courseId: null
-      };
-      this.resetForm("form");
+      });
     },
-    /** 搜索按钮操作 */
     handleQuery() {
+      this.queryParams.tabType = this.activeTab
       this.queryParams.pageNum = 1;
       this.getList();
     },
-    /** 重置按钮操作 */
     resetQuery() {
-      this.resetForm("queryForm");
-      this.handleQuery();
-    },
-    // 多选框选中数据
-    handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.logId)
-      this.single = selection.length!==1
-      this.multiple = !selection.length
+      this.timeRange = null;
+      this.queryParams = {
+        ...this.queryParams,
+        startDate: null,
+        endDate: null,
+        companyId: null,
+        project: null,
+        courseId: null,
+        pageNum: 1,
+      };
+      this.getList();
     },
-    /** 新增按钮操作 */
-    handleAdd() {
-      this.reset();
-      this.open = true;
-      this.title = "添加短链课程流量记录";
+    formatTrafficData(traffic) {
+      return `${(traffic / (1024 ** 3)).toFixed(4)} GB`;
     },
-    /** 修改按钮操作 */
-    handleUpdate(row) {
-      this.reset();
-      const logId = row.logId || this.ids
-      getCourseTrafficLog(logId).then(response => {
-        this.form = response.data;
-        this.open = true;
-        this.title = "修改短链课程流量记录";
-      });
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.logId);
     },
-    /** 提交按钮 */
-    submitForm() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
-          if (this.form.logId != null) {
-            updateCourseTrafficLog(this.form).then(response => {
-              this.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
-          } else {
-            addCourseTrafficLog(this.form).then(response => {
-              this.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
-          }
-        }
+    handleExport() {
+      this.$confirm("确认导出数据?", "提示").then(() => {
+        this.exportLoading = true;
+        return exportCourseTrafficLog(this.queryParams);
+      }).then(res => {
+        this.download(res.msg);
+      }).finally(() => {
+        this.exportLoading = false;
       });
     },
-    /** 删除按钮操作 */
-    handleDelete(row) {
-      const logIds = row.logId || this.ids;
-      this.$confirm('是否确认删除短链课程流量记录编号为"' + logIds + '"的数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return delCourseTrafficLog(logIds);
-        }).then(() => {
-          this.getList();
-          this.msgSuccess("删除成功");
-        }).catch(() => {});
-    },
-    /** 导出按钮操作 */
-    handleExport() {
-      const queryParams = this.queryParams;
-      this.$confirm('是否确认导出所有短链课程流量记录数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
-          this.exportLoading = true;
-          return exportCourseTrafficLog(queryParams);
-        }).then(response => {
-          this.download(response.msg);
-          this.exportLoading = false;
-        }).catch(() => {});
-    }
   }
 };
 </script>

+ 294 - 0
src/views/course/courseTrafficLog/statistics.vue

@@ -0,0 +1,294 @@
+<template>
+  <div class="app-container">
+    <!-- 查询条件 -->
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <!-- 公司选择 -->
+      <el-form-item label="统计维度">
+        <el-select v-model="queryParams.statisticsType" placeholder="请选择统计维度" filterable clearable size="small">
+          <el-option v-for="(option, index) in dimensionStatistics" :key="index" :value="option.value" :label="option.text"></el-option>
+        </el-select>
+      </el-form-item>
+
+      <!-- 项目选择 -->
+      <el-form-item label="选择公司">
+        <el-select v-model="queryParams.companyId" placeholder="请选择公司" filterable clearable size="small">
+          <el-option v-for="dict in companyList" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
+        </el-select>
+      </el-form-item>
+
+      <!-- 时间选择 -->
+      <el-form-item label="年月">
+        <el-date-picker
+          v-model="timeRange"
+          type="daterange"
+          placeholder="选择年月"
+          :value-format="'yyyy-MM-dd'"
+          :picker-options="pickerOptions"
+          @change="handleDateData"
+        ></el-date-picker>
+      </el-form-item>
+
+
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+      <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+          v-hasPermi="['course:courseTrafficLog:statisticsExport']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+
+    <!-- 表格 -->
+    <el-table border v-loading="loading" :data="courseTrafficLogList" @selection-change="handleSelectionChange"
+              show-summary :summary-method="getSummaries">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="公司" align="center" prop="companyName" />
+      <el-table-column v-if="showDept" label="部门" align="center" prop="deptName" />
+      <el-table-column label="统计范围" align="center" prop="dateRange" />
+      <el-table-column label="使用流量" align="center"  prop="formattedTotalTraffic">
+      </el-table-column>
+      <el-table-column label="金额" align="center" prop="totalAmount">
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import { listCourseTrafficLog, exportCourseTrafficLog,statisticsSummaryList,exportStatisticsSummary } from "@/api/course/courseTrafficLog";
+import { courseList } from "@/api/course/courseRedPacketLog";
+import { allList } from "@/api/company/company";
+
+export default {
+  data() {
+    return {
+      showDept:false,
+      dimensionStatistics:[
+        {text:"按公司",value:1},
+        {text:"按部门",value:2}
+      ],
+      timeRange: null, // 时间范围单独绑定
+      companyList: [],
+      projectOptions: [],
+      pickerOptions: {
+        shortcuts: [
+          {
+            text: '今日',
+            onClick(picker) {
+              const start = new Date();
+              const end = new Date();
+              picker.$emit('pick', [start, end]);
+            }
+          },
+          {
+            text: '昨日',
+            onClick(picker) {
+              const start = new Date();
+              start.setDate(start.getDate() - 1);
+              const end = new Date(start);
+              picker.$emit('pick', [start, end]);
+            }
+          },
+          {
+            text: '本周',
+            onClick(picker) {
+              const now = new Date();
+              const day = now.getDay() || 7;
+              const start = new Date(now);
+              start.setDate(now.getDate() - day + 1);
+              const end = new Date();
+              picker.$emit('pick', [start, end]);
+            }
+          },
+          {
+            text: '本月',
+            onClick(picker) {
+              const start = new Date(new Date().setDate(1));
+              const end = new Date();
+              picker.$emit('pick', [start, end]);
+            }
+          }
+        ]
+      },
+      courseLists: [],
+      loading: false,
+      exportLoading: false,
+      showSearch: true,
+      total: 0,
+      courseTrafficLogList: [],
+      queryParams: {
+        tabType: "", // 当前 tab 类型
+        startDate: null,
+        endDate: null,
+        pageNum: 1,
+        pageSize: 10,
+        statisticsType: null,//统计维度 1、按照公司 2、按照部门
+        companyId:null,
+        project: null,
+        courseId: null
+      }
+    };
+  },
+  created() {
+    courseList().then(res => this.courseLists = res.list);
+    this.getDicts("sys_course_project").then(res => this.projectOptions = res.data);
+    this.getAllCompany();
+    this.getList();
+  },
+  methods: {
+
+    getSummaries(param) {
+      // 原有的汇总方法
+      const { columns, data } = param;
+      const sums = [];
+
+      columns.forEach((column, index) => {
+        if (index === 0) {
+          sums[index] = '总计';
+          return;
+        }
+
+        if (column.property === 'formattedTotalTraffic') {
+          sums[index] = this.getTotalTraffic();
+        } else if (column.property === 'totalAmount') {
+          sums[index] = '¥' + this.getTotalAmount();
+        } else {
+          sums[index] = '';
+        }
+      });
+
+      return sums;
+    },
+
+
+    // 计算总流量(不四舍五入)
+    getTotalTraffic() {
+      if (!this.courseTrafficLogList || this.courseTrafficLogList.length === 0) {
+        return '0';
+      }
+      let total = 0;
+
+      // 方法B:从格式化字符串中提取数值(如果formattedTotalTraffic类似 "1.23GB")
+      total = this.courseTrafficLogList.reduce((sum, item) => {
+        // 移除非数字字符,只保留数字和小数点
+        if (item.formattedTotalTraffic) {
+          const numStr = item.formattedTotalTraffic.replace(/[^\d.]/g, '');
+          return sum + parseFloat(numStr || 0);
+        }
+        return sum;
+      }, 0);
+
+      // 保留所有小数,不四舍五入
+      return total.toFixed(10).replace(/\.?0+$/, '');
+    },
+
+    // 计算总金额(不四舍五入)
+    getTotalAmount() {
+      if (!this.courseTrafficLogList || this.courseTrafficLogList.length === 0) {
+        return '0';
+      }
+
+      const total = this.courseTrafficLogList.reduce((sum, item) => {
+        return sum + (parseFloat(item.totalAmount) || 0);
+      }, 0);
+
+      // 保留两位小数,不四舍五入
+      return Math.floor(total * 100) / 100;
+    },
+
+    handleTabClick(tab) {
+      this.queryParams.tabType = tab.name;
+      this.queryParams.pageNum = 1;
+
+      // 清理互斥参数
+      if (tab.name !== "project") this.queryParams.project = null;
+      if (tab.name !== "course") this.queryParams.courseId = null;
+      if (tab.name !== "company") this.queryParams.companyId = null;
+
+      this.getList();
+    },
+
+    handleDateData() {
+      if (this.timeRange) {
+        this.queryParams.startDate = this.timeRange[0];
+        this.queryParams.endDate = this.timeRange[1];
+      } else {
+        this.queryParams.startDate = null;
+        this.queryParams.endDate = null;
+      }
+    },
+    getAllCompany() {
+      allList().then(res => this.companyList = res.rows);
+    },
+    getList() {
+      this.loading = true;
+      if(this.queryParams.statisticsType == 2){
+         this.showDept = true;
+      }else{
+        this.showDept = false;
+      }
+      statisticsSummaryList(this.queryParams).then(res => {
+        this.courseTrafficLogList = res.rows;
+        this.total = res.total;
+      }).finally(() => {
+        this.loading = false;
+      });
+    },
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    resetQuery() {
+      this.timeRange = null;
+      this.queryParams = {
+        ...this.queryParams,
+        startDate: null,
+        endDate: null,
+        companyId: null,
+        project: null,
+        courseId: null,
+        pageNum: 1,
+      };
+      this.getList();
+    },
+    formatTrafficData(traffic) {
+      if (traffic < 1024) return `${traffic} B`;
+      if (traffic < 1024 ** 2) return `${(traffic / 1024).toFixed(2)} KB`;
+      if (traffic < 1024 ** 3) return `${(traffic / 1024 ** 2).toFixed(2)} MB`;
+      return `${(traffic / 1024 ** 3).toFixed(2)} GB`;
+    },
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.logId);
+    },
+    handleExport() {
+      this.$confirm("确认导出数据?", "提示").then(() => {
+        this.exportLoading = true;
+        return exportStatisticsSummary(this.queryParams);
+      }).then(res => {
+        this.download(res.msg);
+      }).finally(() => {
+        this.exportLoading = false;
+      });
+    }
+  }
+};
+</script>

+ 1 - 0
src/views/course/courseWatchLog/index.vue

@@ -786,6 +786,7 @@ export default {
       courseLists:[],
       deptOptions: undefined,
       scheduleLists:[], // 营期名称
+      periodList: [], // 营期列表
       videoList:[],
       logTypeOptions:[],
       projectOptions:[],

+ 255 - 0
src/views/fastGpt/fastGptPushTokenTotal/index.vue

@@ -0,0 +1,255 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+
+      <el-form-item label="创建时间" prop="createTime">
+        <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"  @change="changeTime"></el-date-picker>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table border v-loading="loading" :data="fastGptPushTokenTotalList" :row-class-name="() => 'fixed-bottom-row'"
+              @selection-change="handleSelectionChange" :max-height="600">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="公司名称" align="center" prop="companyName" />
+      <el-table-column label="token消耗" align="center" prop="count" />
+      <el-table-column label="耗费金额(元)" align="center" prop="amount" />
+      <el-table-column label="时间" align="center" prop="statTime" />
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import { listFastgptEventLogTotal, exportFastgptEventLogTotal, getFastGptRoleAppKeyList} from "@/api/fastGpt/fastgptEventLogTotal";
+import { getFastGptPushTokenTotal} from "@/api/fastGpt/fastGptPushTokenTotal";
+import SelectTree from "@/components/TreeSelect/index.vue";
+import {getDeptData} from "@/api/system/employeeStats";
+import TreeSelect from '@riophae/vue-treeselect'
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
+import {allList} from "@/api/company/company";
+
+
+
+export default {
+  name: "FastgptEventLogTotal",
+  components: {SelectTree,TreeSelect},
+  data() {
+    return {
+      createTime:null,
+      // 遮罩层
+      loading: true,
+      // 导出遮罩层
+      exportLoading: false,
+      selectedCompanyList: [],
+      companyList:[],
+      deptList: [],
+      companyUserList: [],
+      selectedAppKey: null,
+      selectedAppKeyLabel: '',
+      appKeyOptions: [],
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // token统计表格数据
+      fastGptPushTokenTotalList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      typeCountMap: null,
+      // 日志类型字典
+      typeOptions: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        roleId: null,
+        count: null,
+        type: null,
+        companyId: null,
+        companyUserId: null,
+        qwUserId: null,
+        typeCountMap: null,
+        beginTime:null,
+        endTime:null,
+        appKey:null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+      }
+    };
+  },
+  created() {
+    this.getList();
+    this.getAllCompany();
+
+  },
+
+  methods: {
+    getAllCompany() {
+      allList().then(response => {
+        this.companyList = response.rows;
+        this.companyList.push({dictLabel: "无",
+          dictValue: "0"})
+      });
+    },
+    /** 查询ai事件埋点统计列表 */
+    getList() {
+      this.loading = true;
+
+      getFastGptPushTokenTotal(this.queryParams).then(response => {
+        console.log(response)
+        this.fastGptPushTokenTotalList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    normalizer(node) {
+      return {
+        id: node.id,
+        label: node.label,
+        children: node.children,
+        disabled: node.disabled
+      }
+    },
+    handleAppKeyChange(value) {
+      const node = this.findNodeById(this.appKeyOptions, value);
+      if (!node) {
+        this.selectedAppKeyLabel = '';
+        return;
+      }
+
+      // 如果是子节点,则找父节点 label
+      if (node.parentLabel) {
+        this.queryParams.appKey = node.parentLabel;
+        this.selectedAppKeyLabel = node.parentLabel;
+        this.selectedAppKey = this.selectedAppKeyLabel;
+      } else {
+        this.queryParams.appKey = node.label;
+        this.selectedAppKeyLabel = node.label;
+        this.selectedAppKey = this.selectedAppKeyLabel;
+      }
+    },
+    findNodeById(nodes, id) {
+      for (const node of nodes) {
+        if (node.id === id) return node;
+        if (node.children) {
+          const found = this.findNodeById(node.children, id);
+          if (found) return found;
+        }
+      }
+      return null;
+    },
+    changeTime(){
+      console.log(this.createTime);
+      if(this.createTime!=null){
+        this.queryParams.beginTime=this.createTime[0];
+        this.queryParams.endTime=this.createTime[1];
+      }else{
+        this.queryParams.beginTime=null;
+        this.queryParams.endTime=null;
+      }
+      console.log(this.queryParams.beginTime);
+      console.log(this.queryParams.endTime);
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        roleId: null,
+        count: null,
+        type: null,
+        companyId: null,
+        companyUserId: null,
+        qwUserId: null,
+        statTime: null
+      };
+      this.resetForm("form");
+    },
+    getPercentageColor(percentage) {
+      // HSL模式从黄色(60度)渐变到红色(0度)
+      const percent = Math.min(100, Math.max(0, parseFloat(percentage)));
+
+      // 调整色相范围:从深黄色(40°)渐变到红色(0°)
+      const hue = 40 - 40 * (percent / 100); // 初始 hue=40(深黄),终点 hue=0(红)
+
+      // 提高饱和度(100%),亮度保持 50%(鲜艳但不刺眼)
+      return `hsl(${hue}, 100%, 50%)`;
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      console.log(this.selectedAppKey)
+      if(this.selectedAppKey === null || typeof this.selectedAppKey === 'undefined'){
+        this.queryParams.appKey = null;
+      }
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.selectedAppKey = null;
+      this.selectedAppKeyLabel = '';
+      this.selectedCompanyList = [];
+      this.queryParams.appKey = null;
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+
+      if(this.selectedCompanyList != null && this.selectedCompanyList.length > 0) {
+        this.queryParams.userIds = this.selectedCompanyList;
+      }else {
+        this.queryParams.userIds = [];
+      }
+      this.$confirm('是否确认导出所有ai事件埋点统计数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          this.exportLoading = true;
+          return exportFastgptEventLogTotal(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+          this.exportLoading = false;
+        }).catch(() => {});
+    }
+  }
+};
+</script>