123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- app.controller('myKnowledgeListCtrl', ["$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('myKnowledgeListCtrl is load');
- $scope.load = {
- 'pageIndex': 0, //第几页
- 'pageSum': 10, //每页条数
- 'pageCount': 0 //总页数
- };
- //弹出框
- // 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>';
- // $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 = $scope.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('myKnowledgeList', {});
- history.go(-1);
- }
- $scope.commentFunction = function() {
- $state.go('tab.myKnowledgeComment', {
- 'item': JSON.stringify(solutionUser)
- // 'solutionId': $state.params.id,
- // 'review': $state.params.content
- });
- }
- //页面刷新
- $scope.reload = function() {
- $scope.refreshListData();
- }
- //下拉刷新
- $scope.doRefresh = function() {
- $scope.load.pageIndex = 0;
- $scope.refreshListData('', 'down');
- $scope.domore = false;
- if (angular.isString($scope.searchInput) && $scope.searchInput != '') {
- $scope.searchInput = '';
- }
- };
- //上拉加载
- $scope.loadMore = function() {
- //开启上拉加载
- $scope.domore = false;
- //数据列表加1
- $scope.filterData.idx += 1;
- $scope.load.pageIndex += 1;
- //定时器
- var timer = null;
- //参数
- var filterData = defaultData;
- angular.extend(filterData, { 'idx': $scope.filterData.idx });
- //加载
- if ($scope.load.pageIndex < $scope.load.pageCount) {
- // api_solution.findSolutionReviewById(loginUser.id, solutionUser.id, $scope.filterData.idx, $scope.load.pageSum).then(function(response) {
- api_solution.fetchDataList('solutionReview', { 'idx': $scope.filterData.idx, 'sum': $scope.load.pageSum, 'solutionReview': { 'solutionId': solutionUser.id, 'userId': loginUser.id, 'status': 2 } }).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- if (angular.isArray(myData.list) && myData.list.length > 0) {
- angular.forEach(myData.list, function(item) {
- $scope.myData.push(item);
- });
- $scope.$broadcast('scroll.infiniteScrollComplete');
- } else {
- $scope.domore = true;
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- }, function(data) {});
- } else {
- $scope.domore = true;
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- };
- //数据加载
- $scope.refreshListData = function(filterData, loadStyle) {
- var showData = {};
- if (filterData) {
- showData = angular.extend(defaultData, filterData);
- } else {
- showData = defaultData;
- }
- //遮罩层开启
- $ionicLoading.show({
- template: 'Loading...'
- });
- // api_solution.findSolutionReviewById(loginUser.id, solutionUser.id, 0, $scope.load.pageSum).then(function(response) {
- api_solution.fetchDataList('solutionReview', { 'idx': 0, 'sum': $scope.load.pageSum, 'solutionReview': { 'solutionId': solutionUser.id, 'userId': loginUser.id, 'status': 2 } }).then(function(response) {
- var myData = Restangular.stripRestangular(response);
- if (angular.isArray(myData.list) && myData.list.length > 0) {
- $scope.myData = myData.list;
- //计算总页数
- $scope.load.pageCount = Math.ceil(myData.totalNum / $scope.load.pageSum);
- if (loadStyle == 'down') {
- $scope.$broadcast('scroll.refreshComplete');
- }
- } else {
- $scope.listShow = false;
- }
- //遮罩层关闭
- $ionicLoading.hide();
- }, function() {
- //遮罩层关闭
- $ionicLoading.hide();
- });
- }
- //页面加载
- // $scope.reload();
- //跳转成功刷新页面
- $scope.$on('$stateChangeSucess', $scope.reload())
- }])
|