UserManageList.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. (function ($ang_userRole) {
  2. 'use strict';
  3. $ang_userRole.module('devself.common', []).controller("UserManageListController", function ($scope, $http, $rootScope, $alert, $modal, $ocLazyLoad, $filter) {
  4. $scope.role = $rootScope.role
  5. $scope.UserRoleLists = [];
  6. $scope.Name = "";
  7. //人员选择
  8. $rootScope.selectedID = '';
  9. $rootScope.selectedName = '';
  10. $rootScope.selectedDataUsers = [];
  11. $rootScope.selectedGuids = '';
  12. //分页参数设置
  13. $scope.finddata = {
  14. pageindex: 1,
  15. pagesize: 5,
  16. ptotal: 0
  17. };
  18. //监测页面变化
  19. $scope.$watch("finddata.pageindex", function (newVal, oldVal) {
  20. if ($scope.finddata.ptotal > 0) {
  21. $scope.getUserRoleList();
  22. }
  23. })
  24. //查询按钮
  25. $scope.selectpage = function () {
  26. $scope.finddata.pageindex = 1;
  27. $scope.finddata.ptotal = 0;
  28. $scope.getUserRoleList();
  29. }
  30. //通过roleId以及名字去实现模糊查询
  31. $scope.getUserRoleList = function () {
  32. $http({
  33. url: "../../api/systemsetting/UserRole/GetUserListByRole",
  34. method: 'post',
  35. data: {
  36. roleID: $rootScope.role.roleId,
  37. //roleName: $rootScope.role.roleName,
  38. name: $scope.Name,
  39. pageIndex: $scope.finddata.pageindex,
  40. pageSize: $scope.finddata.pagesize
  41. }
  42. })
  43. .then(function (result) {
  44. //console.log(rq);
  45. $scope.UserRoleLists = result.data.Data.rows;
  46. $scope.finddata.ptotal = result.data.Data.total;
  47. }, function (result) {
  48. alert("获取失败");
  49. });
  50. }
  51. $scope.getUserRoleList();
  52. //根据UserId删除一条角色对应的人员信息记录
  53. $scope.deleteUserRole = function (UserId, RoleId) {
  54. if (!confirm("确认删除?")) {
  55. return;
  56. }
  57. $http({
  58. url: "../../api/systemsetting/UserRole/DeleteUserRole",
  59. method: 'POST',
  60. data: {
  61. userId: UserId,
  62. roleId: RoleId
  63. }
  64. }).then(function (res) {
  65. if (res.data.IsSuccess) {
  66. $scope.showalert("删除成功");
  67. $scope.getUserRoleList();
  68. } else {
  69. $scope.showalert(res.Message);
  70. }
  71. }, function () {
  72. $alert({ title: '错误:', content: '服务器错误', placement: 'top', type: 'info', show: true, duration: 2 });
  73. });
  74. };
  75. //给弹窗界面进行赋值操作
  76. var MyEditModalController = function ($scope, $http) {
  77. $scope.userList = [];
  78. $scope.selectUserParams = {
  79. url: '../../api/systemsetting/Account/GetAllUsersForSelect',
  80. isMulti: true,
  81. selectData: { loginID: '登录账号', name: '姓名' },
  82. columns: { LoginID: '登录账号', Name: '姓名', SexName: '性别' },
  83. selectLabelKey: 'Name',
  84. selectValuekey: 'UserID',
  85. selectedValueData: '',
  86. selectedLabeData: '',
  87. selectedJData: [],
  88. selectParams: {
  89. }
  90. };
  91. $scope.$watch('selectUserParams.selectedValueData', function (newVal) {
  92. if (newVal != '' && newVal != undefined) {
  93. angular.forEach($scope.selectUserParams.selectedJData, function (val) {
  94. if ($filter('filter')($scope.userList, { UserID: val.UserID }).length == 0) {
  95. $scope.userList.push(val.UserID)
  96. //$scope.userList.push({
  97. //UserID: val.UserID,
  98. //LoginID: val.LoginID,
  99. //Name: val.Name,
  100. //Sex: val.Sex,
  101. //SexName: val.SexName,
  102. //rowChecked: false
  103. //});
  104. }
  105. });
  106. }
  107. });
  108. $scope.title = "新增人员信息";
  109. $scope.userRole = myModal.data;
  110. $scope.saveUserRole = function (isflag) {
  111. if (isflag) {
  112. $http({
  113. url: "../../api/systemsetting/UserRole/SaveUserRoleList",
  114. method: 'POST',
  115. data: {
  116. roleId: $scope.userRole.roleId,
  117. //name: $scope.userRole.name
  118. userIds: $scope.userList
  119. }
  120. }).then(function (res) {
  121. //console.log(res);
  122. if (res.data.IsSuccess) {
  123. myModal.$promise.then(myModal.hide);
  124. $scope.showalert("添加成功");
  125. } else {
  126. myModal.$promise.then(myModal.hide);
  127. $scope.showalert(res.Message);
  128. }
  129. $scope.getUserRoleList();
  130. }, function (res) {
  131. $scope.showalert("添加人员失败");
  132. });
  133. }
  134. };
  135. };
  136. MyEditModalController.$inject = ['$scope', '$http'];
  137. var myModal = $modal({ scope: $scope, title: '修改人员', templateUrl: '../main/systemsetting/role/editUserRoleModal.html', controller: MyEditModalController, show: false, animation: 'am-fade-and-slide-top' });
  138. $scope.editModal = function (e) {
  139. myModal.data = e;
  140. myModal.$promise.then(myModal.show);
  141. };
  142. $scope.addModal = function () {
  143. $scope.userRole = {
  144. RoleName: $rootScope.role.roleName,
  145. roleId: $rootScope.role.roleId,
  146. selectedGuids: $rootScope.selectedGuids
  147. //name: "",
  148. };
  149. $scope.editModal($scope.userRole);
  150. };
  151. $scope.showalert = function (data) {
  152. $alert({ title: '提示:', content: data, placement: 'top', type: 'info', show: true, duration: 3 });
  153. };
  154. });
  155. })(angular);
  156. var roleUsersModal