Browse Source

项目增加所属部门

Lijy 2 năm trước cách đây
mục cha
commit
be1d1d2baf

+ 69 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/project/info.vue

@@ -13,6 +13,10 @@
                         <el-col :span="5" ><span class="gray_label">项目描述:</span></el-col><el-col :span="7" ></el-col>
                         <el-col :span="18" ><span>{{project.projectDesc}}</span></el-col>
                     </el-row>
+                    <el-row :gutter="10" >
+                        <el-col :span="5" ><span class="gray_label">所属部门:</span></el-col><el-col :span="7" ></el-col>
+                        <el-col :span="18" ><span>{{project.departmentName}}</span></el-col>
+                    </el-row>
                     <el-row :gutter="10">
                         <el-col :span="5" ><span class="gray_label">状态:</span></el-col><el-col :span="7" ><span >{{project.status==null?'-':statusTxt[project.status]}}</span></el-col>
                         <el-col :span="5" ><span class="gray_label">完成度: </span></el-col><el-col :span="7" ><span>
@@ -286,6 +290,13 @@
                 <el-form-item label="项目描述" prop="projectDesc">
                     <el-input type="textarea" :rows="2" v-model="addForm.projectDesc" maxlength="4000" show-word-limit  placeholder="请输入项目描述" clearable></el-input>
                 </el-form-item>
+
+                <el-form-item label="所属部门">
+                    <el-cascader v-model="addForm.deptId" :options="departmentList" placeholder="请选择部门"
+                        :props="{ checkStrictly: true }" clearable filterable @change="cascaderChange"
+                    ></el-cascader>
+                </el-form-item>
+
                 <el-form-item label="级别" >
                     <el-select v-model="addForm.level"  placeholder="请选择级别" style="width:32%;" v-if="user.timeType.projectLevelState == 1">
                         <el-option v-for="item in levelList" :key="item.id" :label="item.projectLevelName" :value="item.id"></el-option>
@@ -622,7 +633,8 @@
                 contractRecordDialog: false,
                 contractRecordLoading: false,
                 contractRecordData: [],
-                levelList: []
+                levelList: [],
+                departmentList: []
             };
         },
         filters: {
@@ -1460,6 +1472,9 @@
                         if(this.user.companyId == '428') {
                              formData.append("projectCategorySub", this.addForm.projectSeparate.projectCategorySub ? this.addForm.projectSeparate.projectCategorySub : '');
                         }
+                        if(this.addForm.deptId != null && this.addForm.deptId != '') {
+                            formData.append("deptId", this.addForm.deptId[this.addForm.deptId.length - 1]);
+                        }
                         // return
                         this.http.uploadFile(this.port.project.add,formData,
                         res => {
@@ -1522,7 +1537,22 @@
                     }
                 // }
                 this.auseList = arr
+                var listList = JSON.parse(JSON.stringify(this.addForm)),
+                arrList = [],
+                array = [];
+                if (listList.deptCascade != "0" && listList.deptCascade != null) {
+                if (listList.deptCascade.indexOf(",") > -1) {
+                    arrList = listList.deptCascade.split(",");
+                } else {
+                    arrList = [].concat(listList.deptCascade);
+                }
+                }
+                for (var i in arrList) {
+                    array.push(parseInt(arrList[i]));
+                }
+                this.$set(this.addForm,'deptId', array.reverse())
                 console.log(this.auseList, '看看是个什么值')
+                console.log(this.addForm, '看看是个什么值')
             },
             showEditPar() {
                 this.addForm = JSON.parse(JSON.stringify(this.project));
@@ -1725,6 +1755,43 @@
                 });
                 this.getProjectProfessionList();
             },
+            // 获取部门
+            getDepartmentList() {
+                this.http.post( this.port.manage.depList, {},
+                    res => {
+                    if (res.code == "ok") {
+                        let dptlist = JSON.parse(JSON.stringify(res.data));
+                        this.departmentList = this.changeArr(dptlist);
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                    },error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
+            changeArr(arr) {
+                for (var i = 0; i < arr.length; i++) {
+                    if(arr[i].id != -1 && arr[i].id != 0) {
+                        if (arr[i].children != null && arr[i].children.length>0) {
+                            arr[i].children = this.changeArr(arr[i].children);
+                        }
+                        arr[i].id && (arr[i].value = arr[i].id);
+                        delete arr[i].id;
+                    }
+                }
+                for(var i in arr) {
+                    if(arr[i].id == -1 || arr[i].id == 0) {
+                        arr.splice(i,1)
+                    }    
+                }
+                return arr;
+            },
             refreshPage() {
                 this.curProjectId = parseInt(this.$route.params.id);
                 this.getMileStoneList();
@@ -1759,6 +1826,7 @@
             this.userssHu()
             this.yanjiuzx()
             this.getProjectLevel()
+            this.getDepartmentList()
         }
     };
 </script>

+ 81 - 7
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -184,6 +184,7 @@
                      </div>
                 </template>
             </el-table-column>
+            <el-table-column prop="departmentName" label="所属部门" width="200"></el-table-column>
             <el-table-column prop="projectMainName" label="主项目" sortable="custom" min-width="250" v-if="user.timeType.mainProjectState == '1'">
             </el-table-column>
             <el-table-column prop="inchargerName" label="项目经理" sortable="custom" min-width="150">
@@ -364,6 +365,13 @@
                         </el-select>
                     </div>
                 </el-form-item>
+
+                <el-form-item label="所属部门">
+                    <el-cascader v-model="addForm.deptId" :options="departmentList" placeholder="请选择部门"
+                        :props="{ checkStrictly: true }" clearable filterable @change="cascaderChange"
+                    ></el-cascader>
+                </el-form-item>
+
                 <!-- 供应商 -->
                 <!-- <el-form-item label="供应商" v-if="user.company.packageProvider">
                     <el-select v-model="addForm.supplierId" multiple collapse-tags style="width:32%;" placeholder="请选择供应商">
@@ -1118,6 +1126,7 @@ a {
                 rowid: '',
                 phaseProjectDialog: false, // 项目阶段
                 levelList: [],  // 项目级别
+                departmentList: []
             };
         },
         // 过滤器
@@ -2924,8 +2933,10 @@ a {
                         category:null,
                         creatorId: this.user.id,
                         projectMainId: '',
-                        outputValue: ''
+                        outputValue: '',
+                        deptId: []
                     }
+
                     if(this.user.companyId == '936') {
                         this.$set(this.addForm, 'contractCode', '')
                         this.$set(this.addForm, 'warrantyStartDate', '')
@@ -2957,7 +2968,21 @@ a {
                     if (names.length > 0) {
                         names = names.substring(0, names.length -1);
                     }
-                    
+                    var listList = JSON.parse(JSON.stringify(item)),
+                    arrList = [],
+                    array = [];
+                    if (listList.deptCascade != "0" && listList.deptCascade != null) {
+                    if (listList.deptCascade.indexOf(",") > -1) {
+                        arrList = listList.deptCascade.split(",");
+                    } else {
+                        arrList = [].concat(listList.deptCascade);
+                    }
+                    }
+
+                    for (var i in arrList) {
+                        array.push(parseInt(arrList[i]));
+                    }
+                    console.log(array, '转换', listList)
                     this.addForm = {
                         id: item.id,
                         name: item.projectName,
@@ -2981,8 +3006,10 @@ a {
                         projectDesc: item.projectDesc,
                         projectMainId: item.projectMainId,
                         creatorId: item.creatorId,
-                        outputValue: item.outputValue
+                        outputValue: item.outputValue,
+                        deptId: array.reverse()
                     }
+                    console.log(this.addForm, '数据')
 
                     // 判断公司id是否等于936
                     if(this.user.companyId == '936') {
@@ -3286,9 +3313,11 @@ a {
                         if(this.user.companyId == '428') {
                              formData.append("projectCategorySub", this.addForm.projectCategorySub ? this.addForm.projectCategorySub : '');
                         }
-
+                        if(this.addForm.deptId != null && this.addForm.deptId != '') {
+                            formData.append("deptId", this.addForm.deptId[this.addForm.deptId.length - 1])
+                        }
                         // formData.append("associateDegreeNames", listName)
-                        // console.log("addform",this.addForm);
+                        console.log("addform",this.addForm);
                         // return
                         this.http.uploadFile(this.port.project.add,formData,
                         res => {
@@ -3320,7 +3349,12 @@ a {
                         }
                 });
             },
-
+            cascaderChange(e) {
+                // console.log(e)
+                // console.log(this.addForm)
+                // if(e.length )
+                console.log(e)
+            },
             // 删除
             deletePro(i, item) {
                 this.$confirm("确定要删除项目[" + item.name + "]吗?","删除项目", {
@@ -3431,7 +3465,44 @@ a {
 
             detail(i) {
                 this.$router.push("/list/" + this.list[i].id + "/" + this.list[i].projectName);
-            }
+            },
+            // 获取部门
+            getDepartmentList() {
+                this.http.post( this.port.manage.depList, {},
+                    res => {
+                    if (res.code == "ok") {
+                        let dptlist = JSON.parse(JSON.stringify(res.data));
+                        this.departmentList = this.changeArr(dptlist);
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                    },error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
+            changeArr(arr) {
+                for (var i = 0; i < arr.length; i++) {
+                    if(arr[i].id != -1 && arr[i].id != 0) {
+                        if (arr[i].children != null && arr[i].children.length>0) {
+                            arr[i].children = this.changeArr(arr[i].children);
+                        }
+                        arr[i].id && (arr[i].value = arr[i].id);
+                        delete arr[i].id;
+                    }
+                }
+                for(var i in arr) {
+                    if(arr[i].id == -1 || arr[i].id == 0) {
+                        arr.splice(i,1)
+                    }    
+                }
+                return arr;
+            },
         },
         created() {
             let height = window.innerHeight;
@@ -3474,6 +3545,9 @@ a {
             } else {
                 this.importanceList = [{id:1,label:'正常'},{id:2,label:'紧急'},{id:3,label:'重要'},{id:4,label:'重要且紧急'}]
             }
+
+            // 获取部门
+            this.getDepartmentList()
             
         }
     };