123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- 'use strict';
- app.controller('cmdbauditlistCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_bpm", "api_bpm_data", "api_user_data", function($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_bpm, api_bpm_data, api_user_data) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.myData = [];
- var loginUser = $rootScope.user;
- var loginuserGroup = "";
- for (var i = 0; i < $rootScope.user.group.length; i++) {
- if (i == 0) {
- loginuserGroup = $rootScope.user.group[i].id;
- } else {
- loginuserGroup = loginuserGroup + "," + $rootScope.user.group[i].id;
- }
- }
- var pdKey = $state.current.pdKey;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableSelectAll = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.enableSorting = true;
- $scope.gridOptions.useExternalSorting = true;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- var mun = $scope.gridOptions.paginationPageSize;
- // $scope.gridOptions.rowTemplate = "<div ng-click=\"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.transferstatus = function(item) {
- var statecolor = "待处理";
- if (item == 1) { //待处理
- statecolor = "待处理";
- } else if (item == 2) { //已处理
- statecolor = "已处理";
- }
- return statecolor;
- }
- $scope.gridOptions.columnDefs = [
- // {
- // name: 'id',
- // displayName: '',
- // width: 40,
- // cellTemplate: '<div>' +
- // '<div class="ui-grid-cell-contents" tooltip={{grid.appScope.transfertip(row.entity)}} tooltip-placement="right"><i style="font-size: 18px !important;" class="{{grid.appScope.transferColor(row.entity)}}"></i></div></div>' +
- // '</div>'
- // },
- {
- name: 'item',
- displayName: '序号',
- width: 50,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'orderId',
- displayName: '审计单号',
- width: '25%',
- enableSorting: false
- },
- {
- name: 'user.name',
- displayName: '审计执行人',
- width: '15%',
- enableSorting: false
- },
- {
- name: 'time',
- displayName: '审计时间',
- width: '20%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.time)}}</div>' +
- '</div>'
- },
- {
- name: 'status',
- displayName: '状态',
- width: '15%',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.transferstatus(row.entity.status)}}</div>' +
- '</div>'
- },
- { name: '操作', enableSorting: false, cellTemplate: '<cmdblistoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">', enableFiltering: false },
- ];
- $scope.value = 10;
- $scope.decrement = function() {
- $scope.value = $scope.value - 1;
- };
- $scope.record = function() {
- api_text.record($rootScope.takes).then(function(data) {
- if (data.errno == 0) {
- $scope.busy = false;
- }
- })
- };
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $scope.parameters = null;
- $scope.open = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.othcode = {};
- $scope.searchkeys = {};
- //状态
- $scope.state = [{ id: 1, name: "待处理" }, { id: 2, name: "已处理" }];
- // api_bpm_data.fetchDataList('incidentstatus', { "idx": 0, "sum": 100 }).then(function(response) {
- // if (response) {
- // if (response.status = 200) {
- // $scope.state = response.list;
- // if (sessionStorage.searchcmdbau && JSON.parse(sessionStorage.getItem("searchcmdbau")).comptroller) {
- // angular.forEach($scope.state, function(item) {
- // if (item.code == JSON.parse(sessionStorage.getItem("searchcmdbau")).comptroller.statusId) {
- // $scope.othcode = { "state": item };
- // }
- // })
- // }
- // }
- // }
- // })
- if (sessionStorage.searchcmdbau && JSON.parse(sessionStorage.getItem("searchcmdbau")).comptroller) {
- if (JSON.parse(sessionStorage.getItem("searchcmdbau")).comptroller) {
- $scope.searchkeys = JSON.parse(sessionStorage.getItem("searchcmdbau")).comptroller;
- }
- if ($scope.searchkeys.startDate) {
- $scope.searchkeys.startDate = new Date($scope.searchkeys.startDate);
- }
- if ($scope.searchkeys.endDate) {
- $scope.searchkeys.endDate = new Date($scope.searchkeys.endDate);
- }
- }
- //刷新
- $scope.clear = function() {
- $scope.searchkeys = {};
- $scope.othcode = {};
- var fildata = {
- "idx": JSON.parse(sessionStorage.getItem("searchcmdbau")).idx,
- "sum": JSON.parse(sessionStorage.getItem("searchcmdbau")).sum
- }
- sessionStorage.removeItem("searchcmdbau");
- $scope.memoryfilterData = fildata;
- $scope.refreshData('expand-right', $scope.fileData);
- }
- $scope.searchkeys={};
- $scope.fileData={
- "idx":0,
- "sum":10,
- "comptroller":{
- }
- }
- // 重置
- $scope.reset=function(){
- $scope.searchkeys={};
- $scope.fileData.comptroller={};
- $scope.refreshData('expand-right', $scope.fileData);
- }
- $scope.chiceIncident = function(item) {
- var fildata = {};
- if (sessionStorage.searchcmdbau) {
- fildata = JSON.parse(sessionStorage.getItem("searchcmdbau"));
- $scope.gridOptions.paginationCurrentPage = 1;
- fildata.idx = 0;
- } else {
- fildata = defaultFilterData;
- }
- // $scope.memoryfilterData = fildata;
- if (!fildata.comptroller) {
- fildata['comptroller'] = {};
- }
- if (item.startDate) {
- item.startDate = moment(item.startDate).format('YYYY-MM-DD HH:mm:ss');
- }
- if (item.endDate) {
- item.endDate = moment(item.endDate).format('YYYY-MM-DD 23:59:59')
- }
- var transitiondata = angular.copy(item);
- angular.extend(fildata.comptroller, transitiondata)
- sessionStorage['searchcmdbau'] = angular.copy(JSON.stringify(fildata));
- $scope.memoryfilterData = fildata;
- $scope.fileData.comptroller=item;
- $scope.refreshData('expand-right', $scope.fileData);
- }
- //受理人,处理人
- var getUser = function(fieldatas, it) {
- api_user_data.fetchDataList('user', fieldatas).then(function(data) {
- if (it == 1) {
- $scope.acceptUser = data.list;
- } else if (it == 2) {
- $scope.handlingPersonnelUser = data.list;
- // } else if (it == 3) {
- // $scope.acceptUser = data.list;
- // $scope.handlingPersonnelUser = data.list;
- }
- });
- }
- // var fieldata = { "idx": 0, "sum": 10, "flag": -1 };
- // getUser(fieldata, 3);
- //受理人过滤
- $scope.onChangeacceptUser = function(key) {
- var filuser = {
- "idx": 0,
- "sum": 10,
- "flag": -1,
- "user": { "flag": -1, "name": key,engineer: 1, }
- }
- getUser(filuser, 1);
- }
- //处理人过滤
- $scope.onChangehandling = function(key) {
- var filuser = {
- "idx": 0,
- "sum": 10,
- "flag": -1,
- "user": { "flag": -1, "name": key,engineer: 1, }
- }
- getUser(filuser, 2);
- }
- $scope.starttime = function(data) {
- return moment(new Date(data)).format('YYYY-MM-DD')
- }
- $scope.overtime = function(data) {
- return moment(new Date(data)).format('YYYY-MM-DD HH:mm')
- }
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- $scope.fileData.idx=newPage - 1;
- filtersData.sum = pageSize;
- $scope.fileData.sum=pageSize;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- 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['comptroller'])) {
- filtersData['comptroller'] = {};
- }
- filtersData['comptroller'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.refreshData('expand-right', filtersData);
- });
- };
- //当前人是否分组
- // if ($rootScope.user.group) {
- // if ($rootScope.user.group.length == 0) {
- // SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
- // } else {
- // $scope.memoryfilterData = defaultFilterData = {
- // "idx": 0,
- // "sum": mun
- // };
- // }
- // } else {
- // $scope.memoryfilterData = defaultFilterData = {
- // "idx": 0,
- // "sum": mun
- // };
- // }
- //编辑
- $scope.selectRowFunction = function(data) {
- $state.go('app.means.auditeditor', { model: JSON.stringify(data) });
- };
- //查看
- $scope.onDblClick = function(data) {
- data.entity.look = true;
- $state.go('app.means.auditeditor', { model: JSON.stringify(data.entity) });
- };
- //新增
- $scope.newaudit = function() {
- $state.go('app.means.newaudit', {});
- };
- //删除
- $scope.eventDeleted = function(event) {
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function(isConfirm) {
- if (isConfirm) {
- api_bpm_schedule.remove([event.id]).then(function(response) {
- if (response.status == 200) {
- $scope.events.splice(event.id, 1); //有修改的一行
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- } else {
- SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
- }
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- };
- if ($stateParams.model) {
- if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
- $scope.searchTypes = JSON.parse($stateParams.model).searchType;
- } else {
- $scope.searchTypes = "todo";
- }
- } else {
- $scope.searchTypes = "todo";
- }
- if ($rootScope.user.group) {
- var defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- } else {
- var defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- }
- // var defaultFilterData = {
- // "assignee":$rootScope.user.id,
- // "candidateGroups":$rootScope.user.group[0].id,
- // "idx":0,
- // "sum":mun
- // };
- if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.comptroller)) {
- defaultFilterData['searchType'] = $rootScope.search.comptroller;
- $scope.searchTypes = $rootScope.search.comptroller;
- }
- // if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
- // if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
- // $rootScope['cmdbs'] = 'incident';
- // defaultFilterData.idx = $rootScope.idx - 1;
- // } else { $rootScope.cmdbs = ""; }
- $scope.ldloading = {};
- // $scope.Change= function(upTypes){
- // if(angular.isDefined(upTypes)&&upTypes=='upincident'){
- // $state.go('app.problem.incident',{});
- // }
- // else if(angular.isDefined(upTypes)&&upTypes=='upchange'){
- // $state.go('app.change.incident',{});
- // }
- // }
- //事件类型筛选
- $scope.onChange = function(searchType) {
- defaultFilterData = $scope.memoryfilterData;
- defaultFilterData['searchType'] = searchType;
- $scope.refreshData('expand-right', defaultFilterData);
- }
- //获取列表数据
- $scope.refreshData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- if (sessionStorage.searchcmdbau) {
- filterData = JSON.parse(sessionStorage.getItem("searchcmdbau"));
- $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- } else {
- filterData = defaultFilterData;
- }
- }
- $scope.myData = [];
- sessionStorage['searchcmdbau'] = angular.copy(JSON.stringify(filterData));
- $scope.memoryfilterData = filterData;
- $scope.gridOptions['sum'] = filterData.sum;
- if (filterData.comptroller && filterData.comptroller.status) {
- if (filterData.comptroller.status.id == 1) {
- filterData.comptroller.status = 1;
- } else if (filterData.comptroller.status.id == 2) {
- filterData.comptroller.status = 2;
- }
- }
- api_bpm.fetchDataList('comptroller', filterData).then(function(data) {
- if (data.status == 200) {
- var myData = Restangular.stripRestangular(data);
- var list = [];
- $scope.gridOptions['totalItems'] = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "请稍后再试!",
- type: "error"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData2 = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- if (sessionStorage.searchcmdbau) {
- filterData = JSON.parse(sessionStorage.getItem("searchcmdbau"));
- $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- } else {
- filterData = defaultFilterData;
- }
- }
- // $scope.myData = [];
- sessionStorage['searchcmdbau'] = angular.copy(JSON.stringify(filterData));
- $scope.memoryfilterData = filterData;
- $scope.gridOptions['sum'] = filterData.sum;
- if (filterData.comptroller && filterData.comptroller.status) {
- if (filterData.comptroller.status.id == 1) {
- filterData.comptroller.status = 1;
- } else if (filterData.comptroller.status.id == 2) {
- filterData.comptroller.status = 2;
- }
- }
- api_bpm.fetchDataList('comptroller', filterData).then(function(data) {
- if (data.status == 200) {
- var myData = Restangular.stripRestangular(data);
- var list = [];
- $scope.gridOptions['totalItems'] = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "请稍后再试!",
- type: "error"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData('expand-right',$scope.fileData);
- $scope.timer = $interval(function () {
- $scope.refreshData2('expand-right',$scope.fileData)
- }, $rootScope.refreshTime);
- $scope.$on('$destroy', function () {
- $interval.cancel($scope.timer)
- });
- }]);
- //操作按钮权限控制
- app.controller('CmdblistOperCtrl', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
- if ($scope.item.status != null) {
- if ($scope.item.status == 1 && $scope.item.user.id == $rootScope.user.id) {
- $scope.item.chaozuoPower = true;
- } else {
- $scope.item.chaozuoPower = false;
- }
- }
- $scope.look = function() {
- //$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: $scope.item.id});
- $scope.colobject.grid.appScope.lookFunction($scope.item);
- }
- $scope.edit = function() {
- $scope.colobject.grid.appScope.selectRowFunction($scope.item);
- }
- // $scope.handler = function() {
- // $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
- // $scope.doComment($scope.item.id);
- // }
- }]);
- //操作按钮
- app.directive('cmdblistoperator', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'CmdblistOperCtrl',
- template: '<div><div class="cl-effect-1 ui-grid-cell-contents center" >' +
- // '<a ng-click="changeCenter()" ng-show="{{item.xiugai}}" class="luyinfont">修改</a>' +
- '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" class="bianjifont">处理</a>' +
- '</div></div>'
- };
- });
|