demo.js 2.88 KB

(function () {
    "user strict";

    var demoController = function($scope,$modal,$http,dialogService,railwayService){
        $scope.$emit('navShow', 5);
        $scope.vm = {
            pageSize : 10,
            pageNumber : 1,
            totalCount : 0,
            type : "PARTNER"
        }
        $scope.getList = function(){
            PartnerService.findTag($scope.vm).success(function(data){
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                }else{
                    $scope.tagList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        }
        $scope.getList();
        $scope.doAddTag = function(){
            var vm = {};
            var modalInstance = $modal.open({
                templateUrl: "create.html",
                controller:createTagController,
                size:"md",
                resolve: {
                    items: function () {
                        return vm;
                    }
                }
            });
            modalInstance.result.then(function () {
                $scope.getList();
            });
        }
        $scope.doEdit = function (id) {
            var vm = {
                id:id
            };
            var modalInstance = $modal.open({
                templateUrl: "create.html",
                controller:editTagController,
                size:"md",
                resolve: {
                    items: function () {
                        return vm;
                    }
                }
            });
            modalInstance.result.then(function () {
                $scope.getList();
            });
        }
        $scope.doSearch = function(){
            $scope.vm.pageNumber = 1;
            $scope.getList();
        }
        $scope.doDelete = function(id){
            var dialogDefaults = {
                size: "sm"
            };
            var dialogOptions = {
                closeButtonText: "取消",
                actionButtonText: "确定",
                headerText: "提示",
                bodyText: "确认删除吗",
                callback: function () {
                    PartnerService.deleteTag({id:id}).success(function(data){
                        if (data.errors == null || data.errors.length > 0) {
                            dialogService.tip(data.errors);
                        }else{
                            dialogService.tip([{"message": "删除成功!" }]);
                            $scope.getList();
                        }
                    })
                }
            };
            dialogService.confirm(dialogDefaults, dialogOptions);
        }
    }

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