angular.module("alController",["alSfdcService","alImageService"]).controller("TopCtrl",["$scope","$q","$location","$log","alAppConfig","alPhotos","sfdcService",function(a,b,c,d,e,f,g){a.working=!0,a.config=e,a.land={},a.typeSelecter={},a.initLnad=function(){a.land={name:new Date,status:null,address:"",latLng:{latitude:null,longitude:null},pid:"",photoType:""},a.type_selecter={ra_type:"",rp_type:"",ast_type:""}},a.initLnad(),a.config.longSidePixcel={!$Label.s1_longSidePixel},a.config.maxFileSize=7e5,a.config.jpegQuality={!$Label.s1_jpegQuality},a.loading=!1,a.working=!1}]).controller("LandCtrl",["$scope","$log","$q","$state","$stateParams",function(a,b,c,d,e){a.nameFilter=null,a.loading=!0,a.land.pid=e.pid;a.loading=!1,a.next=function(){a.type_selecter.ra_type||a.type_selecter.rp_type||a.type_selecter.ast_type?d.go("menu.send"):alert("请输入照片种类")}}]).controller("SendCtrl",["$scope","$log","$q","$location","alPhotos","alHistory","alModal","sfdcService","$stateParams",function(a,b,c,d,e,f,g,h,i){switch(a.editMode=!1,a.photos=e.all(),a.land.pid.substr(0,3)){case"a0t":a.land.photoType=a.type_selecter.ra_type;break;case"a0J":a.land.photoType=a.type_selecter.rp_type;break;case"02i":a.land.photoType=a.type_selecter.ast_type}angular.isUndefined(a.land.latLng)&&(a.land.latLng={});var j=function(){a.showOption=!1,a.status={title:"送信中",msg:"",finished:!1,success:!1,showLog:!1,logs:[],max:0,value:0}},k=function(d,e,f,g){var i=c.defer();return a.status.logs.push((new Date).toLocaleString()+": "+e.no+"枚目 写真登録開始"),h.createAttachment(d,e,f,g,function(c){a.status.logs.push((new Date).toLocaleString()+": "+e.no+"枚目 写真登録完了 ID="+c.id),a.$apply(),b.info(a.status.logs[a.status.logs.length-1]);var d={attachmentId:c.id};i.resolve(d)},function(c){a.status.logs.push((new Date).toLocaleString()+": "+e.no+"枚目 写真登録失敗"),a.status.logs.push("statusCode: "+c.statusCode+", type: "+c.type+", message: "+c.message),a.errMsg=c.message,a.$apply(),b.error(a.status.logs[a.status.logs.length-1]),i.reject()}),i.promise},l=function(b,c){b.name=a.land.name,b.location.lat=a.land.latLng.latitude,b.location.lng=a.land.latLng.longitude;var d=c[0],e=k(a.land.pid,d,a.land.photoType,a.land.name);e.then(function(c){b.attachmentIds.push(c.attachmentId),b.success=!0,a.status.msg="上传成功。",a.status.finished=!0,a.status.success=!0},function(c){b.success=!1,alert(c),a.status.msg="上传失败。",a.status.finished=!0,a.status.success=!1})},m=function(b){a.status.max=2+b.length,g.openProgress(a).then(function(b){a.status.success&&(e.clear(),a.initLnad(),d.path("/menu/land")),j()})};a.upload=function(){b.info("upload");var c=e.all();g.openConfirm(a,"confirmSend.html").then(function(){a.status.msg="正在上传...",m(c);var b=f.getTemplate(a.land.latLng);l(b,c)},function(){j()})},a.buttonOnLongPress=function(){1!=a.editMode&&(a.showOption=!0,a.status.showLog=!0)},a.buttonOnTouchEnd=function(){1!=a.editMode&&a.upload()},a.cancel=function(){d.path("/menu/land")},a.toggleEditMode=function(){a.editMode=!a.editMode},j()}]).controller("PhotosCtrl",["$scope","$log","$q","alPhotos","alModal",function(a,b,c,d,e){a.photos=d.all(),a.objs=null,a.disableInput=!1,a.removePhoto=function(b){a.photos.splice(b,1),0==a.photos.length&&a.toggleEditMode()},a.send=function(){$location.path("/menu/upload")};var f=function(a){return!!(a&&a instanceof File&&a.type.match("image.*"))},g=function(a){if(!a)return!1;if(a instanceof FileList)for(var b=0;b<a.length;b++){if(0==f(a[b]))return e.openWarning((b+1).toString()+"番目のファイルの種類が違います。"),!1;if(!angular.isDefined(a[b].size)||0==a[b].size)return e.openWarning((b+1).toString()+"番目のファイルが読み込めません。"),!1}else if(0==f(a))return e.openWarning("ファイルの種類が違います。"),!1;return!0},h=function(b){var d=c.defer();return b.length+a.photos.length<=1?d.resolve(b.length):a.photos.length<1?e.openConfirm(a,"confirmMaxFileCount.html").then(function(){d.resolve(1-a.photos.length)},function(){d.reject()}):(e.openWarning("添付できるファイル数を超過しています。"),d.reject()),d.promise};a.$watch("imageFiles",function(c){c&&0!=c.length&&(a.disableInput=!0,1==g(c)&&h(c).then(function(f){e.openLoading();for(var g=0,h=0;h<c.length&&h<f;h++)d.appendFile(c[h],a.config,function(a){b.info(a),g++,g!=c.length&&g!=f||e.closeLoading()},function(a){b.error(a),g++,e.closeLoading()})}),a.disableInput=!1)})}]).controller("redirectCtrl",["$scope",function(a){a.redirect=function(){sforce.one.navigateToSObject(a.land.pid)}}]).controller("PhotosOldCtrl",["$scope","$log","$location","alPhotos","alModal",function(a,b,c,d,e){a.editMode=!1,a.photos=d.all(),a.objs=null,a.nameFilter=null,a.searchFilter=function(b){var c=new RegExp(a.nameFilter,"i");return!a.nameFilter||c.test(b.Name)},a.doDetail=function(a){},a.removePhoto=function(b){a.photos.splice(b,1),0==a.photos.length&&(a.editMode=!1)},a.send=function(){c.path("/menu/upload")},a.$watch("imageFile",function(c){a.barValue=0,a.Max=0,c&&c.type.match("image.*")&&(e.openLoading(),d.appendFile(c,a.config,function(a){b.info(a),e.closeLoading()},function(a){b.error(a),e.closeLoading()}))})}]);
|