123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- 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 = '<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.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()
- }
- }])
|