123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- '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 = false;
- $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 = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: '50',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>',
- enableFiltering: false
- },
- {
- name: 'changesign',
- displayName: '变更单号',
- width: '8%',
- minWidth: '125',
- enableFiltering: false
- },
- {
- name: 'title',
- displayName: '变更标题',
- width: '12%',
- enableFiltering: false
- },
- {
- name: 'requestingPerson.name',
- displayName: '请求人',
- width: '8%',
- minWidth: '85',
- enableFiltering: false
- },
- {
- name: 'registrationTime',
- displayName: '登记时间',
- width: '10%',
- minWidth: '140',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.registrationTime)}}</div>' +
- '</div>'
- },
- {
- name: 'source.name',
- displayName: '变更来源',
- width: '10%',
- enableFiltering: false
- },
- {
- name: 'type.name',
- displayName: '变更类型',
- width: '7%',
- minWidth: '73',
- enableFiltering: false
- },
- {
- name: 'classify.name',
- displayName: '变更分类',
- width: '10%',
- enableFiltering: false
- },
- {
- name: 'rickLevel.name',
- displayName: '风险等级',
- width: '8%',
- enableFiltering: false
- },
- {
- name: 'state.name',
- displayName: '状态',
- width: '8%',
- enableFiltering: false
- },
- {
- name: '操作',
- cellTemplate: '<changeoperator item="row.entity" colobject="col">',
- width: '13%',
- enableFiltering: false
- }
- ];
- $scope.searchstate = 'todo';
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $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.clear = function () {
- $scope.searchkeys = {};
- var fildata = JSON.parse(sessionStorage.getItem("searchchange"));
- fildata.assignee = $rootScope.user.id;
- fildata.candidateGroups = $rootScope.user.group[0].id;
- fildata.idx = 0;
- fildata.sum = 10;
- delete fildata.change;
- // $scope.try_async_load();
- // 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("searchchange");
- $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.searchchange) {
- fildata = JSON.parse(sessionStorage.getItem("searchchange"));
- $scope.gridOptions.paginationCurrentPage = 1;
- fildata.idx = 0;
- } else {
- fildata = defaultFilterData;
- }
- // $scope.memoryfilterData = fildata;
- if (!fildata.change) {
- fildata['change'] = {};
- }
- // 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) {
- if (!fildata.change) {
- fildata.change = {};
- }
- var transitiondata = angular.copy(item);
- angular.extend(fildata.change, transitiondata)
- sessionStorage['searchchange'] = 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;
- $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,
- // "searchType": "all",
- "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,dataId:data.id });
- };
- $scope.onDblClick = 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.entity.id,
- taskId: data.entity.taskId,
- processInstanceId: data.entity.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,
- // "searchType": "all",
- "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.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('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: '<div class="cl-effect-1 ui-grid-cell-contents">' +
- // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
- '<a ng-click="edit()" class="bianjifont" ng-show="{{item.chaozuoPower}}" >处理</a>' +
- '</div>'
- };
- });
|