'use strict'; app.controller('problemListCtrl', ["$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, 20, 50, 100]; $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: 'item', displayName: '序号', width: '5%', cellTemplate: '
' + '
{{row.entity.item}}
' + '
', enableFiltering: false }, { name: 'problemsign', displayName: '问题单号', width: '125', enableFiltering: false }, { name: 'title', displayName: '问题标题', width: '10%', enableFiltering: false }, { name: 'proposePerson.name', displayName: '问题提出人', width: '10%', enableFiltering: false }, { name: 'incident.incidentsign', displayName: '关联事件单号', width: '130', enableFiltering: false }, { name: 'des', displayName: '问题描述', width: '15%', enableFiltering: false }, { name: 'influence', displayName: '问题影响', width: '15%', enableFiltering: false }, { name: 'priority.name', displayName: '优先级', width: '6%', minWidth:'55', enableFiltering: false }, { name: 'manager.name', displayName: '问题经理', width: '8%', minWidth:'75', enableFiltering: false }, { name: 'largeClassification.name', displayName: '问题大类', width: '9%', minWidth:'83', enableFiltering: false }, { name: 'currentStage.name', displayName: '问题状态', width: '8%', minWidth:'75', enableFiltering: false }, { name: 'openingTime', displayName: '问题开启时间', width: '12%', minWidth: '150', enableFiltering: false, cellTemplate: '
' + '
{{grid.appScope.transferTime(row.entity.openingTime)}}
' + '
' }, { name: '操作', cellTemplate: '', width: 100, enableFiltering: false } ]; $scope.searchstate = 'todo'; $scope.states = [{ id: "all", name: '全部的问题' }, { id: "todo", name: '待我处理的问题' }, { id: "create", name: '我创建的问题' }, { id: "done", name: '我处理过的问题' } ]; $scope.onChange = function (searchType) { $scope.searchstate = searchType; defaultFilterData = $scope.memoryfilterData; defaultFilterData['searchType'] = searchType; $scope.refreshData('expand-right', defaultFilterData); } $scope.transferTime = function(time) { return moment(time).format('YYYY-MM-DD HH:mm'); } $scope.clear = function () { $scope.searchkeys = {}; // $scope.try_async_load(); var fildata = JSON.parse(sessionStorage.getItem("searchproblem")); fildata.assignee = $rootScope.user.id; fildata.candidateGroups = $rootScope.user.group[0].id; fildata.idx = 0; fildata.sum = 10; delete fildata.problem; // var fildata = { // // "assignee": $rootScope.user.id, // // "candidateGroups": loginuserGroup, // // "searchType": JSON.parse(sessionStorage.getItem("searchproblem")).searchType, // // "idx": JSON.parse(sessionStorage.getItem("searchproblem")).idx, // // "sum": JSON.parse(sessionStorage.getItem("searchproblem")).sum // "assignee": $rootScope.user.id, // "candidateGroups": $rootScope.user.group[0].id, // "idx": 0, // "sum": 10, // } sessionStorage.removeItem("searchproblem"); $scope.memoryfilterData = fildata; $scope.refreshData('expand-right', fildata); } $scope.chiceIncident = function (item, stateid) { // if (stateid && stateid.code) { // item.statusId = stateid.code; // } else { // item.statusId = undefined; // } var fildata = {}; if (sessionStorage.searchproblem) { fildata = JSON.parse(sessionStorage.getItem("searchproblem")); $scope.gridOptions.paginationCurrentPage = 1; fildata.idx = 0; } else { fildata = defaultFilterData; } // $scope.memoryfilterData = fildata; if (!fildata.problem) { fildata['problem'] = {}; } // if (item.acceptDate) { // item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD HH:mm:ss'); // } // if (item.acceptDateEnd) { // // item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD HH:mm:ss'); // item.acceptDateEnd = moment(new Date(item.acceptDateEnd).getTime() + 86399999).format('YYYY-MM-DD HH:mm:ss'); // } if (item) { var transitiondata = angular.copy(item); angular.extend(fildata.problem, transitiondata) sessionStorage['searchproblem'] = angular.copy(JSON.stringify(fildata)); } $scope.memoryfilterData = fildata; $scope.refreshData('expand-right', fildata); } $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; $scope.refreshData('expand-right', filtersData); }); 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['problem'])) { filtersData['problem'] = {}; } filtersData['problem'][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.problem.editor', { taskId: data.taskId, processInstanceId: data.processInstanceId,dataId:data.id}); }; $scope.onDblClick = function (data) { //console.log(row.entity); $state.go('app.detail', { formKey: 'problemDetail', pdKey: 'problem', dataId: data.entity.id, taskId: data.entity.taskId, processInstanceId: data.entity.processInstanceId }); }; /* appScopeProvider: { onDblClick : function(row) { var url = '//google.com'; $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no"); } }, rowTemplate: "
" */ 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['searchproblem'])) { defaultFilterData['searchType'] = $rootScope['searchproblem']; $scope.searchTypes = $rootScope['searchproblem'] } $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['searchproblem'] = $scope.searchTypes; sessionStorage['searchproblem'] = $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.resultCount; $scope.myData = myData.data; $scope.ldloading[style.replace('-', '_')] = false; for (var i = 0; i < $scope.myData.length; i++) { $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum } }, function () { $scope.ldloading[style.replace('-', '_')] = false; }); }; $scope.refreshData('expand-right', defaultFilterData); }]); app.controller('ProblemOperCtrl', ['$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.onDblClick($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('problemoperator', function () { return { restrict: 'E', scope: { item: '=', colobject: '=' }, controller: 'ProblemOperCtrl', template: '' }; });