'use strict'; app.controller('changeListCtrl', ["$scope","i18nService","$rootScope", "$state","$timeout" , "$interval", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", function ($scope,i18nService,$rootScope, $state,$timeout , $interval, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain) { $scope.langs=i18nService.getAllLangs(); $scope.lang = 'zh-cn'; i18nService.setCurrentLang($scope.lang); var pdKey = $state.current.pdKey; $scope.gridOptions = {}; $scope.gridOptions.data = 'myData'; $scope.gridOptions.enableColumnResizing = true; $scope.gridOptions.enableFiltering = true; $scope.gridOptions.enableGridMenu = true; $scope.gridOptions.enableRowSelection = true; $scope.gridOptions.showGridFooter = true; $scope.gridOptions.showColumnFooter = true; $scope.gridOptions.fastWatch = true; $scope.gridOptions.useExternalFiltering=true; $scope.gridOptions.useExternalPagination = true; $scope.gridOptions.paginationPageSizes = [10]; $scope.gridOptions.paginationPageSize = 10; $scope.gridOptions.multiSelect = false; // $scope.gridOptions.rowTemplate= "
"; // $scope.gridOptions.rowIdentity = function(row) { return row.id; }; $scope.gridOptions.getRowIdentity = function(row) { return row.id; }; $scope.gridOptions.columnDefs = [ { name:'changesign', displayName:'变更单号', width:80}, { name:'title', displayName:'变更标题', width:100}, { name:'requestingPerson.name', displayName:'请求人', width:100, enableFiltering:false}, { name:'registrationTime', displayName:'登记时间', width:120, enableFiltering:false}, { name:'source.name', displayName:'变更来源', width:100, enableFiltering:false}, { name:'type.name', displayName:'变更类型', width:100, enableFiltering:false}, { name:'classify.name', displayName:'变更分类', width:100, enableFiltering:false}, { name:'rickLevel.name', displayName:'风险等级', width:100, enableFiltering:false}, { name:'state.name', displayName:'状态', width:100, enableFiltering:false}, { name:'操作', cellTemplate:'', width:100,enableFiltering:false}]; $scope.gridOptions.onRegisterApi = function(gridApi){ $scope.gridApi = gridApi; gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { var filtersData = $scope.memoryfilterData; filtersData.idx=newPage-1; filtersData.sum=pageSize; $rootScope['idxchange']=newPage-1; $scope.refreshData('expand-right',filtersData); // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize}); }); gridApi.selection.on.rowSelectionChanged($scope, function(data){ //$scope.selected.item = data.entity; // console.log(data); }); gridApi.core.on.filterChanged($scope, function() { var grid = this.grid; var filtersData = { "assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, idx:0, sum:10 }; angular.forEach(grid.columns,function(item){ if(item.enableFiltering){ if(angular.isDefined(item.filters[0].term)&&item.filters[0].term!=''){ // console.log('item.filters[0]='+JSON.stringify(item.filters[0])); if(angular.isUndefined(filtersData['change'])){ filtersData['change']={}; } filtersData['change'][item.field]=item.filters[0].term; } } }); $scope.memoryfilterData = filtersData; $scope.refreshData('expand-right', filtersData); }); }; $scope.memoryfilterData = defaultFilterData = { "assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":0, "sum":10 }; $scope.selectRowFunction = function(data){ // console.log(data); // $state.go('app.process.modeler',{modelId:data.id}); $state.go('app.change.editor',{taskId:data.taskId,processInstanceId: data.processInstanceId}); }; $scope.lookFunction = function(data){ console.log('data='+JSON.stringify(data.id)); //$state.go('app.detail',{taskId:data.taskId,processInstanceId: data.processInstanceId}); $state.go('app.detail', { formKey:'changeDetail', pdKey:'change', dataId: data.id,taskId:data.taskId,processInstanceId: data.processInstanceId}); }; this.removeRowFunction = function(data){ //TODO $translate('key') SweetAlert.swal({ title: "确认删除?", text: "删除以后,你将不能恢复该数据!", type: "warning", cancelButtonText: "取消", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "确认删除!" }, function (isConfirm) { if (isConfirm) { // api_bpm_domain.removemodel(data.id).then(function(response){ // if(response){ // $scope.refreshData(); // SweetAlert.swal({ // title: "删除成功!", // confirmButtonColor: "#007AFF" // }); // } // }); }else{ } }); } //$scope.callsPending = 0; //var i = 0; var defaultFilterData = { "assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":0, "sum":10 }; if(angular.isDefined($rootScope['searchchange'])){ defaultFilterData['searchType']=$rootScope['searchchange']; $scope.searchTypes=$rootScope['searchchange']; // console.log($scope.searchTypes); } // $scope.searchTypeOptions = [ // {name:'请选择...', search:''}, // {name:'待我处理的变更', search:'todo'}, // {name:'我创建的变更', search:'create'}, // {name:'我处理过的变更', search:'done'}, // ]; // if(angular.isDefined($rootScope['idxchange'])){ // defaultFilterData.idx=$rootScope['idxchange']; // } $scope.ldloading = {}; $scope.refreshData = function(style, filterData){ $scope.ldloading[style.replace('-', '_')] = true; if(angular.isUndefined(filterData)){ filterData = defaultFilterData; } if(angular.isDefined($scope.searchTypes)){ filterData['searchType'] = $scope.searchTypes; $rootScope['searchchange']=$scope.searchTypes; } $scope.myData = []; //var start = new Date(); //var sec = $interval(function () { //$scope.callsPending++; api_bpm_domain.fetchtask(pdKey,filterData).then(function(data){ $scope.callsPending--; // console.log('filterData='+JSON.stringify(filterData)); var myData = Restangular.stripRestangular(data); $scope.gridOptions.totalItems = myData.totalNum; $scope.myData = myData.data; $scope.ldloading[style.replace('-', '_')] = false; },function(){ $scope.ldloading[style.replace('-', '_')] = false; }); }; $scope.refreshData('expand-right', defaultFilterData); }]); app.controller('ChangeOperCtrl', ['$rootScope','$http', '$scope', function ($rootScope,$http, $scope, $event) { // console.log('$rootScope.user3='+JSON.stringify($scope.item)); if( $scope.item.handlerUser!=null){ if ($rootScope.user.id==$scope.item.handlerUser.id) { $scope.item.chaozuoPower=true; } } $scope.look = function(){ $scope.colobject.grid.appScope.lookFunction($scope.item); // console.log('$scope.item='+JSON.stringify($scope.item)); } $scope.edit = function(){ $scope.colobject.grid.appScope.selectRowFunction($scope.item); // console.log('$scope.item='+JSON.stringify($scope.item)); $scope.doEdit($scope.item.id); } }]); app.directive('changeoperator', function () { return { restrict: 'E', scope: { item: '=', colobject: '=' }, controller: 'ChangeOperCtrl', template: '' }; });