main.js 8.14 KB
/** shcedule 营运计划App module */

var ScheduleApp = angular.module('ScheduleApp', [
    'ui.router', // ui-route跳转
    'ui.bootstrap', // ui bootstrap封装
    'oc.lazyLoad', // 动态加载模块(html,js,css等)
    'ngSanitize', // 净化html标签,配合ng-bind-html使用
    'ngResource' // resource服务
]);

ScheduleApp.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
}]);

/** ocLazyLoader 配置 */
ScheduleApp.config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {
    $ocLazyLoadProvider.config({
        // TODO:全局配置在这里
    });
}]);

/** 配置全局配置信息 */
ScheduleApp.factory('settings', ['$rootScope', function($rootScope) {
    // 封装 settings服务,并设置给 $rootScope同名对象
    var settings = {
        // TODO:
    };

    $rootScope.settings = settings;

    return settings;
}]);

/** Schedule App 主应用控制器 */
ScheduleApp.controller('ScheduleAppController', ['$scope', function($scope) {
    $scope.$on('$viewContentLoaded', function(event) {
        console.log("子页面已载入:" + event);
    });
}]);

/** 配置所有模块页面route */
ScheduleApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    // 默认路由
    //$urlRouterProvider.otherwise('/busConfig.html');

    $stateProvider
        // 车辆基础信息模块配置
        .state("busInfoManage", {
            url: '/busInfoManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/index.html'
                },
                "list@busInfoManage": {
                    templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busInfoManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
                        ]
                    });
                }]
            }
        })
        //.state("busInfoManage.list", {
        //    url: 'list',
        //    templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/list.html',
        //    resolve: {
        //        deps: ['$ocLazyLoad', function($ocLazyLoad) {
        //            return $ocLazyLoad.load({
        //                name: 'busInfoManage_module',
        //                insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
        //                files: [
        //                    "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
        //                ]
        //            });
        //        }]
        //    }
        //})
        //.state("busInfoManage.form", {
        //    url: 'form',
        //    views: {
        //        "": {templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/form.html'}
        //    },
        //    resolve: {
        //        deps: ['$ocLazyLoad', function($ocLazyLoad) {
        //            return $ocLazyLoad.load({
        //                name: 'busInfoManage_module',
        //                insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
        //                files: [
        //                    "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
        //                ]
        //            });
        //        }]
        //    }
        //})
        //.state("busInfoManage.detail", {
        //    url: 'detail',
        //    views: {
        //        "": {templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/detail.html'}
        //    },
        //    resolve: {
        //        deps: ['$ocLazyLoad', function($ocLazyLoad) {
        //            return $ocLazyLoad.load({
        //                name: 'busInfoManage_module',
        //                insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
        //                files: [
        //                    "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
        //                ]
        //            });
        //        }]
        //    }
        //})

        // 人员基础信息模块配置
        .state("employeeInfoManage", {
            url: '/employeeInfoManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/basicInfo/employeeInfoManage/index.html'
                },
                "list@employeeInfoManage": {
                    templateUrl: 'pages/scheduleApp/module/basicInfo/employeeInfoManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeInfoManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/basicInfo/employeeInfoManage/employeeInfoManage.js"
                        ]
                    });
                }]
            }
        })

        // 车辆设备信息模块配置
        .state("deviceInfoManage", {
            url: '/deviceInfoManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/basicInfo/deviceInfoManage/index.html'
                },
                "list@deviceInfoManage": {
                    templateUrl: 'pages/scheduleApp/module/basicInfo/deviceInfoManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'deviceInfoManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/basicInfo/deviceInfoManage/deviceInfoManage.js"
                        ]
                    });
                }]
            }
        })

        // 车辆配置模块
        .state("busConfig", {
            url: '/busConfig',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/busConfig/index.html'
                },
                "list@busConfig": {
                    templateUrl: 'pages/scheduleApp/module/core/busConfig/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'deviceInfoManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/busConfig/busConfig.js"
                        ]
                    });
                }]
            }
        })
        // 路牌管理
        .state('guideboardManage', {
            url: '/guideboardManage.html',
            templateUrl: 'pages/scheduleApp/module/core/guideboardManage/guideboardManage2.html',
            data: {},
            controller: 'guideboardManageCtrl',
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'guideboardManage.html',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            'pages/scheduleApp/module/core/guideboardManage/service2.js',
                            'pages/scheduleApp/module/core/guideboardManage/controller2.js'
                        ]
                    });
                }]
            }
        });
}]);