main.js 68.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727
/** 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.factory('requestNotificationChannel', ['$rootScope', function($rootScope) {
    // 通知消息常量
    var _START_REQUEST_ = '_START_REQUEST_'; // 开始请求通知message
    var _END_REQUEST_ = '_END_REQUEST_'; // 请求结束通知message

    // 计数器
    var activeCalls = 0;

    // 发布开始请求通知
    var requestStarted = function() {
        activeCalls += 1;
        console.log("activeCalls=" + activeCalls);
        $rootScope.$broadcast(_START_REQUEST_);
    };
    // 发布请求结束通知
    var requestEnded = function() {
        activeCalls -= 1;
        console.log("activeCalls=" + activeCalls);
        $rootScope.$broadcast(_END_REQUEST_);
    };

    /**
     * 订阅开始请求通知。
     * @param $scope 作用域
     * @param handler 通知处理器函数
     */
    var onRequestStarted = function($scope, handler) {
        $scope.$on(_START_REQUEST_, function(event) {
            handler();
        });
    };
    /**
     * 订阅请求结束通知。
     * @param $scope 作用域
     * @param handler 通知处理器函数
     */
    var onRequestEnded = function($scope, handler) {
        $scope.$on(_END_REQUEST_, function(event) {
            handler();
        });
    };

    return {
        requestStarted : requestStarted,
        requestEnded : requestEnded,
        onRequestStarted : onRequestStarted,
        onRequestEnded : onRequestEnded
    };

}]);

// http 拦截器
ScheduleApp.factory('myInterceptor', ['requestNotificationChannel', function(requestNotificationChannel) {
    return {
        request: function(config) {
            requestNotificationChannel.requestStarted();
            return config;
        },
        requestError: function(rejection) {
            requestNotificationChannel.requestEnded();
            return rejection;
        },
        response: function(response) {
            requestNotificationChannel.requestEnded();
            return response;
        },
        responseError: function(rejection) {
            requestNotificationChannel.requestEnded();
            return rejection;
        }
    };

}]);

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

/** 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'
                },
                "busInfoManage_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: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js",
                            "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("busInfoManage_form", {
            url: '/busInfoManage_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busInfoManage_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("busInfoManage_edit", {
            url: '/busInfoManage_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busInfoManage_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/basicInfo/busInfoManage/busInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("busInfoManage_detail", {
            url: '/busInfoManage_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/busInfoManage/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busInfoManage_detail_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'
                },
                "employeeInfoManage_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: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js",
                            "pages/scheduleApp/module/basicInfo/employeeInfoManage/employeeInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("employeeInfoManage_form", {
            url: '/employeeInfoManage_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/employeeInfoManage/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeInfoManage_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/basicInfo/employeeInfoManage/employeeInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("employeeInfoManage_edit", {
            url: '/employeeInfoManage_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/employeeInfoManage/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeInfoManage_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/basicInfo/employeeInfoManage/employeeInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("employeeInfoManage_detail", {
            url: '/employeeInfoManage_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/employeeInfoManage/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeInfoManage_detail_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'
                },
                "deviceInfoManage_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("deviceInfoManage_form", {
            url: '/deviceInfoManage_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/deviceInfoManage/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'deviceInfoManage_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/basicInfo/deviceInfoManage/deviceInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("deviceInfoManage_edit", {
            url: '/deviceInfoManage_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/deviceInfoManage/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'deviceInfoManage_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/basicInfo/deviceInfoManage/deviceInfoManage.js"
                        ]
                    });
                }]
            }
        })
        .state("deviceInfoManage_detail", {
            url: '/deviceInfoManage_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/basicInfo/deviceInfoManage/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'deviceInfoManage_detail_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'
                },
                "busConfig_list@busConfig": {
                    templateUrl: 'pages/scheduleApp/module/core/busConfig/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busConfig_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js",
                            "pages/scheduleApp/module/core/busConfig/busConfig.js"
                        ]
                    });
                }]
            }
        })
        .state("busConfig_form", {
            url: '/busConfig_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/busConfig/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busConfig_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/busConfig/busConfig.js"
                        ]
                    });
                }]
            }
        })
        .state("busConfig_edit", {
            url: '/busConfig_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/busConfig/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busConfig_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/busConfig/busConfig.js"
                        ]
                    });
                }]
            }
        })
        .state("busConfig_detail", {
            url: '/busConfig_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/busConfig/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'busConfig_detail_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/busConfig/busConfig.js"
                        ]
                    });
                }]
            }
        })

        // 人员配置模块
        .state("employeeConfig", {
            url: '/employeeConfig',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/employeeConfig/index.html'
                },
                "employeeConfig_list@employeeConfig": {
                    templateUrl: 'pages/scheduleApp/module/core/employeeConfig/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeConfig_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js",
                            "pages/scheduleApp/module/core/employeeConfig/employeeConfig.js"
                        ]
                    });
                }]
            }
        })
        .state("employeeConfig_form", {
            url: '/employeeConfig_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/employeeConfig/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeConfig_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/employeeConfig/employeeConfig.js"
                        ]
                    });
                }]
            }
        })
        .state("employeeConfig_edit", {
            url: '/employeeConfig_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/employeeConfig/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeConfig_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/employeeConfig/employeeConfig.js"
                        ]
                    });
                }]
            }
        })
        .state("employeeConfig_detail", {
            url: '/employeeConfig_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/employeeConfig/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'employeeConfig_detail_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/employeeConfig/employeeConfig.js"
                        ]
                    });
                }]
            }
        })

        // 路牌管理
        .state("guideboardManage", {
            url: '/guideboardManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/guideboardManage/index.html'
                },
                "guideboardManage_list@guideboardManage": {
                    templateUrl: 'pages/scheduleApp/module/core/guideboardManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'guideboardManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js",
                            "pages/scheduleApp/module/core/guideboardManage/guideboardManage.js"
                        ]
                    });
                }]
            }
        })
        .state("guideboardManage_detail", {
            url: '/guideboardManage_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/guideboardManage/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'guideboardManage_detail_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/guideboardManage/guideboardManage.js"
                        ]
                    });
                }]
            }
        })


        // 时刻表管理
        .state("timeTableManage", {
            url: '/timeTableManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/timeTableManage/index.html'
                },
                "timeTableManage_list@timeTableManage": {
                    templateUrl: 'pages/scheduleApp/module/core/timeTableManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'timeTableManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js",
                            "pages/scheduleApp/module/core/timeTableManage/timeTableManage.js"
                        ]
                    });
                }]
            }
        })
        .state("timeTableManage_form", {
            url: '/timeTableManage_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/timeTableManage/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'timeTableManage_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/timeTableManage/timeTableManage.js"
                        ]
                    });
                }]
            }
        })
        .state("timeTableManage_edit", {
            url: '/timeTableManage_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/timeTableManage/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'timeTableManage_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/timeTableManage/timeTableManage.js"
                        ]
                    });
                }]
            }
        })
        .state("timeTableManage_detail", {
            url: '/timeTableManage_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/timeTableManage/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'timeTableManage_detail_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/timeTableManage/timeTableManage.js"
                        ]
                    });
                }]
            }
        })
        .state("timeTableDetailInfoManage", {
            url: '/timeTableDetailInfoManage/:xlid/:ttid',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/timeTableManage/detail_info.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'timeTableDetailInfoManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/timeTableManage/timeTableDetailManage.js"
                        ]
                    });
                }]
            }
        })

        // 排班规则管理模块
        .state("scheduleRuleManage", {
            url: '/scheduleRuleManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/scheduleRuleManage/index.html'
                },
                "scheduleRuleManage_list@scheduleRuleManage": {
                    templateUrl: 'pages/scheduleApp/module/core/scheduleRuleManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'scheduleRuleManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/scheduleRuleManage/scheduleRuleManage.js"
                        ]
                    });
                }]
            }
        })
        .state("scheduleRuleManage_form", {
            url: '/scheduleRuleManage_form',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/scheduleRuleManage/form.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'scheduleRuleManage_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/scheduleRuleManage/scheduleRuleManage.js"
                        ]
                    });
                }]
            }
        })
        .state("scheduleRuleManage_edit", {
            url: '/scheduleRuleManage_edit/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/scheduleRuleManage/edit.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'scheduleRuleManage_edit_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/scheduleRuleManage/scheduleRuleManage.js"
                        ]
                    });
                }]
            }
        })
        .state("scheduleRuleManage_detail", {
            url: '/scheduleRuleManage_detail/:id',
            views: {
                "": {templateUrl: 'pages/scheduleApp/module/core/scheduleRuleManage/detail.html'}
            },
            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'scheduleRuleManage_detail_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "pages/scheduleApp/module/core/scheduleRuleManage/scheduleRuleManage.js"
                        ]
                    });
                }]
            }
        })

        // 排班计划管理模块
        .state("schedulePlanManage", {
            url: '/schedulePlanManage',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/schedulePlanManage/index.html'
                },
                "schedulePlanManage_list@schedulePlanManage": {
                    templateUrl: 'pages/scheduleApp/module/core/schedulePlanManage/list.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'schedulePlanManage_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/schedulePlanManage/schedulePlanManage.js"
                        ]
                    });
                }]
            }
        })
        .state("schedulePlanManage_form", {
            url: '/schedulePlanManage_form',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/schedulePlanManage/form.html'
                }
            },

            resolve: {
                deps: ['$ocLazyLoad', function($ocLazyLoad) {
                    return $ocLazyLoad.load({
                        name: 'schedulePlanManage_form_module',
                        insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置
                        files: [
                            "assets/bower_components/angular-ui-select/dist/select.min.css",
                            "assets/bower_components/angular-ui-select/dist/select.min.js",
                            "pages/scheduleApp/module/core/schedulePlanManage/schedulePlanManage.js"
                        ]
                    });
                }]
            }
        })

        // 排班计划明细管理模块
        .state("schedulePlanInfoManage", {
            url: '/schedulePlanInfoManage/:spid/:xlname/:ttname/:stime/:etime',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/schedulePlanManage/index_info.html'
                },
                "schedulePlanInfoManage_list@schedulePlanInfoManage": {
                    templateUrl: 'pages/scheduleApp/module/core/schedulePlanManage/list_info.html'
                }
            },

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

        // 线路运营概览模块
        .state("busLineInfoStat", {
            url: '/busLineInfoStat',
            views: {
                "": {
                    templateUrl: 'pages/scheduleApp/module/core/busLineInfoStat/index.html'
                },
                "busLineInfoStat_list@busLineInfoStat": {
                    templateUrl: 'pages/scheduleApp/module/core/busLineInfoStat/list.html'
                }
            },

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





        // TODO:

        ;
}]);

// 自定义的一些指令



// 全局service放置在此处,
// 一般这种服务会被其他模块调用的,所以干脆放到main.js里

// 车辆信息service
angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', function($resource) {
    return {
        rest: $resource(
            '/cars/:id',
            {order: 'carCode', direction: 'ASC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        ),
        validate: $resource(
            '/cars/validate/:type',
            {},
            {
                insideCode: {
                    method: 'GET'
                }
            }
        )
    };
}]);
// 人员信息service
angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) {
    return {
        rest : $resource(
            '/personnel/:id',
            {order: 'jobCode', direction: 'ASC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        ),
        validate: $resource(
            '/personnel/validate/:type',
            {},
            {
                jobCode: {
                    method: 'GET'
                }
            }
        )
    };
}]);
// 车辆设备信息service
angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) {
    return $resource(
        '/carDevice/:id',
        {order: 'createDate', direction: 'DESC', id: '@id_route'},
        {
            list: {
                method: 'GET',
                params: {
                    page: 0
                }
            },
            get: {
                method: 'GET'
            },
            save: {
                method: 'POST'
            }
        }
    );
}]);

// 车辆配置service
angular.module('ScheduleApp').factory('BusConfigService_g', ['$resource', function($resource) {
    return {
        rest : $resource(
            '/cci/:id',
            {order: 'createDate', direction: 'ASC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        )
    };
}]);

// 人员配置service
angular.module('ScheduleApp').factory('EmployeeConfigService_g', ['$resource', function($resource) {
    return {
        rest : $resource(
            '/eci/:id',
            {order: 'createDate', direction: 'ASC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        ),
        validate: $resource( // TODO:
            '/personnel/validate/:type',
            {},
            {
                jobCode: {
                    method: 'GET'
                }
            }
        )
    };
}]);

// 路牌管理service
angular.module('ScheduleApp').factory('GuideboardManageService_g', ['$resource', function($resource) {
    return {
        rest: $resource(
            '/gic/:id',
            {order: 'createDate', direction: 'DESC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        )
    };
}]);

// 排班管理service
angular.module('ScheduleApp').factory('ScheduleRuleManageService_g', ['$resource', function($resource) {
    return {
        rest: $resource(
            '/sr1fc/:id',
            {order: 'createDate', direction: 'DESC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        )
    };
}]);

// 时刻表管理service
angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', function($resource) {
    return {
        rest: $resource(
            '/tic/:id',
            {order: 'createDate', direction: 'DESC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        )
    };
}]);
// 时刻表明细管理service
angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resource', function($resource) {
    return {
        rest: $resource(
            '/tidc/:id',
            {order: 'createDate', direction: 'DESC', id: '@id_route'},
            {
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        ),
        edit: $resource(
            '/tidc/edit/:xlid/:ttid',
            {},
            {
                list: {
                    method: 'GET'
                }
            }
        )
    };
}]);



// 排班计划管理service
angular.module('ScheduleApp').factory('SchedulePlanManageService_g', ['$resource', function($resource) {
    return {
        rest : $resource(
            '/spc/:id',
            {order: 'createDate', direction: 'DESC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        )
    };
}]);

// 排班计划明细管理service
angular.module('ScheduleApp').factory('SchedulePlanInfoManageService_g', ['$resource', function($resource) {
    return {
        rest : $resource(
            '/spic/:id',
            {order: 'scheduleDate,lp,fcno', direction: 'ASC', id: '@id_route'},
            {
                list: {
                    method: 'GET',
                    params: {
                        page: 0
                    }
                },
                get: {
                    method: 'GET'
                },
                save: {
                    method: 'POST'
                }
            }
        )
    };
}]);

// 线路运营统计service
angular.module('ScheduleApp').factory('BusLineInfoStatService_g', ['$resource', function($resource) {
    return $resource(
        '/bic/:id',
        {order: 'createDate', direction: 'DESC', id: '@id_route'}, // TODO:以后需要根据属性对象的属性查询
        {
            list: {
                method: 'GET',
                params: {
                    page: 0
                }
            }
        }
    );
}]);

//--------------------------- 通用filter和directive -----------------------------//
angular.module('ScheduleApp').filter("dict", [function() {
    /**
     * 字典过滤器,将后台的字典编码转换成文字说明。
     * code,过滤的值,group,过滤的参数(字典group类型),dv没有匹配到的默认值
     * 用例:sfdc | dict:'dctype'
     */
    return function(code, group, dv) {
        if (code == null) {
            return dv;
        } else {
            return dictionaryUtils.transformCode(group, code);
        }
    };
}]);

angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) {
    return {
        restrict: 'E',
        templateUrl: '/pages/scheduleApp/module/other/MyDictionarySelectTemplate.html',
        scope: {
            model: "="
        },
        controllerAs: "$saSelectCtrl",
        bindToController: true,
        controller: function() {
            var self = this;
            self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}}
        },
        /**
         * 此阶段可以改dom结构,此时angular还没扫描指令,
         * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
         * @param tElem
         * @param tAttrs
         * @returns {{pre: Function, post: Function}}
         */
        compile: function(tElem, tAttrs) {
            // 确定是否使用angularjs required验证
            // 属性 required
            // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加
            var required_attr = tAttrs["required"];
            if (required_attr) {
                if (required_attr == "true") {
                    // 添加required属性指令
                    tElem.find("ui-select").attr("required", "");
                } else {
                    // 不等于true,不添加required属性指令
                }
            } else {
                // 不添加required属性指令
            }

            //console.log("saSelect" + ":compile = >" + tElem.html());

            return {
                pre: function(scope, element, attr) {
                    // TODO:
                },
                /**
                 * 相当于link函数。
                 *
                 * 重要属性如下:
                 * model 是绑定外部值。
                 * dicgroup 字典组的类型
                 * name input name属性值
                 */
                post: function(scope, element, attr) {
                    // 1、获取属性
                    var dicgroup_attr = attr['dicgroup']; // 字典组的类型
                    var name_attr = attr['name']; // input name属性值
                    var dicname_attr = attr['dicname']; // model关联的字典名字段
                    var codename_attr = attr['codename']; // model关联的字典值字段
                    var placeholder_attr = attr['placeholder']; // select placeholder提示

                    // 系统的字典对象,使用dictionaryUtils类获取
                    var origin_dicgroup;
                    var dic_key; // 字典key

                    if (dicgroup_attr) { // 赋值指定的字典数据
                        origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr);
                        for (dic_key in origin_dicgroup) {
                            var data = {}; // 重新组合的字典元素对象
                            if (dic_key == "true")
                                data.code = true;
                            else
                                data.code = dic_key;
                            data.name = origin_dicgroup[dic_key];
                            scope["$saSelectCtrl"].datas.push(data);
                        }
                    }

                    if (name_attr) {
                        scope["$saSelectCtrl"].nv = name_attr;
                    }
                    if (placeholder_attr) {
                        scope["$saSelectCtrl"].ph = placeholder_attr;
                    }

                    scope["$saSelectCtrl"].select = function($item) {
                        if (codename_attr) {
                            scope["$saSelectCtrl"].model[codename_attr] = $item.code;
                        }
                        if (dicname_attr) {
                            scope["$saSelectCtrl"].model[dicname_attr] = $item.name;
                        }
                    };

                    scope["$saSelectCtrl"].remove = function() {
                        if (codename_attr) {
                            scope["$saSelectCtrl"].model[codename_attr] = null;
                        }
                        if (dicname_attr) {
                            scope["$saSelectCtrl"].model[dicname_attr] = null;
                        }
                        scope["$saSelectCtrl"].cmodel = null;
                    };

                    $timeout(function() {
                        // 创建内部使用的绑定对象
                        var model_code = scope["$saSelectCtrl"].model[codename_attr];
                        scope["$saSelectCtrl"].cmodel = model_code;
                    }, 0);
                }
            }
        }
    };
}]);

angular.module('ScheduleApp').directive("saRadiogroup", [function() {
    /**
     * 使用字典数据的单选按钮组的指令。
     * 指令名称:truefalse-Dic
     */
    return {
        restrict: 'E',
        templateUrl: '/pages/scheduleApp/module/other/MyDictionaryRadioGroupTemplate.html',
        scope: {
            model: "="
        },
        controllerAs: "ctrl",
        bindToController: true,
        controller: function($scope) {
            //$scope["model"] = {selectedOption: null};
            //console.log("controller");
            //console.log("controller:" + $scope["model"]);
        },
        /**
         * 重要属性如下:
         * model 是绑定外部值。
         * disabled 说明是否不能修改
         * dicgroup 字典组的类型
         * name input name属性值
         */
        link: function(scope, element, attr) {
            //console.log("link");
            //console.log("link:" + scope.model);
            //scope["model"] = {selectedOption: null};

            if (attr["name"]) {
                scope["ctrl"].nv = attr["name"];
            }

            if (attr["disabled"]) {
                scope["ctrl"].disabled = true;
            }
            if (attr["dicgroup"]) {
                var obj = dictionaryUtils.getByGroup(attr['dicgroup']);
                scope["ctrl"].dic = obj;
                // 处理 scope["dic"] key值
                scope["ctrl"].dicvalueCalcu = function(value) {
                    if (value == "true") {
                        //console.log(value);
                        return true;
                    } else if (value == "false") {
                        //console.log(value);
                        return false;
                    } else {
                        return value;
                    }
                };
            }
        }
    };
}]);

angular.module('ScheduleApp').directive("remoteValidaton", [
        'BusInfoManageService_g',
        'EmployeeInfoManageService_g',
        function(
            busInfoManageService_g,
            employeeInfoManageService_g
        ) {
    /**
     * 远端验证指令,依赖于ngModel
     * 指令名称 remote-Validation
     * 需要属性 rvtype 表示验证类型
     */
    return {
        restrict: "A",
        require: "^ngModel",
        link: function(scope, element, attr, ngModelCtrl) {
            element.bind("keyup", function() {
                var modelValue = ngModelCtrl.$modelValue;
                var rv1_attr = attr["rv1"];
                if (attr["rvtype"]) {

                    // 根据rvtype的值,确定使用那个远端验证的url,
                    // rv1, rv2, rv3是关联比较值,暂时使用rv1
                    // 这个貌似没法通用,根据业务变换
                    // TODO:暂时有点乱以后改
                    if (attr["rvtype"] == "insideCode") {
                        busInfoManageService_g.validate.insideCode(
                            {"insideCode_eq": modelValue, type: "equale"},
                            function(result) {
                                //console.log(result);
                                if (result.status == "SUCCESS") {
                                    ngModelCtrl.$setValidity('remote', true);
                                } else {
                                    ngModelCtrl.$setValidity('remote', false);
                                }
                            },
                            function(result) {
                                //console.log(result);
                                ngModelCtrl.$setValidity('remote', true);
                            }
                        );
                    } else if (attr["rvtype"] == "jobCode") {
                        if (!rv1_attr) {
                            ngModelCtrl.$setValidity('remote', false);
                            return;
                        }

                        employeeInfoManageService_g.validate.jobCode(
                            {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},
                            function(result) {
                                //console.log(result);
                                if (result.status == "SUCCESS") {
                                    ngModelCtrl.$setValidity('remote', true);
                                } else {
                                    ngModelCtrl.$setValidity('remote', false);
                                }
                            },
                            function(result) {
                                //console.log(result);
                                ngModelCtrl.$setValidity('remote', true);
                            }
                        );
                    }
                } else {
                    // 没有rvtype,就不用远端验证了
                    ngModelCtrl.$setValidity('remote', true);
                }

                attr.$observe("rv1", function(value) {
                    if (attr["rvtype"] == "jobCode") {
                        if (!value) {
                            ngModelCtrl.$setValidity('remote', false);
                            return;
                        }

                        employeeInfoManageService_g.validate.jobCode(
                            {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},
                            function(result) {
                                //console.log(result);
                                if (result.status == "SUCCESS") {
                                    ngModelCtrl.$setValidity('remote', true);
                                } else {
                                    ngModelCtrl.$setValidity('remote', false);
                                }
                            },
                            function(result) {
                                //console.log(result);
                                ngModelCtrl.$setValidity('remote', true);
                            }
                        );
                    }

                });
            });
        }
    };
}]);


/**
 * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。
 * 1、compile阶段使用的属性如下:
 *      required:用于和表单验证连接,指定成required="true"才有效。
 * 2、link阶段使用的属性如下
 *      model:关联的模型对象
 *      name:表单验证时需要的名字
 *      type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
 *      modelcolname1:关联的模型字段名字1(一般应该是编码字段)
 *      modelcolname2:关联的模型字段名字2(一般应该是名字字段)
 *      datacolname1;内部数据对应的字段名字1(与模型字段1对应)
 *      datacolname2:内部数据对应的字段名字2(与模型字段2对应)
 *      showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用
 *      placeholder:select placeholder字符串描述
 *
 * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。
 * $$SearchInfoService_g,内部使用的数据服务
 */
// saSelect2指令使用的内部信service
angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {
    return {
        xl: $resource(
            '/line/:type',
            {order: 'name', direction: 'ASC'},
            {
                list: {
                    method: 'GET',
                    isArray: true
                }
            }
        ),
        ry: $resource(
            '/personnel/:type',
            {order: 'personnelName', direction: 'ASC'},
            {
                list: {
                    method: 'GET',
                    isArray: true
                }
            }
        ),
        cl: $resource(
            '/cars/:type',
            {order: "insideCode", direction: 'ASC'},
            {
                list: {
                    method: 'GET',
                    isArray: true
                }
            }
        ),
        ttInfo: $resource(
            '/tic/:type',
            {order: "name", direction: 'ASC'},
            {
                list: {
                    method: 'GET',
                    isArray: true
                }
            }
        ),
        ccl: $resource(
            '/cci/cars',
            {},
            {
                list: {
                    method: 'GET',
                    isArray: true
                }
            }

        )
    }
}]);
angular.module('ScheduleApp').filter("$$pyFilter", function() {
    return function(items, props) {
        var out = [];
        var limit = props["limit"] || 20; // 默认20条记录

        if (angular.isArray(items)) {
            items.forEach(function(item) {
                if (out.length < limit) {
                    if (props.search) {
                        var upTerm = props.search.toUpperCase();
                        if(item.fullChars.indexOf(upTerm) != -1
                            || item.camelChars.indexOf(upTerm) != -1) {
                            out.push(item);
                        }
                    }
                }
            });
        }

        return out;
    };
});
angular.module('ScheduleApp').directive("saSelect2", [
        '$timeout', '$$SearchInfoService_g',
        function($timeout, $$searchInfoService_g) {
    return {
        restrict: 'E',
        templateUrl: '/pages/scheduleApp/module/other/MySearchSelectTemplate.html',
        scope: {
            model: "=" // 独立作用域,关联外部的模型对象
        },
        controllerAs: "$saSelectCtrl",
        bindToController: true,
        controller: function($scope) {
            var self = this;
            self.$$data = []; // 内部关联的数据
        },
        /**
         * 此阶段可以改dom结构,此时angular还没扫描指令,
         * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
         * @param tElem
         * @param tAttrs
         * @returns {{pre: Function, post: Function}}
         */
        compile: function(tElem, tAttrs) {
            // 1、获取此阶段使用的属性
            var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。

            // 2、处理属性

            // 确定是否使用angularjs required验证
            // 属性 required
            // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加
            if ($required_attr) {
                if ($required_attr == "true") {
                    // 添加required属性指令
                    tElem.find("ui-select").attr("required", "");
                } else {
                    // 不等于true,不添加required属性指令
                }
            } else {
                // 不添加required属性指令
            }

            //console.log("saSelect" + ":compile = >" + tElem.html());

            return {
                pre: function(scope, element, attr) {
                    // TODO:
                },
                /**
                 * 相当于link函数。
                 *
                 * 重要属性如下:
                 * model 是绑定外部值。
                 * dicgroup 字典组的类型
                 * name input name属性值
                 */
                post: function(scope, element, attr) {
                    // 1、获取此阶段使用的属性
                    var $name_attr = attr["name"]; // 表单验证时需要的名字
                    var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
                    var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段)
                    var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段)
                    var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应)
                    var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应)
                    var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名
                    var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述

                    // 2、处理属性、转换成$saSelectCtrl内部使用的属性
                    if ($name_attr) {
                        scope["$saSelectCtrl"].$name_attr = $name_attr;
                    }
                    if ($placeholder_attr) {
                        scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr;
                    }
                    if ($showcolname_attr) {
                        scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr;
                    }

                    // 2-1、添加内部方法,根据type值,改变$$data的值
                    scope["$saSelectCtrl"].$$internal_data_change_fn = function() {
                        // 根据type属性动态载入数据
                        if ($type_attr) {
                            $$searchInfoService_g[$type_attr].list(
                                {type: "all"},
                                function(result) {
                                    scope["$saSelectCtrl"].$$data = [];
                                    for (var i = 0; i < result.length; i ++) {
                                        var data = {}; // data是result的一部分属性集合,根据配置来确定
                                        if ($datacolname1_attr) {
                                            data[$datacolname1_attr] = result[i][$datacolname1_attr];
                                        }
                                        if ($datacolname2_attr) {
                                            data[$datacolname2_attr] = result[i][$datacolname2_attr];
                                        }
                                        if ($showcolname_attr) {
                                            // 动态添加基于名字的拼音
                                            data[$showcolname_attr] = result[i][$showcolname_attr];
                                            if (data[$showcolname_attr]) {
                                                data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼
                                                data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼
                                            }
                                        }
                                        if (data["fullChars"])
                                            scope["$saSelectCtrl"].$$data.push(data);
                                    }
                                },
                                function(result) {

                                }
                            );
                        }
                    };

                    // 3、选择、删除事件映射模型和内部数据对应的字段
                    scope["$saSelectCtrl"].$select_fn_attr = function($item) {
                        if ($modelcolname1_attr && $datacolname1_attr) {
                            scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr];
                        }
                        if ($modelcolname2_attr && $datacolname2_attr) {
                            scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr];
                        }
                    };
                    scope["$saSelectCtrl"].$remove_fn_attr = function() {
                        if ($modelcolname1_attr) {
                            scope["$saSelectCtrl"].model[$modelcolname1_attr] = null;
                        }
                        if ($modelcolname2_attr) {
                            scope["$saSelectCtrl"].model[$modelcolname2_attr] = null;
                        }
                        scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空

                        scope["$saSelectCtrl"].$$internal_data_change_fn();
                    };

                    // 4、搜索事件
                    scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) {
                        //var fullChars = pinyin.getFullChars($search).toUpperCase();
                        //var camelChars = pinyin.getCamelChars($search);
                        //
                        //console.log(fullChars + " " + camelChars);
                        // TODO:事件暂时没用,放着以后再说
                    };

                    // 5、全部载入后,输入的
                    $timeout(function() {
                        // 创建内部使用的绑定对象,用于确认选中那个值
                        scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr];

                        scope["$saSelectCtrl"].$$internal_data_change_fn();
                    }, 0);
                }
            }
        }
    };
}]);