瀏覽代碼

子项目增加复制功能

seyason 2 年之前
父節點
當前提交
4bdea77e1c

+ 34 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/SubProjectController.java

@@ -1,6 +1,8 @@
 package com.management.platform.controller;
 
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.ProjectTimer;
 import com.management.platform.entity.SubProject;
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -39,6 +42,37 @@ public class SubProjectController {
     @Resource
     private UserMapper userMapper;
 
+    /**
+     * 复制子项目到其他项目下
+     */
+    @RequestMapping("/copyToProjects")
+    public HttpRespMsg copyToProjects(Integer projectId, String targetProjectIds) {
+        HttpRespMsg msg = new HttpRespMsg();
+        List<SubProject> subProjects = subProjectService.list(new QueryWrapper<SubProject>().eq("project_id", projectId));
+        if (subProjects.size() == 0) {
+            msg.setError("该项目下没有子项目");
+        } else {
+            System.out.println(targetProjectIds);
+            JSONArray array = JSON.parseArray(targetProjectIds);
+            List<SubProject> batchList = new ArrayList<>();
+            for (int i =0; i < array.size(); i++) {
+                String targetProjectId = array.getString(i);
+                for (SubProject subProject : subProjects) {
+                    SubProject newSubProject = new SubProject();
+                    newSubProject.setCompanyId(subProject.getCompanyId());
+                    newSubProject.setProjectId(Integer.parseInt(targetProjectId));
+                    newSubProject.setName(subProject.getName());
+                    newSubProject.setStatus(subProject.getStatus());
+                    newSubProject.setCode(subProject.getCode());
+                    batchList.add(newSubProject);
+                }
+            }
+            subProjectService.saveBatch(batchList);
+        }
+
+        return msg;
+    }
+
     /**
      * 获取子项目列表
      */

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -214,10 +214,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     //只能看本人参与的项目
                     httpRespMsg.data = projectMapper.getOnlyJoinProjects(user.getId(), user.getCompanyId());
                 } else {
-                    //有权限的填报全部的进行中或者暂停的项目
+                    //有权限的填报全部的进行中项目
                     QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("company_id", user.getCompanyId())
-                            .and(wrapper->wrapper.eq("status", 1).or().eq("status", 4))
+                            .eq("status", 1)
                             .orderByDesc("is_public").orderByAsc("id");
                     httpRespMsg.data = projectMapper.selectList(queryWrapper);
                 }

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -139,7 +139,7 @@
     <select id="getOnlyJoinProjects" resultType="java.util.Map">
         SELECT id, project_code AS projectCode, project_name AS projectName, status, task_gp_incharge as taskGpIncharge, project_desc as projectDesc
         FROM project
-        WHERE (status = 1 or status = 4) and (id IN (
+        WHERE status = 1 and (id IN (
             SELECT project_id
             FROM participation
             WHERE user_id = #{userId}
@@ -1582,7 +1582,7 @@
 
     <select id="selectNearProject" resultType="com.management.platform.entity.Project">
         select * from project
-        where id in (
+        where status = 1 and id in (
             SELECT project_id
             from (
                 SELECT project_id

+ 56 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -843,10 +843,25 @@
 
             </el-table>
             <div slot="footer" class="dialog-footer">
+                <el-button type="default" :disabled="subProjectList.length == 0" @click="forSubProjectlist = list.filter(a=>a.id != currentProject.id);copySubPListVisible = true;" style="align:left;">复制到其他项目</el-button>
                 <el-button type="primary" @click="subProjectVisible = false" >{{ $t('Shutdown') }}</el-button>
                 <el-button type="primary" @click="addNewSubProject()" >{{ $t('addsubitems') }}</el-button>
             </div>
         </el-dialog>
+        <!--选择项目弹出框-->
+        <el-dialog title="选择要复制到的目标项目" v-if="copySubPListVisible" :visible.sync="copySubPListVisible" :close-on-click-modal="false" customClass="customWidth" width="700px">
+            <el-table ref="projectForSubCopy" border @cell-mouse-enter="hoverCall" @cell-mouse-leave="handCall" :cell-class-name="tableCellClassName" :data="forSubProjectlist" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @selection-change="checkedProlistForSub" @sort-change="tableSort">
+                <el-table-column type="selection" width="60" >
+                </el-table-column>
+                <el-table-column prop="projectCode" :label="$t('Itemno')"  width="150"></el-table-column>
+                <el-table-column prop="projectName" :label="$t('headerTop.projectName')" min-width="250">
+                </el-table-column>
+            </el-table>
+            <div slot="footer" class="dialog-footer">
+                <el-button @click.native="copySubPListVisible = false">{{ $t('btn.cancel') }}</el-button>
+                <el-button type="primary" @click="submitCopySubProject()" >{{ $t('btn.submit') }}</el-button>
+            </div>
+        </el-dialog>
 
 
         <!-- 新增子项目弹出框 -->
@@ -1378,6 +1393,8 @@ a {
         },
         data() {
             return {
+                forSubProjectlist:[],
+                copySubPListVisible: false,
                 projectManagerEdit: false,
                 canOnlyModParticipator: false,
                 curChangeProject:null,
@@ -1499,7 +1516,7 @@ a {
                 },
                 statusClf:null,
                 permissionsObj: {},
-
+                checkedPForSubArr:[],
                 checkedProjectArr: [],
                 checkedWuduDialog: false,
                 checkedWuduArr: [],
@@ -1609,6 +1626,41 @@ a {
             })
         },
         methods: {
+            submitCopySubProject() {
+                //获取选中的项目
+                if (this.checkedPForSubArr.length == 0) {
+                    this.$message(this.$t('defaultText.pleaseSelectSnItem'))
+                    return
+                }
+                
+                var targetPIds = JSON.stringify(this.checkedPForSubArr.map((a)=>{return a.id}));
+                //http post请求提交
+                this.http.post('/sub-project/copyToProjects', {
+                    projectId: this.currentProject.id,
+                    targetProjectIds: targetPIds,
+                },
+                res => {
+                    if (res.code == "ok") {
+                        this.$message({
+                            message: '操作成功',
+                            type: "success"
+                        });
+                        this.copySubPListVisible = false;
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+
+            },
             confirmChangeStage() {
                 let currentStageName = ''
                 for(var i in this.phaseList) {
@@ -2039,6 +2091,9 @@ a {
                     })
                 })
             },
+            checkedProlistForSub(e) {
+                this.checkedPForSubArr = e;
+            },
             // 批量修改自定义维度
             checkedWudulist(e){
                 // console.log(e);