From b8c8c344ca7adf43be59bacaebe2c3f3b682065e Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期三, 21 八月 2024 12:08:15 +0800 Subject: [PATCH] agent 修改名称 --- src/views/sessionManager/components/historySession.vue | 117 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 95 insertions(+), 22 deletions(-) diff --git a/src/views/sessionManager/components/historySession.vue b/src/views/sessionManager/components/historySession.vue index e7c9c5e..16eb7ff 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> @@ -94,7 +97,7 @@ getDialogListApi, getSessionDetailsApi, deleteSessionApi, - sessionListApi + sessionListApiPage } from "@/api/session"; import { queryCanvasList } from "@/api/Agent"; @@ -112,8 +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) { @@ -163,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 { @@ -171,7 +187,11 @@ showtype: 1 } }); - + isReached.value = false; + setTimeout(()=>{ + isReached.value = true; + },100) + // total.value = sessionList.value.length; } else { @@ -200,34 +220,25 @@ const querySessionDetail = async (session) => { console.log(session, 'session'); - - // 鏌ヨ鍘嗗彶璁板綍 - if (session.base == 'agent') { + if (session.app_type == '2') { // agent瀵硅薄鏁版嵁灏佽 - // const { code, data } = await getAgentSessionDetailsApi(session.app_id); + // 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, - // } - // + // // let sessionObj = { + // // id: session.app_id, + // // dsl: data.dsl, + // // title: session.name, + // // } // } - EventBus.emit("queryAgentSessionDetail",{ - ...sessionObj, - id: session.app_id, - }); + EventBus.emit("queryAgentSessionDetail",session); emit('changeAgentType','2'); } else { // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇� emit('changeAgentType','1'); emit('querySessionDetail',session); } - - - } @@ -238,6 +249,58 @@ const handleMouseLeave = (session) => { 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() @@ -251,6 +314,16 @@ querySessionList(''); }); + // 娣诲姞婊氬姩浜嬩欢鐩戝惉鍣� + scrollRef.value.$el.addEventListener('scroll', handleScroll); + + // 娓呯悊鍑芥暟 + return () => { + scrollRef.value.$el.removeEventListener('scroll', handleScroll); + }; + + + }) onBeforeUnmount(() => { EventBus.off("history"); -- Gitblit v1.8.0