12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- app.controller('UploadCtrl', [ '$rootScope', '$scope', '$stateParams', '$timeout', function($rootScope, $scope, $stateParams, $timeout) {
- if ($stateParams == undefined || $stateParams.enrol_id == undefined) {
- $.alert('参数错误,无法获取报考详细信息', function() {
- $rootScope.goWechat();
- });
- return;
- }
-
- $rootScope.ajaxRequest({
- url : '../enrol/log.htm',
- data : {
- logType:'WebPageUploadPhoto'
- }
- }, function(response) {
- });
-
-
- $scope.getEnrol = function() {
- $rootScope.ajaxRequest({
- url : '../enrol/std/enrol/find.htm',
- data : {
- enrol_id : $stateParams.enrol_id,
- aspect_batch : 1
- }
- }, function(response) {
- $scope.EnrolMap = response.map.StdEnrol;
- });
- }
- $scope.getEnrol();
-
- $scope.uploadFile = function(photo_type){
- var file = document.getElementById(photo_type).files[0];
- if(document.getElementById(photo_type).files==null||file==null){
- $.alert('请选择照片!');
- return;
- }
-
- var data = new FormData();
- data.append('file', file);
- data.append('enrol_id',$stateParams.enrol_id);
- data.append('photo_type',photo_type);
-
- $rootScope.ajaxRequest({
- url: '../enrol/exam/upload.htm',
- data:data,
- headers: {'Content-Type': undefined},
- transformRequest: angular.identity
- }, function(response) {
- if('photo_file'==photo_type){
- $scope.EnrolMap.photo_file=response.entity;
- console.log($scope.EnrolMap.photo_file);
- }else if('photo_file1'==photo_type){
- $scope.EnrolMap.photo_file1=response.entity;
- console.log($scope.EnrolMap.photo_file1);
- }else if('photo_file2'==photo_type){
- $scope.EnrolMap.photo_file2=response.entity;
- console.log($scope.EnrolMap.photo_file2);
- }
- });
- }
-
- $scope.uploadAllFile = function(){
-
- if((!$scope.EnrolMap.photo_file &&document.getElementById('photo_file').files.length==0)||(!$scope.EnrolMap.photo_file1&&document.getElementById('photo_file1').files.length==0)||(!$scope.EnrolMap.photo_file2&&document.getElementById('photo_file2').files.length==0)){
- $.alert('请同时选择三张照片后,再上传!!');
- return;
- }
-
- var file0=document.getElementById('photo_file').files[0];
- var file1=document.getElementById('photo_file1').files[0];
- var file2=document.getElementById('photo_file2').files[0];
- // if (file0.name==file1.name||file0.name==file2.name||file2.file==file1.name){
- //
- // $.alert('选择照片中存在相同的文件!');
- // return;
- // }
- if(!$scope.EnrolMap.photo_file)
- $scope.uploadFile('photo_file');
- if(!$scope.EnrolMap.photo_file1)
- $scope.uploadFile('photo_file1');
- if(!$scope.EnrolMap.photo_file2)
- $scope.uploadFile('photo_file2');
-
- }
- $scope.goBack = function(){
- $rootScope.goLocation('exam/voide/' + $stateParams.enrol_id +'/true');
- }
-
-
- } ])
|