myKnowledgeCommentCtrl.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. 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) {
  2. console.log('myKnowledgeCommentCtrl is load');
  3. $scope.load = {
  4. 'pageIndex': 0, //第几页
  5. 'pageSum': 10, //每页条数
  6. 'pageCount': 0 //总页数
  7. };
  8. $scope.search = {
  9. 'pageIndex': 0, //第几页
  10. 'pageSum': 10, //每页条数
  11. 'pageCount': 0 //总页数
  12. };
  13. //弹出框
  14. // var template = '<ion-popover-view><ion-header-bar> <h1 class="title">My Popover Title</h1> </ion-header-bar> <ion-content> Hello! </ion-content></ion-popover-view>';
  15. // $scope.popover = $ionicPopover.fromTemplate(template, {
  16. // scope: $scope
  17. // });
  18. // .fromTemplateUrl() method
  19. $ionicPopover.fromTemplateUrl('assets/views/weChat/myIncident/popover.html', {
  20. scope: $scope
  21. }).then(function(popover) {
  22. $scope.popover = popover;
  23. });
  24. $scope.openPopover = function($event) {
  25. $scope.popover.show($event);
  26. };
  27. $scope.closePopover = function() {
  28. $scope.popover.hide();
  29. };
  30. //Cleanup the popover when we're done with it!
  31. $scope.$on('$destroy', function() {
  32. $scope.popover.remove();
  33. });
  34. // Execute action on hidden popover
  35. $scope.$on('popover.hidden', function() {
  36. // Execute action
  37. });
  38. // Execute action on remove popover
  39. $scope.$on('popover.removed', function() {
  40. // Execute action
  41. });
  42. $scope.statuses = [
  43. { status: 'all', label: '全部的事件', idName: 'a' },
  44. { status: 'todo', label: '待我处理的', idName: 'b' },
  45. { status: 'create', label: '我创建的', idName: 'c' },
  46. { status: 'done', label: '我处理过的', idName: 'd' },
  47. // { status: 's', label: '已驳回', idName: 'e' },
  48. // { status: '6', label: '已拒绝', idName: 'f' }
  49. ];
  50. $scope.searchTypeFunction = function(searchType) {
  51. $scope.reload(searchType);
  52. $scope.popover.hide();
  53. }
  54. // $scope.loginForm = {};
  55. // var loginUser = $rootScope.user;
  56. //获取login中的数据
  57. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  58. var loginUser = sessionLogin.user;
  59. var solutionUser = JSON.parse($state.params.item);
  60. //定义流程代号
  61. // var pdKey = $state.current.pdKey;
  62. var pdKey = 'bpm_incident';
  63. //默认数据
  64. var defaultData = {
  65. 'assignee': loginUser.id,
  66. 'idx': 0,
  67. 'sum': 10,
  68. };
  69. //页面数据容器
  70. $scope.myData = [];
  71. //是否加载上拉刷新
  72. $scope.domore = false;
  73. //填充数据
  74. $scope.filterData = {
  75. 'assignee': loginUser.id,
  76. 'idx': 0,
  77. 'sum': 10,
  78. };
  79. //本地数据初始化
  80. // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
  81. $scope.goBack = function() {
  82. // $state.go('tab.myKnowledge', {});
  83. history.go(-1);
  84. }
  85. // $scope.ratingsObject = {
  86. // iconOn: 'ion-ios-star', //Optional
  87. // iconOff: 'ion-ios-star-outline', //Optional
  88. // iconOnColor: 'rgb(200, 200, 100)', //Optional
  89. // iconOffColor: 'rgb(200, 100, 100)', //Optional
  90. // rating: 2, //Optional
  91. // minRating: 1, //Optional
  92. // readOnly: true, //Optional
  93. // callback: function(rating, index) { //Mandatory
  94. // $scope.ratingsCallback(rating, index);
  95. // }
  96. // };
  97. // $scope.ratingsCallback = function(rating, index) {
  98. // console.log('Selected rating is : ', rating, ' and the index is : ', index);
  99. // };
  100. $scope.ratingStates = [
  101. { stateOn: 'glyphicon-ok-sign', stateOff: 'glyphicon-ok-circle' },
  102. { stateOn: 'glyphicon-star', stateOff: 'glyphicon-star-empty' },
  103. { stateOn: 'glyphicon-heart', stateOff: 'glyphicon-ban-circle' },
  104. { stateOn: 'glyphicon-heart' },
  105. { stateOff: 'glyphicon-off' }
  106. ];
  107. $scope.commentSubmit = function() {
  108. if (sessionLogin.tokenType == 'requester') {
  109. var data = {
  110. id: null,
  111. solutionId: solutionUser.id,
  112. account: loginUser.account,
  113. // userId: loginUser.id,
  114. review: '<p>' + $scope.reviewContent + '</p>',
  115. // reviewScore: reviewScore,
  116. reviewTime: new Date()
  117. };
  118. } else {
  119. var data = {
  120. id: null,
  121. solutionId: solutionUser.id,
  122. userId: loginUser.id,
  123. review: '<p>' + $scope.reviewContent + '</p>',
  124. // reviewScore: reviewScore,
  125. reviewTime: new Date()
  126. };
  127. }
  128. api_solution.addSolutionReview(data).then(function(response) {
  129. var status = response.status;
  130. if (status == "200") {
  131. $ionicPopup.alert({
  132. title: '评论成功!',
  133. }).then(function(res) {
  134. history.go(-1);
  135. });
  136. } else {
  137. $ionicPopup.alert({
  138. title: '评论失败!',
  139. }).then(function(res) {
  140. // history.go(-1);
  141. });
  142. }
  143. });
  144. };
  145. }])