Explorar el Código

直播数据校验添加导出按钮

yuhongqi hace 6 días
padre
commit
dd53dcc3bf
Se han modificado 2 ficheros con 42 adiciones y 3 borrados
  1. 8 0
      src/api/live/liveData.js
  2. 34 3
      src/views/live/liveData/index.vue

+ 8 - 0
src/api/live/liveData.js

@@ -47,4 +47,12 @@ export function getLiveUserDetailListByServer(liveId) {
     url: '/liveData/liveData/getLiveUserDetailListByServer?liveId=' + liveId,
     method: 'get'
   })
+}
+
+// 导出直播间用户详情数据
+export function exportLiveUserDetail(liveId) {
+  return request({
+    url: '/liveData/liveData/exportLiveUserDetail?liveId=' + liveId,
+    method: 'get'
+  })
 }

+ 34 - 3
src/views/live/liveData/index.vue

@@ -524,7 +524,10 @@
 
       <!-- 用户详情列表 -->
       <div v-else class="user-detail-content">
-        <el-button type="text" icon="el-icon-arrow-left" @click="showUserDetail = false" style="margin-bottom: 20px;">返回</el-button>
+        <div style="margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center;">
+          <el-button type="text" icon="el-icon-arrow-left" @click="showUserDetail = false">返回</el-button>
+          <el-button type="primary" size="small" icon="el-icon-download" :loading="userDetailExportLoading" @click="handleExportUserDetail">导出用户详情</el-button>
+        </div>
         <el-table
           :data="userDetailList"
           v-loading="userDetailLoading"
@@ -558,7 +561,7 @@
 </template>
 
 <script>
-import { listLiveData, exportLiveData, autoTagAndRemark, dashboardData, getLiveDataDetailBySql, getLiveUserDetailListBySql } from "@/api/live/liveData";
+import { listLiveData, exportLiveData, autoTagAndRemark, dashboardData, getLiveDataDetailBySql, getLiveUserDetailListBySql, exportLiveUserDetail } from "@/api/live/liveData";
 import { batchUpdateExternalContactNotes } from "@/api/qw/externalContact";
 import { addTag } from "@/api/qw/externalContact";
 
@@ -629,7 +632,8 @@ export default {
       detailData: {},
       userDetailList: [],
       userDetailLoading: false,
-      showUserDetail: false
+      showUserDetail: false,
+      userDetailExportLoading: false
     };
   },
   created() {
@@ -904,6 +908,33 @@ export default {
     formatMoney(value) {
       if (value == null || value === undefined) return '¥0.00';
       return '¥' + (typeof value === 'number' ? value : parseFloat(value)).toFixed(2);
+    },
+    /** 导出用户详情数据 */
+    handleExportUserDetail() {
+      if (!this.currentLiveId) {
+        this.$message.warning('无法获取直播间ID');
+        return;
+      }
+      if (!this.userDetailList || this.userDetailList.length === 0) {
+        this.$message.warning('暂无用户详情数据可导出');
+        return;
+      }
+      this.$confirm('是否确认导出当前直播间的用户详情数据?', "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.userDetailExportLoading = true;
+        return exportLiveUserDetail(this.currentLiveId);
+      }).then(response => {
+        if (response.code === 200) {
+          this.download(response.msg);
+          this.$message.success('导出成功');
+        }
+        this.userDetailExportLoading = false;
+      }).catch(() => {
+        this.userDetailExportLoading = false;
+      });
     }
   }
 };