zhangxiao
2024-08-30 724a9fec2338aaf5cc4c4d222b6ea0974703132e
src/views/sessionManager/index.vue
@@ -384,9 +384,11 @@
                ></updataFile>
                <!-- <uploadFile
                  ref="fileInput"
                  :sessionId="activeSessionId"
                  :handleRemove="handleRemove"
                  :typeXLse="false"
                  @selectFileCallback="selectFileCallback"
                ></uploadFile> -->
                <a-button
                  :disabled="chatDis"
                  @click="sentClick"
@@ -545,6 +547,9 @@
    getSessionDetailsApi,
    sessionListApi,
    uploadWithoutKb,
    uploadAndParse,
    chatInfos,
    chatRm,
  } from '@/api/session';
  import { getAuthorization } from '@/utils/auth';
  import { queryCanvasList } from '@/api/Agent';
@@ -772,11 +777,79 @@
    uploaditemList.value = [...uploaditemList.value, ...data];
  };
  //上传
  // const selectFileCallback = async (resData, file) => {
  //   console.log(111);
  //   try {
  //     const formData = new FormData();
  //     uploaditemList.value = resData;
  //     uploaditemList.value.map((item) => {
  //       if (item.name == file[0].file.name) {
  //         item.onFileSelectedLoading = true;
  //         item.textName = '上传中';
  //       }
  //       return item;
  //     });
  //     debugger;
  //     if (!activeSessionId.value) {
  //       await createSession(resData);
  //     }
  //     // onFileSelectedLoading.value = true;
  //     // textName.value = '上传中';
  //     formData.append('files', file[0].file);
  //     formData.append('conversation_id', activeSessionId.value);
  //     console.log(formData, 'formData');
  //     const { data, code } = await uploadAndParse(formData);
  //     if (code === 200) {
  //       uploaditemList.value.map((item: any) => {
  //         item.onFileSelectedLoading = false;
  //         item.textName = '上传成功';
  //         return item;
  //       });
  //       getInfo(data);
  //       // onFileSelectedLoading.value = false;
  //       // textName.value = '上传成功';
  //     }
  //   } catch (err) {
  //     uploaditemList.value.map((item: any) => {
  //       item.onFileSelectedLoading = false;
  //       item.textName = '上传失败';
  //       return item;
  //     });
  //     // onFileSelectedLoading.value = false;
  //     // textName.value = '上传失败';
  //     Message.error('上传失败');
  //   }
  // };
  //上传成功解析getinfo
  const getInfo = async (id) => {
    const { code, data } = await chatInfos({
      doc_ids: activeSessionId.value,
    });
    if (code === 200) {
      uploaditemList.value = data;
    }
  };
  //删除上传文档
  const deleteUpload = async (id) => {
    const { code, data } = await chatRm({
      doc_id: id,
    });
    if (code === 200) {
      getInfo();
    }
  };
  let onFileSelectedLoading = ref(false);
  const deleteFile = (item) => {
    console.log(uploaditemList.value);
    uploaditemList.value.splice(item.index, 1);
    // EventBus.emit('queryAgent', item);
  };
  const { toClipboard } = useClipboard();
@@ -846,7 +919,7 @@
    console.log(name, '新建会话名称');
    const res = await addSessionApi({
      dialog_id: id,
      dialog_id: '',
      conversation_desc: name,
    });
    // console.log(res, "res");
@@ -1123,9 +1196,10 @@
    activeSessionId.value = '';
  });
  onMounted(() => {
    document.getElementsByTagName;
    let container = document.getElementById('container');
    container.addEventListener('click', () => {
      fileInput.value.cancel();
      // fileInput.value.cancel();
    });
    EventBus.on('newChat', () => {
      agentType.value = '1';
@@ -1391,6 +1465,11 @@
        }
      }
    }
    .uploadFileDis {
      :deep(.arco-upload-list-type-text) {
        display: none;
      }
    }
    .chat-item {
      padding: 10px 0;