list.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. (function ($app) {
  2. $app.module('ylmis').controller('roleCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState, $rootScope) {
  3. $scope.dataList = [];
  4. $state.params = $bsRouterState.$params($scope);
  5. //初始化查询参数
  6. $scope.selectparams = {
  7. roleName: '',
  8. pageIndex: 1,
  9. pageSize: 10
  10. };
  11. $scope.pageInfo = { ptotal: 0 };
  12. //监视页数变化
  13. $scope.$watch("selectparams.pageIndex", function (newVal, oldVal) {
  14. if ($scope.pageInfo.ptotal > 0) {
  15. $scope.loadData();
  16. }
  17. });
  18. //查询
  19. $scope.search = function () {
  20. $scope.loadData();
  21. };
  22. //加载列表数据
  23. $scope.loadData = function () {
  24. $http
  25. ({
  26. method: 'post', url: '../../api/systemsetting/Role/GetRoleList', data: $scope.selectparams
  27. }).then(function (result) {
  28. $scope.dataList = result.data.Data.rows;
  29. $scope.pageInfo.ptotal = result.data.Data.total;
  30. });
  31. };
  32. $scope.showMsg = function (title, content) {
  33. $alert({
  34. title: title + ':',
  35. content: content,
  36. placement: 'top',
  37. type: 'info',
  38. show: true,
  39. duration: 3
  40. });
  41. };
  42. $scope.addRole = function () {
  43. $scope.edit(null, '添加角色');
  44. };
  45. $scope.editRole = function (roleID) {
  46. $scope.edit(roleID, '修改角色');
  47. };
  48. $scope.delRole = function () {
  49. if (confirm("是否要删除该角色?")) {
  50. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.RoleID; });
  51. if (ids.length <= 0) {
  52. $scope.showMsg("消息", "请选择需要删除的数据");
  53. return false;
  54. }
  55. $http.post('../../api/systemsetting/Role/Delete', { roleIDs: ids }).then(function (res) {
  56. if (res.data.IsSuccess) {
  57. $scope.loadData();
  58. $scope.showMsg('成功', '删除成功');
  59. } else {
  60. $scope.showMsg('错误', res.data.Message);
  61. }
  62. });
  63. }
  64. };
  65. $scope.editData = {};
  66. $scope.edit = function (id, title) {
  67. $scope.editData.params = {
  68. roleID: id,
  69. title: title
  70. };
  71. $scope.editData.parentLoad = $scope.loadData;
  72. editModal.$promise.then(editModal.show);
  73. };
  74. //定义模态框
  75. var editModal = $modal({
  76. resolve: {
  77. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  78. $ocLazyLoad.load('systemsetting/role/edit.js?' + window.sysVersion);
  79. }]
  80. },
  81. scope: $scope,
  82. controller: 'editRoleCtrl',
  83. templateUrl: '../main/systemsetting/role/edit.html',
  84. show: false,
  85. animation: 'am-fade-and-slide-top'
  86. });
  87. //添加人员管理弹出模块
  88. var roleUsersModal = $modal({
  89. resolve: {
  90. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  91. $rootScope.aid = "100";
  92. return $ocLazyLoad.load('../main/systemsetting/role/UserManageList.js');
  93. }]
  94. }, scope: $scope,
  95. controller: 'UserManageListController',
  96. templateUrl: '../main/systemsetting/role/UserManageList.html',
  97. show: false,
  98. animation: 'am-fade-and-slide-top'
  99. });
  100. $scope.editRoleUsers = function (e) {
  101. $rootScope.role = {
  102. roleName: e.RoleName,
  103. roleId: e.RoleID
  104. }
  105. roleUsersModal.$promise.then(roleUsersModal.show);
  106. };
  107. $scope.hideRoleUsersModal = function () {
  108. roleUsersModal.$promise.then(roleUsersModal.hide);
  109. }
  110. $scope.loadData();
  111. });
  112. })(angular);