app.controller('myKnowledgeCommentCtrl', ["$rootScope", "$scope", '$stateParams', '$http', '$state', '$timeout', '$ionicPopover', '$ionicPopup', '$ionicLoading', 'api_bpm_domain', 'Restangular', 'api_solution', function($rootScope, $scope, $stateParams, $http, $state, $timeout, $ionicPopover, $ionicPopup, $ionicLoading, api_bpm_domain, Restangular, api_solution) {
console.log('myKnowledgeCommentCtrl is load');
$scope.load = {
'pageIndex': 0, //第几页
'pageSum': 10, //每页条数
'pageCount': 0 //总页数
};
$scope.search = {
'pageIndex': 0, //第几页
'pageSum': 10, //每页条数
'pageCount': 0 //总页数
};
//弹出框
// var template = ' My Popover Title
Hello! ';
// $scope.popover = $ionicPopover.fromTemplate(template, {
// scope: $scope
// });
// .fromTemplateUrl() method
$ionicPopover.fromTemplateUrl('assets/views/weChat/myIncident/popover.html', {
scope: $scope
}).then(function(popover) {
$scope.popover = popover;
});
$scope.openPopover = function($event) {
$scope.popover.show($event);
};
$scope.closePopover = function() {
$scope.popover.hide();
};
//Cleanup the popover when we're done with it!
$scope.$on('$destroy', function() {
$scope.popover.remove();
});
// Execute action on hidden popover
$scope.$on('popover.hidden', function() {
// Execute action
});
// Execute action on remove popover
$scope.$on('popover.removed', function() {
// Execute action
});
$scope.statuses = [
{ status: 'all', label: '全部的事件', idName: 'a' },
{ status: 'todo', label: '待我处理的', idName: 'b' },
{ status: 'create', label: '我创建的', idName: 'c' },
{ status: 'done', label: '我处理过的', idName: 'd' },
// { status: 's', label: '已驳回', idName: 'e' },
// { status: '6', label: '已拒绝', idName: 'f' }
];
$scope.searchTypeFunction = function(searchType) {
$scope.reload(searchType);
$scope.popover.hide();
}
// $scope.loginForm = {};
// var loginUser = $rootScope.user;
//获取login中的数据
var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
var loginUser = sessionLogin.user;
var solutionUser = JSON.parse($state.params.item);
//定义流程代号
// var pdKey = $state.current.pdKey;
var pdKey = 'bpm_incident';
//默认数据
var defaultData = {
'assignee': loginUser.id,
'idx': 0,
'sum': 10,
};
//页面数据容器
$scope.myData = [];
//是否加载上拉刷新
$scope.domore = false;
//填充数据
$scope.filterData = {
'assignee': loginUser.id,
'idx': 0,
'sum': 10,
};
//本地数据初始化
// sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
$scope.goBack = function() {
// $state.go('tab.myKnowledge', {});
history.go(-1);
}
// $scope.ratingsObject = {
// iconOn: 'ion-ios-star', //Optional
// iconOff: 'ion-ios-star-outline', //Optional
// iconOnColor: 'rgb(200, 200, 100)', //Optional
// iconOffColor: 'rgb(200, 100, 100)', //Optional
// rating: 2, //Optional
// minRating: 1, //Optional
// readOnly: true, //Optional
// callback: function(rating, index) { //Mandatory
// $scope.ratingsCallback(rating, index);
// }
// };
// $scope.ratingsCallback = function(rating, index) {
// console.log('Selected rating is : ', rating, ' and the index is : ', index);
// };
$scope.ratingStates = [
{ stateOn: 'glyphicon-ok-sign', stateOff: 'glyphicon-ok-circle' },
{ stateOn: 'glyphicon-star', stateOff: 'glyphicon-star-empty' },
{ stateOn: 'glyphicon-heart', stateOff: 'glyphicon-ban-circle' },
{ stateOn: 'glyphicon-heart' },
{ stateOff: 'glyphicon-off' }
];
$scope.commentSubmit = function() {
if (sessionLogin.tokenType == 'requester') {
var data = {
id: null,
solutionId: solutionUser.id,
account: loginUser.account,
// userId: loginUser.id,
review: '
' + $scope.reviewContent + '
',
// reviewScore: reviewScore,
reviewTime: new Date()
};
} else {
var data = {
id: null,
solutionId: solutionUser.id,
userId: loginUser.id,
review: '' + $scope.reviewContent + '
',
// reviewScore: reviewScore,
reviewTime: new Date()
};
}
api_solution.addSolutionReview(data).then(function(response) {
var status = response.status;
if (status == "200") {
$ionicPopup.alert({
title: '评论成功!',
}).then(function(res) {
history.go(-1);
});
} else {
$ionicPopup.alert({
title: '评论失败!',
}).then(function(res) {
// history.go(-1);
});
}
});
};
}])