ソースを参照

分配合同段人员

gangyj 3 年 前
コミット
8d2e234443

+ 10 - 0
src/api/manager/contractinfo.js

@@ -87,3 +87,13 @@ export const removeContractInfo = (ids) => {
     }
   })
 }
+
+export const findJobByRoleId = (id) => {
+  return request({
+    url: '/api/blade-manager/contractInfo/findJobByRoleId',
+    method: 'get',
+    params: {
+      id
+    }
+  })
+}

+ 287 - 17
src/views/manager/contractinfo/detail.vue

@@ -186,7 +186,52 @@
         </el-tab-pane>
         <el-tab-pane label="分配项目人员" name="3">
           <div>
-            
+            <div class="flex jc-al-c">
+              <span class="mg-r-10">项目名称</span>
+              <el-input v-model="projectInfo.projectName" disabled style="width:300px;margin-right:30px;"></el-input>
+              <span class="mg-r-10">合同段名称</span>
+              <el-input v-model="contractForm.contractName" disabled style="width:300px;"></el-input>
+            </div>
+            <el-divider></el-divider>
+            <div class="flex jc-al-c mg-b-10">
+              <div>
+                <span class="mg-r-10">角色方</span>
+                <el-radio-group v-model="rId">
+                  <el-radio-button v-for="(item) in roleList" :label="item.id" :key="item.key">{{item.title}}</el-radio-button>
+                </el-radio-group>
+              </div>
+              <div>
+                <span class="mg-r-10 mg-l-20">请选择岗位</span>
+                <el-select v-model="postId" filterable placeholder="请输入搜索">
+                  <el-option v-for="item in postList" :key="item.id" :label="item.postName"  :value="item.id"></el-option>
+                </el-select>
+              </div>
+            </div>
+            <div>
+              <el-table  :data="contractUserList" border height="500" style="width: 100%">
+                <el-table-column prop="name" label="姓名" align="center"></el-table-column>
+                <el-table-column prop="account" label="登录账号" align="center"></el-table-column>
+                <el-table-column prop="password" label="密码" align="center"></el-table-column>
+                <el-table-column label="操作" align="center">
+                  <template slot-scope="scope">
+                    <el-link class="mg-r-20" type="primary" @click="copyAccPas(scope.row)">复制</el-link>
+                    <el-link class="mg-r-20" type="primary">重置密码</el-link>
+                    <el-link type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-link>
+                  </template>
+                </el-table-column>
+              </el-table>
+               <el-input v-model="copyText" ref="copyInput" type="textarea" style='opacity: 0;position: absolute;'></el-input>
+            </div>
+            <div class="flex jc-al-c mg-t-20">
+              <span>添加项目人员</span>
+              <el-select v-model="userId" filterable placeholder="请输入搜索">
+                <el-option v-for="item in userList" :key="item.id" :label="item.name"  :value="item.id"></el-option>
+              </el-select>
+              <el-button type="success" @click="addUserToProject">添加</el-button>
+              <el-button type="primary">创建新用户</el-button>
+              <el-button type="danger" @click="handleDeletes">全部删除</el-button>
+            </div>
+            <el-divider></el-divider>
           </div>
         </el-tab-pane>
       </el-tabs>
@@ -195,7 +240,8 @@
         <div></div>
         <div>
           <el-button type="success" size="medium" @click="saveQuit">保存并退出</el-button>
-          <el-button type="info" size="medium" @click="saveNext">保存并进入下一步</el-button>
+          <el-button type="info" size="medium" v-if="activeType != 1" @click="saveNext('p')">保存并返回上一步</el-button>
+          <el-button type="info" size="medium" v-if="activeType != 3" @click="saveNext('n')">保存并进入下一步</el-button>
         </div>
       </div>
     </div>
@@ -205,7 +251,10 @@
 
 <script>
   import {getProjectDeatil} from "@/api/manager/projectinfo";
-  import {submitContractInfo,getContractInfo,delFileFromUrl} from "@/api/manager/contractinfo";
+  import {submitContractInfo,getContractInfo,delFileFromUrl,
+          findJobByRoleId,findAllUserByCondition,findUserByName,
+          saveUserInfoByProject,removeUsersByIds} from "@/api/manager/contractinfo";
+  import {getRoleTree} from "@/api/system/role";
   import {getDictionary} from "@/api/system/dict";
   import {remove as removeFile} from "@/api/resource/attach";
   import website from '@/config/website';
@@ -216,6 +265,11 @@
     data() {
       return {
         activeType:'1',
+        typeChang:{
+          1:false,
+          2:false,
+          3:false,
+        },
 
         pid:'',
         cid:'',
@@ -240,15 +294,63 @@
           // dragEnable: false,
         },
         flageData:[],
+
+        rId:'',
+        roleList:[],
+        postId:'',
+        postList:[],
+        contractUserList:[],
+        userId:'',
+        userList:[],
+        copyText:'',
       }
     },
     computed: {
       ...mapGetters(["userInfo"]),
     },
+    watch:{
+      contractForm:{
+        handler: function() { // 此处注意,handler函数不能为箭头函数,this会取上下文,而不是组件里的this,此外,深度监听,必须为handler函数名,否则会无效果
+          this.typeChang['1'] = true;
+        },
+        deep: true
+      },
+      activeType: function (newValue) {
+        if(newValue == '3'){
+          this.getRoleList();
+          this.getUserByName();
+        }
+      },
+      rId:function(newValue){
+        findJobByRoleId(newValue).then((res)=>{
+          this.postList = res.data.data;
+        }).catch(()=>{
+          this.postList = [];
+        }).finally(()=>{
+          this.postId = '';
+        })
+      },
+      postId:function(newValue){
+        if(newValue){
+          this.findAllUserByCondition();
+        }else{
+          this.contractUserList = [];
+        }
+      }
+    },
     created() {
       this.init();
       //console.log(this.userInfo)
     },
+    mounted(){
+      this.$nextTick(()=>{
+        this.typeChang = {
+          1:false,
+          2:false,
+          3:false,
+        }
+      })
+    },
     methods: {
       init(){
         this.pid = this.$route.query.pid;
@@ -258,13 +360,42 @@
         }else{
           this.getContractInfo();
         }
+        if(this.$route.query.type){
+          this.activeType = this.$route.query.type;
+        }
+
         this.getContractTypeList();
         this.getProjectDeatil();
         this.setHeaders(); 
       },
       beforeLeave(activeName, oldActiveName){
-        console.log(oldActiveName,'oldActiveName');
-        console.log(this.activeType);
+        if(oldActiveName == '1' && !this.contractForm.id){
+          this.$message({
+            type: "warning",
+            message: "请先保存合同段后,再进行合同段的分配"
+          });
+          return false;
+        }
+
+       if(this.typeChang[oldActiveName]){
+         this.$confirm('检测到新编辑内容, 是否保存?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '不用',
+          type: 'warning'
+        }).then(() => {
+          switch (oldActiveName) {
+            case '1':
+              this.savecontract().then((res)=>{
+                this.contractForm.id = res.data.data.id;
+                this.$message({
+                  type: "success",
+                  message: "保存成功!"
+                });
+              });
+              break;
+          }
+        })
+       }
       },
 
       getProjectDeatil(){
@@ -281,24 +412,42 @@
           if(this.contractForm.projectPlace){
             this.flageData = ['','',this.contractForm.projectPlace]
           }
+          this.$nextTick(()=>{
+            this.typeChang['1'] = false;
+          })
         })
       },
 
-      saveQuit(){
-        this.savecontract().then((res)=>{
-          this.contractForm.id = res.data.data.id;
-          this.$message({
-            type: "success",
-            message: "保存成功!"
-          });
-          this.$router.go(-1);
-        }).catch((res)=>{
-          console.log(res)
-        })
+      async saveQuit(){
+        if(this.activeType == '1'){
+          await this.savecontract();
+        }
+        this.$message({
+          type: "success",
+          message: "保存成功!"
+        });
+        this.$router.go(-1);
       },
-      saveNext(){
+      async saveNext(type){
+        if(this.activeType == '1'){
+          let res = await this.savecontract();
+          this.contractForm.id = res.data.data.id;
+        }
+        this.$message({
+          type: "success",
+          message: "保存成功!"
+        });
+        this.typeChang[this.activeType] = false;
+        let num = Number(this.activeType);
+        if(type == 'n'){
+            num++;
+        }else if(type == 'p'){
+            num--;
+        }
 
+        this.activeType = num.toString();
       },
+
       savecontract(){
         return new Promise((resolve, reject) => {
           this.$refs['contractForm'].validate((valid) => {
@@ -347,6 +496,101 @@
         })
       },
 
+      addUserToProject(){
+        if(!this.userId){
+          this.$message({
+              type: "warning",
+              message: "请先选择用户再进行添加"
+            });
+          return;
+        }
+        if(!this.postId){
+          this.$message({
+              type: "warning",
+              message: "请先选择岗位再进行添加"
+            });
+          return;
+        }
+        if(!this.rId){
+          this.$message({
+              type: "warning",
+              message: "请先选择角色再进行添加"
+            });
+          return;
+        }
+        let list = [{
+          projectId:this.pid,
+          contractId:this.contractForm.id,
+          userId:this.userId,
+          postId:this.postId,
+          roleId:this.rId
+        }];
+        saveUserInfoByProject(list).then(()=>{
+          this.findAllUserByCondition();
+        })
+      },
+
+      findAllUserByCondition(){
+        findAllUserByCondition({
+          "cId": this.contractForm.id,
+          "pId": this.pid,
+          "postId": this.postId,
+          "rId": this.rId
+        }).then((res)=>{
+          this.contractUserList = res.data.data;
+        })
+      },
+
+      handleDelete(index,row){
+        this.$confirm('是否将该用户移除出合同段', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          removeUsersByIds(row.id).then(()=>{
+            this.contractUserList.splice(index,1);
+            this.$message({
+              type: "success",
+              message: "删除成功!"
+            });
+          })
+        })
+      },
+      handleDeletes(){
+        this.$confirm('是否将所有用户移除出合同段', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          let ids = [];
+          this.contractUserList.forEach((element)=>{
+            ids.push(element.id);
+          })
+          removeUsersByIds(ids.join(',')).then(()=>{
+            this.contractUserList = [];
+            this.$message({
+              type: "success",
+              message: "删除成功!"
+            });
+          })
+        })
+      },
+
+      copyAccPas(row){
+        this.copyText = `姓名:${row.name}
+账号:${row.account}
+密码:${row.password}`;
+        this.$nextTick(()=>{
+          this.$refs.copyInput.select()
+          document.execCommand('copy')
+          this.$message({
+            type: "success",
+            message: "成功复制在剪贴板!"
+          });
+        })
+ 
+      },
+
       getContractTypeList(){
         if(this.contractTypeList.length >1){
           return;
@@ -361,6 +605,32 @@
         })
       },
 
+      getRoleList(){
+        if(this.roleList.length > 1){
+          return;
+        }
+
+        getRoleTree().then((res)=>{
+          let list = [];
+          res.data.data.forEach((element)=>{
+            if(element.title == '监理方'||
+               element.title == '业主方'){
+                 list.push(element);
+            }else if(element.title == '施工方'){
+              //给个默认
+              this.rId = element.id;
+              list.push(element);
+            }
+          })
+          this.roleList = list;
+        })
+      },
+      getUserByName(){
+       findUserByName('').then((res)=>{
+         this.userList = res.data.data;
+       })
+     },
+
     }
   };
 </script>

+ 31 - 5
src/views/manager/projectinfo/list.vue

@@ -37,7 +37,7 @@
         </div>
       </div>
       <div style="height:400px;overflow: auto;" v-if="contractList.length > 0">
-        <el-card shadow="never" v-for="(item) in contractList" :key="item.id">
+        <el-card shadow="never" v-for="(item,index) in contractList" :key="item.id">
           <div class="flex jc-sb">
             <div class="flex jc-al-c">
               <el-avatar :size="50" :class="getAvatarBg(item.contractType)">{{getFont(item.contractType)}}</el-avatar>
@@ -45,9 +45,9 @@
             </div>
             <div class="flex jc-al-c">
               <el-link type="primary" @click="editContract(item)">编辑合同段信息</el-link>
-              <el-link type="primary" class="mg-l-10">分配WBS</el-link>
-              <el-link type="primary" class="mg-l-10">分配项目人员</el-link>
-              <el-link type="primary" class="mg-l-10">删除</el-link>
+              <el-link type="primary" class="mg-l-10" @click="contractDetail(item,'2')">分配WBS</el-link>
+              <el-link type="primary" class="mg-l-10" @click="contractDetail(item,'3')">分配项目人员</el-link>
+              <el-link type="primary" class="mg-l-10" @click="delContract(item,index)">删除</el-link>
             </div>
           </div>
         </el-card>
@@ -61,7 +61,7 @@
 
 <script>
   import {getProjectList} from "@/api/manager/projectinfo";
-  import {findContractByProjectId} from "@/api/manager/contractinfo";
+  import {findContractByProjectId,removeContractInfo} from "@/api/manager/contractinfo";
   import {getDictionary} from "@/api/system/dict";
   import {mapGetters} from "vuex";
   export default {
@@ -156,6 +156,32 @@
           }
         });
       },
+      contractDetail(item,type){
+        this.$router.push({
+          path:'/contract/detail',
+          query:{
+            pid:item.pid,
+            cid:item.id,
+            type,
+          }
+        });
+      },
+
+      delContract(item,index){
+        this.$confirm('是否删除【'+item.contractName+'】?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          removeContractInfo(item.id).then(()=>{
+            this.$message({
+              type: "success",
+              message: "删除成功!"
+            });
+            this.contractList.splice(index,1);
+          })
+        })
+      },
 
       getFont(type){
         if(type == 1){