diff --git a/src/views/modules/project/projectInfo/com_projectInfo-add-or-update.vue b/src/views/modules/project/projectInfo/com_projectInfo-add-or-update.vue index 62a4175..47a4020 100644 --- a/src/views/modules/project/projectInfo/com_projectInfo-add-or-update.vue +++ b/src/views/modules/project/projectInfo/com_projectInfo-add-or-update.vue @@ -118,9 +118,9 @@ :close-on-click-modal="false" :visible.sync="managerFlag"> + key: 'operatorId', + label: 'operatorName' + }" :data="operatorList" :titles="['未选择', '已选择']">
确定 @@ -135,15 +135,13 @@ :close-on-click-modal="false" :visible.sync="ownerFlag"> + key: 'operatorId', + label: 'operatorName' + }" :data="operatorList" :titles="['未选择', '已选择']"> -
- 确定 - 取消 -
-
+ 确定 + 取消 + { + this.queryUserRoleListLoading = false + },5000) + } + } }, computed:{ saveCheckAllIndeterminate(){ @@ -505,7 +513,7 @@ if (this.dataForm.customerId){ requestCustomer = JSON.parse(JSON.stringify(this.dataForm)) } - if(this.dataForm.id!=0){ + if(this.dataForm.id!==0){ let inData={ page: 1, limit: 10, @@ -563,6 +571,8 @@ userRoleList:[], productSet:'', } + // 默认插入当前用户 + this.addRollForUsername(this.$store.state.user.name,this.$store.state.user.userDisplay) // this.searchUserRollAll(); } @@ -577,10 +587,20 @@ projectId:this.dataForm.projectId, username:this.userRoleForm.username, userDisplay:this.userRoleForm.userDisplay, + checkList:this.dataForm.userRoleList, } + this.queryUserRoleListLoading = true this.userRoleList = [] searchUserRoll(inData3).then(({data}) => { - this.userRoleList = data.rows; + if (data && data.code === 0){ + this.userRoleList = data.rows; + }else { + this.$message.warning(data.msg) + } + this.queryUserRoleListLoading = false + }).catch((error)=>{ + this.$message.error(error) + this.queryUserRoleListLoading = false }) }, searchUserRollAll(){ @@ -608,12 +628,22 @@ }, saveManagerList(){ let projectManagerName=''; - for (let i = 0; i < this.projectManagerList.length; i++) { - let select= this.operatorList.filter(item => item.operatorId === this.projectManagerList[i]) - if(select.length>0){ - projectManagerName+=select[0].operatorName+';' - this.addRollForUsername(select[0].operatorId,select[0].operatorName); - } + let indexList = []; + let selectionOwnerList = this.operatorList.filter((item,index) => { + indexList.push(index) + return this.projectManagerList.includes(item.operatorId) + }) + projectManagerName=selectionOwnerList.map(item => item.operatorName).join(';'); + // for (let i = 0; i < this.projectManagerList.length; i++) { + // let select= this.operatorList.filter(item => item.operatorId === this.projectManagerList[i]) + // if(select.length > 0){ + // projectManagerName+=select[0].operatorName+';' + // this.addRollForUsername(select[0].operatorId,select[0].operatorName); + // } + // } + for (let i = 0; i < indexList.length; i++) { + let row = this.operatorList[indexList[i]] + this.addRollForUsername(row.operatorId,row.operatorName) } this.dataForm.projectManagerName=projectManagerName this.dataForm.projectManagerList=JSON.parse(JSON.stringify(this.projectManagerList)); @@ -634,21 +664,31 @@ }, saveOwnerList(){ let projectOwnerName=''; - for (let i = 0; i < this.projectOwnerList.length; i++) { - let select= this.operatorList.filter(item => item.operatorId === this.projectOwnerList[i]) - if(select.length>0){ - projectOwnerName+=select[0].operatorName+';' - this.addRollForUsername(select[0].operatorId,select[0].operatorName); - } + let indexList = []; + let selectionOwnerList = this.operatorList.filter((item,index) => { + indexList.push(index) + return this.projectOwnerList.includes(item.operatorId) + }) + projectOwnerName=selectionOwnerList.map(item => item.operatorName).join(';'); + // for (let i = 0; i < this.projectOwnerList.length; i++) { + // let select= this.operatorList.filter(item => item.operatorId === this.projectOwnerList[i]) + // if(select.length>0){ + // projectOwnerName+=select[0].operatorName+';' + // // this.`addRollForUsername`(select[0].operatorId,select[0].operatorName); + // } + // } + for (let i = 0; i < indexList.length; i++) { + let row = this.operatorList[indexList[i]] + this.addRollForUsername(row.operatorId,row.operatorName) } - this.dataForm.projectOwnerName=projectOwnerName + + this.dataForm.projectOwnerName = projectOwnerName this.dataForm.projectOwnerList=JSON.parse(JSON.stringify(this.projectOwnerList)); this.ownerFlag=false }, addRollForUsername(username,userDisplay){ - debugger if(this.dataForm.userRoleList.length>0) { let checkList = this.dataForm.userRoleList.filter(item => item.username === username) if (checkList.length === 0) { @@ -665,11 +705,8 @@ userDisplay: userDisplay, username: username, }) - this.dataForm.userRoleName += userDisplay + ';' } }else { - console.log(username) - console.log(userDisplay) this.dataForm.userRoleList=[{ checkAll: true, deleteCheck: true, @@ -683,40 +720,45 @@ userDisplay: userDisplay, username: username, }] - this.dataForm.userRoleName = userDisplay + ';' } + this.dataForm.userRoleName = this.dataForm.userRoleList.map(item => item.userDisplay).join(';'); }, userRollModal(){ this.searchUserRoll() this.userRoleFlag=true }, saveUserList(){ - for (let i = 0; i item.username != this.userRoleList[i].username) - if(this.userRoleList[i].searchCheck||this.userRoleList[i].updateCheck||this.userRoleList[i].downCheck||this.userRoleList[i].deleteCheck){ - this.dataForm.userRoleList.push(this.userRoleList[i]) - } - } - for (let i = 0; i < this.dataForm.userRoleList.length; i++) { - if(this.dataForm.userRoleList[i].searchCheck||this.dataForm.userRoleList[i].updateCheck - ||this.dataForm.userRoleList[i].downCheck||this.dataForm.userRoleList[i].deleteCheck){ - name+=this.dataForm.userRoleList[i].userDisplay+';' - } - } - this.dataForm.userRoleName=name + let name = ""; + let selectionUserList = this.userRoleList.filter(item => item.searchCheck || item.updateCheck || item.downCheck || item.deleteCheck) + + this.dataForm.userRoleList = [...selectionUserList] + name = selectionUserList.map(item => item.userDisplay).join(";") + // for (let i = 0; i item.username !== this.userRoleList[i].username) + // if(this.userRoleList[i].searchCheck||this.userRoleList[i].updateCheck||this.userRoleList[i].downCheck||this.userRoleList[i].deleteCheck){ + // this.dataForm.userRoleList.push(this.userRoleList[i]) + // } + // } + // for (let i = 0; i < this.dataForm.userRoleList.length; i++) { + // if(this.dataForm.userRoleList[i].searchCheck||this.dataForm.userRoleList[i].updateCheck + // ||this.dataForm.userRoleList[i].downCheck||this.dataForm.userRoleList[i].deleteCheck){ + // name+=this.dataForm.userRoleList[i].userDisplay+';' + // } + // } + this.dataForm.userRoleName = name // this.dataForm.userRoleList=JSON.parse(JSON.stringify(this.userRoleList)); this.userRoleFlag=false diff --git a/src/views/modules/sys/user-add-or-update.vue b/src/views/modules/sys/user-add-or-update.vue index b4b2187..d1a177a 100644 --- a/src/views/modules/sys/user-add-or-update.vue +++ b/src/views/modules/sys/user-add-or-update.vue @@ -364,6 +364,10 @@ export default { }, // 表单提交 dataFormSubmit() { + if (!this.dataForm.userDisplay){ + this.$message.warning((this.buttons.userDisplay||'用户名') +"不能为空") + return + } this.$refs['dataForm'].validate((valid) => { if (valid) { this.$http({