123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- (function ($ang_userRole) {
- 'use strict';
- $ang_userRole.module('devself.common', []).controller("UserManageListController", function ($scope, $http, $rootScope, $alert, $modal, $ocLazyLoad, $filter) {
- $scope.role = $rootScope.role
- $scope.UserRoleLists = [];
- $scope.Name = "";
- //人员选择
- $rootScope.selectedID = '';
- $rootScope.selectedName = '';
- $rootScope.selectedDataUsers = [];
- $rootScope.selectedGuids = '';
- //分页参数设置
- $scope.finddata = {
- pageindex: 1,
- pagesize: 5,
- ptotal: 0
- };
- //监测页面变化
- $scope.$watch("finddata.pageindex", function (newVal, oldVal) {
- if ($scope.finddata.ptotal > 0) {
- $scope.getUserRoleList();
- }
- })
- //查询按钮
- $scope.selectpage = function () {
- $scope.finddata.pageindex = 1;
- $scope.finddata.ptotal = 0;
- $scope.getUserRoleList();
- }
- //通过roleId以及名字去实现模糊查询
- $scope.getUserRoleList = function () {
- $http({
- url: "../../api/systemsetting/UserRole/GetUserListByRole",
- method: 'post',
- data: {
- roleID: $rootScope.role.roleId,
- //roleName: $rootScope.role.roleName,
- name: $scope.Name,
- pageIndex: $scope.finddata.pageindex,
- pageSize: $scope.finddata.pagesize
- }
- })
- .then(function (result) {
- //console.log(rq);
- $scope.UserRoleLists = result.data.Data.rows;
- $scope.finddata.ptotal = result.data.Data.total;
- }, function (result) {
- alert("获取失败");
- });
- }
- $scope.getUserRoleList();
- //根据UserId删除一条角色对应的人员信息记录
- $scope.deleteUserRole = function (UserId, RoleId) {
- if (!confirm("确认删除?")) {
- return;
- }
- $http({
- url: "../../api/systemsetting/UserRole/DeleteUserRole",
- method: 'POST',
- data: {
- userId: UserId,
- roleId: RoleId
- }
- }).then(function (res) {
- if (res.data.IsSuccess) {
- $scope.showalert("删除成功");
- $scope.getUserRoleList();
- } else {
- $scope.showalert(res.Message);
- }
- }, function () {
- $alert({ title: '错误:', content: '服务器错误', placement: 'top', type: 'info', show: true, duration: 2 });
- });
- };
- //给弹窗界面进行赋值操作
- var MyEditModalController = function ($scope, $http) {
- $scope.userList = [];
- $scope.selectUserParams = {
- url: '../../api/systemsetting/Account/GetAllUsersForSelect',
- isMulti: true,
- selectData: { loginID: '登录账号', name: '姓名' },
- columns: { LoginID: '登录账号', Name: '姓名', SexName: '性别' },
- selectLabelKey: 'Name',
- selectValuekey: 'UserID',
- selectedValueData: '',
- selectedLabeData: '',
- selectedJData: [],
- selectParams: {
- }
- };
- $scope.$watch('selectUserParams.selectedValueData', function (newVal) {
- if (newVal != '' && newVal != undefined) {
- angular.forEach($scope.selectUserParams.selectedJData, function (val) {
- if ($filter('filter')($scope.userList, { UserID: val.UserID }).length == 0) {
- $scope.userList.push(val.UserID)
- //$scope.userList.push({
- //UserID: val.UserID,
- //LoginID: val.LoginID,
- //Name: val.Name,
- //Sex: val.Sex,
- //SexName: val.SexName,
- //rowChecked: false
- //});
- }
- });
- }
- });
- $scope.title = "新增人员信息";
- $scope.userRole = myModal.data;
- $scope.saveUserRole = function (isflag) {
- if (isflag) {
- $http({
- url: "../../api/systemsetting/UserRole/SaveUserRoleList",
- method: 'POST',
- data: {
- roleId: $scope.userRole.roleId,
- //name: $scope.userRole.name
- userIds: $scope.userList
- }
- }).then(function (res) {
- //console.log(res);
- if (res.data.IsSuccess) {
- myModal.$promise.then(myModal.hide);
- $scope.showalert("添加成功");
- } else {
- myModal.$promise.then(myModal.hide);
- $scope.showalert(res.Message);
- }
- $scope.getUserRoleList();
- }, function (res) {
- $scope.showalert("添加人员失败");
- });
- }
- };
- };
- MyEditModalController.$inject = ['$scope', '$http'];
- var myModal = $modal({ scope: $scope, title: '修改人员', templateUrl: '../main/systemsetting/role/editUserRoleModal.html', controller: MyEditModalController, show: false, animation: 'am-fade-and-slide-top' });
- $scope.editModal = function (e) {
- myModal.data = e;
- myModal.$promise.then(myModal.show);
- };
- $scope.addModal = function () {
- $scope.userRole = {
- RoleName: $rootScope.role.roleName,
- roleId: $rootScope.role.roleId,
- selectedGuids: $rootScope.selectedGuids
- //name: "",
- };
- $scope.editModal($scope.userRole);
- };
- $scope.showalert = function (data) {
- $alert({ title: '提示:', content: data, placement: 'top', type: 'info', show: true, duration: 3 });
- };
- });
- })(angular);
- var roleUsersModal
|