123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- 'use strict';
- app.controller('gdzc_historyCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_text", "api_bpm_data", "api_user_data", "api_cmdb", "api_cmdb2", "api_cmdb3", "api_cmdb4", function($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_text, api_bpm_data, api_user_data, api_cmdb, api_cmdb2, api_cmdb3, api_cmdb4) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.myData = [];
- var loginUser = $rootScope.user;
- var pdKey = $state.current.pdKey;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = false;
- $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.transferColor = function(item) {
- var color = "icon iconfont icon-zhengchang greenfont";
- if (item.colourInfo) {
- if (item.colourInfo.id == 1) {
- color = "icon iconfont icon-yiyuqi redfont";
- } else if (item.colourInfo.id == 2) {
- color = "iconfont icon-yuqixinxiu yellofont";
- }
- } else {
- // color = "white";
- }
- return color;
- }
- $scope.transfertip = function(item) {
- var tip = "正常";
- if (item.colourInfo) {
- if (item.colourInfo.id == 1) {
- tip = "逾期";
- } else if (item.colourInfo.id == 2) {
- tip = "即将逾期";
- }
- } else {
- // color = "white";
- }
- return tip;
- }
- $scope.transferstatus = function(item) {
- var statecolor = "#fc4c58";
- if (item.id == 2) { //待处理
- statecolor = "#fc4c58";
- } else if (item.id == 7) { //待审核
- statecolor = "#fcb44c";
- } else if (item.id == 3) { //请求重新指派
- statecolor = "#ebf902";
- } else if (item.id == 4) { //处理中
- statecolor = "#0aa5f5";
- } else if (item.id == 5) { //已解决
- statecolor = "#2edbb8";
- } else if (item.id == 6) { //已关闭
- statecolor = "#bbbbbb";
- }
- return statecolor;
- }
- $scope.gridOptions.columnDefs = [{
- name: 'versionNumber',
- displayName: '版本',
- width: '14%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.versionNumber}}</div>' +
- '</div>'
- },
- {
- name: 'name',
- displayName: '操作人',
- width: '13%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.operator.name}}</div>' +
- '</div>'
- },
- {
- name: 'time',
- displayName: '操作时间',
- width: '20%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.time}}</div>' +
- '</div>'
- },
- {
- name: 'motion',
- displayName: '操作动作',
- width: '13%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.motion}}</div>' +
- '</div>'
- }, {
- name: 'description',
- displayName: '内容',
- width: '40%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" tooltip={{row.entity.description}} ng-if="row.entity.description&&row.entity.description.length>23" tooltip-placement="bottom">{{row.entity.description}}</div><div class="ui-grid-cell-contents" ng-if="row.entity.description&&row.entity.description.length<=23" >{{row.entity.description}}</div>' +
- '</div>'
- }
- ];
- $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.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 = {};
- var items = [];
- $scope.selected = {
- items: []
- };
- var wt_data = {};
- //列表排序
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- var index = 0;
- var oldheader = {};
- gridApi.grid.sortColumn = function(gridApi) {
- if (oldheader.field) {
- if (oldheader.field == gridApi.field) {
- // index = 0;
- } else {
- index = 0;
- }
- }
- index++;
- oldheader = gridApi;
- var fildata = $scope.memoryfilterData;
- if (index % 3 == 0) {
- delete $scope.memoryfilterData.incident;
- fildata = $scope.memoryfilterData;
- } else if (index % 3 == 1) {
- if (fildata.incident) {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata.incident, { "sort": gridApi.field });
- } else {
- angular.extend(fildata.incident, { "sort": gridApi.field + " desc , _incident.acceptDate" });
- }
- } else {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata, { 'incident': { "sort": gridApi.field } });
- } else {
- angular.extend(fildata, { 'incident': { "sort": gridApi.field + " desc , _incident.acceptDate" } });
- }
- }
- } else if (index % 3 == 2) {
- if (fildata.incident) {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata.incident, { "sort": gridApi.field, "order": "asc" });
- } else {
- angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
- }
- } else {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
- } else {
- angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
- }
- }
- // angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
- }
- $scope.refreshData('expand-right', fildata);
- }
- 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;
- if ($rootScope.user.group) {
- var filtersData = {
- idx: 0,
- sum: mun
- };
- } else {
- var filtersData = {
- idx: 0,
- sum: mun
- };
- }
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- filtersData = $scope.memoryfilterData
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- if (item.field == 'requester.name') {
- filtersData['incident']['requester'] = {};
- filtersData.incident.requester['accountName'] = item.filters[0].term;
- } else if (item.field == 'handlingPersonnelUser.name') {
- filtersData['incident']['handlingPersonnelUser'] = {};
- filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
- } else if (item.field == 'requester.account') {
- filtersData['incident']['requester'] = {};
- filtersData.incident.requester['account'] = item.filters[0].term;
- } else if (item.field == 'acceptUser.name') {
- filtersData['incident']['acceptUser'] = {};
- filtersData.incident.acceptUser['name'] = item.filters[0].term;
- } else {
- filtersData['incident'][item.field] = item.filters[0].term;
- }
- }
- }
- });
- filtersData.idx = 0;
- $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
- };
- };
- var items = [];
- 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
- };
- }
- if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
- defaultFilterData['searchType'] = $rootScope.search.incident;
- $scope.searchTypes = $rootScope.search.incident;
- }
- 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 = {};
- // console.log($stateParams.idd)
- //获取列表数据
- $scope.refreshData = function(style, filterData) {
- var pdKey = "assetConsumablesHistory";
- $scope.myData = [];
- $scope.gridOptions['sum'] = filterData.sum;
- filterData['assetConsumablesHistory'] = { "assetConsumablesId": $stateParams.idd };
- api_cmdb3.fetchDataList(pdKey, filterData).then(function(data) {
- // console.log(data.list);
- if (data.list) {
- var myData = Restangular.stripRestangular(data);
- var list = [];
- $scope.gridOptions['totalItems'] = myData.totalNum;
- $scope.myData = myData.list;
- // console.log($scope.myData);
- 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', defaultFilterData);
- }])
|