admin_majorZhpj.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. app.controller('AdminMajorZhpjCtrl', function($rootScope, $scope, $http, $timeout, $state, $window, $q, toaster) {
  2. $scope.pageObj = {pageSize: 10, total: 1, page: 1, totalPage: 1, query: '',passed:'',province:''};
  3. $scope.goPage = function(page){
  4. if(page < 1){
  5. toaster.pop('error', '已是第一页');
  6. return;
  7. }else if(page > $scope.pageObj.totalPage){
  8. toaster.pop('error', '超过最大页码');
  9. return;
  10. }
  11. $scope.pageObj.page = page;
  12. var getCount = $http({
  13. url : $rootScope.host_url + '/adminOptr/majorZhpjCount?session=' + $rootScope.session,
  14. method : 'post',
  15. data : angular.toJson($scope.pageObj)
  16. }).success(function(data) {
  17. if(data.code == 0){
  18. $scope.pageObj.total = data.result.stdCount;
  19. $scope.pageObj.totalPage = Math.ceil(data.result.stdCount / $scope.pageObj.pageSize);
  20. $scope.pageObj.totalPage = $scope.pageObj.totalPage == 0 ? 1 : $scope.pageObj.totalPage;
  21. }
  22. }).error(function() {
  23. });
  24. var getData = $http({
  25. url : $rootScope.host_url + '/adminOptr/majorZhpj?session=' + $rootScope.session,
  26. method : 'post',
  27. data : angular.toJson($scope.pageObj)
  28. }).success(function(data) {
  29. if(data.code == 0){
  30. $scope.stds = data.result;
  31. }
  32. }).error(function() {
  33. });
  34. $scope.myPromise = $q.all([getData, getCount]);
  35. }
  36. $scope.load = function(){
  37. $scope.goPage(1);
  38. }
  39. $scope.load();
  40. $scope.showStdOverview = function(std_id){
  41. $state.go('stdInfo', {std_id: std_id});
  42. }
  43. $scope.exportToExcel = function(){
  44. $scope.myPromise = $http({
  45. url : $rootScope.host_url + '/adminOptr/majorZhpjExport?session=' + $rootScope.session,
  46. method : 'post'
  47. }).success(function(data) {
  48. if(data.code == 0){
  49. window.open($rootScope.host_url + data.message);
  50. }
  51. }).error(function() {
  52. });
  53. }
  54. });