Browse Source

CID订单统计增加获客助手筛选条件

cgp 2 ngày trước cách đây
mục cha
commit
189934ce03

+ 8 - 0
src/api/company/statistics.js

@@ -223,3 +223,11 @@ export function salesUserDetail(query) {
     data: query
   });
 }
+
+// 根据企微主体ID获取获客链接助手列表
+export function listSalesAcquisitionAssistants(corpId) {
+  return request({
+    url: '/company/statistics/salesStat/' + corpId,
+    method: 'post'
+  })
+}

+ 75 - 10
src/views/his/statistics/companyStatisticsCID.vue

@@ -40,8 +40,15 @@
         </el-select>
       </el-form-item>
 
+      <!-- 企微主体(变更时只清空助手相关,不加载列表) -->
       <el-form-item label="企微主体" prop="corpId">
-        <el-select v-model="queryParams.corpId" placeholder="请选择所属公司" filterable size="small">
+        <el-select
+          v-model="queryParams.corpId"
+          placeholder="请选择所属公司"
+          filterable
+          size="small"
+          @change="handleCorpChange"
+        >
           <el-option
             v-for="(option, index) in corpOptions"
             :key="index"
@@ -51,6 +58,25 @@
         </el-select>
       </el-form-item>
 
+      <!-- 获客链接助手(点击下拉框才加载) -->
+      <el-form-item label="获客链接助手" prop="qwAcquisitionAssistantId" v-if="queryParams.corpId">
+        <el-select
+          v-model="queryParams.qwAcquisitionAssistantId"
+          placeholder="请选择获客链接助手"
+          clearable
+          size="small"
+          @change="handleQuery"
+          @visible-change="handleAssistantVisibleChange"
+        >
+          <el-option
+            v-for="item in qwAssistantOptions"
+            :key="item.id"
+            :label="item.linkName"
+            :value="item.id"
+          />
+        </el-select>
+      </el-form-item>
+
       <!-- 企微用户名:仅在“企微用户统计”Tab 下显示 -->
       <el-form-item label="企微用户名" prop="qwUserName" v-if="activeTab === 'account'">
         <el-input
@@ -175,7 +201,12 @@
 <script>
 import { treeselect } from "@/api/company/companyDept";
 import { listCompanyUser } from "@/api/company/companyUser";
-import { getSalesStatistics, salesUserDetail, getSalesAccountStat } from "@/api/company/statistics";
+import {
+  getSalesStatistics,
+  salesUserDetail,
+  getSalesAccountStat,
+  listSalesAcquisitionAssistants   // 新增接口
+} from "@/api/company/statistics";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import { allCorp } from "@/api/qw/qwCompany";
@@ -211,9 +242,12 @@ export default {
         orderByColumn: null,
         isAsc: null,
         corpId: null,
-        qwUserName: null
+        qwUserName: null,
+        qwAcquisitionAssistantId: null   // 获客链接助手主键
       },
       corpOptions: [],
+      qwAssistantOptions: [],          // 获客链接助手列表
+      assistantLoadedCorpId: null,     // 记录已加载助手列表的 corpId,避免重复加载
       // 详情弹窗
       detailVisible: false,
       detailLoading: false,
@@ -240,11 +274,9 @@ export default {
   methods: {
     /** 切换 Tab */
     handleTabClick() {
-      // 切换回汇总时,清空企微用户名搜索条件
       if (this.activeTab === 'summary') {
         this.queryParams.qwUserName = null;
       }
-      // 清空当前表格数据和分页,但不发送请求
       if (this.activeTab === 'summary') {
         this.summaryList = [];
       } else {
@@ -302,8 +334,41 @@ export default {
           this.userLoading = false;
         });
       }
-      // 移除 this.handleQuery()
     },
+    /** 企微主体变更:清空助手相关数据,不加载列表 */
+    handleCorpChange(corpId) {
+      this.qwAssistantOptions = [];
+      this.queryParams.qwAcquisitionAssistantId = null;
+      this.assistantLoadedCorpId = null;   // 标志重置
+      // 如果 corpId 被清空,无需额外操作;如果选择了新的,等待用户点击助手框再加载
+    },
+
+    /** 获客链接助手下拉框可见性变化事件 */
+    handleAssistantVisibleChange(visible) {
+      if (!visible) return; // 仅处理展开
+
+      // 没有选择企微主体时,清空列表并返回
+      if (!this.queryParams.corpId) {
+        this.qwAssistantOptions = [];
+        this.assistantLoadedCorpId = null;
+        return;
+      }
+
+      // 若已加载过当前主体且列表不为空,则不再重复请求
+      if (this.assistantLoadedCorpId === this.queryParams.corpId && this.qwAssistantOptions.length > 0) {
+        return;
+      }
+
+      // 请求接口加载列表
+      listSalesAcquisitionAssistants(this.queryParams.corpId).then(response => {
+        this.qwAssistantOptions = response.data || [];
+        this.assistantLoadedCorpId = this.queryParams.corpId;
+      }).catch(() => {
+        this.qwAssistantOptions = [];
+        this.assistantLoadedCorpId = null;
+      });
+    },
+
     /** 进粉时间变更 */
     changeAddTime(val) {
       if (val) {
@@ -337,17 +402,18 @@ export default {
       this.userList = [];
       this.queryParams.orderByColumn = null;
       this.queryParams.isAsc = null;
-      // 重置后保留 queryForm 已清空 qwUserName,再手动确保
       this.queryParams.qwUserName = null;
+      this.queryParams.qwAcquisitionAssistantId = null;
+      this.qwAssistantOptions = [];
+      this.assistantLoadedCorpId = null;
       this.handleQuery();
     },
     /** 获取列表数据(根据 activeTab 调不同接口) */
     getList() {
       this.loading = true;
-      // 构建请求参数,确保汇总标签不传入 qwUserName
       const params = { ...this.queryParams };
       if (this.activeTab === "summary") {
-        params.qwUserName = undefined; // 移除该字段
+        params.qwUserName = undefined;
       }
       const request = this.activeTab === "summary"
         ? getSalesStatistics(params)
@@ -367,7 +433,6 @@ export default {
     },
     /** 打开详情弹窗 */
     handleDetail(row) {
-      // 兼容汇总表 (userId) 和账号表 (companyUserId)
       const userId = row.userId || row.companyUserId;
       if (!userId) return;
       this.detailVisible = true;