app.controller('myIncidentCtrl', ["$rootScope", "$scope", '$aside', '$stateParams', '$http', '$state', '$stateParams', '$timeout', '$ionicPopover', '$ionicLoading', '$ionicScrollDelegate', 'api_bpm_domain', 'Restangular', 'getLoginUser', function($rootScope, $scope, $aside, $stateParams, $http, $state, $stateParams, $timeout, $ionicPopover, $ionicLoading, $ionicScrollDelegate, api_bpm_domain, Restangular, getLoginUser) { console.log('myIncidentCtrl is load'); //弹出框 // var template = '

My Popover Title

Hello!
'; // $scope.popover = $ionicPopover.fromTemplate(template, { // scope: $scope // }); // .fromTemplateUrl() method // if(){ // } $scope.statecolor = []; $scope.goBack = function() { $state.go('tab.requesterDashboard'); } $scope.load = { 'pageIndex': 0, //第几页 'pageSum': 10, //每页条数 'pageCount': 0 //总页数 }; $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: -2, label: '全部', idName: 'a', active: false }, { status: 0, label: '未受理', idName: 'b', active: true }, { status: 2, label: '处理中', idName: 'c', active: false }, { status: 3, label: '待评价', idName: 'd', active: false }, { status: 4, label: '已解决', idName: 'e', active: false } // { status: 's', label: '已驳回', idName: 'e' }, // { status: '6', label: '已拒绝', idName: 'f' } ]; $scope.searchstate = { status: -2, label: '全部', idName: 'a', active: false }; $scope.inputclick = function() { var modalInstance = $aside.open({ // templateUrl: 'assets/views/customform/tpl/searchright.html', templateUrl: 'assets/views/customform/tpl/bottomlist.html', placement: 'bottom', backdrop: true, controller: function($scope, $modalInstance, scope) { $scope.statuses = [ { status: -2, label: '全部', idName: 'a', active: false }, { status: 0, label: '未受理', idName: 'b', active: true }, { status: 2, label: '处理中', idName: 'c', active: false }, { status: 3, label: '待评价', idName: 'd', active: false }, { status: 4, label: '已解决', idName: 'e', active: false }, ]; $scope.ok = function(item) { $modalInstance.close(item); } $scope.cancel = function() { $modalInstance.dismiss('cancel'); } }, size: 'sm', resolve: { scope: function() { return $scope; } } }); modalInstance.result.then(function(selectedItem) { $ionicScrollDelegate.scrollTop(); $scope.searchstate = selectedItem; angular.forEach($scope.statuses, function(item) { if (selectedItem.status == item.status) { item.active = true; } else { item.active = false; } }) $scope.refreshListData({ 'state': selectedItem.status, 'idx': 0 }); }); } $scope.searchTypeFunction = function(searchType) { $ionicScrollDelegate.scrollTop(); angular.forEach($scope.statuses, function(item) { if (searchType == item.status) { item.active = true; } else { item.active = false; } }) $scope.refreshListData({ 'state': -2, 'idx': 0 }); } // $scope.loginForm = {}; // var loginUser = $rootScope.user; //获取login中的数据 // var sessionLogin = JSON.parse(sessionStorage.sessionLogin); // var loginUser = sessionLogin.user; //定义流程代号 // var pdKey = $state.current.pdKey; var pdKey = ''; // var incidentListMobileParameter = { // 'assignee': loginUser.id, // 'idx': 0, // 'sum': 10, // 'status': '', // 'count': 0, // 'currentPage': 1, // 'endPage': 0, // 'pages': [] // }; //默认数据 // var defaultData = { // 'assignee': loginUser.account, // 'idx': 0, // 'sum': 10, // }; //页面数据容器 $scope.myData = []; //是否加载上拉刷新 $scope.domore = false; //填充数据 // $scope.filterData = { // 'assignee': loginUser.account, // 'idx': 0, // 'sum': 10, // }; $scope.newFunction = function() { $state.go('tab.customFormIndex', { 'formKey': 'requestMobileEditor' }); }; //本地数据初始化 // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter); //新增数据 $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.incidentHandlerCustomFormDetail', { // "formKey": 'requester_detail', // "pdKey": 'bpm_incident', // "dataId": data.id, // "taskId": data.taskId, // "processInstanceId": data.processInstanceId // }); $state.go('tab.myIncidentDetail', { 'item': JSON.stringify(data) }); }; //跳转到评价页面 $scope.degreeFunction = function(data) { $state.go('tab.requesterDegree', { "formKey": 'requesterDegree', "incidentid": data.id, }); }; //页面刷新 $scope.reload = function() { $scope.refreshListData(); } //下拉刷新 $scope.doRefresh = function() { $scope.filterData.idx = 0; var idx = { 'idx': $scope.filterData.idx } $scope.refreshListData(idx, 'down'); $scope.domore = false; }; //上拉加载 $scope.loadMore = function() { //开启上拉加载 $scope.domore = false; //数据列表加1 // $scope.filterData.idx += 1; $scope.load.pageIndex += 1; //定时器 var timer = null; //参数 var showData = $scope.defaultData; angular.extend(showData, { 'idx': $scope.load.pageIndex }); //加载 // api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) { if ($scope.load.pageIndex < $scope.load.pageCount) { api_bpm_domain.weChatFetchServiceTasks(pdKey, showData).then(function(data) { var myData = Restangular.stripRestangular(data); $scope.statecolor(myData.data); if (angular.isArray(myData.data) && myData.data.length > 0) { angular.forEach(myData.data, 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.isgetdata = true; //数据加载 $scope.refreshListData = function(filterData, loadStyle) { $scope.isgetdata = false; //获取本地数据 // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter); //对接口参数进行重新组装 // var showData = { // 'assignee': filterData.assignee, // // 'idx': filterData.currentPage ? filterData.currentPage - 1 : 0, // 'idx': filterData.idx, // 'searchType': filterData.searchType, // 'status': filterData.status, // 'sum': filterData.sum, // }; var showData = {}; if (filterData) { showData = angular.extend($scope.defaultData, filterData); } else { showData = $scope.defaultData; } // if (filterData.candidateGroups) { // angular.extend(showData, { 'candidateGroups': filterData.candidateGroups }); // }; // api_bpm_domain.fetchtask(pdKey, showData).then(function(data) { //遮罩层开启 $ionicLoading.show({ template: 'Loading...' }); $scope.statecolor = function(myData) { angular.forEach(myData, function(item, index) { if (item.state == '未受理') { myData[index].statecolor = "state-wrap-basetwo" } else if (item.state == "处理中") { myData[index].statecolor = "state-wrap-basethree" } else if (item.state == "待评价") { myData[index].statecolor = "state-wrap-basefour" } else if (item.state == "已解决") { myData[index].statecolor = "state-wrap-baseone" } }); } // var ceshi={"assignee":"dsadmin","idx":"0","state":"-2","sum":"10"}; api_bpm_domain.weChatFetchServiceTasks(pdKey, showData).then(function(data) { // api_bpm_domain.weChatFetchServiceTasks(pdKey, ceshi).then(function(data) { var myData = Restangular.stripRestangular(data); // filterData.count = myData.resultCount; // if (angular.isArray(myData.data) && myData.data.length > 0) { if (angular.isArray(myData.data)) { $scope.statecolor(myData.data); $scope.myData = myData.data; $scope.load.pageIndex = myData.pageIndex; $scope.load.pageCount = Math.ceil(myData.resultCount / myData.pageSize); if (loadStyle == 'down') { $scope.$broadcast('scroll.refreshComplete'); } } else { // SweetAlert.swal({ // title: "数据为空", // text: myData.data, // type: "warning" // }); // if ($scope.paginationList || $scope.paginationList.count) { // $scope.paginationList.count = 0; // } $scope.listShow = false; } $scope.domore = 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) { //返回成功 $scope.tokenType = sessionLogin.tokenType; var sessionLogin = JSON.parse(sessionStorage.sessionLogin); var loginUser = sessionLogin.user; $scope.sessionLogin = sessionLogin $rootScope.user = sessionLogin.user; $scope.defaultData = { 'assignee': loginUser.id, // 'account': loginUser.account, 'idx': 0, 'sum': 10, 'state': -2, // 'candidateGroups': loginUser.group["0"].id }; $scope.filterData = { 'assignee': loginUser.id, // 'account': loginUser.account, 'idx': 0, 'sum': 10, 'state': -2 }; if (sessionStorage.getItem("toMyIncident") || sessionStorage.getItem("toMyIncident") != null) { var toMyIncident = JSON.parse(sessionStorage.getItem("toMyIncident")); if (toMyIncident.isClick == true) { $scope.searchTypeFunction(toMyIncident.searchType); sessionStorage.setItem("toMyIncident", null); } } else { $scope.reload() } }, function(data) { //返回失败 }); } else { var sessionLogin = JSON.parse(sessionStorage.sessionLogin); var loginUser = sessionLogin.user; $scope.sessionLogin = sessionLogin $rootScope.user = sessionLogin.user; $scope.defaultData = { 'assignee': loginUser.id, // 'account': loginUser.account, 'idx': 0, 'sum': 10, 'state': -2, // 'candidateGroups': loginUser.group["0"].id }; $scope.filterData = { 'assignee': loginUser.id, // 'account': loginUser.account, 'idx': 0, 'sum': 10, 'state': -2 }; if (sessionStorage.getItem("toMyIncident")) { var toMyIncident = JSON.parse(sessionStorage.getItem("toMyIncident")); if (toMyIncident.isClick == true) { $scope.searchTypeFunction(toMyIncident.searchType); sessionStorage.removeItem("toMyIncident"); } } else { $scope.reload() } } }]); //过滤状态 // app.filter('filterStatus', function() { // return function(text) { // if (text == '待接单' || text == '未受理') { // return '待受理' // } else if (text == '请求重新分派' || text == '处理中' || text == '待审核') { // return '受理中' // } else if (text == '已解决') { // return '待评价' // } else if (text == '已关闭' || text == '不受理') { // return '已关闭' // } // } // });