123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /**
- * Created by pushkeji on 2018/12/27.
- */
- angular.module('push')
- .controller('activityApplyCtrl', ['$scope','activitiesModuleService','$timeout','$q','UserService','$stateParams','ResourceLibraryService','$ionicSlideBoxDelegate','CommentService','ConfigService','ScienceCircleService','CommonService','$ionicScrollDelegate','ConstantService','$ionicActionSheet','UtilService','ShareService','dataToolsService','$sce',function($scope,activitiesModuleService,$timeout,$q,UserService,$stateParams,ResourceLibraryService,$ionicSlideBoxDelegate,CommentService,ConfigService,ScienceCircleService,CommonService,$ionicScrollDelegate,ConstantService,$ionicActionSheet,UtilService,ShareService,dataToolsService,$sce){
- console.log($stateParams);
- $scope.formList=JSON.parse(localStorage.settingItems||$stateParams.settingItems);
- localStorage.emptyFormList=$stateParams.settingItems;
- var activityid=$stateParams.activityid||localStorage.activityid;
- var title='';
- // console.log(JSON.parse(localStorage.feedbackItem||'{}'));
- // console.log(activityid);
- // console.log($stateParams);
- angular.forEach($scope.formList,function(val){
- if(val.type=='configurablePages'&&!val.otherid){
- val.isedit=0;
- val.buttonText='添加'+val.text;
- val.acitivityid=$stateParams.acitivityid||localStorage.activityid;
- }
- if(val.type=='select'){
- dataToolsService.getTypeEntryListByTypeName(val.selectkey).then(function(res){
- if(res.code==3350){
- // console.log(res);
- val.listItem=[];
- angular.forEach(res.data,function(value){
- val.listItem.push({
- text: '<a class="action-sheet-push">' + value.itemkey + '</a>',
- itemkey: value.itemvalue,
- itemvalue: value.itemkey //名字
- })
- })
- }
- });
- }
- });
- var feedbackItem=JSON.parse(localStorage.feedbackItem||'{}');
- for(var key in feedbackItem){
- if(feedbackItem[key].length>0&&key!='connid'){
- for(var i=0;i<$scope.formList.length;i++){
- if((key=='achievement'&&$scope.formList[i].text=='成果')||(key=='demand'&&$scope.formList[i].text=='需求')||(key=='patent'&&$scope.formList[i].text=='专利')){
- $scope.formList[i].isedit=1;//编辑
- $scope.formList[i].content=feedbackItem.connid;//
- $scope.formList[i].buttonText='编辑'+$scope.formList[i].text;
- $scope.formList[i].otherid='';
- angular.forEach(feedbackItem[key],function(val){
- $scope.formList[i].otherid+=val.id+',';
- });
- break;
- }
- }
- }
- }
- $scope.selectItems=function(index){
- if($scope.formList[index].type=='select'||$scope.formList[index].type=='selectDomain'||$scope.formList[index].type=='affiliatedOrg'||$scope.formList[index].type=='companyTaskSelect'){
- var list=$scope.formList[index].listItem;
- $ionicActionSheet.show({
- buttons:list,
- cancelText:'取消',
- buttonClicked:function(indx){
- $scope.formList[index].key=list[indx].itemkey;
- $scope.formList[index].content=list[indx].itemvalue;
- return true;
- }
- })
- }
- }
- // 录入
- var orgType = "";
- $scope.goToInput=function(index){
- angular.forEach($scope.formList, function(val){
- if(val.text == "身份类别"){
- if(val.content == "高校"){
- orgType = 10105;
- }
- if(val.content == "企业"){
- orgType = 10104;
- }
- }
- })
- console.log($scope.formList[index]);
- localStorage.settingItems=JSON.stringify($scope.formList);
- localStorage.activityid=$stateParams.activityid||localStorage.activityid;
- for(var i=0;i<$scope.formList.length;i++){
- if($scope.formList[i].text=='所属机构'){
- title=$scope.formList[i].content;
- }
- }
- if (UserService.node == '330122000' && $scope.formList[index].pageid == 4) {
- $scope.go('visitModularFormDemand', {
- companyid: 0,
- connid:$scope.formList[index].content,
- pageid: $scope.formList[index].pageid,
- orgtype: orgType,
- pagecode: $scope.formList[index].pagecode,
- isedit: $scope.formList[index].isedit,
- node: UserService.node,
- pageTitle: '新建录入',
- comfrom:$stateParams.comfrom||'activityApply',
- title:title
- });
- } else{
- $scope.go('visitModularForm', {companyid: 0,connid:$scope.formList[index].content, pageid: $scope.formList[index].pageid, orgtype: orgType,pagecode:$scope.formList[index].pagecode, isedit: $scope.formList[index].isedit,node:UserService.node,pageTitle:$scope.formList[index].isedit?'编辑录入':'新建录入',comfrom:$stateParams.comfrom||'activityApply',title:title});
- }
- }
- var saveflg=0;
- // 活动报名
- $scope.submitForm=function(){
- console.log($scope.formList);
- if(saveflg){
- return;
- }
- saveflg=1;
- // 非空判断
- for(var i=0;i<$scope.formList.length;i++){
- if($scope.formList[i].isneed&&(!$scope.formList[i].content&&!$scope.formList[i].otherid)){
- if($scope.app){
- UtilService.showMess($scope.formList[i].text+'是必填项');
- }else{
- CommonService.showMessage($scope.formList[i].text+'是必填项',$scope);
- }
- $scope.hideLoadingToast();
- saveflg =0;
- return;
- }
- }
- var params={};
- params.data=[];
- angular.forEach($scope.formList,function(val){
- params.data.push({
- "activityid":$stateParams.activityid||localStorage.activityid,
- "userid":UserService.id,
- "itemid":val.id,
- "otherid":val.otherid||'',
- "linktype":val.linktype,
- "itemvalue":val.content||''
- })
- });
- params.node = UserService.node;
- // console.log(params);
- activitiesModuleService.applyForActivity(params).then(function(res){
- console.log(res);
- if(res.code==3350){
- localStorage.settingItems='';
- localStorage.activityid='';
- localStorage.feedbackItem='';
- if($stateParams.comfrom=='participantList'){
- $scope.go('participantList',{activityid:activityid,settingItems:localStorage.emptyFormList});
- }else{
- $scope.go('activityDetail',{activityid:activityid});
- }
- }
- })
- }
- // 模糊查询
- $scope.queryOrgName=function(index){
- if($scope.formList[index].fuzzyquery){
- if($scope.formList[index].content){
- var pagecode=$scope.code==4803?1000003:1000004;
- dataToolsService.getOrganizationModelByOrgname($scope.formList[index].content,pagecode,0).then(function (response) {
- // console.log(response);
- if(response.code==3350){
- $scope.orgList = response.data;
- $scope.isRelateUl = true;
- }else{
- $scope.orgList = [];
- $scope.isRelateUl = false;
- }
- }, function () {
- })
- }else{
- $scope.isRelateUl=false;
- $scope.orgList=[];
- }
- }
- }
- $scope.ttt=function(tmptitle){
- return $sce.trustAsHtml(tmptitle);
- }
- // 选中机构
- $scope.setOrgName=function(org,index){
- console.log(org);
- $scope.orgid=org.id;
- $scope.formList[index].content=org.name;
- $scope.formList[index].otherid=org.id;
- // console.log($scope.formList);
- $scope.isRelateUl = false;
- }
- $scope.gobackToComfrom=function(){
- if($stateParams.comfrom=='participantList'){
- $scope.go('participantList',{activityid:activityid,settingItems:localStorage.emptyFormList});
- }else{
- $scope.go('activityDetail',{activityid:activityid});
- }
- }
- $scope.$on("$ionicView.beforeLeave", function(){
- // localStorage.settingItems='';
- })
- }]);
|