(function ($app) { $app.module('ylmis').controller('userCtrl', function ($scope, $http, $filter, $modal, excelPopup, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) { $scope.dataList = []; $scope.recordStatusList = []; $scope.RoleList = []; $state.params = $bsRouterState.$params($scope); //初始化查询参数 $scope.selectparams = { userName: '', pageIndex: 1, pageSize: 10, recordStatus: null, RoleID:null }; $scope.pageInfo = { ptotal: 0 }; //监视页数变化 $scope.$watch("selectparams.pageIndex", function (newVal, oldVal) { if ($scope.pageInfo.ptotal > 0) { $scope.loadData(); } }); //查询 $scope.search = function () { $scope.loadData(); }; //加载列表数据 $scope.loadData = function () { $loading.show(); $http ({ method: 'post', url: '../../api/systemsetting/User/GetUserList', data: $scope.selectparams }).then(function (result) { $loading.hide(); $scope.dataList = result.data.Data.rows; $scope.pageInfo.ptotal = result.data.Data.total; }); }; $scope.GetRoleList = function () { $http ({ method: 'post', url: '../../api/systemsetting/User/GetUserRoleList', data: {} }).then(function (result) { $scope.RoleList = result.data.Data.rows; }); }; $scope.GetRoleList(); $scope.getrecordStatus = function () { $http({ method: 'post', url: '../../api/systemsetting/dictionary/GetDicList', data: { code: 'RecordStatus' } }).then(function (result) { $scope.recordStatusList = result.data.Data; }); } $scope.getrecordStatus(); $scope.addUser = function () { $scope.edit(null, '新增用户'); }; $scope.editUser = function (userID) { $scope.edit(userID, '修改用户'); }; $scope.resetPwd = function (id) { if (confirm("是否重置密码?")) { $http ({ method: 'get', url: '../../api/systemsetting/User/ResetPwd', params: { Id: id } }).then(function (res) { if (res.data.IsSuccess) { $scope.loadData(); $scope.showMsg('成功', '重置成功'); } else { $scope.showMsg('错误', res.data.Message); } }); } }; $scope.delUser = function () { if (confirm("是否要删除该用户?")) { var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.UserID; }); if (ids.length <= 0) { $scope.showMsg("消息", "请选择需要删除的数据"); return false; } $http.post('../../api/systemsetting/User/Delete', { userIDs: ids }).then(function (res) { if (res.data.IsSuccess) { $scope.loadData(); $scope.showMsg('成功', '删除成功'); } else { $scope.showMsg('错误', res.data.Message); } }); } }; $scope.export = function () { var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.UserID; }); excelPopup.export('../../api/systemsetting/User/ExportPort', angular.extend($scope.selectparams, { userId: ids.join(",") }), "用户信息.xls"); }; $scope.editData = {}; $scope.edit = function (id, title) { $scope.editData.params = { userID: id, title: title }; $scope.editData.parentLoad = $scope.loadData; editModal.$promise.then(editModal.show); }; //定义模态框 var editModal = $modal({ resolve: { load: ['$ocLazyLoad', function ($ocLazyLoad) { return $ocLazyLoad.load('systemsetting/user/edit.js?' + window.sysVersion); }] }, scope: $scope, controller: 'editUserCtrl', templateUrl: '../main/systemsetting/user/edit.html', show: false, animation: 'am-fade-and-slide-top' }); $scope.loadData(); }); })(angular);