Эх сурвалжийг харах

fix: 修复已结束会话列表筛选后, 点击进入会话, 列表数据会被重置为全部会话的问题

cuiyalong 2 жил өмнө
parent
commit
d2f2bac1a6

+ 35 - 4
src/views/CustomerServiceView.vue

@@ -543,7 +543,9 @@ export default {
         this.selectItem = e
         this.selectItem = e
         const { userId, nickName, userType, headImg, sessionId } = data.item
         const { userId, nickName, userType, headImg, sessionId } = data.item
         // 点击某一项清除未读消息角标
         // 点击某一项清除未读消息角标
-        this.getUserListFn({})
+        // 获取筛选参数, 在<会话中>列表返回空对象
+        const params = this.sortSearchParams()
+        this.getUserListFn(params)
         data.list.forEach(v => {
         data.list.forEach(v => {
           if (userId === v.userId) {
           if (userId === v.userId) {
             v.badge = 0
             v.badge = 0
@@ -562,7 +564,7 @@ export default {
         if (e === '结束') {
         if (e === '结束') {
           this.showInfo = false
           this.showInfo = false
           this.showMsgBox = true
           this.showMsgBox = true
-          this.getUserListFn({})
+          this.getUserListFn(params)
           // 点已结束 发送一句话即加入会话列表
           // 点已结束 发送一句话即加入会话列表
         } else {
         } else {
           if (e === '排队') {
           if (e === '排队') {
@@ -860,12 +862,41 @@ export default {
         })
         })
       }
       }
     },
     },
+    /**
+     * 获取并整理筛选器参数
+     * data数据格式如下,data如果不传,则直接从筛选器组件中取
+     * data = {
+     *  phone: '13200000000',
+     *  time: ['2022-09-19', '2022-09-20']
+     */
+    sortSearchParams (data) {
+      // 整理数据
+      if (data) {
+        const { phone, time } = data
+        const params = { phone, startTime: time ? time[0] : '', endTime: time ? time[1] : '' }
+        return params
+      } else {
+        // 获取数据并整理
+        const searchFilter = this.$refs.searchFilter
+        try {
+          // 已结束会话筛选,此时一定有searchFilter组件
+          const getData = {
+            phone: searchFilter.phoneVal,
+            time: searchFilter.timeVal
+          }
+          return this.sortSearchParams(getData)
+        } catch (error) {
+          // 会话中情况下,调用此方法会找不到筛选器组件报错
+          // 此时返回空对象
+          return {}
+        }
+      }
+    },
     /**
     /**
      * 筛选组件传值
      * 筛选组件传值
      */
      */
     onSearch (data) {
     onSearch (data) {
-      const { phone, time } = data
-      const params = { phone, startTime: time ? time[0] : '', endTime: time ? time[1] : '' }
+      const params = this.sortSearchParams(data)
       this.getUserListFn(params)
       this.getUserListFn(params)
     },
     },
     /**
     /**