123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- 'use strict';
- app.controller('cmdbCtrl', ["$rootScope","$scope", "$state", "$timeout", "$interval", 'i18nService',"SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", function ($rootScope, $scope, $state, $timeout, $interval,i18nService, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain) {
- var pdKey = $state.current.pdKey;
- $scope.langs=i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $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.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $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;
- };
- // '<a class="btn btn-sm btn-warning" ng-click="grid.appScope.pdList.removeRowFunction(row.entity)">' + '<i class="fa fa-trash"/></a>'
- $scope.gridOptions.columnDefs = [
- { name:'configuresign', displayName:'资产流水号', width:140, enableFiltering:false},
- { name:'configureName', displayName:'资产标题', width:140},
- { name:'initUser.name', displayName:'创建人', width:100, enableFiltering:false},
- { name:'registrationTime', displayName:'登记时间', width:100, enableFiltering:false},
- { name:'configureClassfy.name', displayName:'资产分类', width:100, enableFiltering:false},
- { name:'configureStage.name', displayName:'状态', width:100, enableFiltering:false},
- { name:'操作', cellTemplate:'<cmdbcpertor item="row.entity" colobject="col">', width:100,enableFiltering:false}];
- // cellTemplate:'<a class="btn btn-sm btn-info" ' +
- // 'ng-click="grid.appScope.pdList.selectRowFunction(row.entity)">' +
- // '<i class="fa fa-pencil-square-o"/></a>' , enableFiltering:false}
- // ];
- // $scope.gridOptions.importerDataAddCallback = function( grid, newObjects ) {
- // $scope.myData = $scope.myData.concat( newObjects );
- // console.log($scope);
- // };
-
-
- $scope.gridOptions.onRegisterApi = function(gridApi){
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- console.log(newPage);
- console.log(pageSize);
- $scope.refreshData('expand-right',{"assignee":$rootScope.user.id, "idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(data){
- //$scope.selected.item = data.entity;
- console.log(data);
- });
- };
- // $scope.gridOptions.appScopeProvider = {
- // onDblClick : function(row) {
- // $state.go('app.form.detail',{data:row, formKey:'changeDetail', pdKey:'change'});
- // //var url = '//google.com';
- // //$window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
- // }
- // };
- $scope.selectRowFunction = function(data){
- console.log(data);
- // $state.go('app.process.modeler',{modelId:data.id});
- $state.go('app.cmdb.modeler',{taskId:data.taskId,processInstanceId: data.processInstanceId});
- };
- $scope.onDblClick = function(data){
- $state.go('app.detail', { formKey:'cmdbDetail', pdKey:'configure', dataId: data.id,processInstanceId: data.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: "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" ui-grid-cell ></div>"
- */
- 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,
- "idx":0,
- "sum":10,
- };
- if(angular.isDefined($rootScope['searchcmdb'])){
- defaultFilterData['searchType']=$rootScope['searchcmdb'];
- $scope.searchTypes=$rootScope['searchcmdb'];
- }
- $scope.ldloading = {};
- $scope.refreshData = function(style, filterData){
- $scope.ldloading[style.replace('-', '_')] = true;
- console.log($scope.ldloading.expand_right)
- if(angular.isUndefined(filterData)){
- filterData = defaultFilterData;
- }
- if(angular.isDefined($scope.searchTypes)){
- filterData['searchType'] = $scope.searchTypes;
- $rootScope['searchcmdb']=$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--;
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.resultCount;
- $scope.myData = myData.data;
- $scope.ldloading[style.replace('-', '_')] = false;
- },function(){
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- //}, 200, 1);
- // var timeout = $timeout(function() {
- // $interval.cancel(sec);
- // $scope.left = '';
- // }, 2000);
- // $scope.$on('$destroy', function(){
- // $timeout.cancel(timeout);
- // $interval.cancel(sec);
- // });
- };
- $scope.refreshData('expand-right', defaultFilterData);
- }]);
- app.controller('CmdbOperCtrl', ['$rootScope','$http', '$scope', function ($rootScope,$http, $scope, $event) {
- // console.log($scope.item);
- if( $scope.item.handlerUser!=null){
-
- if ($rootScope.user.id==$scope.item.handlerUser.id) {
- $scope.item.chaozuoPower=true;
-
- }
- }
-
-
- $scope.view = function(){
- $scope.colobject.grid.appScope.onDblClick($scope.item);
- }
- $scope.edit = function(){
- $scope.colobject.grid.appScope.selectRowFunction($scope.item);
- // $scope.doEdit($scope.item.id);
- }
-
- }]);
- app.directive('cmdbcpertor', function () {
- return {
- restrict: 'E',
- scope:
- {
- item: '=',
- colobject: '='
- },
- controller: 'CmdbOperCtrl',
- template: '<div class="links cl-effect-1">' +
- '<a ng-click="view()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>'+
- '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>'+
- '</div>'
- };
- });
|