admis.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. var app = angular.module("scoreApp", []);
  2. app.config(function($httpProvider) {
  3. $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
  4. $httpProvider.defaults.headers.post['Accept'] = 'application/json, text/javascript, */*; q=0.01';
  5. $httpProvider.defaults.headers.post['X-Requested-With'] = 'XMLHttpRequest';
  6. $httpProvider.defaults.transformRequest = [ function(data) {
  7. var param = function(obj) {
  8. var query = '';
  9. var name, value, fullSubName, subName, subValue, innerObj, i;
  10. for (name in obj) {
  11. value = obj[name];
  12. if (value instanceof Array) {
  13. for (i = 0; i < value.length; ++i) {
  14. subValue = value[i];
  15. fullSubName = name + '[]';
  16. innerObj = {};
  17. innerObj[fullSubName] = subValue;
  18. query += param(innerObj) + '&';
  19. }
  20. // console.log(query);
  21. } else if (value instanceof Date) {
  22. query += encodeURIComponent(name) + '=' + encodeURIComponent(value.toJSON()) + '&';
  23. } else if (value instanceof Object) {
  24. for (subName in value) {
  25. subValue = $.trim(value[subName]);
  26. fullSubName = name + '[' + subName + ']';
  27. innerObj = {};
  28. innerObj[fullSubName] = subValue;
  29. query += param(innerObj) + '&';
  30. }
  31. } else if (value !== undefined && value !== null) {
  32. query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
  33. }
  34. }
  35. // console.log(query);
  36. return query.length ? query.substr(0, query.length - 1) : query;
  37. };
  38. return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
  39. } ];
  40. });
  41. app.controller('scoreController', ['$scope','$http','$rootScope',function($scope, $http,$rootScope) {
  42. $scope.flag = false;
  43. var array = new Array();
  44. for (var k = 0; k < 9; k++){
  45. array.push({
  46. subject_id : k
  47. })
  48. }
  49. $scope.subjectArray = array;
  50. // $scope.cert_id = "";
  51. $scope.goSearch = function() {
  52. if ($scope.cert_id == undefined || $scope.std_name == undefined)
  53. return;
  54. $scope.map = undefined;
  55. $http({
  56. url : '../wish/std/searchNy.htm',
  57. method : 'post',
  58. data : {
  59. cert_id : $scope.cert_id,
  60. std_name : $scope.std_name,
  61. exam_id : $scope.exam_id
  62. }
  63. }).success(function(data) {
  64. if (data.success == false) {
  65. alert(data.errorMsg);
  66. $scope.flag = false;
  67. document.getElementById('cert_id').focus();
  68. return;
  69. }
  70. $scope.flag = true;
  71. $scope.map = data.map;
  72. if($scope.map == undefined) {
  73. $scope.admisFlag = 'noAdmis';
  74. } else {
  75. $scope.admisFlag = 'admis';
  76. }
  77. }).error(function(data) {
  78. $scope.flag = false;
  79. alert('网络错误,请重试');
  80. document.getElementById('cert_id').focus();
  81. });
  82. }
  83. $scope.changeStdName = function($event) {
  84. $scope.admisFlag = '';
  85. if ($event.keyCode == 13)
  86. $scope.goSearch();
  87. }
  88. $rootScope.openNewWindow = function(url) {
  89. window.open(url);
  90. };
  91. $scope.download = function(){
  92. $http({
  93. url : 'std/score/download.htm',
  94. method : 'post',
  95. data:{
  96. cert_id :$scope.cert_id
  97. }
  98. }).success(function(data) {
  99. $rootScope.openNewWindow('frame/file/download/template1.htm?file_name=/temp/' + data.entity);
  100. }).error(function(data) {
  101. alert('网络错误,请重试');
  102. });
  103. }
  104. }]);