From 176b1538bb80fc65539f004a7ccbae94b7d8eafc Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期三, 21 八月 2024 16:18:30 +0800
Subject: [PATCH] 智能体详情信息

---
 src/views/sessionManager/index.vue |  150 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 128 insertions(+), 22 deletions(-)

diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue
index 3c71541..464e69b 100644
--- a/src/views/sessionManager/index.vue
+++ b/src/views/sessionManager/index.vue
@@ -20,7 +20,32 @@
           <div class="header___lEPyH">
             <div class="chatHeader">
               <div class="chatHeaderBox">
-                <span class="title">{{ agentTitle }}</span>
+<!--                <span class="title">{{ agentTitle }}</span>-->
+
+                <a-popover
+                  position="bottom"
+                  trigger="click"
+                >
+                  <a-button border
+                  >{{agentTitle}}
+                    <icon-down style="margin-left: 4px" />
+                  </a-button>
+                  <template #content>
+                    <a-button
+                      type="text"
+                      class="button"
+                      style="color: #2a2a2b"
+                      @click="handleClick()"
+                    >
+                      <template #icon>
+                        <icon-edit />
+                      </template>
+                      淇敼鍚嶇О
+                    </a-button>
+<!--                    <a-divider style="margin: 10px 0" />-->
+                  </template>
+                </a-popover>
+
               </div>
             </div>
           </div>
@@ -175,7 +200,7 @@
             <!--                </template>-->
             <!--              </a-upload>-->
             <!--            </div>-->
-            <spa style="position: absolute;top:96px;left: 10px;z-index: 10000;cursor: pointer">
+            <span style="position: absolute;top:94px;left: 20px;z-index: 999;cursor: pointer">
               <icon-attachment size="28" @click="selectFile" style="color: #0960bd;" />
               <input
                 ref="fileInput"
@@ -183,7 +208,7 @@
                 style="display: none;"
                 @change="onFileSelected"
               />
-            </spa>
+            </span>
             <div class="uploadFileList">
               <div class="files" v-for="(item,index) in uploaditemList" :key="index"
                    style="position: relative;width: 200px;margin-top: 10px;">
@@ -193,7 +218,12 @@
                   style="background: var(--color-bg-2);padding:10px;border-radius: 10px"
                 >
                   <template #avatar>
-                    <a-button type="text" :loading="onFileSelectedLoading" v-if="onFileSelectedLoading"></a-button>
+                    <a-spin :loading="onFileSelectedLoading" v-if="onFileSelectedLoading">
+                      <template #icon>
+                        <icon-sync />
+                      </template>
+                    </a-spin>
+<!--                    <a-button type="text" :loading="onFileSelectedLoading" v-if="onFileSelectedLoading"></a-button>-->
                     <a-avatar v-if="!onFileSelectedLoading">
                       <icon-file style="color: #0960bd" />
                     </a-avatar>
@@ -209,7 +239,7 @@
       </a-col>
       <a-col :span="23" v-show="agentType == '2'">
         <div class="center">
-          <agentSession :modalObj="agentObj"></agentSession>
+          <agentSession :modalObj="agentObj" ></agentSession>
         </div>
       </a-col>
       <a-col :span="23" v-show="agentType == '3'">
@@ -230,6 +260,19 @@
         </div>
       </a-col>
     </a-row>
+    <a-modal v-model:visible="visible" title="淇敼鍚嶇О" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start">
+      <a-form ref="formRef" :rules="rules" :model="chatObj" @submit="handleSubmit" >
+        <a-form-item field="name" label="鍚嶇О">
+          <a-input v-model="agentTitle" placeholder="璇疯緭鍏ュ悕绉�"/>
+        </a-form-item>
+        <a-form-item>
+          <div style="width: 100%;text-align: right">
+            <a-button @click="visible = false">鍙栨秷</a-button>
+            <a-button style="margin-left: 10px" type="primary" html-type="submit">纭畾</a-button>
+          </div>
+        </a-form-item>
+      </a-form>
+    </a-modal>
   </div>
 </template>
 <script setup lang="ts">
@@ -258,6 +301,7 @@
 import agentSession from "@/views/sessionManager/components/agentSession.vue";
 import historySession from "@/views/sessionManager/components/historySession.vue";
 import smartAi from "@/views/sessionManager/components/smartAi.vue";
+import setName from "@/views/sessionManager/components/setName.vue";
 import EventBus from "@/utils/EventBus";
 import {
   addSessionApi,
@@ -300,6 +344,54 @@
 const files = ref([]);
 const file = ref('');
 const fileInput = ref(null);
+const chatDataMeg = reactive({})
+const visible = ref(false);
+
+
+
+const rules = {
+  name: [
+    {
+      required: true,
+      message:'鍚嶇О涓嶅厑璁镐负绌�',
+    },
+  ],
+}
+
+const handleSubmit = async({values, errors}) => {
+  if(errors) return;
+  // chatObj.name = agentTitle.value;
+  // chatObj.conversation_id = chatObj.id;
+  let chatData = {
+    id:chatObj.id,
+    conversation_id:chatObj.id,
+    name: agentTitle.value
+  }
+  const { code, data } = await addSessionApi(chatData);
+  if (data) {
+    Message.success("淇敼鎴愬姛");
+    handleCancel()
+    queryNewSessionDetail(activeSessionId.value);
+  }
+}
+
+const handleClick = () => {
+  visible.value = true;
+};
+const handleCancel = () => {
+  visible.value = false;
+}
+
+const handleOpened =(el) => {
+  // Object.assign(form,{
+  //   name: '',// 鐢ㄦ埛鍚�
+  // });
+  // formRef.value.resetFields();
+}
+
+
+
+
 
 const selectFile = () => {
   fileInput.value.click();
@@ -549,11 +641,12 @@
       if (done) {
         console.info("done");
         displayedText.value = "";
-        // if(!isStopChat.value){
-        //   queryNewSessionDetail(activeSessionId.value);
-        // }
-        queryNewSessionDetail(activeSessionId.value);
-        EventBus.emit("queryAppUsageList");
+        if(isStopChat.value){
+          setChatDataMeg(chatDataMeg);
+        }else{
+          queryNewSessionDetail(activeSessionId.value);
+          EventBus.emit("queryAppUsageList");
+        }
         break;
       }
     }
@@ -563,12 +656,16 @@
   loading.value = false;
 };
 
+
+
 const stopChat = async () => {
   // const { code, data } = await stopChatApi(activeSessionId.value);
   // if (code === 200) {
   //   Message.success("宸插仠姝�");
   //   queryNewSessionDetail(activeSessionId.value);
   // }
+  loading.value = false;
+  chatDis.value = false;
   isStopChat.value = true;
   console.log("stopChat");
   console.log(displayedText.value, "displayedText");
@@ -583,22 +680,31 @@
     role: "assistant"
   }];
   sessionDetailList.value = sessionDetailList.value.splice(0, sessionDetailList.value.length - 2).concat(lastArr);
+
   console.log(sessionDetailList.value, "sessionDetailList2");
   console.log(chatObj, "chatObj瀵硅薄");
   chatObj.message = chatObj.message.concat(lastArr);
-  // clearTimeout(timer!);
-  // timer = null;
-  // const { code, data } = await addSessionApi(chatObj);
-  // if (data) {
-  //   //鍋滄瀹氭椂鍣�
-  //   clearTimeout(timer!);
-  //   timer = null;
-  //   displayedText.value = "";
-  //   queryNewSessionDetail(activeSessionId.value);
-  // }
-
+  Object.assign(chatDataMeg,{
+    id:chatObj.id,
+    conversation_id:chatObj.id,
+    message: sessionDetailList.value
+  });
 
 };
+
+const setChatDataMeg = async(chatData) => {
+  const { code, data } = await addSessionApi(chatData);
+  if (data) {
+    //鍋滄瀹氭椂鍣�
+    clearTimeout(timer!);
+    timer = null;
+    // displayedText.value = "";
+    queryNewSessionDetail(activeSessionId.value);
+  }
+};
+
+
+
 
 const queryNewSessionDetail = async (id) => {
   activeSessionId.value = id;
@@ -888,7 +994,7 @@
 
         .btn-send {
           position: absolute !important;
-          right: 10px;
+          right: 4px;
           top: 90px;
           z-index: 10;
         }

--
Gitblit v1.8.0