123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- var app = angular.module("scoreApp", []);
- app.config(function($httpProvider) {
- $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
- $httpProvider.defaults.headers.post['Accept'] = 'application/json, text/javascript, */*; q=0.01';
- $httpProvider.defaults.headers.post['X-Requested-With'] = 'XMLHttpRequest';
- $httpProvider.defaults.transformRequest = [ function(data) {
- var param = function(obj) {
- var query = '';
- var name, value, fullSubName, subName, subValue, innerObj, i;
- for (name in obj) {
- value = obj[name];
- if (value instanceof Array) {
- for (i = 0; i < value.length; ++i) {
- subValue = value[i];
- fullSubName = name + '[]';
- innerObj = {};
- innerObj[fullSubName] = subValue;
- query += param(innerObj) + '&';
- }
- // console.log(query);
- } else if (value instanceof Date) {
- query += encodeURIComponent(name) + '=' + encodeURIComponent(value.toJSON()) + '&';
- } else if (value instanceof Object) {
- for (subName in value) {
- subValue = $.trim(value[subName]);
- fullSubName = name + '[' + subName + ']';
- innerObj = {};
- innerObj[fullSubName] = subValue;
- query += param(innerObj) + '&';
- }
- } else if (value !== undefined && value !== null) {
- query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
- }
- }
- // console.log(query);
- return query.length ? query.substr(0, query.length - 1) : query;
- };
- return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
- } ];
- });
- app.controller('scoreController', ['$scope','$http','$rootScope',function($scope, $http,$rootScope) {
- $scope.flag = false;
- var array = new Array();
- for (var k = 0; k < 9; k++){
- array.push({
- subject_id : k
- })
- }
-
- $scope.subjectArray = array;
- // $scope.cert_id = "";
- $scope.goSearch = function() {
- if ($scope.cert_id == undefined || $scope.std_name == undefined)
- return;
- $scope.map = undefined;
- $http({
- url : '../wish/std/searchNy.htm',
- method : 'post',
- data : {
- cert_id : $scope.cert_id,
- std_name : $scope.std_name,
- exam_id : $scope.exam_id
- }
- }).success(function(data) {
- if (data.success == false) {
- alert(data.errorMsg);
- $scope.flag = false;
- document.getElementById('cert_id').focus();
- return;
- }
- $scope.flag = true;
- $scope.map = data.map;
- if($scope.map == undefined) {
- $scope.admisFlag = 'noAdmis';
- } else {
- $scope.admisFlag = 'admis';
- }
- }).error(function(data) {
- $scope.flag = false;
- alert('网络错误,请重试');
- document.getElementById('cert_id').focus();
- });
- }
- $scope.changeStdName = function($event) {
- $scope.admisFlag = '';
- if ($event.keyCode == 13)
- $scope.goSearch();
- }
- $rootScope.openNewWindow = function(url) {
- window.open(url);
- };
- $scope.download = function(){
- $http({
- url : 'std/score/download.htm',
- method : 'post',
- data:{
- cert_id :$scope.cert_id
- }
- }).success(function(data) {
- $rootScope.openNewWindow('frame/file/download/template1.htm?file_name=/temp/' + data.entity);
- }).error(function(data) {
- alert('网络错误,请重试');
- });
- }
- }]);
|