+
@@ -34,7 +34,7 @@
PeopleItem
},
props: {
- selectedUserList: {//选择的人员列表 利用folderPerm是否为2来区分是否是普通人员
+ memberList: {//选择的人员列表 利用folderPerm是否为2来区分是否是普通人员
type: Array,
default() {
return []
@@ -45,7 +45,7 @@
document.body.addEventListener('resize',()=> {
this.adjustHeightOperate();
})
- this.selectedUserListEl = this.$refs.selectedUserList;
+ this.selectedUserListEl = this.$refs.membersView;
if(this.selectedUserListEl) {
this.selectedUserListElWidth = this.selectedUserListEl.clientWidth;
this.selectedUserListElHeight = this.selectedUserListEl.clientHeight;
@@ -54,14 +54,14 @@
},
computed: {
selectedUserListLength() {
- return this.selectedUserList.length;
+ return this.memberList.length;
},
showAdjustHeight() {
return this.isAdjustHeight ? `${this.selectedUserListElHeight - 31}px` : `auto`;
}
},
watch: {
- selectedUserList: {
+ memberList: {
immediate: true,
handler(val) {
if(val.length > 0) {
@@ -108,7 +108,7 @@
}
// 获取当前选中的人员的索引
for(let i = 0; i < totalNum; i++) {
- if(this.selectedUserList[i].folderPerm == 2) {
+ if(this.memberList[i].folderPerm == 2) {
currentUserIndex = i;
break;
}
diff --git a/src/views/main_web/project/index.vue b/src/views/main_web/project/index.vue
index 22f0a2f8..f33ab806 100644
--- a/src/views/main_web/project/index.vue
+++ b/src/views/main_web/project/index.vue
@@ -124,7 +124,7 @@
@@ -234,20 +234,20 @@
cnName: "",
selectedUser: [], // 当前文件夹的已选协作人
selectedManageUser: [], // 当前文件夹的已选负责人
- showTitle: "1", //默认显示标题
- disabled: false, //添加合作人可点击
- checked: false,
- activeName: "1",
- showAll: false, //项目信息概况
- isBottomNewProj: false, //底部弹框
- nodeLeaves: false, //工作树叶子
- isShowStaffList: false, //显示项目负责人
- opentree: true, //工作树三角
- ischeckAll: false, //是否是全部选中
- isShowPrjDesc: false, //分配项目--项目概况
- isSlectPal: true, //分配项目--项目概况
+ // showTitle: "1", //默认显示标题
+ // disabled: false, //添加合作人可点击
+ // checked: false,
+ // activeName: "1",
+ // showAll: false, //项目信息概况
+ // isBottomNewProj: false, //底部弹框
+ // nodeLeaves: false, //工作树叶子
+ // isShowStaffList: false, //显示项目负责人
+ // opentree: true, //工作树三角
+ // ischeckAll: false, //是否是全部选中
+ // isShowPrjDesc: false, //分配项目--项目概况
+ // isSlectPal: true, //分配项目--项目概况
- folderPerm: "1",
+ // folderPerm: "1",
// -----------------------------------------------
isShowFirstPage: true,
isShowSecondPage: false,
@@ -288,7 +288,7 @@
isProjDescScroll: false,//项目概况页面是否滚动
projDescEl: null,
- plastScrollTime: null,
+ // plastScrollTime: null,
isTemplateDescScroll: false,//模板概况页面是否滚动
templateDescEl: null,
@@ -345,7 +345,6 @@
},
mounted() {
-
// 从新建项目过来的 一开始直接显示工作指派界面
this.isShowDistWorkPage = this.$route.query.isShowDistworkPage ? this.$route.query.isShowDistworkPage : this.isShowDistworkPage;
this.isShowStartProjDesc = !this.isShowDistWorkPage;//不显示开始的项目概况页面
@@ -444,7 +443,7 @@
this.isShowTemplateSummary = false;
this.isStartEditNestTemp = false;
this.isTemNest = false;
- await this.fetchProjectDetail();
+ this.fetchProjectDetail();
},
/**
* 退出编辑回到项目列表页
@@ -673,93 +672,6 @@
})
},
- /*
- *返回文件夹页面
- */
- backFirstPage: function () {
- this.listDept=JSON.parse(JSON.stringify(this.currListDeptUserData));
- debugger;
- if(!this.isShowManager)
- {
- this.listManagerUser=[];
- this.selectedUser.forEach(user => {
- // if( user.userID != this.currUser.userID)
- if( user.id != this.currUser.id)
- {
- this.listManagerUser.push(user);
- }
- });
- }
- this.isAllhide();
- this.isShowManager=true;
- this.isShowFirstPage = true;
- },
- toFirstPage(){
- this.$confirm('退出“职员选择”您编辑的内容被清空,确定退出?', "", {
- confirmButtonText: "退出",
- cancelButtonText: "取消",
- showClose:false,
- type: "warning"
- }).then(() => {
- // 注意这里将folderID修改为 id字段
- for (var i = 0; i < this.listNewFolder.length; i++) {
- if( this.listNewFolder[i].id == this.currSelectData.id){
- this.listNewFolder[i] = this.currSelectData;
- }
- for (var j = 0; j < this.listNewFolder[i].listChildren.length; j++) {
- if( this.listNewFolder[i].listChildren[j].id == this.currSelectData.id){
- this.listNewFolder[i].listChildren[j] = this.currSelectData;
- }
- }
- }
- this.listDept=JSON.parse(JSON.stringify(this.currListDeptUserData));
- debugger;
- this.isAllhide();
- this.isShowFirstPage = true;
- this.isShowManager=true;
- });
- },
-
- /**
- * 设置负责人
- */
- // setManagerUser(nowUser) {
- // if (this.InitData.manageUser.length != 0) {
- // this.InitData.manageUser[0].selected = false;
- // let topIndex = 0;
- // this.listDept.forEach((dept, i) => {
- // dept.listUser.forEach(user => {
- // if(user.id === this.InitData.manageUser[0].id) {
- // user.selected = false;
- // user.folderPerm = 1;
- // topIndex = i;
- // }
- // })
- // })
- // this.getIsCheckSecondLevel(topIndex);//将原来选中的工作负责人进行二级状态修正
- // // this.InitData.manageUser[0].roleName = "普通职员";
- // for (var i = 0; i < this.selectedUser.length; i++) {
- // if (this.selectedUser[i].id == this.InitData.manageUser[0].id) {
- // this.InitData.manageUser[0].folderPerm = 0;
- // this.selectedUser.splice(i, 1);
- // }
- // }
- // }
-
- // var listManageUser = [];
- // nowUser.folderPerm = 2;
- // listManageUser.push(nowUser);
- // this.selectedUser.forEach(user => {//将userID 修改为id
- // if (user.folderPerm == 2 && user.id != nowUser.id) {
- // user.folderPerm = 1;
- // }
- // if (user.id == nowUser.id) {
- // user.folderPerm = 2;
- // }
- // });
- // this.InitData.manageUser = listManageUser;
- // },
-
/**
* 分配人员
*/
@@ -821,7 +733,6 @@
if (data.listUser == null) {
data.listUser = [];
}
- debugger;
this.InitData = data;
this.setFolderPerm(data);
this.selectedUser = data.listUser;
@@ -871,265 +782,78 @@
// this.isShowThreePage = true;
// this.isShowFirstPage = false;
},
-
- /*
- *二级条目全选
- * index: 是所在的部门的index
- * prevChecked 未更新前的选中状态
- */
- // handleCheckItemAll(dept, targetChecked) {
- // debugger;
- // dept.listUser.forEach(user => {
- // this.handleCheckedOne(dept, user, !!targetChecked);
- // });
- // },
- /*
- *子项单选
- * topIndex:当前所选条目的上级 部门的index
- *index:当前所选条目
- * prevChecked: 为更新前的选中状态 targetChecked想要达到的状态
- */
- handleCheckedOne(topIndex, user, targetChecked) {
- if(!this.isAllowedDelete(user) && targetChecked == false)
- {
+ onSelectMembers(operationMemberNodes, targetChecked) {
+ let selectedMemberKeys = [...this.selectedMemberKeys];
+ operationMemberNodes.forEach(memberNode => {
+ const userData = cloneDeep(memberNode.data);
+ const execute = () => {
+ this.checkDeptUserName(userData, targetChecked);
+ userData.folderPerm = 1;
+ if(this.selectedUser.length == 1 && targetChecked == true) {
+ // 选中为负责人
+ userData.folderPerm = 2;
+ }
+ }
+ if(targetChecked) { // 添加
+ if(selectedMemberKeys.find(key => key === memberNode.id)) { return; }
+ selectedMemberKeys.push(memberNode.id);
+ execute();
+ return;
+ }
+ // 移除
+ if(!this.isAllowedDelete(userData)) {
this.$notify({
message: "不能移除自己。",
type: "warning",
offset: 100,
duration: 5000
});
- user.selected=true;
return;
}
- if(this.isEditProjManager)
- {
- if(user.id == this.currUser.id && targetChecked == false)//取消选中项目创建者
- {
- this.$notify({
- message: "不可以移除项目创建者。",
- type: "warning",
- offset: 100,
- duration: 5000
- });
- return;
- }
- }
- // 删除的是工作负责人
- if(this.activeFolder) {
- const isExists = this.activeFolder.manageUser.find(t => t.id === user.id);
- if(isExists && targetChecked == false) {
- this.removeManageUser(user);
- this.activeFolder.manageUser.splice(0);
- this.getIsCheckSecondLevel(topIndex);
- this.getIsCheckAll();
- return;
- }
- } else if(this.isEditProjManager && targetChecked == false) {
- // 删除的是具有项目管理权限的 且能运行到这里是可以删除的
- const index = this.listManagerUser.findIndex(people => people.id === user.id);
- if(index > -1) {
- this.listManagerUser.splice(index, 1);
- }
-
- }
- // //点击人员列表删除
- // if(user.folderPerm == 2 && targetChecked == false)
- // {
- // this.removeManageUser(user);
- // this.getIsCheckSecondLevel(topIndex);
- // this.getIsCheckAll();
- // return;
- // }
- // 全选的时候 跳过节点负责人的不执行checkDeptUserName 防止对folderPerm重新赋值
- if(user.folderPerm == 2 && user.selected == true && targetChecked == true) {
- return;
- }
- this.checkDeptUserName(user, targetChecked);
- user.folderPerm = 1;
- if(this.selectedUser.length == 1 && targetChecked == true) {
- // 选中为负责人
- user.folderPerm = 2;
- }
- this.getIsCheckSecondLevel(topIndex);
- this.getIsCheckAll();
- },
- onSelectMembers(operationMemberNodes, targetChecked) {
- const selectedMemberKeys = [...this.selectedMemberKeys];
- operationMemberNodes.forEach(memberNode => {
- const userData = memberNode.data;
- if(targetChecked === false && !this.isAllowedDelete(userData)) {
+ if(this.isEditProjManager && userData.id === this.currUser.id) { // 取消选中项目创建者
this.$notify({
- message: "不能移除自己。",
+ message: "不可以移除项目创建者。",
type: "warning",
offset: 100,
duration: 5000
});
return;
}
- if(this.isEditProjManager){
- if(userData.id == this.currUser.id && targetChecked == false)//取消选中项目创建者
- {
- this.$notify({
- message: "不可以移除项目创建者。",
- type: "warning",
- offset: 100,
- duration: 5000
- });
- return;
- }
- }
+ selectedMemberKeys = selectedMemberKeys.filter(key => userData.id !== key);
// 删除的是工作负责人
- if(this.activeFolder) {
- const isExists = this.activeFolder.manageUser.find(t => t.id === userData.id);
- if(isExists && targetChecked == false) {
+ if(this.activeFolder && this.activeFolder.manageUser.find(t => t.id === userData.id)) {
this.removeManageUser(userData);
this.activeFolder.manageUser.splice(0);
- // this.getIsCheckSecondLevel(topIndex);
- // this.getIsCheckAll();
return;
- }
- } else if(this.isEditProjManager && targetChecked == false) {
+ } else if(this.isEditProjManager) {
// 删除的是具有项目管理权限的 且能运行到这里是可以删除的
const index = this.listManagerUser.findIndex(people => people.id === userData.id);
if(index > -1) {
this.listManagerUser.splice(index, 1);
}
-
}
+
+ execute();
+
});
- // todo
- },
- /**
- * 当前二级选中状态修正
- */
- // getIsCheckSecondLevel(topIndex) {
- // var checkCount = 0;
- // let len = this.listDept[topIndex] && this.listDept[topIndex].listUser ? this.listDept[topIndex].listUser.length : 0;
- // if(len > 0) {
- // for (var i = 0; i < len; i++) {
- // if (this.listDept[topIndex].listUser[i].selected == true) {
- // checkCount++;
- // } else {
- // checkCount--;
- // }
- // }
-
- // if (checkCount == this.listDept[topIndex].listUser.length) {
- // //三级级全勾选
- // this.listDept[topIndex].selected = true;
- // } else {
- // //三级级全不勾选
- // this.listDept[topIndex].selected = false;
- // }
- // }
-
- // },
-
- /*
- *当前首级全选状态修正
- */
- getIsCheckAll() {
- debugger;
- // var checkCount = 0;
- // var haveDataCount = 0;
- // for (var j = 0; j < this.listDept.length; j++) {
- // //全选checkbox状态
-
- // if (this.listDept[j].listUser.length > 0) {
- // haveDataCount++;
- // if (this.listDept[j].selected == true) {
- // checkCount++;
- // }
- // }
- // }
- // if ((checkCount == haveDataCount) && checkCount !== 0 && haveDataCount !== 0) {
- // this.ischeckAll = true;
- // } else {
- // this.ischeckAll = false;
- // }
+ this.selectedMemberKeys = selectedMemberKeys;
},
- /**
- * 移除选中人员
- */
- // removeSelectUser(item) {
- // // debugger;
- // if(item.id == this.currUser.id && !this.isShowManager)
- // {
- // this.$notify({
- // message: "没有权限删除项目创建者。",
- // type: "warning",
- // offset: 100,
- // duration: 5000
- // });
- // return;
- // }
- // if(item.id == sessionStorage.userId && !this.isShowManager)
- // {
- // this.$notify({
- // message: "不能移除自己。",
- // type: "warning",
- // offset: 100,
- // duration: 5000
- // });
- // return;
- // }
- // // 如果当前登录者是项目负责人分配的某个节点的负责人(不是项目负责人) 那么不能删除自己
- // // 自己指派自己是可以移除的
- // if(!this.isAllowedDelete(item))
- // {
- // this.$notify({
- // type: "warning",
- // message: "没有权限移除自己。",
- // offset: 100,
- // duration: 5000
- // });
- // return;
- // }
- // if(item.folderPerm == 2) {
- // this.removeManageUser(item);
- // } else {
- // this.checkDeptUserName(false, item);
- // this.cancelCheck(item.id);
- // }
-
- // },
-
-
/**
* 移除负责人
*/
removeManageUser(user) {
- debugger;
- // user.folderPerm = 1;
- // // user.roleName = "查看编辑";
- // this.selectedManageUser.splice(0,1);
- // for (var k = 0; k < this.selectedUser.length; k++) {
- // if (this.selectedUser[k].id == user.id) {
- // this.selectedUser[k].folderPerm = 0;
- // this.selectedUser.splice(k, 1);
- // }
- // }
- // this.cancelCheck(user.id);
- },
-
- /*
- *取消选中
- */
- cancelCheck(userID) {
- debugger;
- // for (var i = 0; i < this.listDept.length; i++) {
- // for (var j = 0; j < this.listDept[i].listUser.length; j++) {
- // if (this.listDept[i].listUser[j].id === userID) {
- // this.listDept[i].listUser[j].selected = false;
- // this.listDept[i].listUser[j].folderPerm = 0;
- // this.getIsCheckSecondLevel(i);
- // }
- // }
- // }
- // this.getIsCheckAll();
+ user.folderPerm = 1;
+ // user.roleName = "查看编辑";
+ this.selectedManageUser.splice(0,1);
+ for (var k = 0; k < this.selectedUser.length; k++) {
+ if (this.selectedUser[k].id == user.id) {
+ this.selectedUser[k].folderPerm = 0;
+ this.selectedUser.splice(k, 1);
+ }
+ }
},
/**
@@ -1140,7 +864,7 @@
item.selected = targetChecked;
if (item.selected) {
item.folderPerm = 1; // 默认角色为:查看和编辑
- var valueUser = JSON.parse(JSON.stringify(item));
+ var valueUser = cloneDeep(item);
if(!this.selectedUser.find(user => user.id == item.id)) {
this.selectedUser.push(valueUser);
}
@@ -1189,81 +913,6 @@
this.oldPlainFolderList = plainFolderList;
this.lastFolderId = this.oldPlainFolderList[this.oldPlainFolderList.length -1].id;
},
- // todo 待移除
- async fetchProjectDetailOld() {
- const currentCompanyId = this.$store.state.currentCompanyId;
- const [userList, projectDataRes, deptList, memberData] = await Promise.all([
- this.getUserList(),
- this.$fetchApi('folder/queryNodeFolderListByProjectId', { projectId: sessionStorage.projId }),
- fetchDeptList(currentCompanyId),
- fetchMemberTree(currentCompanyId),
- ]);
-
- // console.log(memberData);
- // debugger;
- // const deptHeadList = deptList[0].children || [];
- let oList = this.plainTreeNodes(deptList, userList);
-
- // 如果人员没有设置部门的话
- const aloneUserList = this.userList.filter(user => {
- for(let i = 0; i < deptList.length; i++) {
- if(deptList[i].id == user.deptId) {
- return false;
- }
- }
- return true;
- });
-
- if(aloneUserList.length > 0) {
- const emptyDept = {};
- emptyDept.id = "0";
- emptyDept.deptName = sessionStorage.CompanyName || "";
- emptyDept.listUser = [];
- emptyDept.listUser.push(...aloneUserList);
- oList.push(emptyDept);
- }
-
- oList.forEach(item=>{
- // console.log(1)
- // console.log(item.listUser)
- item.listUser=item.listUser.sort((a, b) => a.cnName.localeCompare(b.cnName))
- })
-
- this.listDept = oList;
- this.currListDeptUserData = oList;
-
- const { folder, manager } = (projectDataRes.Data || {});
- // console.log(folder, manager, userList);
- const userHash = userList.reduce((h, user) => {
- h[user.id] = user;
- return h;
- }, {});
- this.listManagerUser = manager.map(u => userHash[u.UserId]);
- // debugger;
- if(this.listManagerUser.length) {
- this.currUser = this.listManagerUser[0] || {};
- this.isProjCreator = this.currUser.id === this.userId;
- this.listManagerUser = this.listManagerUser.slice(1);
- this.isProjManager = !!this.listManagerUser.find(m => m.id == this.userId) || this.currUser.id == this.userId;
- }
- this.oldListManagerUser = cloneDeep(this.listManagerUser);
-
- let uniqFolder = uniqBy(folder, 'Id');
- // console.log(folder, uniqFolder);
- const folderList = mergeFolderList(uniqFolder, userHash);
- this.getfolderPerm(folderList);
- this.listNewFolder = folderList;
- this.oldFolderList = cloneDeep(this.listNewFolder);
- this.getPlainOldFolderList();
- // console.log('得到的listNewFolder', this.listNewFolder);
-
- this.getAllChildrenLists(this.listNewFolder,this.userId,this.allChildrenLists);
- },
- // async getUserList(){
- // const { list: userList } = await getUserListByNode({ id: this.$store.state.currentCompanyId, nodeType: 'company' }, 1, 10000);
- // this.userList = userList;
- // return userList;
- // },
async fetchProjectDetail() {
const currentCompanyId = this.$store.state.currentCompanyId;
const [projectDataRes, { treeList: memberTree, memberMap }] = await Promise.all([
@@ -1289,6 +938,7 @@
this.getfolderPerm(folderList);
this.listNewFolder = folderList;
this.oldFolderList = cloneDeep(this.listNewFolder);
+
this.getPlainOldFolderList();
// console.log('得到的listNewFolder', this.listNewFolder);
@@ -1306,10 +956,10 @@
}
})
},
- /**
+ /**
* 全部的子节点
*/
- getAllChildrenLists(folderLists,id,allChildrenLists){
+ getAllChildrenLists(folderLists,id,allChildrenLists){
folderLists.forEach(folder=>{
if(folder.manageUser.length>0){
if(folder.manageUser[0].id==id){
@@ -1393,39 +1043,10 @@
});
}
},
- },
-
-
- computed: {
- /**
- * 过滤后的部门列表:去除没有用户数据的部门
- */
- listDeptComputed() {
- return this.listDept.filter(function (dept) {
- return dept.listUser.length > 0;
- });
- },
- /**
- * 当未选择人员时,部门不显示
- */
- listDeptUserNoZero(user) {
- return function (user) {
- let temp = [];
- for (let i = 0; i < user.length; i++) {
- if (user[i].folderPerm != 2) {
- temp.push(user[i].deptId);
- }
- }
- var x = new Set(temp);
- return [...x];
- };
- },
-
- },
-
- }
+ },
+}
- function mergeFolderList(plainFolderList, userHash) {
+function mergeFolderList(plainFolderList, userHash) {
const [rootFolder, commonFolder, ...restFolderList] = plainFolderList;
const rootFolderId = rootFolder.Id;
const headList = [];