123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- angular.module('push')
- .controller('addMemberCtrl', function ($scope, AuthorityService, AuthorityModel, CommentService, UtilService, $stateParams,AuthorityModelService) {
- $scope.act = true;
- $scope.userList = [];
- $scope.AuthorityList = [];
- $scope.type = $stateParams.type;
- $scope.showshare = false;
- $scope.shownone = false;//是否显示无网络页面
- // console.log($scope.qrcodeurl);
- //已选择用户id拼接
- var useridlist = "";
- var getUserIdList = function (flg) {
- useridlist = "";
- angular.forEach(AuthorityModel.getMemberList(), function (value, index) {
- var tempid = "'" + value.userId + "'";
- useridlist = useridlist + tempid + ",";
- });
- // console.log(useridlist);
- //切换tab时需用户刷选
- if (flg) {
- toSelectUserList($scope.userList);
- toSelectAuthorityList($scope.AuthorityList);
- }
- };
- getUserIdList();
- //关注用户刷选
- var toSelectUserList = function (userList) {
- $scope.userList = angular.copy(userList);
- angular.forEach(userList, function (data, index) {
- var tempid = "'" + data.userId + "'";
- if (useridlist.indexOf(tempid) != -1) {
- $scope.userList[index].isExisits = 1;
- } else {
- $scope.userList[index].isExisits = 0;
- }
- })
- };
- //权限用户组刷选
- var toSelectAuthorityList = function (authorityList) {
- //刷选是否有批量导入
- var authlist = AuthorityModel.getAuthorityList();
- $scope.AuthorityList = angular.copy(authorityList);
- angular.forEach(authlist, function (value, index) {
- $scope.AuthorityList[value].isadd = 1;
- });
- //刷选权限下用户组
- angular.forEach(authorityList, function (value, index) {
- angular.forEach(value.userList, function (data, ind) {
- var tempid = data.userId + "";
- if (useridlist.indexOf(tempid) != -1) {
- $scope.AuthorityList[index].userList[ind].isExisits = 1;
- } else {
- $scope.AuthorityList[index].userList[ind].isExisits = 0;
- }
- });
- });
- };
- var initData = function () {
- //获取关注用户列表
- CommentService.getMyAttentionList(0, "", "").then(function (response) {
- // console.log(response.userList);
- toSelectUserList(response.userList);
- $scope.shownone = false;
- }, function () {
- $scope.shownone = true;
- });
- //获取权限列表
- AuthorityService.getAuthorityList("", "").then(function (response) {
- // console.log(response.cloautlist);
- toSelectAuthorityList(response.cloautlist);
- $scope.shownone = false;
- }, function () {
- $scope.shownone = true;
- });
- };
- initData();
- //切换关注、权限
- $scope.changeTab = function () {
- getUserIdList(true);
- $scope.act = !$scope.act;
- };
- //关注用户添加
- $scope.addMember = function (user, index) {
- $scope.userList[index].isExisits = 1;
- var tempobj = {
- userId: user.userId,
- userName: user.userName,
- photo: user.photo,
- iscreator: 0,
- comefrom: user.comefrom
- };
- AuthorityModel.addMemberList(tempobj);
- };
- //处理批量添加user(剔除重复user)
- var handleAddMembers = function (userList) {
- //获得当前选择useridlist
- useridlist = "";
- angular.forEach(AuthorityModel.getMemberList(), function (value, index) {
- useridlist = useridlist + value.userId + ",";
- });
- angular.forEach(userList, function (data, index) {
- var tempid = data.userId + "";
- if (useridlist.indexOf(tempid) == -1) {
- var tempobj = {
- userId: data.userId,
- userName: data.userName,
- photo: data.photo,
- iscreator: 0,
- comefrom: data.comefrom
- };
- AuthorityModel.addMemberList(tempobj);
- }
- });
- };
- //批量导入权限
- $scope.addAuthority = function (authority, index) {
- handleAddMembers(authority.userList);
- $scope.AuthorityList[index].isadd = 1;
- angular.forEach($scope.AuthorityList[index].userList, function (data, ind) {
- $scope.AuthorityList[index].userList[ind].isExisits = 1;
- });
- AuthorityModel.addAuthorityList(index);
- };
- //单个导入权限下用户
- $scope.addAuthorityMember = function (authority, user, index) {
- var i = $scope.AuthorityList.indexOf(authority);
- var tempobj = {
- userId: user.userId,
- userName: user.userName,
- photo: user.photo,
- iscreator: 0,
- comefrom: user.comefrom
- };
- AuthorityModel.addMemberList(tempobj);
- $scope.AuthorityList[i].userList[index].isExisits = 1;
- };
- //是否现在权限下用户
- $scope.showMember = function (index) {
- $scope.AuthorityList[index].showlist = !$scope.AuthorityList[index].showlist;
- };
- $scope.goUserSearch = function () {
- $scope.go('userSearch', {searchtype: 1, isset: 0});
- };
- $scope.goGroupCreate = function () {
- AuthorityModelService.isfirst = 0;
- $scope.go('groupCreate');
- };
- //网络重载
- $scope.initMember=function () {
- initData();
- }
- });
|