UserManageList.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. (function ($ang_userRole) {
  2. 'use strict';
  3. $ang_userRole.module('devself.common', []).controller("UserManageListController", function ($scope, $http, $rootScope, $alert, $modal, $ocLazyLoad) {
  4. $scope.RoleUserLists = [];
  5. $scope.Name = "";
  6. //人员选择
  7. $rootScope.selectedID = '';
  8. $rootScope.selectedName = '';
  9. $rootScope.selectedDataUsers = [];
  10. $rootScope.selectedGuids = '';
  11. //分页参数设置
  12. $scope.finddata = {
  13. pageindex: 1,
  14. pagesize: 5,
  15. ptotal: 0
  16. };
  17. //监测页面变化
  18. $scope.$watch("finddata.pageindex", function (newVal, oldVal) {
  19. if ($scope.finddata.ptotal > 0) {
  20. $scope.getUserRoleList();
  21. }
  22. })
  23. //查询按钮
  24. $scope.selectpage = function () {
  25. $scope.finddata.pageindex = 1;
  26. $scope.finddata.ptotal = 0;
  27. $scope.getUserRoleList();
  28. }
  29. //通过roleId以及名字去实现模糊查询
  30. $scope.getUserRoleList = function () {
  31. $http({
  32. url: "../../api/userrole/GetRoleUserList",
  33. method: 'GET',
  34. params: {
  35. roleId: $rootScope.role.roleId,
  36. //roleName: $rootScope.role.roleName,
  37. name: $scope.Name,
  38. pageIndex: $scope.finddata.pageindex,
  39. pageSize: $scope.finddata.pagesize
  40. }
  41. })
  42. .then(function (rq) {
  43. //console.log(rq);
  44. $scope.RoleUserLists = rq.data.item.list;
  45. $scope.finddata.ptotal = rq.data.item.total;
  46. }, function (rq) {
  47. alert("获取失败");
  48. });
  49. }
  50. $scope.getUserRoleList();
  51. //根据UserId删除一条角色对应的人员信息记录
  52. $scope.deleteUserRole = function (UserId, RoleId) {
  53. if (!confirm("确认删除?")) {
  54. return;
  55. }
  56. $http({
  57. url: "../../api/user/deleteUserRole",
  58. method: 'GET',
  59. params: {
  60. userId: UserId,
  61. roleId: RoleId
  62. }
  63. }).then(function (res) {
  64. $scope.showalert(res.data.msg);
  65. $scope.getUserRoleList();
  66. }, function () {
  67. $alert({title: '错误:', content: '服务器错误', placement: 'top', type: 'info', show: true, duration: 2});
  68. });
  69. };
  70. //给弹窗界面进行赋值操作
  71. var MyEditModalController = function ($scope, $http) {
  72. $scope.title = "新增人员信息";
  73. $scope.userRole = myModal.data;
  74. $scope.saveUserRole = function (isflag) {
  75. if (isflag) {
  76. $http({
  77. url: "../../api/systemsetting/UserRole/SaveUserRoleList",
  78. method: 'POST',
  79. data: {
  80. roleId: $scope.userRole.roleId,
  81. //name: $scope.userRole.name
  82. userIds: $scope.userRole.selectedGuids
  83. }
  84. }).then(function (res) {
  85. //console.log(res);
  86. if (res.data.success) {
  87. myModal.$promise.then(myModal.hide);
  88. } else {
  89. myModal.$promise.then(myModal.hide);
  90. }
  91. $scope.getUserRoleList();
  92. $scope.showalert(res.data.msg);
  93. }, function (res) {
  94. $scope.showalert("添加人员失败");
  95. });
  96. }
  97. };
  98. };
  99. MyEditModalController.$inject = ['$scope', '$http'];
  100. var myModal = $modal({
  101. scope: $scope,
  102. title: '修改人员',
  103. templateUrl: '../js/setting/userRole/editUserRoleModal.html',
  104. controller: MyEditModalController,
  105. show: false,
  106. animation: 'am-fade-and-slide-top'
  107. });
  108. $scope.editModal = function (e) {
  109. myModal.data = e;
  110. myModal.$promise.then(myModal.show);
  111. };
  112. $scope.addModal = function () {
  113. $scope.userRole = {
  114. RoleName: $rootScope.role.roleName,
  115. roleId: $rootScope.role.roleId,
  116. selectedGuids: $rootScope.selectedGuids
  117. //name: "",
  118. };
  119. $scope.editModal($scope.userRole);
  120. };
  121. $scope.showalert = function (data) {
  122. $alert({title: '提示:', content: data, placement: 'top', type: 'info', show: true, duration: 3});
  123. };
  124. });
  125. })(angular);