userRole.js 3.29 KB
/**
 * Created by cjl on 2018/4/23.
 */
(function () {
    "user strict";

    var UserRoleController = function($scope,$modal,$http,$interval,dialogService,railwayService){
        $scope.$emit('navShow', 7);
        $scope.settingShow = 7;
        $scope.vm = {
            account: '',
            totalCount : 0,
            pageNumber : 1,
            pageSize : 10,
            userId : ''
        };
        $scope.getList = function(){
            railwayService.findUserRoleList($scope.vm).success(function(data){
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                }else{
                    $scope.userRoleList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        };
        $scope.getList();

        $scope.doSearch = function(){
            $scope.vm.pageNumber = 1;
            $scope.getList();
        }
    };

    var AssignRoleController = function($scope,$modal,$http,$interval,dialogService,railwayService){
        $scope.$emit('navShow', 7);
        $scope.settingShow = 7;
        $scope.vm = {
            account: '',
            totalCount : 0,
            pageNumber : 1,
            pageSize : 10,
            userId : ''
        };

        //查找商品品牌
        $scope.brandOptions = {
            pageNumber: 1,
            pageSize: 10,
            methodName: "getBrandList"
        };
        $scope.brand = "";
        $scope.getBrandList = function (item) {
            var param = {
                fieldList : ["name"],
                value : item.data.keyword,
                allList : [
                    {name:"无印良品1"},
                    {name:"无印良品2"},
                    {name:"无印良品3"},
                    {name:"无印良品4"},
                    {name:"无印良品5"}
                ],
                pageSize: item.data.pageSize,
                pageNumber:item.data.pageNumber
            };
            var returnValue = $scope.foregroundPaging(param);
            $scope.brandList=returnValue.result;
            $scope.brandOptions.totalCount = returnValue.totalCount;
            item.deferred.resolve({itemList:returnValue.result,totalCount:returnValue.totalCount});
        };
        $scope.selectBrand = function(brand){
            $scope.vm.brandName = brand.name;
            $scope.vm.brandId = brand.id;
        };
        $scope.getList = function(){
            railwayService.findUserRoleList($scope.vm).success(function(data){
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                }else{
                    $scope.userRoleList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        };
        $scope.getList();

        $scope.doSearch = function(){
            $scope.vm.pageNumber = 1;
            $scope.getList();
        }
    };

    angular.module("xn.page", ["xn.directive.form"])
        .controller("UserRoleController",["$scope","$modal","$http","$interval","dialogService","RailwayService",UserRoleController])
        .controller("AssignRoleController",["$scope","$modal","$http","$interval","dialogService","RailwayService",AssignRoleController])
})();