ParticipatingUnitsCtrl.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. angular.module('push')
  2. .controller('ParticipatingUnitsCtrl', function ($scope, $ionicActionSheet, ModelService, $stateParams, UtilService) {
  3. // 单位类型type: 0:其他 1:政府 2:园区 3:机构 4:企业 5:高校
  4. $scope.typename = ["未选择", "其他", "政府", "园区", "机构", "企业", "高校"];
  5. var listindex;
  6. if (UtilService.isDefined($stateParams.company)) {
  7. $scope.tempcompany = $stateParams.company;
  8. $scope.index = $stateParams.company.type + 1;
  9. listindex = $stateParams.index;
  10. } else {
  11. $scope.tempcompany = {name: "", type: 1, presentation: ""};
  12. $scope.index = 0;
  13. }
  14. $scope.show = function () {
  15. $ionicActionSheet.show({
  16. buttons: [
  17. {text: '<a class="action-sheet-push">高校</a>'},
  18. {text: '<a class="action-sheet-push">企业</a>'},
  19. {text: '<a class="action-sheet-push">机构</a>'},
  20. {text: '<a class="action-sheet-push">园区</a>'},
  21. {text: '<a class="action-sheet-push">政府</a>'},
  22. {text: '<a class="action-sheet-push">其他</a>'}
  23. ],
  24. cancelText: '取消',
  25. buttonClicked: function (index) {
  26. $scope.index = 6 - index;
  27. $scope.tempcompany.type = 5 - index;
  28. return true;
  29. }
  30. });
  31. };
  32. $scope.saveTempCompany = function () {
  33. if (!UtilService.isDefined($scope.tempcompany.name)) {
  34. UtilService.showMess("单位名称不能为空");
  35. return;
  36. }
  37. if ($scope.index == 0) {
  38. UtilService.showMess("单位类型不能为空");
  39. return;
  40. }
  41. if (UtilService.isDefined($stateParams.company)) {
  42. var tempCompanyList = ModelService.getTempCompanies();
  43. tempCompanyList[listindex] = $scope.tempcompany;
  44. ModelService.setTempCompanies2(tempCompanyList);
  45. } else {
  46. $scope.tempcompany.localid = UtilService.formatDate().timestamp + "";
  47. ModelService.setTempCompanies($scope.tempcompany);
  48. }
  49. $scope.goback();
  50. }
  51. });