zhangxiao
2024-08-29 8a67c292deeacaf228e0a5489b4c26a1fdd83803
src/views/sessionManager/components/historySession.vue
@@ -9,7 +9,8 @@
                left: -40px;
                font-size: 30px;
                z-index: 99;
                cursor: pointer"
        cursor: pointer;
      "
                @click="emit('changeAgentType','1')"
              >
                <template #icon>
@@ -30,7 +31,6 @@
              >
                <div class="historyTitle___F_iam">历史会话</div>
                <div class="search">
<!--                  查询框-->
                  <div class="search-box">
@@ -38,12 +38,10 @@
                    <a-input
                      placeholder="搜索历史会话"
                      v-model="searchValue"
                      style="width: 90%;"
            style="width: 90%"
                    />
                  </div>
                </div>
                <div class="historyCenter">
                  <div
@@ -61,8 +59,7 @@
                      />
                      {{ session.name }}
                    </div>
                    <div class="time"
                    >
          <div class="time">
                      <span v-show="session.showtype == 1" style="font-size: 14px">
                        {{
                          moment(new Date(session.create_time)).format(
@@ -71,7 +68,12 @@
                        }}
                      </span>
                    </div>
                    <a-button type="text" @click.stop="deleteSession(session)" style="color: red;position: absolute;right: 10px;top: 10px;"  v-show="session.showtype == 2">
          <a-button
            type="text"
            @click.stop="deleteSession(session)"
            style="color: red; position: absolute; right: 10px; top: 10px"
            v-show="session.showtype == 2"
          >
                      <icon-delete style="font-size: 14px" />
                    </a-button>
                  </div>
@@ -83,37 +85,46 @@
import {
  IconClose,
  IconSearch,
  IconTiktokColor
} from "@arco-design/web-vue/es/icon";
import { useAppStore, useUserStore } from "@/store";
import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue";
    IconTiktokColor,
  } from '@arco-design/web-vue/es/icon';
  import { useAppStore, useUserStore } from '@/store';
  import {
    computed,
    nextTick,
    onMounted,
    watch,
    reactive,
    ref,
    onBeforeMount,
    onBeforeUnmount,
  } from 'vue';
import { Message, Modal } from "@arco-design/web-vue";
  import { Message, Modal } from '@arco-design/web-vue';
import EventBus from '@/utils/EventBus';
import moment from "moment";
  import moment from 'moment';
import {
  addSessionApi,
  chatApi,
  getDialogListApi,
  getSessionDetailsApi,
  deleteSessionApi,
  sessionListApiPage
} from "@/api/session";
    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";
  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" };
  const activeSessionId = ref('');
  const fieldNames = { value: 'id', label: 'name' };
const dialogs = ref([]);
const dialogObj = reactive({});
const agentObj = reactive({});
const agentList = ref([]);
const searchValue = ref("");
const selectValue = ref("");
  const searchValue = ref('');
  const selectValue = ref('');
const sectionList = ref({});
const scrollRef = ref(null);
const httpUrl = localStorage.getItem('httpUrl');
@@ -121,8 +132,8 @@
let scrollTopVal = ref(0);
let queryPage = reactive({
  page: 1,
  page_size: 50
})
    page_size: 50,
  });
let total = ref(0);
let sessionScrollList = ref([]);
let isReached = ref(true);
@@ -135,7 +146,7 @@
      dialogs.value = data.map((item) => {
        return {
          ...item,
          type: 1 //智能体
            type: 1, //智能体
        };
      });
      // console.log(data, "dialogs");
@@ -147,12 +158,12 @@
const queryCanvas = async (params = {}) => {
  try {
    const { data } = await queryCanvasList(params);
    console.log(data, "agent");
      console.log(data, 'agent');
    agentList.value = data.map((item) => {
      return {
        ...item,
        name: item.title,
        type: 2 //agent
          type: 2, //agent
      };
    });
    // 合并数组
@@ -165,37 +176,32 @@
    // }
    //新建会话
    querySessionList(dialogs.value[0].id);
  } catch (err) {
    // you can report use errorHandler or other
  } finally {
  }
};
// 查询会话列表
const querySessionList = async (id) => {
  const { code, data } = await sessionListApiPage({
    dialog_id: id,
    ...queryPage
      ...queryPage,
  });
  if (code === 200) {
    sessionList.value = data.map((item) => {
      return {
        ...item,
        showtype: 1
      }
          showtype: 1,
        };
    });
    isReached.value = false;
    setTimeout(()=>{
      isReached.value = true;
    },100)
      }, 100);
    // total.value = sessionList.value.length;
  } else {
    Message.warning("查询失败");
      Message.warning('查询失败');
  }
};
@@ -236,11 +242,13 @@
    //   //   title: session.name,
    //   // }
    // }
    EventBus.emit("queryAgentSessionDetail",session);
      EventBus.emit('queryAgentSessionDetail', session);
    emit('changeAgentType','2');
    } else if (session.base == 'advanced-agent') {
      EventBus.emit('queryAgentSessionDetails', session);
      emit('changeAgentType', '5');
  }
}
  };
const handleMouseEnter = (session) => {
  session.showtype = 2;
@@ -249,7 +257,6 @@
const handleMouseLeave = (session) => {
  session.showtype = 1;
};
const handleScroll = async (e: any) => {
  scrollTopVal.value = e.target.scrollTop;
@@ -268,17 +275,17 @@
    //
    //
    // }
    queryPage.page++
      queryPage.page++;
    const { code, data } = await sessionListApiPage({
      dialog_id: '',
      ...queryPage
        ...queryPage,
    });
    if (code === 200) {
       sessionScrollList.value = data.map((item) => {
        return {
          ...item,
          showtype: 1
        }
            showtype: 1,
          };
      });
      // total.value = sessionList.value.length;
      sessionList.value = [...sessionList.value,...sessionScrollList.value];
@@ -289,32 +296,26 @@
          scrollRef.value.scrollTop(scrollTopVal.value);
          // console.log(scrollRef.value.$el.scrollTop,'scrollTopVal');
          // console.log(scrollTopVal.value,'scrollTopVal');
        })
      },100)
          });
        }, 100);
    } else {
      Message.warning("查询失败");
    }
        Message.warning('查询失败');
  }
}
  };
onBeforeMount(()=>{
  // DialogList()
  querySessionList('');
})
  });
onMounted(() => {
  console.log(httpUrl,'当前地址');
  EventBus.on("history", () => {
    EventBus.on('history', () => {
    emit('changeAgentType','3');
    // DialogList()
    queryPage.page = 1;
    querySessionList('');
  });
  // 添加滚动事件监听器
  scrollRef.value.$el.addEventListener('scroll', handleScroll);
@@ -323,15 +324,10 @@
  return () => {
    scrollRef.value.$el.removeEventListener('scroll', handleScroll);
  };
})
onBeforeUnmount(() => {
  EventBus.off("history");
});
  onBeforeUnmount(() => {
    EventBus.off('history');
  });
</script>
<style scoped lang="less">
  .layoutHisCenter{
@@ -385,15 +381,9 @@
        color: var(--color-text-2);
        //border: 1px solid var(--color-neutral-3);
        background: var(--color-bg-3);
        box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
        box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
          0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
      }
    }
  }
</style>