tab_index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. (function ($app) {
  2. 'use strict';
  3. $app.module('ylmis').controller('tabsIndexCtrl', function ($scope, $state, $filter, $alert, AuthUser, $http, $ocLazyLoad, $bsRouterState) {
  4. $scope.tabs=[{
  5. "title": "首页11",
  6. name:"mainindex",
  7. templateUrl:"home/mainindex.html",
  8. controller: "mainindexCtrl",
  9. resolve: {
  10. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  11. return $ocLazyLoad.load('home/mainindex.js?' + window.sysVersion);
  12. }]
  13. }
  14. },
  15. {
  16. "title": "党建",
  17. name:"partyList",
  18. templateUrl:"party/list.html",
  19. controller: "partyListCtrl",
  20. resolve: {
  21. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  22. return $ocLazyLoad.load('party/list.js?' + window.sysVersion);
  23. }]
  24. }
  25. }
  26. ];
  27. $scope.tabs.activeTab = "mainindex";
  28. $bsRouterState.getTest();
  29. $scope.tabClear=function(tabPane) {
  30. //var i=$scope.tabs.indexOf(tabPane.panedata);
  31. var i=$scope.tabs.indexOf(tabPane.panedata);
  32. //$scope.tabs.splice(i,1);
  33. };
  34. $scope.tabClear1=function(tabPane) {
  35. //var i=$scope.tabs.indexOf(tabPane.panedata);
  36. $scope.tabs.splice(1,1);
  37. };
  38. $scope.addTab=function () {
  39. $scope.tabs.push({
  40. name: "home.cgjqSetting_PostareaList",
  41. "title": "岗区配置",
  42. templateUrl: "cgjq/setting/postarea/list.html?" + window.sysVersion,
  43. controller: "cgjqSetting_PostareaListCtrl",
  44. resolve: {
  45. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  46. return $ocLazyLoad.load(['cgjq/setting/postarea/list.js?' + window.sysVersion]);
  47. }]
  48. }});
  49. $scope.tabs.activeTab=$scope.tabs[$scope.tabs.length-1].name;
  50. };
  51. }).directive('bsPaneUrl', function ($window, $animate, $sce,$bsCompiler) {
  52. return {
  53. require: ['^?ngModel', '^bsTabs'],
  54. scope: {panedata:'='},
  55. link: function postLink (scope, element, attrs, controllers) {
  56. //var ngModelCtrl = controllers[0];
  57. var bsTabsCtrl = controllers[1];
  58. //var bsTabsPanelScope=scope.$new();
  59. var $pane={};
  60. var paneOptions={};
  61. angular.extend(paneOptions,scope["panedata"]);
  62. var promise= $bsCompiler.compile(paneOptions);
  63. promise.then(function (data) {
  64. scope.$tabScope=scope.$new();
  65. var paneEl=data.link(scope.$tabScope);
  66. paneEl.appendTo(element);
  67. });
  68. // Add base class
  69. element.addClass('tab-pane');
  70. // Observe title attribute for change
  71. attrs.$observe('title', function (newValue, oldValue) {
  72. scope.title = $sce.trustAsHtml(newValue);
  73. });
  74. // Save tab name into scope
  75. scope.name = attrs.name;
  76. // Add animation class
  77. if (bsTabsCtrl.$options.animation) {
  78. element.addClass(bsTabsCtrl.$options.animation);
  79. }
  80. attrs.$observe('disabled', function (newValue, oldValue) {
  81. scope.disabled = scope.$eval(newValue);
  82. });
  83. // Push pane to parent bsTabs controller
  84. bsTabsCtrl.$push(scope);
  85. // remove pane from tab controller when pane is destroyed
  86. scope.$on('$destroy', function () {
  87. bsTabsCtrl.$remove(scope);
  88. });
  89. function render () {
  90. var index = bsTabsCtrl.$panes.indexOf(scope);
  91. if(index>=0){
  92. $animate[bsTabsCtrl.$isActive(scope, index) ? 'addClass' : 'removeClass'](element, bsTabsCtrl.$options.activeClass);
  93. }
  94. }
  95. bsTabsCtrl.$activePaneChangeListeners.push(function () {
  96. render();
  97. });
  98. render();
  99. }};
  100. });
  101. })(angular);