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

My Popover Title

Hello!
'; // $scope.popover = $ionicPopover.fromTemplate(template, { // scope: $scope // }); // if ($scope.item.state == 0 && $rootScope.user.id && $rootScope.user.id == $scope.item.handlerUser.id) { // $scope.item.chaozuoPower = true; // } // if ($scope.item.state.id != null && $scope.item.handlerUser != null) { // if ($rootScope.user.id == $scope.item.handlerUser.id) { // $scope.item.chaozuoPower = true; // } // } $scope.look = function(item) { if (item.state == 0 && $rootScope.user.id && $rootScope.user.id == item.handlerUser.id) { $scope.editorFunction(item); } else { $scope.lookFunction(item); } }; // $scope.edit = function() { // $scope.editorFunction($scope.item); // }; // .fromTemplateUrl() method $scope.goBack = function() { $state.go('tab.handlerDashboard'); } $scope.newFunction = function() { $state.go('tab.customFormIndex', { 'formKey': 'requestMobileEditor' }); }; $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(res) { // Execute action }); // Execute action on remove popover $scope.$on('popover.removed', function() { // Execute action }); $scope.statuses = [ { status: 'all', label: '全部', idName: 'a', active: false }, { status: 'todo', label: '待处理', idName: 'b', active: true }, // { status: 'create', label: '我创建的', idName: 'c' }, { status: 'done', label: '已处理', idName: 'd', active: false }, // { status: 's', label: '已驳回', idName: 'e' }, // { status: '6', label: '已拒绝', idName: 'f' } ]; $scope.searchstate = { status: 'todo', label: '待处理', idName: 'b', active: true }; $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({ 'searchType': searchType, 'idx': 0 }); } // 一个精心制作的自定义弹窗 // var myPopup = $ionicPopup.show({ // template: '', // title: 'Enter Wi-Fi Password', // subTitle: 'Please use normal things', // scope: $scope, // buttons: [ // { text: 'Cancel' }, // { // text: 'Save', // type: 'button-positive', // onTap: function(e) { // if (!$scope.data.wifi) { // //不允许用户关闭,除非他键入wifi密码 // e.preventDefault(); // } else { // return $scope.data.wifi; // } // } // }, // ] // }); // myPopup.then(function(res) { // console.log('Tapped!', res); // }); // $timeout(function() { // myPopup.close(); //由于某种原因3秒后关闭弹出 // }, 3000); // 一个确认对话框 $scope.showConfirm = function() { var confirmPopup = $ionicPopup.confirm({ title: 'Consume Ice Cream', template: 'Are you sure you want to eat this ice cream?' }); confirmPopup.then(function(res) { if (res) { console.log('You are sure'); } else { console.log('You are not sure'); } }); }; //状态选择 $scope.searchstate = { status: 'todo', label: '待处理', idName: 'b', active: true }; $scope.inputclick = function() { var modalInstance = $aside.open({ templateUrl: 'assets/views/customform/tpl/bottomlist.html', placement: 'bottom', backdrop: true, controller: function($scope, $modalInstance, scope) { $scope.statuses = [ { status: 'all', label: '全部', idName: 'a', active: false }, { status: 'todo', label: '待处理', idName: 'b', active: true }, { status: 'done', label: '已处理', idName: 'd', 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({ 'searchType': selectedItem.status, 'idx': 0 }); }); } // 一个提示对话框 $scope.showAlert = function() { var alertPopup = $ionicPopup.alert({ title: 'Don\'t eat that!', template: 'It might taste good' }); alertPopup.then(function(res) { console.log('Thank you for not eating my delicious ice cream cone'); }); }; // $scope.loginForm = {}; // var loginUser = $rootScope.user; //获取login中的数据 // var sessionLogin = JSON.parse(sessionStorage.sessionLogin); // var loginUser = sessionLogin.user; // $rootScope.user = sessionLogin.user; //定义流程代号 // var pdKey = $state.current.pdKey; var pdKey = 'bpm_incident'; // var incidentListMobileParameter = { // 'assignee': loginUser.id, // 'idx': 0, // 'sum': 10, // 'status': '', // 'count': 0, // 'currentPage': 1, // 'endPage': 0, // 'pages': [] // }; //默认数据 // 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.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('tab.reServiceCustomFormIndex', { "taskId": data.taskId, "processInstanceId": data.processInstanceId, "pdKey": data.processKey, "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit, // "formUiName": data.inspection.inspectionTypeDTO.formUiName, }); }; //跳转到查看列表 $scope.lookFunction = function(data) { $state.go('tab.reServiceCustomFormDetail', { "formKey": data.inspection.inspectionTypeDTO.formUiName, "dataId": data.id, "taskId": data.taskId, "processInstanceId": data.processInstanceId, "pdKey": data.processKey, // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit, "formUiName": data.inspection.inspectionTypeDTO.formUiName, }); }; //页面刷新 $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 filterData = $scope.defaultData; angular.extend(filterData, { 'idx': $scope.load.pageIndex }); //加载 if ($scope.load.pageIndex < $scope.load.pageCount) { api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) { var myData = Restangular.stripRestangular(data); if (myData.pageIndex <= myData.pageCount) { 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.refreshListData = function(filterData, loadStyle) { //获取本地数据 // 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 }); // }; //遮罩层开启 $ionicLoading.show({ template: 'Loading...' }); // api_bpm_data.fetchServiceTasks(showData.status, showData).then(function(data) { api_bpm_data.fetchInspectServiceTasks(showData.status, showData).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.myData = myData.data; $scope.load.pageIndex = myData.pageIndex; $scope.load.pageCount = myData.pageCount; 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; //遮罩层关闭 $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, 'idx': 0, 'sum': 10, // 'candidateGroups': loginUser.group["0"].id }; $scope.filterData = { 'assignee': loginUser.id, 'idx': 0, 'sum': 10, }; $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, 'idx': 0, 'sum': 10, // 'candidateGroups': loginUser.group["0"].id }; $scope.filterData = { 'assignee': loginUser.id, 'idx': 0, 'sum': 10, }; $scope.reload() } }]); app.controller('handlerExtendCtrl', ['$scope', '$rootScope', '$http', function($scope, $rootScope, $http) { //判断当前事件状态 // if ($scope.item.state.id != null && $scope.item.state.id != 6 && $scope.item.handlerUser != null) { // if ($rootScope.user.id && $rootScope.user.id == $scope.item.handlerUser.id) { // $scope.item.chaozuoPower = true; // } else { // // angular.forEach($rootScope.user.group, function(userItem) { // // angular.forEach($scope.item.handlerUser.group, function(handlerUserItem) { // // if (handlerUserItem == userItem.id) { // // $scope.item.chaozuoPower = true; // // } // // }); // // }); // } // } // if ($scope.item.state && $scope.item.state != null) { // $scope.item.chaozuoPower = true; // } if ($scope.item.state == 0 && $rootScope.user.id && $rootScope.user.id == $scope.item.handlerUser.id) { $scope.item.chaozuoPower = true; } // if ($scope.item.state.id != null && $scope.item.handlerUser != null) { // if ($rootScope.user.id == $scope.item.handlerUser.id) { // $scope.item.chaozuoPower = true; // } // } $scope.look = function() { $scope.$parent.$parent.$parent.lookFunction($scope.item); }; $scope.edit = function() { $scope.$parent.$parent.$parent.editorFunction($scope.item); }; }]);