瀏覽代碼

新增部门统计

xw 3 周之前
父節點
當前提交
fe97ce2d60
共有 1 個文件被更改,包括 67 次插入4 次删除
  1. 67 4
      src/views/fastGpt/readPackage/index.vue

+ 67 - 4
src/views/fastGpt/readPackage/index.vue

@@ -5,6 +5,20 @@
       <el-form-item label="创建时间" prop="createTime">
       <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-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-form-item label="部门" prop="deptId">
+        <treeselect
+          v-model="queryParams.deptId"
+          :options="deptOptions"
+          :normalizer="normalizer"
+          :show-count="true"
+          clearable
+          placeholder="全公司(不选则统计全公司含子部门)"
+          style="width: 260px"
+        />
+      </el-form-item>
+      <el-form-item v-if="redPackageMoney != null && redPackageMoney !== ''">
+        <span class="readpkg-balance-tip">企业红包总余额:<b>¥{{ redPackageMoneyFormatted }}</b>(与部门筛选无关)</span>
+      </el-form-item>
       <el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <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 icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -82,10 +96,10 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import SelectTree from "@/components/TreeSelect/index.vue";
-import TreeSelect from '@riophae/vue-treeselect'
+import Treeselect from '@riophae/vue-treeselect'
 import '@riophae/vue-treeselect/dist/vue-treeselect.css'
 import '@riophae/vue-treeselect/dist/vue-treeselect.css'
 import {allList} from "@/api/company/company";
 import {allList} from "@/api/company/company";
+import { treeselect } from '@/api/company/companyDept'
 import { getReadPackageTotal, exportReadPackageTotal, recharge } from '@/api/course/courseRedPacketLog'
 import { getReadPackageTotal, exportReadPackageTotal, recharge } from '@/api/course/courseRedPacketLog'
 
 
 
 
@@ -93,7 +107,7 @@ import { getReadPackageTotal, exportReadPackageTotal, recharge } from '@/api/cou
 
 
 export default {
 export default {
   name: "FastgptEventLogTotal",
   name: "FastgptEventLogTotal",
-  components: {SelectTree,TreeSelect},
+  components: { Treeselect },
   data() {
   data() {
     return {
     return {
       createTime:this.getDefaultTimeRange(),
       createTime:this.getDefaultTimeRange(),
@@ -104,6 +118,10 @@ export default {
       selectedCompanyList: [],
       selectedCompanyList: [],
       companyList:[],
       companyList:[],
       deptList: [],
       deptList: [],
+      /** 企业部门树(与员工管理页同源 companyDept/treeselect) */
+      deptOptions: [],
+      /** 企业红包总余额,来自列表接口 response.ext.redPackageMoney,不受部门筛选影响 */
+      redPackageMoney: null,
       companyUserList: [],
       companyUserList: [],
       selectedAppKey: null,
       selectedAppKey: null,
       selectedAppKeyLabel: '',
       selectedAppKeyLabel: '',
@@ -141,6 +159,8 @@ export default {
         beginTime:null,
         beginTime:null,
         endTime:null,
         endTime:null,
         appKey:null,
         appKey:null,
+        /** 可选;选中则统计该部门及子部门员工消耗,不传则全公司 */
+        deptId: null,
       },
       },
       // 表单参数
       // 表单参数
       form: {},
       form: {},
@@ -179,6 +199,7 @@ export default {
   created() {
   created() {
     // 先获取公司列表
     // 先获取公司列表
     this.getAllCompany();
     this.getAllCompany();
+    this.getTreeselect();
 
 
     // 等待DOM更新后设置默认时间并获取数据
     // 等待DOM更新后设置默认时间并获取数据
     this.$nextTick(() => {
     this.$nextTick(() => {
@@ -187,7 +208,30 @@ export default {
     });
     });
   },
   },
 
 
+  computed: {
+    redPackageMoneyFormatted() {
+      const n = this.redPackageMoney
+      if (n === null || n === undefined || n === '') return '--'
+      return Number(n).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
+    }
+  },
+
   methods: {
   methods: {
+    /** 查询部门下拉树(复用员工列表接口) */
+    getTreeselect() {
+      treeselect().then((response) => {
+        this.deptOptions = response.data || []
+      })
+    },
+
+    /** 组装 GET 参数:无部门时不传 deptId */
+    buildReadPackageQuery() {
+      const params = { ...this.queryParams }
+      if (params.deptId == null || params.deptId === '') {
+        delete params.deptId
+      }
+      return params
+    },
     // 获取默认时间范围(今天 00:00:00 - 23:59:59)
     // 获取默认时间范围(今天 00:00:00 - 23:59:59)
     getDefaultTimeRange() {
     getDefaultTimeRange() {
       const today = new Date();
       const today = new Date();
@@ -250,10 +294,15 @@ export default {
     getList() {
     getList() {
       this.loading = true;
       this.loading = true;
 
 
-      getReadPackageTotal(this.queryParams).then(response => {
+      getReadPackageTotal(this.buildReadPackageQuery()).then(response => {
         console.log(response)
         console.log(response)
         this.fastGptPushTokenTotalList = response.rows;
         this.fastGptPushTokenTotalList = response.rows;
         this.total = response.total;
         this.total = response.total;
+        if (response.ext && response.ext.redPackageMoney != null) {
+          this.redPackageMoney = response.ext.redPackageMoney
+        }
+        this.loading = false;
+      }).catch(() => {
         this.loading = false;
         this.loading = false;
       });
       });
     },
     },
@@ -312,6 +361,7 @@ export default {
       this.selectedAppKeyLabel = '';
       this.selectedAppKeyLabel = '';
       this.selectedCompanyList = [];
       this.selectedCompanyList = [];
       this.queryParams.appKey = null;
       this.queryParams.appKey = null;
+      this.queryParams.deptId = null;
       this.resetForm("queryForm");
       this.resetForm("queryForm");
       this.handleQuery();
       this.handleQuery();
     },
     },
@@ -338,6 +388,9 @@ export default {
           beginTime: this.queryParams.beginTime,
           beginTime: this.queryParams.beginTime,
           endTime: this.queryParams.endTime
           endTime: this.queryParams.endTime
         };
         };
+        if (this.queryParams.deptId != null && this.queryParams.deptId !== '') {
+          exportData.deptId = this.queryParams.deptId
+        }
         exportReadPackageTotal(exportData)
         exportReadPackageTotal(exportData)
           .then(response => {
           .then(response => {
             if (response && response.msg) this.download(response.msg);
             if (response && response.msg) this.download(response.msg);
@@ -400,3 +453,13 @@ export default {
   }
   }
 };
 };
 </script>
 </script>
+
+<style scoped>
+.readpkg-balance-tip {
+  font-size: 13px;
+  color: #606266;
+}
+.readpkg-balance-tip b {
+  color: #303133;
+}
+</style>