angular.module('push')
.controller('DockingThemeCtrl', function ($scope, $ionicActionSheet, ModelService, $stateParams, UtilService) {
//主题类型:1:需求 2:成果 3:服务 4:其他
$scope.typename = ["需求", "成果", "服务", "其他"];
var listindex;
if (UtilService.isDefined($stateParams.theme)) {
$scope.temptheme = $stateParams.theme;
$scope.index = $stateParams.theme.type - 1;
listindex = $stateParams.index;
} else {
$scope.temptheme = {title: "", type: 1, content: ""};
$scope.index = 0;
}
$scope.show = function () {
$ionicActionSheet.show({
buttons: [
{text: '需求'},
{text: '成果'},
{text: '服务'},
{text: '其他'}
],
cancelText: '取消',
buttonClicked: function (index) {
$scope.index = index;
$scope.temptheme.type = index + 1;
return true;
}
});
};
$scope.saveTempTheme = function () {
if (!UtilService.isDefined($scope.temptheme.title)) {
UtilService.showMess("主题名称不能为空");
return;
}
if (UtilService.isDefined($stateParams.theme)) {
var tempThemeList = ModelService.getTempThemes();
tempThemeList[listindex] = $scope.temptheme;
ModelService.setTempThemes2(tempThemeList);
} else {
$scope.temptheme.localid = UtilService.formatDate().timestamp + "";
ModelService.setTempThemes($scope.temptheme);
}
$scope.goback();
}
});