user.js 4.11 KB
(function () {
    "use strict";

    //员工免登令牌列表页面
    var userIndexController= function ($scope, $http, $modal,SystemService, dialogService) {
            $scope.$emit('navShow',4);
            //分页传入的数值
            $scope.vm = {
                pageNumber: 1,
                pageSize: 10,
                sourceTypes : ["EMPLOYEE", "NONE"]
            };
            $scope.pagedResult = [];
            /**
             * 搜索用户列表
             */
            $scope.getList = function () {
                SystemService.apiSystemUsersSearchBySourceType($scope.vm).success(function (data) {
                    if (data.errors && data.errors.length === 0) {
                        $scope.pagedResult = data.result;
                        $scope.vm.totalCount=data.totalCount;
                    } else {
                        var msg = "由于以下原因,未能取得数据\n";
                        for (var i = 0; i < data.errors.length; i++) {
                            msg += (i + 1) + "." + data.errors[i].message + "\n";
                        }
                        dialogService.tip(msg);
                    }
                });
            };


             //页面初始化加载数据
            $scope.doSearch=function(){
                $scope.vm.pageNumber=1;
                $scope.getList();
            };

            $scope.doSearch();

            //令牌编辑弹窗
            $scope.ssoTokenEdit=function(id){
                var modalInstance = $modal.open({
                    templateUrl: "ssotoken.html",
                    controller: SsoTokenController,
                    size:"",
                    resolve: {
                        id: function () {
                            return id ;
                        }
                    }
                });
            };
        }
    //用户免登令牌弹窗
    var SsoTokenController= ["$scope","$modalInstance","$modal","id","PurchasingService","InventoryService","CustomizationService","dialogService",
        function($scope, $modalInstance, $modal,id,purchasingService,inventoryService,customizationService,dialogService){
            console.log(id);
            $scope.vm = {
                pageSize:0,
                id:id
            };
                customizationService.apiCustomizationSsoTokenFind($scope.vm).success(function(data){
                if (data.errors == null || data.errors.length > 0){
                    dialogService.tip(data.errors,null,0);
                } else {
                         $scope.result=data.result[0];
                         $scope.result.id=id;
                }
                });
            $scope.doSave=function(){
                if( $scope.result.userName==null || $scope.result.userName.length!=16){
                    dialogService.tip([{"message": "账户必须为16位且不能为空"}]);
                    return ;
                }
                if($scope.result.userPassWord==null || $scope.result.userPassWord.length!=16){
                    dialogService.tip([{"message": "密码必须为16位且不能为空"}]);
                    return ;
                }
                customizationService.apiCustomizationSsoTokenUpdate($scope.result).success(function(data){

                    if (data.errors == null || data.errors.length > 0)
                        dialogService.tip(data.errors,null,0);
                    else {
                        dialogService.tip([{"message": "更新成功!"}],"/customization/user.htm");
                        $modalInstance.close();
                    }
                });
            };
            $scope.clean = function () {
                $scope.itemCategoryList =[];
                $modalInstance.dismiss('cancel');
            };

        }];

    angular.module("xn.page", [])
        .controller("UserIndexController", ["$scope", "$http", "$modal","SystemService", "dialogService","CustomizationService",userIndexController])
        // .controller("SsoTokenController",["$scope","$modalInstance","$modal","supplierId","PurchasingService","InventoryService","dialogService",UserIndexController])
})();