Преглед на файлове

优化会话审计调用逻辑

cgp преди 3 дни
родител
ревизия
cbded082d7
променени са 2 файла, в които са добавени 34 реда и са изтрити 61 реда
  1. 1 1
      src/views/qw/conversationNew/ContentSearchTab.vue
  2. 33 60
      src/views/qw/conversationNew/EmployeeQueryTab.vue

+ 1 - 1
src/views/qw/conversationNew/ContentSearchTab.vue

@@ -235,7 +235,7 @@ export default {
           chatType: this.searchForm.chatType || undefined,
           startTime: this.searchForm.startTime,
           endTime: this.searchForm.endTime,
-          limit: 20,
+          limit: 50,
           cursor: reset ? null : this.cursor,
         };
         const res = await qwSearchMsg(params);

+ 33 - 60
src/views/qw/conversationNew/EmployeeQueryTab.vue

@@ -9,7 +9,7 @@
             filterable
             clearable
             placeholder="请选择员工"
-            :loading="staffLoading"
+            :loading="staffOptionsLoading"
           >
             <el-option
               v-for="item in staffOptions"
@@ -29,7 +29,7 @@
       </el-form>
     </div>
 
-    <!-- 员工列表(端分页) -->
+    <!-- 员工列表(端分页) -->
     <el-table
       v-loading="tableLoading"
       :data="staffList"
@@ -106,6 +106,7 @@
 
 <script>
 import { getAllCompanyUserListNoParams } from "@/api/company/companyUser";
+import { selectQwUserListByCondition } from "@/api/qw/qwUser";
 import { listExternalContact } from "@/api/qw/externalContact";
 import ConversationPanelPure from "./ConversationPanelPure.vue";
 import Pagination from "@/components/Pagination";
@@ -115,13 +116,11 @@ export default {
   components: { ConversationPanelPure, Pagination },
   data() {
     return {
-      // 所有员工数据(全量)
-      allStaffData: [],
-      // 员工下拉选项
+      // 员工下拉选项(全量,用于查询条件)
       staffOptions: [],
-      staffLoading: false,
+      staffOptionsLoading: false,
 
-      // 员工查询参数(分页)
+      // 员工查询参数(后端分页)
       queryParams: {
         userId: null,
         qwUserName: "",
@@ -152,16 +151,15 @@ export default {
     }
   },
   mounted() {
-    this.loadAllStaff();
+    this.loadStaffOptions();
+    this.getStaffList();
   },
   methods: {
-    // 加载所有员工(无公司限制)
-    async loadAllStaff() {
-      this.staffLoading = true;
-      this.tableLoading = true;
+    // 加载所有员工用于下拉选项(无公司限制)
+    async loadStaffOptions() {
+      this.staffOptionsLoading = true;
       try {
         const res = await getAllCompanyUserListNoParams();
-        // 兼容不同的返回格式
         let data = [];
         if (res.code === 200) {
           data = res.data || [];
@@ -171,7 +169,7 @@ export default {
           data = res.data;
         }
 
-        this.allStaffData = data.map(item => ({
+        this.staffOptions = data.map(item => ({
           userId: item.userId,
           nickName: item.nickName,
           qwUserName: item.qwUserName,
@@ -179,60 +177,35 @@ export default {
           departmentName: item.departmentName,
           corpId: item.corpId
         }));
-
-        // 初始化员工下拉选项
-        this.staffOptions = [...this.allStaffData];
-
-        // 加载第一页数据
-        this.queryParams.pageNum = 1;
-        this.getStaffList();
       } catch (e) {
-        console.error("加载员工数据失败", e);
-        this.allStaffData = [];
+        console.error("加载员工下拉选项失败", e);
         this.staffOptions = [];
-        this.staffList = [];
-        this.total = 0;
       } finally {
-        this.staffLoading = false;
-        this.tableLoading = false;
+        this.staffOptionsLoading = false;
       }
     },
 
-    // 获取员工列表(前端过滤 + 分页)
-    getStaffList() {
-      if (!this.allStaffData.length) {
-        this.staffList = [];
-        this.total = 0;
-        return;
-      }
-
+    // 获取员工列表(后端分页)
+    async getStaffList() {
       this.tableLoading = true;
       try {
-        // 1. 过滤数据
-        let filtered = [...this.allStaffData];
-
-        // 按员工ID筛选
-        if (this.queryParams.userId) {
-          filtered = filtered.filter(item => item.userId === this.queryParams.userId);
-        }
-
-        // 按企微昵称模糊筛选
-        if (this.queryParams.qwUserName) {
-          const keyword = this.queryParams.qwUserName.trim();
-          filtered = filtered.filter(item =>
-            item.qwUserName && item.qwUserName.includes(keyword)
-          );
+        // 构建请求参数,不传 companyId 让后端返回所有公司的员工(需后端支持)
+        const params = {
+          userId: this.queryParams.userId,
+          qwUserName: this.queryParams.qwUserName,
+          pageNum: this.queryParams.pageNum,
+          pageSize: this.queryParams.pageSize
+        };
+        const res = await selectQwUserListByCondition(params);
+        if (res.code === 200 && res.data) {
+          this.staffList = res.data.list || [];
+          this.total = res.data.total || 0;
+        } else {
+          this.staffList = [];
+          this.total = 0;
         }
-
-        // 2. 更新总数
-        this.total = filtered.length;
-
-        // 3. 分页
-        const start = (this.queryParams.pageNum - 1) * this.queryParams.pageSize;
-        const end = start + this.queryParams.pageSize;
-        this.staffList = filtered.slice(start, end);
       } catch (e) {
-        console.error("筛选员工数据失败", e);
+        console.error("获取员工列表失败", e);
         this.staffList = [];
         this.total = 0;
       } finally {
@@ -275,8 +248,8 @@ export default {
         const params = {
           pageNum: this.customerPageNum,
           pageSize: this.customerPageSize,
-          qwUserId: this.currentStaff.qwUserId,   // 员工的企微userId
-          corpId: this.currentStaff.corpId         // 员工所属企业的corpId
+          qwUserId: this.currentStaff.it,
+          corpId: this.currentStaff.corpId
         };
         const res = await listExternalContact(params);
         if (res.rows) {