angular.module('push') .controller('ParticipatingUnitsCtrl', function ($scope, $ionicActionSheet, ModelService, $stateParams, UtilService) { // 单位类型type: 0:其他 1:政府 2:园区 3:机构 4:企业 5:高校 $scope.typename = ["未选择", "其他", "政府", "园区", "机构", "企业", "高校"]; var listindex; if (UtilService.isDefined($stateParams.company)) { $scope.tempcompany = $stateParams.company; $scope.index = $stateParams.company.type + 1; listindex = $stateParams.index; } else { $scope.tempcompany = {name: "", type: 1, presentation: ""}; $scope.index = 0; } $scope.show = function () { $ionicActionSheet.show({ buttons: [ {text: '高校'}, {text: '企业'}, {text: '机构'}, {text: '园区'}, {text: '政府'}, {text: '其他'} ], cancelText: '取消', buttonClicked: function (index) { $scope.index = 6 - index; $scope.tempcompany.type = 5 - index; return true; } }); }; $scope.saveTempCompany = function () { if (!UtilService.isDefined($scope.tempcompany.name)) { UtilService.showMess("单位名称不能为空"); return; } if ($scope.index == 0) { UtilService.showMess("单位类型不能为空"); return; } if (UtilService.isDefined($stateParams.company)) { var tempCompanyList = ModelService.getTempCompanies(); tempCompanyList[listindex] = $scope.tempcompany; ModelService.setTempCompanies2(tempCompanyList); } else { $scope.tempcompany.localid = UtilService.formatDate().timestamp + ""; ModelService.setTempCompanies($scope.tempcompany); } $scope.goback(); } });