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) { console.log('myKnowledgeCtrl is load'); $scope.goBack = function() { if ($scope.sessionLogin.tokenType == 'user') { $state.go('tab.handlerDashboard'); } else { $state.go('tab.requesterDashboard'); } } $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.refreshListData({ 'searchType': searchType, 'idx': 0, }); $scope.popover.hide(); } // $scope.loginForm = {}; // var loginUser = $rootScope.user; //获取login中的数据 // var sessionLogin = JSON.parse(sessionStorage.sessionLogin); // var loginUser = sessionLogin.user; //定义流程代号 // var pdKey = $state.current.pdKey; var pdKey = 'bpm_incident'; //默认数据 // var defaultData = { // 'assignee': loginUser.id, // 'idx': 0, // 'sum': 10, // }; //页面数据容器 $scope.myData = []; //是否加载上拉刷新 $scope.domore = false; //本地数据初始化 // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter); //搜索栏 $scope.searchSolution = function(searchInput) { if (!$scope.searchInput) { $scope.load.pageIndex = 0; } if ($scope.searchInput && $scope.load.pageIndex > 0) { $scope.load.pageIndex = 0; } $scope.refreshListData(); //遮罩层开启 // $ionicLoading.show({ // template: 'Loading...' // }); // if (angular.isString(searchInput) && searchInput != '') { // api_solution.queryBBSSolutions($scope.search.pageIndex, $scope.search.pageSum, 'createtime', loginUser.id, searchInput).then(function(response) { // var myData = Restangular.stripRestangular(response); // if (angular.isArray(myData.list) && myData.list.length > 0) { // $scope.myData = myData.list; // //计算总页数 // $scope.search.pageCount = Math.ceil(myData.totalNum / $scope.search.pageSum); // } else { // $ionicPopup.alert({ // title: '对不起,没有搜索到相关内容!', // }) // $scope.listShow = false; // } // //遮罩层关闭 // $ionicLoading.hide(); // }); // } } //新增数据 $scope.addData = function() { var data = JSON.parse(sessionStorage.incidentListMobileParameter); if (data.formUiEdit) { var formUiEdit = data.formUiEdit; }; if (data.formUiName) { var formUiName = data.formUiName; }; if (data.processKey) { var pdKey = data.processKey; }; if (data.formUiStart) { var formUiStart = data.formUiStart; }; if (pdKey) { $state.go('app.incidentMobile.incidentEditorMobile', { 'pdKey': pdKey, 'formUiEdit': formUiEdit, 'formUiName': formUiName, 'formUiStart': formUiStart, 'userId': data.status }); } else { SweetAlert.swal({ title: "当前服务类型不可新建", // text: myData.data, type: "warning" }); } }; //跳转到编辑列表 $scope.editorFunction = function(data) { // $state.go('app.inspection.inspectListEditor', { // "taskId": data.taskId, // "processInstanceId": data.processInstanceId, // "pdKey": data.processKey, // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit, // // "formUiName": data.inspection.inspectionTypeDTO.formUiName, // }); $state.go('app.incidentMobile.incidentEditorMobile', { taskId: data.taskId, processInstanceId: data.processInstanceId }); }; //跳转到查看列表 $scope.lookFunction = function(data) { $state.go('tab.myKnowledgeDetail', { 'item': JSON.stringify(data) }); }; //跳转到评论列表 $scope.listFunction = function(data) { // $state.go('tab.myKnowledgeList', { // 'item': JSON.stringify(data) // }); $state.go('tab.myKnowledgeList', { 'item': JSON.stringify(data) // 'id': data.id, // 'content': data.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.load.pageIndex += 1; //定时器 // var timer = null; //参数 // var filterData = defaultData; // angular.extend(filterData, { 'idx': $scope.filterData.idx }); //获取数据 $scope.refreshListData('', 'up'); //加载 // if (angular.isString($scope.searchInput) && $scope.searchInput != '') { // $scope.search.pageIndex += 1; // if ($scope.search.pageIndex < $scope.search.pageCount) { // // api_solution.queryBBSSolutions($scope.search.pageIndex, $scope.search.pageSum, "createtime", loginUser.id).then(function(data) { // api_solution.fetchDataList('solution', { 'idx': showData.idx, 'sum': showData.sum, 'solution': { 'searchType': 3 } }).then(function(data) { // var myData = Restangular.stripRestangular(data); // if (angular.isArray(myData.list) && myData.list.length > 0) { // angular.forEach(myData.list, function(item) { // $scope.myData.push(item); // }); // } // $scope.$broadcast('scroll.infiniteScrollComplete'); // }, function(data) { // }); // } else { // $scope.domore = true; // $scope.$broadcast('scroll.infiniteScrollComplete'); // } // } else { // $scope.load.pageIndex += 1; // if ($scope.load.pageIndex < $scope.load.pageCount) { // api_solution.fetchBBSSolutions($scope.load.pageIndex, $scope.load.pageSum, "createtime", loginUser.id).then(function(data) { // var myData = Restangular.stripRestangular(data); // if (angular.isArray(myData.list) && myData.list.length > 0) { // angular.forEach(myData.list, function(item) { // $scope.myData.push(item); // }); // } // $scope.$broadcast('scroll.infiniteScrollComplete'); // }, function(data) { // }); // } else { // $scope.domore = true; // $scope.$broadcast('scroll.infiniteScrollComplete'); // } // } }; //数据加载 $scope.isgetdata = true; $scope.refreshListData = function(filterData, loadStyle) { $scope.isgetdata = false; var searchType = 3; if ($scope.sessionLogin) { if ($scope.sessionLogin.tokenType == 'user') { searchType = 2; } } var solution = { 'searchType': searchType, }; if ($scope.sessionLogin) { if ($scope.sessionLogin.tokenType == 'user') { angular.extend(solution, { 'createUserId': $scope.loginUser.id }); } } if (angular.isString($scope.searchInput) && $scope.searchInput != '') { angular.extend(solution, { 'keywords': $scope.searchInput }); } //遮罩层开启 $ionicLoading.show({ template: 'Loading...' }); // api_solution.fetchBBSSolutions($scope.load.pageIndex, $scope.load.pageSum, "createtime", loginUser.id).then(function(data) { api_solution.fetchDataList('solution', { 'idx': $scope.load.pageIndex, 'sum': $scope.load.pageSum, solution }).then(function(data) { var myData = Restangular.stripRestangular(data); 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.myData = myData.list; $scope.$broadcast('scroll.refreshComplete'); } else if (loadStyle == 'up') { angular.forEach(myData.list, function(item) { $scope.myData.push(item); }); $scope.$broadcast('scroll.infiniteScrollComplete'); $scope.domore = true; } else { $scope.myData = myData.list; } } else { if (loadStyle == 'down') { $scope.$broadcast('scroll.refreshComplete'); } else if (loadStyle == 'up') { $scope.$broadcast('scroll.infiniteScrollComplete'); $scope.domore = true; } else { $scope.listShow = false; } } $scope.isgetdata = true; //遮罩层关闭 $ionicLoading.hide(); }, function() { //遮罩层关闭 $ionicLoading.hide(); }); } //页面加载 // $scope.reload(); //跳转成功刷新页面 // $scope.$on('$stateChangeSucess', $scope.reload()); if (!sessionStorage.sessionLogin) { var promise = getLoginUser.query(); promise.then(function(sessionLogin) { //返回成功 var sessionLogin = JSON.parse(sessionStorage.sessionLogin); var loginUser = sessionLogin.user; $scope.tokenType = sessionLogin.tokenType; $scope.sessionLogin = sessionLogin $scope.loginUser = sessionLogin.user; $rootScope.user = sessionLogin.user; // $scope.defaultData = { // 'assignee': loginUser.account, // 'idx': 0, // 'sum': 10, // // 'candidateGroups': loginUser.group["0"].id // }; // $scope.filterData = { // 'assignee': loginUser.account, // 'idx': 0, // 'sum': 10, // }; $scope.reload() }, function(data) { //返回失败 }); } else { var sessionLogin = JSON.parse(sessionStorage.sessionLogin); var loginUser = sessionLogin.user; $scope.tokenType = sessionLogin.tokenType; $scope.sessionLogin = sessionLogin $scope.loginUser = sessionLogin.user; $rootScope.user = sessionLogin.user; // $scope.defaultData = { // 'assignee': loginUser.account, // 'idx': 0, // 'sum': 10, // // 'candidateGroups': loginUser.group["0"].id // }; // $scope.filterData = { // 'assignee': loginUser.account, // 'idx': 0, // 'sum': 10, // }; $scope.reload() } }])