/** * Created by pushkeji on 2018/10/11. */ angular.module('push') .controller('unionIntroductionCtrl', ['$scope', '$stateParams', '$ionicActionSheet', '$ionicLoading', '$ionicScrollDelegate', 'UtilService', 'dataToolsService', '$sce', 'UserService', '$ionicSlideBoxDelegate', '$timeout', '$state', '$http', 'ConfigService', '$ionicPopup', 'ResourceLibraryService', 'taskModuleService', 'ScienceCircleService', '$ionicModal', '$q', 'CommonService', function ($scope, $stateParams, $ionicActionSheet, $ionicLoading, $ionicScrollDelegate, UtilService, dataToolsService, $sce, UserService, $ionicSlideBoxDelegate, $timeout, $state, $http, ConfigService, $ionicPopup, ResourceLibraryService, taskModuleService, ScienceCircleService, $ionicModal, $q, CommonService) { $scope.union = $stateParams.union; var tecBroker = [ { title: '联盟名称', placeholder: '请填写联盟名称', fuzzyQuery: false, content: "", type: 'input', needed: false, saveKey: 'name1', }, { title: '联盟名称', placeholder: '请填写联盟名称', fuzzyQuery: false, content: $scope.union.name ? $scope.union.name : "", type: 'input', needed: true, saveKey: 'name', }, { title: '联盟简介', placeholder: '请填写联盟简介', type: 'textarea', maxlength: 500, fuzzyQuery: false, content: $scope.union.content ? $scope.union.content : "", needed: true, saveKey: 'content', }, { title: '会长单位', placeholder: '请填写会长单位', content: $scope.union.org ? $scope.union.org : "", type: 'input', needed: true, saveKey: 'org', }, { title: '副会长单位', placeholder: '请填写副会长单位', content: '', type: 'upload', needed: true, saveKey: 'viceorg', }, { title: '联盟联系电话', placeholder: '请填写联盟联系电话', content: $scope.union.tel ? $scope.union.tel : "", type: 'input', needed: true, saveKey: 'tel', } ]; $scope.formList = tecBroker; var bool = $scope.union.viceorgList== null || $scope.union.viceorgList==undefined; $scope.orgList = bool ? [] : $scope.union.viceorgList; $scope.addViceOrg = function(list){ if(list.content == ""){ $ionicPopup.alert({ title: '提示', template: list.placeholder }) return; } $scope.orgList.push(list.content); list.content = ""; document.getElementById("viceorgid").value = ""; } $scope.deleteOrg = function(index){ $scope.orgList[index] = null; $scope.newOrgList = []; angular.forEach($scope.orgList, function (val, index) { if (val != null) { $scope.newOrgList.push(val); } }) $scope.orgList = $scope.newOrgList; } $scope.submitForm = function () { var saveUnionFlag = true; angular.forEach($scope.formList, function (val, index) { if (val.needed && val.content == "" && val.title != "副会长单位") { $ionicPopup.alert({ title: '提示', template: val.placeholder }) saveUnionFlag = false; } }) if ($scope.orgList.length == 0) { $ionicPopup.alert({ title: '提示', template: '请填写副会长单位' }) saveUnionFlag = false; } if (saveUnionFlag) { var saveData={}; saveData.data=[]; angular.forEach($scope.formList, function (val, index) { if (val.content != "" && val.type != "upload") { saveData.data.push(val.content); } }) var viceorg = ""; angular.forEach($scope.orgList, function(val, index){ if(val != null) { viceorg += val + ","; } }) saveData.data.push(viceorg); taskModuleService.saveUnion(saveData).then(function (res) { if (res.code == 3350) { $scope.go("unionDetail"); } }) } } } ]) ;