myKnowledgeCtrl.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. app.controller('myKnowledgeCtrl', ["$rootScope", "$scope", '$stateParams', '$http', '$state', '$timeout', '$ionicPopover', '$ionicPopup', '$ionicLoading', 'api_bpm_domain', 'Restangular', 'api_solution', 'getLoginUser', function($rootScope, $scope, $stateParams, $http, $state, $timeout, $ionicPopover, $ionicPopup, $ionicLoading, api_bpm_domain, Restangular, api_solution, getLoginUser) {
  2. console.log('myKnowledgeCtrl is load');
  3. $scope.goBack = function() {
  4. if ($scope.sessionLogin.tokenType == 'user') {
  5. $state.go('tab.handlerDashboard');
  6. } else {
  7. $state.go('tab.requesterDashboard');
  8. }
  9. }
  10. $scope.load = {
  11. 'pageIndex': 0, //第几页
  12. 'pageSum': 10, //每页条数
  13. 'pageCount': 0 //总页数
  14. };
  15. // $scope.search = {
  16. // 'pageIndex': 0, //第几页
  17. // 'pageSum': 10, //每页条数
  18. // 'pageCount': 0 //总页数
  19. // };
  20. //弹出框
  21. // 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>';
  22. // $scope.popover = $ionicPopover.fromTemplate(template, {
  23. // scope: $scope
  24. // });
  25. // .fromTemplateUrl() method
  26. $ionicPopover.fromTemplateUrl('assets/views/weChat/myIncident/popover.html', {
  27. scope: $scope
  28. }).then(function(popover) {
  29. $scope.popover = popover;
  30. });
  31. $scope.openPopover = function($event) {
  32. $scope.popover.show($event);
  33. };
  34. $scope.closePopover = function() {
  35. $scope.popover.hide();
  36. };
  37. //Cleanup the popover when we're done with it!
  38. $scope.$on('$destroy', function() {
  39. $scope.popover.remove();
  40. });
  41. // Execute action on hidden popover
  42. $scope.$on('popover.hidden', function() {
  43. // Execute action
  44. });
  45. // Execute action on remove popover
  46. $scope.$on('popover.removed', function() {
  47. // Execute action
  48. });
  49. $scope.statuses = [
  50. { status: 'all', label: '全部的事件', idName: 'a' },
  51. { status: 'todo', label: '待我处理的', idName: 'b' },
  52. { status: 'create', label: '我创建的', idName: 'c' },
  53. { status: 'done', label: '我处理过的', idName: 'd' },
  54. // { status: 's', label: '已驳回', idName: 'e' },
  55. // { status: '6', label: '已拒绝', idName: 'f' }
  56. ];
  57. $scope.searchTypeFunction = function(searchType) {
  58. $scope.refreshListData({
  59. 'searchType': searchType,
  60. 'idx': 0,
  61. });
  62. $scope.popover.hide();
  63. }
  64. // $scope.loginForm = {};
  65. // var loginUser = $rootScope.user;
  66. //获取login中的数据
  67. // var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  68. // var loginUser = sessionLogin.user;
  69. //定义流程代号
  70. // var pdKey = $state.current.pdKey;
  71. var pdKey = 'bpm_incident';
  72. //默认数据
  73. // var defaultData = {
  74. // 'assignee': loginUser.id,
  75. // 'idx': 0,
  76. // 'sum': 10,
  77. // };
  78. //页面数据容器
  79. $scope.myData = [];
  80. //是否加载上拉刷新
  81. $scope.domore = false;
  82. //本地数据初始化
  83. // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
  84. //搜索栏
  85. $scope.searchSolution = function(searchInput) {
  86. if (!$scope.searchInput) {
  87. $scope.load.pageIndex = 0;
  88. }
  89. if ($scope.searchInput && $scope.load.pageIndex > 0) {
  90. $scope.load.pageIndex = 0;
  91. }
  92. $scope.refreshListData();
  93. //遮罩层开启
  94. // $ionicLoading.show({
  95. // template: 'Loading...'
  96. // });
  97. // if (angular.isString(searchInput) && searchInput != '') {
  98. // api_solution.queryBBSSolutions($scope.search.pageIndex, $scope.search.pageSum, 'createtime', loginUser.id, searchInput).then(function(response) {
  99. // var myData = Restangular.stripRestangular(response);
  100. // if (angular.isArray(myData.list) && myData.list.length > 0) {
  101. // $scope.myData = myData.list;
  102. // //计算总页数
  103. // $scope.search.pageCount = Math.ceil(myData.totalNum / $scope.search.pageSum);
  104. // } else {
  105. // $ionicPopup.alert({
  106. // title: '对不起,没有搜索到相关内容!',
  107. // })
  108. // $scope.listShow = false;
  109. // }
  110. // //遮罩层关闭
  111. // $ionicLoading.hide();
  112. // });
  113. // }
  114. }
  115. //新增数据
  116. $scope.addData = function() {
  117. var data = JSON.parse(sessionStorage.incidentListMobileParameter);
  118. if (data.formUiEdit) {
  119. var formUiEdit = data.formUiEdit;
  120. };
  121. if (data.formUiName) {
  122. var formUiName = data.formUiName;
  123. };
  124. if (data.processKey) {
  125. var pdKey = data.processKey;
  126. };
  127. if (data.formUiStart) {
  128. var formUiStart = data.formUiStart;
  129. };
  130. if (pdKey) {
  131. $state.go('app.incidentMobile.incidentEditorMobile', {
  132. 'pdKey': pdKey,
  133. 'formUiEdit': formUiEdit,
  134. 'formUiName': formUiName,
  135. 'formUiStart': formUiStart,
  136. 'userId': data.status
  137. });
  138. } else {
  139. SweetAlert.swal({
  140. title: "当前服务类型不可新建",
  141. // text: myData.data,
  142. type: "warning"
  143. });
  144. }
  145. };
  146. //跳转到编辑列表
  147. $scope.editorFunction = function(data) {
  148. // $state.go('app.inspection.inspectListEditor', {
  149. // "taskId": data.taskId,
  150. // "processInstanceId": data.processInstanceId,
  151. // "pdKey": data.processKey,
  152. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  153. // // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  154. // });
  155. $state.go('app.incidentMobile.incidentEditorMobile', {
  156. taskId: data.taskId,
  157. processInstanceId: data.processInstanceId
  158. });
  159. };
  160. //跳转到查看列表
  161. $scope.lookFunction = function(data) {
  162. $state.go('tab.myKnowledgeDetail', {
  163. 'item': JSON.stringify(data)
  164. });
  165. };
  166. //跳转到评论列表
  167. $scope.listFunction = function(data) {
  168. // $state.go('tab.myKnowledgeList', {
  169. // 'item': JSON.stringify(data)
  170. // });
  171. $state.go('tab.myKnowledgeList', {
  172. 'item': JSON.stringify(data)
  173. // 'id': data.id,
  174. // 'content': data.content
  175. });
  176. };
  177. //页面刷新
  178. $scope.reload = function() {
  179. $scope.refreshListData();
  180. }
  181. //下拉刷新
  182. $scope.doRefresh = function() {
  183. $scope.load.pageIndex = 0;
  184. $scope.refreshListData('', 'down');
  185. $scope.domore = false;
  186. // if (angular.isString($scope.searchInput) && $scope.searchInput != '') {
  187. // $scope.searchInput = '';
  188. // }
  189. };
  190. //上拉加载
  191. $scope.loadMore = function() {
  192. //开启上拉加载
  193. $scope.domore = false;
  194. // 数据列表加1
  195. $scope.load.pageIndex += 1;
  196. //定时器
  197. // var timer = null;
  198. //参数
  199. // var filterData = defaultData;
  200. // angular.extend(filterData, { 'idx': $scope.filterData.idx });
  201. //获取数据
  202. $scope.refreshListData('', 'up');
  203. //加载
  204. // if (angular.isString($scope.searchInput) && $scope.searchInput != '') {
  205. // $scope.search.pageIndex += 1;
  206. // if ($scope.search.pageIndex < $scope.search.pageCount) {
  207. // // api_solution.queryBBSSolutions($scope.search.pageIndex, $scope.search.pageSum, "createtime", loginUser.id).then(function(data) {
  208. // api_solution.fetchDataList('solution', { 'idx': showData.idx, 'sum': showData.sum, 'solution': { 'searchType': 3 } }).then(function(data) {
  209. // var myData = Restangular.stripRestangular(data);
  210. // if (angular.isArray(myData.list) && myData.list.length > 0) {
  211. // angular.forEach(myData.list, function(item) {
  212. // $scope.myData.push(item);
  213. // });
  214. // }
  215. // $scope.$broadcast('scroll.infiniteScrollComplete');
  216. // }, function(data) {
  217. // });
  218. // } else {
  219. // $scope.domore = true;
  220. // $scope.$broadcast('scroll.infiniteScrollComplete');
  221. // }
  222. // } else {
  223. // $scope.load.pageIndex += 1;
  224. // if ($scope.load.pageIndex < $scope.load.pageCount) {
  225. // api_solution.fetchBBSSolutions($scope.load.pageIndex, $scope.load.pageSum, "createtime", loginUser.id).then(function(data) {
  226. // var myData = Restangular.stripRestangular(data);
  227. // if (angular.isArray(myData.list) && myData.list.length > 0) {
  228. // angular.forEach(myData.list, function(item) {
  229. // $scope.myData.push(item);
  230. // });
  231. // }
  232. // $scope.$broadcast('scroll.infiniteScrollComplete');
  233. // }, function(data) {
  234. // });
  235. // } else {
  236. // $scope.domore = true;
  237. // $scope.$broadcast('scroll.infiniteScrollComplete');
  238. // }
  239. // }
  240. };
  241. //数据加载
  242. $scope.isgetdata = true;
  243. $scope.refreshListData = function(filterData, loadStyle) {
  244. $scope.isgetdata = false;
  245. var searchType = 3;
  246. if ($scope.sessionLogin) {
  247. if ($scope.sessionLogin.tokenType == 'user') {
  248. searchType = 2;
  249. }
  250. }
  251. var solution = {
  252. 'searchType': searchType,
  253. };
  254. if ($scope.sessionLogin) {
  255. if ($scope.sessionLogin.tokenType == 'user') {
  256. angular.extend(solution, { 'createUserId': $scope.loginUser.id });
  257. }
  258. }
  259. if (angular.isString($scope.searchInput) && $scope.searchInput != '') {
  260. angular.extend(solution, { 'keywords': $scope.searchInput });
  261. }
  262. //遮罩层开启
  263. $ionicLoading.show({
  264. template: 'Loading...'
  265. });
  266. // api_solution.fetchBBSSolutions($scope.load.pageIndex, $scope.load.pageSum, "createtime", loginUser.id).then(function(data) {
  267. api_solution.fetchDataList('solution', { 'idx': $scope.load.pageIndex, 'sum': $scope.load.pageSum, solution }).then(function(data) {
  268. var myData = Restangular.stripRestangular(data);
  269. if (angular.isArray(myData.list) && myData.list.length > 0) {
  270. // $scope.myData = myData.list;
  271. //计算总页数
  272. // $scope.load.pageCount = Math.ceil(myData.totalNum / $scope.load.pageSum);
  273. if (loadStyle == 'down') {
  274. $scope.myData = myData.list;
  275. $scope.$broadcast('scroll.refreshComplete');
  276. } else if (loadStyle == 'up') {
  277. angular.forEach(myData.list, function(item) {
  278. $scope.myData.push(item);
  279. });
  280. $scope.$broadcast('scroll.infiniteScrollComplete');
  281. $scope.domore = true;
  282. } else {
  283. $scope.myData = myData.list;
  284. }
  285. } else {
  286. if (loadStyle == 'down') {
  287. $scope.$broadcast('scroll.refreshComplete');
  288. } else if (loadStyle == 'up') {
  289. $scope.$broadcast('scroll.infiniteScrollComplete');
  290. $scope.domore = true;
  291. } else {
  292. $scope.listShow = false;
  293. }
  294. }
  295. $scope.isgetdata = true;
  296. //遮罩层关闭
  297. $ionicLoading.hide();
  298. }, function() {
  299. //遮罩层关闭
  300. $ionicLoading.hide();
  301. });
  302. }
  303. //页面加载
  304. // $scope.reload();
  305. //跳转成功刷新页面
  306. // $scope.$on('$stateChangeSucess', $scope.reload());
  307. if (!sessionStorage.sessionLogin) {
  308. var promise = getLoginUser.query();
  309. promise.then(function(sessionLogin) { //返回成功
  310. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  311. var loginUser = sessionLogin.user;
  312. $scope.tokenType = sessionLogin.tokenType;
  313. $scope.sessionLogin = sessionLogin
  314. $scope.loginUser = sessionLogin.user;
  315. $rootScope.user = sessionLogin.user;
  316. // $scope.defaultData = {
  317. // 'assignee': loginUser.account,
  318. // 'idx': 0,
  319. // 'sum': 10,
  320. // // 'candidateGroups': loginUser.group["0"].id
  321. // };
  322. // $scope.filterData = {
  323. // 'assignee': loginUser.account,
  324. // 'idx': 0,
  325. // 'sum': 10,
  326. // };
  327. $scope.reload()
  328. }, function(data) { //返回失败
  329. });
  330. } else {
  331. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  332. var loginUser = sessionLogin.user;
  333. $scope.tokenType = sessionLogin.tokenType;
  334. $scope.sessionLogin = sessionLogin
  335. $scope.loginUser = sessionLogin.user;
  336. $rootScope.user = sessionLogin.user;
  337. // $scope.defaultData = {
  338. // 'assignee': loginUser.account,
  339. // 'idx': 0,
  340. // 'sum': 10,
  341. // // 'candidateGroups': loginUser.group["0"].id
  342. // };
  343. // $scope.filterData = {
  344. // 'assignee': loginUser.account,
  345. // 'idx': 0,
  346. // 'sum': 10,
  347. // };
  348. $scope.reload()
  349. }
  350. }])