From 53fd55bdf6544ae9c2697e460766ce2d53044dbe Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期一, 26 八月 2024 14:54:26 +0800
Subject: [PATCH] fix: 修改bug

---
 src/views/sessionManager/components/historySession.vue |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 111 insertions(+), 8 deletions(-)

diff --git a/src/views/sessionManager/components/historySession.vue b/src/views/sessionManager/components/historySession.vue
index 23b3479..f74ed54 100644
--- a/src/views/sessionManager/components/historySession.vue
+++ b/src/views/sessionManager/components/historySession.vue
@@ -18,12 +18,15 @@
               </a-button>
 
               <a-scrollbar
+                ref="scrollRef"
                 class="left-list"
                 style="
-                  height: calc(100vh - 100px);
-                  overflow-y: auto;
+                  height: calc(100vh - 160px);
+                  overflow-y: scroll;
                   overflow-x: hidden;
                 "
+                v-if="isReached"
+                @scroll="handleScroll"
               >
                 <div class="historyTitle___F_iam">鍘嗗彶浼氳瘽</div>
 
@@ -54,7 +57,7 @@
                       <img
                         :style="{ width: '16px' }"
                         alt="dessert"
-                        :src="session.avatar || imgSrc"
+                        :src="session.icon ? httpUrl + session.icon : imgSrc"
                       />
                       {{ session.name }}
                     </div>
@@ -94,13 +97,14 @@
   getDialogListApi,
   getSessionDetailsApi,
   deleteSessionApi,
-  sessionListApi
+  sessionListApiPage
 } from "@/api/session";
 
 import { queryCanvasList } from "@/api/Agent";
 const emit = defineEmits(["querySessionDetail","changeAgentType"]);
 import logo from "@/assets/images/model.png";
 import { deleteKnow } from "@/api/kbList";
+import { getAgentSessionDetailsApi } from "@/api/agentSession";
 const sessionList = ref([]); //浼氳瘽鍒楄〃
 const activeSessionId = ref("");
 const fieldNames = { value: "id", label: "name" };
@@ -111,7 +115,18 @@
 const searchValue = ref("");
 const selectValue = ref("");
 const sectionList = ref({});
+const scrollRef = ref(null);
+const httpUrl = localStorage.getItem('httpUrl');
 const imgSrc = ref(logo);
+let scrollTopVal = ref(0);
+let queryPage = reactive({
+  page: 1,
+  page_size: 50
+})
+let total = ref(0);
+let sessionScrollList = ref([]);
+let isReached = ref(true);
+
 const DialogList = async () => {
   const { code, data } = await getDialogListApi();
   if (code === 200) {
@@ -161,7 +176,10 @@
 
 // 鏌ヨ浼氳瘽鍒楄〃
 const querySessionList = async (id) => {
-  const { code, data } = await sessionListApi(id);
+  const { code, data } = await sessionListApiPage({
+    dialog_id: id,
+    ...queryPage
+  });
   if (code === 200) {
     sessionList.value = data.map((item) => {
       return {
@@ -169,7 +187,11 @@
         showtype: 1
       }
     });
-
+    isReached.value = false;
+    setTimeout(()=>{
+      isReached.value = true;
+    },100)
+    // total.value = sessionList.value.length;
 
 
   } else {
@@ -198,8 +220,25 @@
 
 const querySessionDetail = async (session) => {
   console.log(session, 'session');
-  emit('changeAgentType','1');
-  emit('querySessionDetail',session);
+  // 鏌ヨ鍘嗗彶璁板綍 app_type 1:鏅鸿兘浣� 2:agent
+  if (!session.base) {
+    // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
+    emit('changeAgentType','1');
+    emit('querySessionDetail',session);
+  } else  if (session.base == 'agent'){
+    // agent瀵硅薄鏁版嵁灏佽
+    // const { code, data } = await getAgentSessionDetailsApi(session.dialog_id);
+    // if (code == 0) {
+    //   console.log(data,'浼氳瘽璇︽儏');
+    //   // let sessionObj = {
+    //   //   id: session.app_id,
+    //   //   dsl: data.dsl,
+    //   //   title: session.name,
+    //   // }
+    // }
+    EventBus.emit("queryAgentSessionDetail",session);
+    emit('changeAgentType','2');
+  }
 }
 
 
@@ -211,18 +250,82 @@
   session.showtype = 1;
 };
 
+
+const handleScroll = async (e: any) => {
+  scrollTopVal.value = e.target.scrollTop;
+  let offsetHeight = e.target.offsetHeight;
+  let scrollHeight = e.target.scrollHeight;
+
+  if (scrollTopVal.value + offsetHeight >= scrollHeight-1) {
+    console.log(scrollTopVal.value);
+    // console.log(offsetHeight);
+    // console.log(scrollHeight);
+    //婊氬姩鏉″埌杈惧簳閮�
+    // if (sessionList.value.length < total.value) {
+    //   //鏁版嵁涓哄姞杞藉畬锛岀户缁祴鍊�
+    //   // queryPage.page++
+    //
+    //
+    //
+    // }
+    queryPage.page++
+    const { code, data } = await sessionListApiPage({
+      dialog_id: '',
+      ...queryPage
+    });
+    if (code === 200) {
+       sessionScrollList.value = data.map((item) => {
+        return {
+          ...item,
+          showtype: 1
+        }
+      });
+      // total.value = sessionList.value.length;
+      sessionList.value = [...sessionList.value,...sessionScrollList.value];
+      isReached.value = false;
+      setTimeout(()=>{
+        isReached.value = true;
+        nextTick(()=>{
+          scrollRef.value.scrollTop(scrollTopVal.value);
+          // console.log(scrollRef.value.$el.scrollTop,'scrollTopVal');
+          // console.log(scrollTopVal.value,'scrollTopVal');
+        })
+      },100)
+
+
+    } else {
+      Message.warning("鏌ヨ澶辫触");
+    }
+
+  }
+}
+
+
+
 onBeforeMount(()=>{
   // DialogList()
   querySessionList('');
 })
 
 onMounted(() => {
+  console.log(httpUrl,'褰撳墠鍦板潃');
   EventBus.on("history", () => {
     emit('changeAgentType','3');
     // DialogList()
+    queryPage.page = 1;
     querySessionList('');
 
   });
+  // 娣诲姞婊氬姩浜嬩欢鐩戝惉鍣�
+  scrollRef.value.$el.addEventListener('scroll', handleScroll);
+
+  // 娓呯悊鍑芥暟
+  return () => {
+    scrollRef.value.$el.removeEventListener('scroll', handleScroll);
+  };
+
+
+
 })
 onBeforeUnmount(() => {
   EventBus.off("history");

--
Gitblit v1.8.0