'use strict'; /** * controller for User Profile Example */ // "$aside", "toaster", "api_bpm_domain", "api_configure_data", "api_cmdb", "api_configure_form", app.controller('gdzc_relationCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeout", "$injector", '$parse', "$interval", "$modal", "$stateParams", "$aside", "SweetAlert", "toaster", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_configure_data", "api_cmdb", "api_configure_form","api_cmdb3", function($rootScope, $scope, $http, $state, $timeout, $parse, $injector, $interval, $modal, $stateParams, $aside, SweetAlert, toaster, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_configure_data, api_cmdb, api_configure_form,api_cmdb3) { $scope.ceshi="流程"; $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 = "
"; $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: 'danhao', displayName: '单号', width: '21%', cellTemplate: '
' + '
{{row.entity.danhao}}
' + '
' }, { name: 'zhuti', displayName: '主题', width: '13%', cellTemplate: '
' + '
{{row.entity.zhuti}}
' + '
' }, { name: 'fenlei', displayName: '分类', width: '10%', cellTemplate: '
' + '
{{row.entity.fenlei}}
' + '
' }, { name: 'shenqingren', displayName: '申请人', width: '8%', cellTemplate: '
' + '
{{row.entity.shenqingren}}
' + '
' }, { name: 'chuliren', displayName: '处理人', width: '9%', cellTemplate: '
' + '
{{row.entity.chuliren}}
' + '
' }, { name: 'liuchengleixing', displayName: '流程类型', width: '7%', cellTemplate: '
' + '
{{row.entity.liuchengleixing}}
' + '
' }, { name: 'chuangjiariqi', displayName: '创建时间', width: '15%', cellTemplate: '
' + '
{{row.entity.chuangjiariqi}}
' + '
' }, { name: 'lishishijian', displayName: '操作时间', width: '15%', cellTemplate: '
' + '
{{row.entity.lishishijian}}
' + '
' }, ]; $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); }); }; 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 = {}; var guagua; var get_danhao={ "idx":0, "sum":1000 } $scope.shijian_qu=[]; $scope.biangeng_qu=[]; $scope.myData1=[]; $scope.myData2=[]; $scope.myData3=[]; $scope.myData4=[]; $scope.myData5=[]; $scope.refreshData = function () { var pdKey = "assetConsumablesHistory"; get_danhao['assetConsumablesHistory']={"assetConsumablesId":$stateParams.idd}; $scope.incident_shuzu=[]; $scope.change_shuzu=[]; $scope.incident_time=[]; $scope.change_time=[]; // 请求操作历史列表获取事件单号和变更单号 api_cmdb3.fetchDataList(pdKey, get_danhao).then(function (data) { guagua=data.list; // console.log(data.list); for(var i=0;i