Эх сурвалжийг харах

优化接口并添加修改部门名称等功能

yangg 5 сар өмнө
parent
commit
95e0f4c015

+ 21 - 1
src/api/knowledge.js

@@ -781,4 +781,24 @@ export function exportOutcoms(data) {
     method: 'post',
     data
   })
-}
+}
+
+/* 修改输入项目表信息 */
+
+export function updateInfo(data) {
+  return request({
+    url: 'project-input-temp/update-info',
+    method: 'post',
+    data
+  })
+}
+
+
+/* 批量修改部门 */
+export function batchUpdateInfo(data) {
+  return request({
+    url: 'project-input-temp/batch-update-department',
+    method: 'post',
+    data
+  })
+}

+ 15 - 6
src/components/ai.vue

@@ -206,6 +206,7 @@ export default {
       currentChat_id: "",
       uploadFiles: [], // 存储上传的文件
       documents: [], // 新增:专门存储文档类型文件的数组
+      currentAudio: null, // 添加当前播放的音频实例
     };
   },
   mounted() {
@@ -243,11 +244,19 @@ export default {
   methods: {
     /* 播放音频 */
     playAudio(audioBase64) {
-      console.log(audioBase64);
-      // 创建音频元素
-      const audio = new Audio(audioBase64); // 播放音频
+       // 如果有正在播放的音频,先停止它
+       if (this.currentAudio) {
+        this.currentAudio.pause();
+        this.currentAudio = null;
+      }
+
+      // 创建新的音频实例并播放
+      const audio = new Audio(audioBase64);
+      this.currentAudio = audio;
+      
       audio.play().catch((error) => {
         console.error("Error playing audio:", error);
+        this.currentAudio = null;
       });
     },
     async handleFileUpload(event) {
@@ -533,7 +542,7 @@ export default {
       }
     },
     async getMinioUrls(idObject) {
-      this.minioUrls = []; // 清空���前的 URL
+      this.minioUrls = []; // 清空前的 URL
 
       try {
         console.log("Sending to backend:", JSON.stringify(idObject));
@@ -671,7 +680,7 @@ export default {
 
       const renderedHtml = md.render(rawMarkdown);
 
-      // 使用 setTimeout ���确保 DOM 更新后再添加事件监听器
+      // 使用 setTimeout 确保 DOM 更新后再添加事件监听器
       setTimeout(() => {
         const links = document.querySelectorAll(".custom-link");
         links.forEach((link) => {
@@ -943,7 +952,7 @@ export default {
   border-radius: 50%; /* 圆形头像 */
   /*background-color: #e9e0e0;  暂时用灰色代替,你可以用图片替换 */
   align-self: start; /* 这将覆盖 flex 容器的 align-items 并将头像对齐到顶部 */
-  margin-right: 10px; /* 按需调整以��头像和消息之间提供空间 */
+  margin-right: 10px; /* 按需调整以头像和消息之间提供空间 */
 }
 
 .user-avatar {

+ 126 - 6
src/views/Information/index.vue

@@ -37,7 +37,11 @@
         </el-form-item>
       </el-form>
     </div>
-    <el-table :data="projectList" stripe>
+    <div class="batch-operation">
+      <el-button type="primary" :disabled="selectedRows.length== 0" @click="handleBatchDepartment">批量修改部门</el-button>
+    </div>
+    <el-table :data="projectList" stripe @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" />
       <el-table-column prop="sequence" label="序号" width="80">
         <template #default="scope">
           <div style="display: flex; align-items: center">
@@ -76,14 +80,16 @@
           </el-tag>
         </template>
       </el-table-column>
-      <!-- 添加操作列 -->
-      <!--  <el-table-column label="操作" width="150">
+      <el-table-column label="操作" width="200">
         <template #default="scope">
-          <el-button type="primary" size="small" @click="handleEdit(scope.row)"
-            >编辑</el-button
+          <el-button
+            type="primary"
+            size="small"
+            @click="handleEditInfo(scope.row)"
+            >编辑信息</el-button
           >
         </template>
-      </el-table-column> -->
+      </el-table-column>
     </el-table>
     <!-- 添加分页组件 -->
     <div class="pagination-container">
@@ -145,6 +151,60 @@
         <el-button type="primary" @click="handleContentSubmit">确定</el-button>
       </div>
     </el-dialog>
+    <!-- 添加新的编辑信息对话框 -->
+    <el-dialog
+      title="编辑信息"
+      :visible.sync="infoDialogVisible"
+      width="30%"
+      append-to-body
+    >
+      <el-form :model="infoForm" label-width="80px">
+        <el-form-item label="文件名称">
+          <el-input v-model="infoForm.name" placeholder="请输入文件名称" />
+        </el-form-item>
+        <el-form-item label="部门">
+          <el-select v-model="infoForm.department" placeholder="请选择部门">
+            <el-option
+              v-for="(item, index) in departList"
+              :key="index"
+              :label="item.label"
+              :value="item.label"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="infoDialogVisible = false">取消</el-button>
+          <el-button type="primary" @click="submitInfo">确定</el-button>
+        </span>
+      </template>
+    </el-dialog>
+    <!-- 添加批量修改部门的对话框 -->
+    <el-dialog
+      title="批量修改部门"
+      :visible.sync="batchDepartDialogVisible"
+      width="30%"
+    >
+      <el-form :model="batchDepartForm" label-width="80px">
+        <el-form-item label="部门">
+          <el-select v-model="batchDepartForm.department" placeholder="请选择部门">
+            <el-option
+              v-for="(item, index) in departList"
+              :key="index"
+              :label="item.label"
+              :value="item.label"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="batchDepartDialogVisible = false">取消</el-button>
+          <el-button type="primary" @click="submitBatchDepartment">确定</el-button>
+        </span>
+      </template>
+    </el-dialog>
   </div>
 </template>
   
@@ -156,6 +216,8 @@ import {
   TemplateUpdate,
   departments,
   projectTemUpdate,
+  updateInfo,
+  batchUpdateInfo
 } from "@/api/knowledge";
 import elDragDialog from "@/directive/el-drag-dialog";
 import CanvasEditor from "@/components/CanvasEditor/index"; // 确保路径正确
@@ -196,6 +258,17 @@ export default {
         name: "",
         department: "",
       },
+      infoDialogVisible: false,
+      infoForm: {
+        name: "",
+        department: "",
+      },
+      selectedRows: [], // 存储选中的行
+      batchDepartDialogVisible: false,
+      batchDepartForm: {
+        department: '',
+        ids: []
+      }
     };
   },
   methods: {
@@ -405,6 +478,50 @@ export default {
         this.departList = res.data.departments;
       });
     },
+    handleEditInfo(row) {
+      this.infoForm = {
+        id: row.id,
+        name: row.name,
+        department: row.department,
+      };
+      this.infoDialogVisible = true;
+    },
+    async submitInfo() {
+      try {
+        await updateInfo(this.infoForm);
+        this.$message.success("信息更新成功");
+        this.infoDialogVisible = false;
+        this.getProjectList(); // 刷新列表
+      } catch (error) {
+        this.$message.error("信息更新失败:" + error.message);
+      }
+    },
+    // 处理表格多选
+    handleSelectionChange(selection) {
+      this.selectedRows = selection;
+    },
+
+    // 打开批量修改部门对话框
+    handleBatchDepartment() {
+      this.batchDepartForm.department = '';
+      this.batchDepartForm.ids = this.selectedRows.map(row => row.id);
+      this.batchDepartDialogVisible = true;
+    },
+
+    // 提交批量修改部门
+    async submitBatchDepartment() {
+      try {
+        await batchUpdateInfo({
+          ids:JSON.stringify(this.batchDepartForm.ids),
+          department: this.batchDepartForm.department
+        });
+        this.$message.success('批量修改部门成功');
+        this.batchDepartDialogVisible = false;
+        this.getProjectList(); // 刷新列表
+      } catch (error) {
+        this.$message.error('批量修改部门失败:' + error.message);
+      }
+    }
   },
   created() {
     this.getProjectList();
@@ -438,4 +555,7 @@ export default {
 ::v-deep .el-dialog {
   margin-top: 0 !important;
 }
+.batch-operation {
+  margin: 10px 0;
+}
 </style>

+ 2 - 2
src/views/dashboard/admin/chart.vue

@@ -353,7 +353,7 @@
                                       <a class="dropdown-item" href="#">1周</a>
                                       <a class="dropdown-item" href="#">2年</a>
                                       <a class="dropdown-item" href="#"
-                                        >3个��</a
+                                        >3个</a
                                       >
                                     </div>
                                   </div> -->
@@ -548,7 +548,7 @@
                           </div>
                         </div>
 
-                        <!-- ���入卡片 -->
+                        <!-- 入卡片 -->
                         <div class="col-md-4 col-xl-2 col-sm-6">
                           <div class="card">
                             <div class="card-body">

+ 1 - 1
src/views/knowledgeMenu/category/knowledgeSet.vue

@@ -1506,7 +1506,7 @@ export default {
 <style lang="scss" scoped>
 .project-search {
   display: flex;
-  height: calc(100vh - 100px); // 假设顶部导���栏高度为60px
+  height: calc(100vh - 100px); // 假设顶部导栏高度为60px
   background-color: #f9fafb;
   .custom-tree-node {
     width: 100%;

+ 14 - 5
src/views/login/aiIndex.vue

@@ -209,6 +209,7 @@ export default {
       phone: "",
       uploadFiles: [], // 存储上传的文件
       documents: [], // 新增:专门存储文档类型文件的数组
+      currentAudio: null, // 添加当前播放的音频实例
     };
   },
   mounted() {
@@ -249,11 +250,19 @@ export default {
   methods: {
     /* 播放音频 */
     playAudio(audioBase64) {
-      console.log(audioBase64);
-      // 创建音频元素
-      const audio = new Audio(audioBase64); // 播放音频
+       // 如果有正在播放的音频,先停止它
+       if (this.currentAudio) {
+        this.currentAudio.pause();
+        this.currentAudio = null;
+      }
+
+      // 创建新的音频实例并播放
+      const audio = new Audio(audioBase64);
+      this.currentAudio = audio;
+      
       audio.play().catch((error) => {
         console.error("Error playing audio:", error);
+        this.currentAudio = null;
       });
     },
     async handleFileUpload(event) {
@@ -489,7 +498,7 @@ export default {
               session_id: this.session_id || "",
               source: "pc",
               image_urls: imageUrls,
-              documents: documentUrls, // ��加文档 URLs
+              documents: documentUrls, // 加文档 URLs
               //history_limit: 10
             },
           });
@@ -898,7 +907,7 @@ export default {
 }
 
 .messages {
-  width: 1180px; /* 设置消息列表宽度为屏���宽度的 80% */
+  width: 1180px; /* 设置消息列表宽度为屏宽度的 80% */
   max-width: 90%; /* 限制最大宽度,避免超出视口 */
   margin: 0 auto; /* 上下保持原有的 margin,左右自动调整以居中 */
   overflow-y: auto; /* 如果消息太多,允许滚动 */

+ 2 - 2
src/views/middPage/list.vue

@@ -109,7 +109,7 @@
                 type="daterange"
                 range-separator="至"
                 start-placeholder="开始日期"
-                end-placeholder="结束日��"
+                end-placeholder="结束日"
                 value-format="yyyy-MM-dd"
               />
             </el-form-item> -->
@@ -1072,7 +1072,7 @@ export default {
         );
         if (response.status !== 200) return;
         console.log(this.tagForm.tags);
-        this.$message.success("标签��新成功");
+        this.$message.success("标签新成功");
         this.tagDialogVisible = false;
         this.fetchGpuList(); // 刷新列表
       } catch (error) {

+ 86 - 22
src/views/project/components/dataList.vue

@@ -427,7 +427,7 @@ export default {
   },
   methods: {
     /* 使用html-docx-js方法替换 */
-    // 预处理内容,处理分页��和表格
+    // 预处理内容,处理分页和表格
     preprocessContent(content) {
       const tempDiv = document.createElement("div");
       tempDiv.innerHTML = content;
@@ -859,7 +859,7 @@ export default {
       return hasCellBorder && !hasNoBorderMark;
     },
 
-    // 添加处理分��的辅助方法
+    // 添加处理分的辅助方法
     addPageBreaks(content) {
       // 查找需要分页的位置(可以根据实际需求调整)
       const pageBreakMarkers = ["<h1", "<h2", "<!-- pagebreak -->"];
@@ -906,7 +906,7 @@ export default {
       );
     },
 
-    // 添加内容处��方法
+    // 添加内容处方法
     processContentForWord(content) {
       const tempDiv = document.createElement("div");
       tempDiv.innerHTML = content;
@@ -1116,7 +1116,7 @@ export default {
       if (table.style.border || table.classList.contains("bordered"))
         return true;
 
-      // 检查第一个单���格是否有边框
+      // 检查第一个单格是否有边框
       const firstCell = table.querySelector("td, th");
       if (firstCell && firstCell.style.border) return true;
 
@@ -1888,7 +1888,7 @@ export default {
               const fullMatch = match[0];
               const segments = [match[1], match[2], match[3], match[4]];
 
-              // 验证��个段落的格式
+              // 验证个段落的格式
               const isValid = segments.every((segment) => segment.length > 0);
 
               if (isValid) {
@@ -2919,27 +2919,24 @@ export default {
     //搜索
     async search() {
       try {
+        // 1. 先加载并显示项目列表
         const res = await searchProject(this.queryForm);
         if (!res) return;
-
-        // 获取所有项目的完成度
-        const calculatePromises = res.data.dataList.map(async (item) => {
-          try {
-            const calcRes = await calculate({ id: item.id });
-            if (calcRes.status === 200) {
-              item.calculate = calcRes.data.completionRate;
-            }
-          } catch (err) {
-            console.error(`获取项目${item.id}完成度失败:`, err);
-            item.calculate = 0;
-          }
-        });
-
-        await Promise.all(calculatePromises);
-
-        this.dataList = res.data.dataList;
+        
+        // 2. 先用0初始化完成度,让列表可以立即渲染
+        const projectList = res.data.dataList.map(item => ({
+          ...item,
+          calculate: 0
+        }));
+        
+        // 3. 立即更新列表数据
+        this.dataList = projectList;
         this.recordCount = res.data.totalRecord;
         this.pageTotal = res.data.totalPage;
+
+        // 4. 异步加载完成度
+        this.loadProjectCompletions(projectList);
+        
       } catch (err) {
         console.error("搜索失败:", err);
         this.$message.error("获取项目列表失败");
@@ -3298,7 +3295,74 @@ export default {
       this.templateQueryForm.page = 1; // 重置页码
       this.loadTemplateList(); // 重新加载列表
     },
+
+    // 新增方法:异步加载完成度
+    async loadProjectCompletions(projects) {
+      // 使用 Promise.all 和 chunk 分批处理
+      const chunkSize = 5; // 每批处理5个项目
+      const chunks = this.chunkArray(projects, chunkSize);
+
+      for (const chunk of chunks) {
+        const promises = chunk.map(async (project) => {
+          try {
+            const calcRes = await calculate({ id: project.id });
+            if (calcRes.status === 200) {
+              // 使用 Vue.set 更新单个项目的完成度
+              const index = this.dataList.findIndex(item => item.id === project.id);
+              if (index !== -1) {
+                this.$set(this.dataList[index], 'calculate', calcRes.data.completionRate);
+              }
+            }
+          } catch (err) {
+            console.error(`获取项目${project.id}完成度失败:`, err);
+          }
+        });
+
+        await Promise.all(promises);
+      }
+    },
+
+    // 辅助方法:将数组分成小块
+    chunkArray(array, size) {
+      const chunks = [];
+      for (let i = 0; i < array.length; i += size) {
+        chunks.push(array.slice(i, i + size));
+      }
+      return chunks;
+    },
   },
+  computed: {
+    tableColumns() {
+      return [
+        // ... 其他列配置 ...
+        {
+          prop: 'calculate',
+          label: '完成度',
+          width: '100',
+          render: (h, { row }) => {
+            // 使用过渡效果显示完成度
+            return h('el-tooltip', {
+              props: {
+                content: '加载中...',
+                disabled: row.calculate !== 0
+              }
+            }, [
+              h('span', {
+                class: [
+                  this.getCompletionClass(row.calculate),
+                  'completion-text'
+                ]
+              }, [
+                row.calculate === 0 
+                  ? h('i', { class: 'el-icon-loading' })
+                  : this.formatCompletion(row.calculate)
+              ])
+            ]);
+          }
+        }
+      ];
+    }
+  }
 };
 </script>