yangg 1 روز پیش
والد
کامیت
8ddff5e7e7
2فایلهای تغییر یافته به همراه205 افزوده شده و 29 حذف شده
  1. 201 29
      src/views/middPage/list.vue
  2. 4 0
      src/views/project/ProjectInput.vue

+ 201 - 29
src/views/middPage/list.vue

@@ -77,18 +77,20 @@
                 value-format="yyyy-MM-dd"
               />
             </el-form-item>
-            <!--  <el-form-item label="文档类型:">
+             <el-form-item label="项目:">
               <el-select
-                v-model="searchForm.type"
+                v-model="searchForm.project_id"
                 clearable
-                placeholder="请选择文档类型"
+                placeholder="请选择项目"
               >
-                <el-option label="PDF" value="pdf" />
-                <el-option label="DOCX" value="docx" />
-                <el-option label="DOC" value="doc" />
-                <el-option label="TXT" value="txt" />
+              <el-option
+              v-for="project in projectOptions"
+                :key="project.id"
+                :label="project.name"
+                :value="project.id"
+              />
               </el-select>
-            </el-form-item> -->
+            </el-form-item>
             <el-form-item label="处理状态:">
               <el-select
                 v-model="searchForm.processing_status"
@@ -155,6 +157,12 @@
             :disabled="selectedRows.length == 0"
             >批量绑定标签</el-button
           >
+          <el-button
+            type="primary"
+            @click="handleBatchProject"
+            :disabled="selectedRows.length == 0"
+            >批量绑定项目</el-button
+          >
           <el-button
             type="primary"
             @click="handleExport"
@@ -210,6 +218,18 @@
             :selectable="checkSelectable"
             :reserve-selection="true"
           />
+          <el-table-column prop="projects" label="项目" >
+            <template #default="{ row }">
+              <el-tag
+                v-for="(item, index) in row.projects"
+                :key="index"
+                type=""
+                style="margin-right: 5px; margin-bottom: 5px"
+              >
+                {{ item.name }}
+              </el-tag>
+            </template>
+          </el-table-column>
           <el-table-column prop="id" label="ID" width="80" />
           <el-table-column prop="identifier" label="文献编号"></el-table-column>
 
@@ -218,6 +238,7 @@
               <el-link @click="handleNameClick(row)">{{ row.name }}</el-link>
             </template> -->
           </el-table-column>
+          
           <el-table-column prop="tags" label="已绑定标签">
             <template #default="{ row }">
               <el-tag
@@ -457,6 +478,40 @@
         </span>
       </template>
     </el-dialog>
+
+    <!-- 添加项目对话框 -->
+    <el-dialog
+      title="批量绑定项目"
+      :visible.sync="projectDialogVisible"
+      width="800px"
+    >
+      <el-form :model="projectForm" label-width="150px">
+        <el-form-item label="项目:">
+          <el-select
+            style="width: 350px"
+            v-model="projectForm.projects"
+            multiple
+            filterable
+          
+            :loading="projectsLoading"
+            placeholder="请输入关键词搜索项目"
+          >
+            <el-option
+              v-for="project in projectOptions"
+              :key="project.id"
+              :label="project.name"
+              :value="project.id"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="projectDialogVisible = false">取消</el-button>
+          <el-button type="primary" @click="submitBatchProject">确定</el-button>
+        </span>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -508,6 +563,12 @@ export default {
       activeName: "first", // 当前激活的tab
       sotaDetailsList: [], // SOTA详情列表数据
       sotaSummaryList: [], // SOTA汇总表数据
+      projectDialogVisible: false, // 项目对话框显示状态
+      projectForm: {
+        projects: [], // 选中的项目ID数组
+      },
+      projectOptions: [], // 项目选项
+      projectsLoading: false, // 项目加载状态
       searchForm: {
         name: "",
         createTimeRange: [],
@@ -516,6 +577,7 @@ export default {
         type: "", // 新增文档类型
         processing_status: "", // 新增处理状态
         updateTimeRange: [], // 新增更新时间范围
+        project_id:[]
       },
       selectedRows: [], // 选中的行
       tagDialogVisible: false, // 标签对话框显示状态
@@ -561,6 +623,7 @@ export default {
 
   mounted() {
     this.initialize();
+    this.handleProjectSearch();
   },
 
   computed: {
@@ -573,6 +636,82 @@ export default {
     },
   },
   methods: {
+    // 打开项目对话框
+    handleBatchProject() {
+      this.projectDialogVisible = true;
+      this.projectForm = {
+        projects: [],
+      };
+      
+      this.projectOptions = [];
+       // 获取初始项目列表
+    },
+
+    // 项目搜索
+    async handleProjectSearch() {
+      this.projectsLoading = true;
+      try {
+        const response = await axios.post(
+          `${process.env.VUE_APP_BASE_API}/project/search`,
+          {
+            page: 1,
+            page_size: 50
+          }
+        );
+        
+        if (response.status === 200) {
+          this.projectOptions = response.data.data.dataList;
+        }
+      } catch (error) {
+        console.error("搜索项目失败:", error);
+        this.$message.error("搜索项目失败");
+      } finally {
+        this.projectsLoading = false;
+      }
+    },
+
+    // 提交批量绑定项目
+    async submitBatchProject() {
+      try {
+        const selectedIds = this.isAllDataSelected
+          ? await this.getAllDataIds()
+          : Array.from(this.allSelectedRows.keys());
+
+        if (selectedIds.length === 0) {
+          this.$message.warning("请选择需要绑定的文献");
+          return;
+        }
+
+        if (this.projectForm.projects.length === 0) {
+          this.$message.warning("请选择要绑定的项目");
+          return;
+        }
+
+        const response = await axios.post(
+          `${process.env.VUE_APP_BASE_API}/literature/batch_associate_to_projects`,
+          {
+            literature_ids: selectedIds,
+            project_ids: this.projectForm.projects
+          }
+        );
+
+        if (response.status === 200) {
+          this.$message.success("批量绑定项目成功");
+          this.projectDialogVisible = false;
+          // 保持当前页码和搜索条件刷新列表
+          const currentSearchParams = {
+            page: this.currentPage,
+            page_size: this.pageSize,
+            ...this.searchForm
+          };
+          await this.fetchGpuList(currentSearchParams);
+        }
+      } catch (error) {
+        console.error("批量绑定项目失败:", error);
+        this.$message.error(error.response?.data?.message || "批量绑定项目失败");
+      }
+    },
+
     /* outcoms导出 */
     async outExport() {
       try {
@@ -815,6 +954,7 @@ export default {
           update_time_start: this.searchForm.updateTimeRange?.[0] || "",
           update_time_end: this.searchForm.updateTimeRange?.[1] || "",
           processing_status: this.searchForm.processing_status || null,
+          project_id: this.searchForm.project_id || null,
         };
 
         const response = await axios.post(
@@ -1004,7 +1144,14 @@ export default {
           this.selectedRows = [];
           this.clearSelection();
           this.allSelectedRows.clear();
-          await this.fetchGpuList();
+          
+          // 保持当前页码和搜索条件刷新列表
+          const currentSearchParams = {
+            page: this.currentPage,
+            page_size: this.pageSize,
+            ...this.searchForm
+          };
+          await this.fetchGpuList(currentSearchParams);
         }
       } catch (error) {
         if (error === "cancel") return;
@@ -1027,6 +1174,7 @@ export default {
           update_time_start: this.searchForm.updateTimeRange?.[0] || "",
           update_time_end: this.searchForm.updateTimeRange?.[1] || "",
           processing_status: this.searchForm.processing_status || null,
+          project_id: this.searchForm.project_id || null,
         };
 
         const response = await axios.post(
@@ -1066,13 +1214,16 @@ export default {
     // 修改提交方法
     async submitBatchTag() {
       try {
-        const ids = this.selectedRows.map((row) => row.id);
-        // 这里需要添加实际的API调用
-        /* await edit_tags({
-          ids,
-          tagIds: this.tagForm.tags, // 现在传递的是标签ID数组
-        }); */
-        const idObject = { literature_ids: ids, tag_ids: this.tagForm.tags };
+        const selectedIds = this.isAllDataSelected
+          ? await this.getAllDataIds()
+          : Array.from(this.allSelectedRows.keys());
+
+        if (selectedIds.length === 0) {
+          this.$message.warning("请选择需要绑定标签的文献");
+          return;
+        }
+
+        const idObject = { literature_ids: selectedIds, tag_ids: this.tagForm.tags };
         const response = await axios.post(
           `${process.env.VUE_APP_BASE_API}/literature-tags/relation_tags/`,
           idObject,
@@ -1083,10 +1234,17 @@ export default {
           }
         );
         if (response.status !== 200) return;
-        console.log(this.tagForm.tags);
+        
         this.$message.success("标签更新成功");
         this.tagDialogVisible = false;
-        this.fetchGpuList(); // 刷新列表
+        
+        // 保持当前页码和搜索条件刷新列表
+        const currentSearchParams = {
+          page: this.currentPage,
+          page_size: this.pageSize,
+          ...this.searchForm
+        };
+        await this.fetchGpuList(currentSearchParams);
       } catch (error) {
         this.$message.error("标签更新失败");
       }
@@ -1106,6 +1264,7 @@ export default {
         id: [],
         type: "",
         processing_status: "",
+        project_id:[]
       };
       this.clearSelection(); // 清空选择
       this.handleSearch();
@@ -1179,10 +1338,10 @@ export default {
     },
 
     // 修改 fetchGpuList 方法
-    async fetchGpuList() {
+    async fetchGpuList(customParams = null) {
       this.isLoading = true;
       try {
-        const params = {
+        const params = customParams || {
           page: this.currentPage,
           page_size: this.pageSize,
           keyword: this.searchForm.name,
@@ -1192,6 +1351,7 @@ export default {
           update_time_start: this.searchForm.updateTimeRange?.[0] || "",
           update_time_end: this.searchForm.updateTimeRange?.[1] || "",
           processing_status: this.searchForm.processing_status || null,
+          project_id: this.searchForm.project_id || null,
         };
 
         const response = await axios.post(
@@ -1464,8 +1624,9 @@ export default {
       return `${percentage}%`;
     },
       /*终止 */
-  async endAnalysis() {
-       const selectedIds = this.isAllDataSelected
+      async endAnalysis() {
+      try {
+        const selectedIds = this.isAllDataSelected
           ? await this.getAllDataIds()
           : Array.from(this.allSelectedRows.keys());
         if (selectedIds.length === 0) {
@@ -1473,13 +1634,24 @@ export default {
           return;
         }
 
-      literEndClear(selectedIds).then((res) => {
-        if (res.status !== 200) return;
-        // 更新选中行的状态并启动轮询
-       this.selectedRows = [];
-        this.clearSelection();
-        this.fetchGpuList();
-      });
+        const res = await literEndClear(selectedIds);
+        if (res.status === 200) {
+          this.$message.success("终止任务成功");
+          this.selectedRows = [];
+          this.clearSelection();
+          
+          // 保持当前页码和搜索条件刷新列表
+          const currentSearchParams = {
+            page: this.currentPage,
+            page_size: this.pageSize,
+            ...this.searchForm
+          };
+          await this.fetchGpuList(currentSearchParams);
+        }
+      } catch (error) {
+        this.$message.error("终止任务失败");
+        console.error("终止任务错误:", error);
+      }
     },
   },
   // 在组件销毁时清理所有轮询

+ 4 - 0
src/views/project/ProjectInput.vue

@@ -1469,6 +1469,10 @@ export default {
           page_size: this.pageSize,
           sort_field: this.sort_field,
           sort_order: this.sort_order,
+          ...this.gsprPageForm,
+          ...this.gsprSearchForm,
+          start_date: this.gsprSearchForm.dateRange?.[0] || null,
+          end_date: this.gsprSearchForm.dateRange?.[1] || null,
         };
 
         const response = await projectList(params);