1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- (function ($app) {
- $app.module('ylmis').controller('editUserCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) {
- $scope.params = $scope.$parent.$parent.editData.params;
- $scope.parentLoad = $scope.$parent.$parent.editData.parentLoad;
- $scope.user = {};
- $scope.recordStatusList = [{ dickey: 1, dicvalue: '启用' }, { dickey: 0, dicvalue: '禁用' }];
- $scope.$watch("user.EmployeeId", function (newVal, oldVal) {
- if ($scope.employeeList && $scope.employeeList.length > 0 && newVal != oldVal) {
- $scope.user.Name = $.map($filter('filter')($scope.employeeList, { EmployeeId: newVal }), function (x) { return x.Name; })[0];
- if ($scope.params.userID == undefined || $scope.params.userID == null) {
- $scope.user.CmWorkLinkAccountPsid = $.map($filter('filter')($scope.employeeList, { EmployeeId: newVal }), function (x) { return x.EmployeeNo; })[0];
- $scope.user.LoginID = $.map($filter('filter')($scope.employeeList, { EmployeeId: newVal }), function (x) { return x.EmployeeNo; })[0];
- }
-
- }
- });
- $scope.loadData = function () {
- $loading.show();
- $http({
- method: "post",
- url: "../../api/systemsetting/User/GetUser",
- data: {
- userID: $scope.params.userID
- }
- }).then(function (result) {
- $loading.hide();
- $scope.user = result.data.Data;
- });
- };
- $scope.getEmpList = function () {
- $http
- ({
- method: 'post', url: '../../api/salary/Employee/GetListForSelect', data: { pageIndex: 1, pageSize: 999 }
- }).then(function (result) {
- $scope.employeeList = result.data.Data.rows;
- $scope.employeeList = $scope.employeeList.filter(function (r) { return r.UserId == null || r.UserId == $scope.params.userID })
- });
- };
- $scope.save = function (isflag) {
- if (isflag) {
- $loading.show();
- var url = "../../api/systemsetting/User/Add";
- if ($scope.user.UserID) {
- url = "../../api/systemsetting/User/Edit";
- }
- $http({
- method: "post",
- url: url,
- data: {
- user: $scope.user
- }
- }).then(function (result) {
- $loading.hide();
- if (result.data.IsSuccess) {
- $scope.showMsg('成功', '保存成功。');
- //重新刷新列表
- $scope.parentLoad();
- $scope.$hide();
- } else {
- $scope.showMsg('成功', result.data.Message);
- }
- }, function (resp) {
- $loading.hide();
- $scope.showMsg('错误', '服务器错误');
- });
- }
- }
- if ($scope.params.userID) {
- $scope.loadData();
- } else {
- $scope.user.RecordStatus = 1;
- };
- $scope.getEmpList();
- });
- })(angular);
|