unionIntroductionCtrl.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * Created by pushkeji on 2018/10/11.
  3. */
  4. angular.module('push')
  5. .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) {
  6. $scope.union = $stateParams.union;
  7. var tecBroker = [
  8. {
  9. title: '联盟名称',
  10. placeholder: '请填写联盟名称',
  11. fuzzyQuery: false,
  12. content: "",
  13. type: 'input',
  14. needed: false,
  15. saveKey: 'name1',
  16. }, {
  17. title: '联盟名称',
  18. placeholder: '请填写联盟名称',
  19. fuzzyQuery: false,
  20. content: $scope.union.name ? $scope.union.name : "",
  21. type: 'input',
  22. needed: true,
  23. saveKey: 'name',
  24. }, {
  25. title: '联盟简介',
  26. placeholder: '请填写联盟简介',
  27. type: 'textarea',
  28. maxlength: 500,
  29. fuzzyQuery: false,
  30. content: $scope.union.content ? $scope.union.content : "",
  31. needed: true,
  32. saveKey: 'content',
  33. }, {
  34. title: '会长单位',
  35. placeholder: '请填写会长单位',
  36. content: $scope.union.org ? $scope.union.org : "",
  37. type: 'input',
  38. needed: true,
  39. saveKey: 'org',
  40. }, {
  41. title: '副会长单位',
  42. placeholder: '请填写副会长单位',
  43. content: '',
  44. type: 'upload',
  45. needed: true,
  46. saveKey: 'viceorg',
  47. }, {
  48. title: '联盟联系电话',
  49. placeholder: '请填写联盟联系电话',
  50. content: $scope.union.tel ? $scope.union.tel : "",
  51. type: 'input',
  52. needed: true,
  53. saveKey: 'tel',
  54. }
  55. ];
  56. $scope.formList = tecBroker;
  57. var bool = $scope.union.viceorgList== null || $scope.union.viceorgList==undefined;
  58. $scope.orgList = bool ? [] : $scope.union.viceorgList;
  59. $scope.addViceOrg = function(list){
  60. if(list.content == ""){
  61. $ionicPopup.alert({
  62. title: '提示',
  63. template: list.placeholder
  64. })
  65. return;
  66. }
  67. $scope.orgList.push(list.content);
  68. list.content = "";
  69. document.getElementById("viceorgid").value = "";
  70. }
  71. $scope.deleteOrg = function(index){
  72. $scope.orgList[index] = null;
  73. $scope.newOrgList = [];
  74. angular.forEach($scope.orgList, function (val, index) {
  75. if (val != null) {
  76. $scope.newOrgList.push(val);
  77. }
  78. })
  79. $scope.orgList = $scope.newOrgList;
  80. }
  81. $scope.submitForm = function () {
  82. var saveUnionFlag = true;
  83. angular.forEach($scope.formList, function (val, index) {
  84. if (val.needed && val.content == "" && val.title != "副会长单位") {
  85. $ionicPopup.alert({
  86. title: '提示',
  87. template: val.placeholder
  88. })
  89. saveUnionFlag = false;
  90. }
  91. })
  92. if ($scope.orgList.length == 0) {
  93. $ionicPopup.alert({
  94. title: '提示',
  95. template: '请填写副会长单位'
  96. })
  97. saveUnionFlag = false;
  98. }
  99. if (saveUnionFlag) {
  100. var saveData={};
  101. saveData.data=[];
  102. angular.forEach($scope.formList, function (val, index) {
  103. if (val.content != "" && val.type != "upload") {
  104. saveData.data.push(val.content);
  105. }
  106. })
  107. var viceorg = "";
  108. angular.forEach($scope.orgList, function(val, index){
  109. if(val != null) {
  110. viceorg += val + ",";
  111. }
  112. })
  113. saveData.data.push(viceorg);
  114. taskModuleService.saveUnion(saveData).then(function (res) {
  115. if (res.code == 3350) {
  116. $scope.go("unionDetail");
  117. }
  118. })
  119. }
  120. }
  121. }
  122. ])
  123. ;