list.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. (function ($app) {
  2. $app.module('ylmis').controller('userCtrl', function ($scope, $http, $filter, $modal, excelPopup, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) {
  3. $scope.dataList = [];
  4. $scope.recordStatusList = [];
  5. $scope.RoleList = [];
  6. $state.params = $bsRouterState.$params($scope);
  7. //初始化查询参数
  8. $scope.selectparams = {
  9. userName: '',
  10. pageIndex: 1,
  11. pageSize: 10,
  12. recordStatus: null,
  13. RoleID:null
  14. };
  15. $scope.pageInfo = { ptotal: 0 };
  16. //监视页数变化
  17. $scope.$watch("selectparams.pageIndex", function (newVal, oldVal) {
  18. if ($scope.pageInfo.ptotal > 0) {
  19. $scope.loadData();
  20. }
  21. });
  22. //查询
  23. $scope.search = function () {
  24. $scope.loadData();
  25. };
  26. //加载列表数据
  27. $scope.loadData = function () {
  28. $loading.show();
  29. $http
  30. ({
  31. method: 'post', url: '../../api/systemsetting/User/GetUserList', data: $scope.selectparams
  32. }).then(function (result) {
  33. $loading.hide();
  34. $scope.dataList = result.data.Data.rows;
  35. $scope.pageInfo.ptotal = result.data.Data.total;
  36. });
  37. };
  38. $scope.GetRoleList = function () {
  39. $http
  40. ({
  41. method: 'post', url: '../../api/systemsetting/User/GetUserRoleList', data: {}
  42. }).then(function (result) {
  43. $scope.RoleList = result.data.Data.rows;
  44. });
  45. };
  46. $scope.GetRoleList();
  47. $scope.getrecordStatus = function () {
  48. $http({
  49. method: 'post', url: '../../api/systemsetting/dictionary/GetDicList', data: { code: 'RecordStatus' }
  50. }).then(function (result) {
  51. $scope.recordStatusList = result.data.Data;
  52. });
  53. }
  54. $scope.getrecordStatus();
  55. $scope.addUser = function () {
  56. $scope.edit(null, '新增用户');
  57. };
  58. $scope.editUser = function (userID) {
  59. $scope.edit(userID, '修改用户');
  60. };
  61. $scope.resetPwd = function (id) {
  62. if (confirm("是否重置密码?")) {
  63. $http
  64. ({
  65. method: 'get',
  66. url: '../../api/systemsetting/User/ResetPwd',
  67. params: { Id: id }
  68. }).then(function (res) {
  69. if (res.data.IsSuccess) {
  70. $scope.loadData();
  71. $scope.showMsg('成功', '重置成功');
  72. } else {
  73. $scope.showMsg('错误', res.data.Message);
  74. }
  75. });
  76. }
  77. };
  78. $scope.delUser = function () {
  79. if (confirm("是否要删除该用户?")) {
  80. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.UserID; });
  81. if (ids.length <= 0) {
  82. $scope.showMsg("消息", "请选择需要删除的数据");
  83. return false;
  84. }
  85. $http.post('../../api/systemsetting/User/Delete', { userIDs: ids }).then(function (res) {
  86. if (res.data.IsSuccess) {
  87. $scope.loadData();
  88. $scope.showMsg('成功', '删除成功');
  89. } else {
  90. $scope.showMsg('错误', res.data.Message);
  91. }
  92. });
  93. }
  94. };
  95. $scope.export = function () {
  96. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.UserID; });
  97. excelPopup.export('../../api/systemsetting/User/ExportPort', angular.extend($scope.selectparams, { userId: ids.join(",") }), "用户信息.xls");
  98. };
  99. $scope.editData = {};
  100. $scope.edit = function (id, title) {
  101. $scope.editData.params = {
  102. userID: id,
  103. title: title
  104. };
  105. $scope.editData.parentLoad = $scope.loadData;
  106. editModal.$promise.then(editModal.show);
  107. };
  108. //定义模态框
  109. var editModal = $modal({
  110. resolve: {
  111. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  112. return $ocLazyLoad.load('systemsetting/user/edit.js?' + window.sysVersion);
  113. }]
  114. },
  115. scope: $scope,
  116. controller: 'editUserCtrl',
  117. templateUrl: '../main/systemsetting/user/edit.html',
  118. show: false,
  119. animation: 'am-fade-and-slide-top'
  120. });
  121. $scope.loadData();
  122. });
  123. })(angular);