Ver código fonte

feat: 邀约码统计 原始数据展示与导出

furffico 1 ano atrás
pai
commit
6f7bf4f505

+ 3 - 1
src/avue/crud/liveroomInvite.ts

@@ -1,3 +1,4 @@
+import { datetime_format } from "@/utils/formatters";
 
 export const tableOption = {
   border: false,
@@ -18,7 +19,8 @@ export const tableOption = {
     width: 150,
   }, {
     label: '进入直播间时间',
-    prop: 'createdAt',
+    prop: 'created_at',
+    formatter: (_: any, v: string) => datetime_format(v),
     width: 150,
   }, {
     label: '邀约客户经理信息',

+ 57 - 7
src/views/modules/liveroom/liveroomInvite-all.vue

@@ -1,7 +1,10 @@
 <template>
   <avue-crud ref="crud" :page="page" :data="dataList" :option="tableOption" @on-load="getDataList">
     <template slot="menuLeft">
-      <el-button type="success" icon="el-icon-download" size="small">导出结果至Excel</el-button>
+      <div style="display:flex; flex-direction: row; align-items: center;">
+        <el-button type="success" icon="el-icon-download" size="small" @click="exportToCSVFile">导出结果至Excel</el-button>
+        <div style="padding-left: 1em; color: grey;font-size: small;">共有 {{ page.total }} 条记录</div>
+      </div>
     </template>
   </avue-crud>
 </template>
@@ -11,6 +14,20 @@ import Vue from 'vue'
 import { IPage } from '@/utils/vo'
 import httpx from '@/utils/httpx'
 import { tableOption } from "@/avue/crud/liveroomInvite"
+import datasheet2csv from "@/utils/datasheet2csv"
+import { download_blob } from "@/utils/index"
+import { datetime_format } from '@/utils/formatters'
+
+interface InvitationInfo {
+  user_info: string
+  created_at: string,
+  manager_info: string,
+}
+
+interface ApiReturn {
+  invitesList: InvitationInfo[],
+  total: number
+}
 
 export default Vue.extend({
   props: {
@@ -26,7 +43,7 @@ export default Vue.extend({
         currentPage: 1,
         pageSize: 10,
       } as IPage,
-      dataList: [],
+      dataList: [] as InvitationInfo[],
     }
   },
 
@@ -41,14 +58,14 @@ export default Vue.extend({
       const [start, end] = this.daterange
 
       this.dataListLoading = true
-      httpx.post(httpx.makeurl('/rooms/queryConsultList'), {
-        start,
-        end,
+      httpx.post(httpx.makeurl('/rooms/queryInvitesList'), {
+        startTime: start,
+        endTime: end,
         roomId: this.roomId,
         limit: page?.pageSize || this.page.pageSize,
         page: page?.currentPage || this.page.currentPage,
-      }).then(({ data }) => {
-        this.dataList = data.consultList
+      }).then(({ data }: { data: ApiReturn }) => {
+        this.dataList = data.invitesList
         this.page.total = data.total
         this.dataListLoading = false
         if (done) {
@@ -57,6 +74,39 @@ export default Vue.extend({
         this.$message.success({ message: "加载成功", duration: 700 })
       })
     },
+
+    exportToCSVFile() {
+      const loading = this.$loading({
+        lock: true,
+        text: '正在导出数据',
+        spinner: 'el-icon-loading',
+        background: 'rgba(255,255,255,0.75)'
+      });
+
+      // 获取指定时间范围内的所有数据
+      return httpx.post(
+        httpx.makeurl('/rooms/queryInvitesList'),
+        {
+          startTime: this.daterange[0],
+          endTime: this.daterange[1],
+          roomId: this.roomId,
+          limit: 0, // limit为0时后端会返回全部数据
+          page: 1,
+        }
+      ).then(({ data }: { data: ApiReturn }) => {
+        const blob = datasheet2csv(
+          data.invitesList,
+          (v) => [v.user_info, v.manager_info, datetime_format(v.created_at)],
+          ['受邀客户手机号', '邀约客户经理信息', '进入直播间时间']
+        )
+        const start = (this.daterange[0] as string).replaceAll(':', "-")
+        const end = (this.daterange[1] as string).replaceAll(':', "-")
+        download_blob(blob, `客户邀约记录_${this.roomInfo.title}_${start}至${end}.csv`)
+        this.$message.success({ message: "导出完成", duration: 1500 })
+      }).finally(() => {
+        loading.close()
+      })
+    },
   },
 
   watch: {

+ 2 - 2
src/views/modules/liveroom/liveroomInvite-stats.vue

@@ -73,8 +73,8 @@ export default Vue.extend({
         (v) => [v.manager_info, v.count],
         ['客户经理信息', '有效邀约数量']
       )
-      const start = datetime_format(this.daterange[0] as string, 'YYYY-MM-DD HH-mm-ss')
-      const end = datetime_format(this.daterange[1] as string, 'YYYY-MM-DD HH-mm-ss')
+      const start = (this.daterange[0] as string).replaceAll(':', "-")
+      const end = (this.daterange[1] as string).replaceAll(':', "-")
       download_blob(blob, `客户邀约记录_${this.roomInfo.title}_${start}至${end}.csv`)
     },
   },