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 | 123 ++++++++++++++++++++++++++++++++++------- 1 files changed, 102 insertions(+), 21 deletions(-) diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue index a0e78f2..464e69b 100644 --- a/src/views/sessionManager/index.vue +++ b/src/views/sessionManager/index.vue @@ -31,7 +31,17 @@ <icon-down style="margin-left: 4px" /> </a-button> <template #content> - <setName :activeSessionId="activeSessionId" @queryNewSessionDetail="queryNewSessionDetail"></setName> + <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> @@ -190,7 +200,7 @@ <!-- </template>--> <!-- </a-upload>--> <!-- </div>--> - <span 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" @@ -229,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'"> @@ -250,7 +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"> @@ -322,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(); @@ -571,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; } } @@ -585,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"); @@ -605,22 +680,28 @@ 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); + } +}; @@ -913,7 +994,7 @@ .btn-send { position: absolute !important; - right: 10px; + right: 4px; top: 90px; z-index: 10; } -- Gitblit v1.8.0