liudong
2024-08-19 08b529136889c9a40b12674ebdd06cb34ede84da
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>
@@ -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,48 @@
const files = ref([]);
const file = ref('');
const fileInput = ref(null);
const visible = ref(false);
const rules = {
  name: [
    {
      required: true,
      message:'名称不允许为空',
    },
  ],
}
const handleSubmit = async({values, errors}) => {
  if(errors) return;
  chatObj.name = agentTitle.value;
  const { code, data } = await addSessionApi(chatObj);
  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();
@@ -569,6 +655,8 @@
  //   Message.success("已停止");
  //   queryNewSessionDetail(activeSessionId.value);
  // }
  loading.value = false;
  chatDis.value = false;
  isStopChat.value = true;
  console.log("stopChat");
  console.log(displayedText.value, "displayedText");
@@ -596,9 +684,12 @@
  //   displayedText.value = "";
  //   queryNewSessionDetail(activeSessionId.value);
  // }
};
const queryNewSessionDetail = async (id) => {
  activeSessionId.value = id;
@@ -888,7 +979,7 @@
        .btn-send {
          position: absolute !important;
          right: 10px;
          right: 4px;
          top: 90px;
          z-index: 10;
        }