diff --git a/cloud-common-plugin/src/main/resources/templates/tree/tree-user.html b/cloud-common-plugin/src/main/resources/templates/tree/tree-user.html index 6bddffe..0170c9e 100644 --- a/cloud-common-plugin/src/main/resources/templates/tree/tree-user.html +++ b/cloud-common-plugin/src/main/resources/templates/tree/tree-user.html @@ -32,7 +32,6 @@
@@ -53,7 +52,7 @@ var selectDepartmentUserArray = []; - top.dialog.dialogData.selectedDepartmentUsers = null; + top.dialog.dialogData.selectedDepartmentUsers = []; function closeBox() { top.dialog.dialogData.selectedUsers = null; @@ -115,6 +114,7 @@ } } } + top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserArray; } function initCheckData(zTree) { if(selectedUsers) { @@ -127,7 +127,17 @@ selectedUsers: selectedUsers }, null, function(code, data) { for(var i = 0, item; item = data[i++];) { - addSelectDepartmentUserArray(item.userId, item.userName, ('【'+ item.departmentName +'】'+ item.userName), item.departmentId); + var id = item.userId; + var userName = item.userName; + var userTitle = ('【'+ item.departmentName +'】'+ item.userName); + var departmentId = item.departmentId; + addSelectDepartmentUserArray(id, userName, userTitle, departmentId); + top.dialog.dialogData.selectedDepartmentUsers.push({ + userId: id, + userName: userName, + userTitle: userTitle, + departmentId: departmentId, + }); } initSelectNode(zTree); }, function(code, data) { @@ -199,17 +209,18 @@ } } } - top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserArray; } $(document).on('click', '.remove-selected-user', function() { var zTree = $.fn.zTree.getZTreeObj('leftTree'); removeSelectDepartmentUserArray(this.dataset.userid, this.dataset.departmentid); // 删除选中状态 var node = zTree.getNodeByParam('id', 'u_'+ this.dataset.userid, null); - zTree.checkNode(node, false, true); - top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserArray; + if(node) { + zTree.checkNode(node, false, true); + } }); $('.confirm').on('click', function() { + top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserArray; closeBox(); }); $('.close').on('click', function() {