'use strict';
app.controller('chartCtrl', ["$scope", "i18nService","$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert" , "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data","api_text", function ( $scope,i18nService,$rootScope , $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data,api_text) {
$scope.langs=i18nService.getAllLangs();
$scope.lang = 'zh-cn';
i18nService.setCurrentLang($scope.lang);
// $(window).resize(function() {
// // console.log("1111")
// });
var loginUser=$rootScope.user;
// var voiceurl=$rootScope.audioiIp;
// delete $rootScope.user.authority;
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.enableRowSelection = true;
$scope.gridOptions.showGridFooter = true;
$scope.gridOptions.showColumnFooter = true;
$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 = 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.gridOptions.columnDefs = [
{ name:'incidentTheme', displayName:'事件主题', width:120,cellTemplate:'' +
'
{{row.entity.incidentTheme}}
'+
'
' },
// { name:'incidentDescription', displayName:'事件描述', width:160,cellTemplate:'' +
// '
{{row.entity.incidentDescription}}
'+
// '
' },
{ name:'address', displayName:'地点', width:140,cellTemplate:'' +
'
{{row.entity.address}}
'+
'
' },
{ name:'wxIncidentClassifyDTO.name', displayName:'事件类型', width:120,cellTemplate:'' +
'
{{row.entity.wxIncidentClassifyDTO.name}}
'+
'
' },
{ name:'requester.name', displayName:'请求人', width:120,cellTemplate:'' +
'
{{row.entity.requester.name}}
'+
'
' },
{ name:'state', displayName:'状态', width:120,cellTemplate:'' +
'
{{row.entity.state}}
'+
'
' },
{ name:'state', displayName:'创建时间', width:140,cellTemplate:'' +
'
{{row.entity.createTime}}
'+
'
' },
{ name:'生成事件',enableSorting: false, cellTemplate:'', width:80,enableFiltering:false}
// { name:'生成事件', width:80,cellTemplate:'' }
];
$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.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;
$scope.refreshData('expand-right',filtersData);
// $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
});
$scope.selected = {
items:[]
}
};
$scope.memoryfilterData = defaultFilterData = {
// "assignee":$rootScope.user.id,
// "candidateGroups":$rootScope.user.group[0].id,
"idx":0,
"sum":mun
};
$scope.selectRowFunction = function(data){
var wxincidentdata={}
api_bpm_data.fetchDataList('incidentsource',{"idx":0,"sum":1000}).then(function(requeste){
if(requeste.status==200){
angular.forEach(requeste.list,function(item){
if(item.code=="im"){
wxincidentdata=item.id;
}
})
var formdata={
'model':{
'incident':{
'requester':data.requester,
'area':data.area,
'place':data.place,
'houseNumber':data.address,
'category':data.wxIncidentClassifyDTO.category,
'source':{'id':wxincidentdata},
'description':data.incidentDescription
},
'flow':data.id
}
}
$state.go('app.incident.chart',{'model':JSON.stringify(formdata)});
}
})
// var formdata={
// 'model':{
// 'incident':{
// 'requester':data.requester,
// 'area':data.area,
// 'place':data.place,
// 'category':data.wxIncidentClassifyDTO.category,
// 'source':{'id':wxincidentdata},
// 'description':data.incidentDescription
// },
// 'flow':data.id
// }
// }
// $state.go('app.incident.chart',{'model':JSON.stringify(formdata)});
};
$scope.lookFunction = function(data){
$state.go('app.incident.detail', { formKey:'incident_back', pdKey:'incident', dataId: data.id,taskId:data.taskId,processInstanceId: data.processInstanceId});
};
// $scope.followFunction = function(data){
// //console.log('data='+JSON.stringify(data));
// $state.go('app.detail', { formKey:'statusform', pdKey:'incident', dataId: data.id,processInstanceId: data.processInstanceId});
// };
$scope.onDblClick = function(row){
console.log(row.entity);
if($rootScope.user.id==row.entity.handlerUser.id){$state.go('app.incident.editor',{taskId:row.entity.taskId,processInstanceId: row.entity.processInstanceId});}
else{$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: row.entity.id});}
};
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.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 = {};
// $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['searchType'] = searchType;
// $scope.refreshData('expand-right', defaultFilterData);
// }
$scope.handlerPower=
$scope.refreshData = function(style,filterData){
$scope.ldloading[style.replace('-', '_')] = true;
if(angular.isUndefined(filterData)){
filterData = defaultFilterData;
}
$scope.myData = [];
$scope.gridOptions['sum']=filterData.sum;
api_bpm_data.fetchDataList("wxincident",filterData).then(function(data){
var myData = Restangular.stripRestangular(data);
$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
// if(){
// $scope.myData[i]['handlerPower']=true
// }
}
console.log($scope.myData)
$scope.ldloading[style.replace('-', '_')] = false;
},function(){
$scope.ldloading[style.replace('-', '_')] = false;
});
};
$scope.refreshData('expand-right', defaultFilterData);
}]);
app.controller('WxincidentOperCtrl', ['$rootScope','$http', '$scope', '$modal',function ($rootScope,$http, $scope, $modal) {
// console.log('$rootScope.user3='+JSON.stringify($scope.item));
if($scope.item.state== '已转换'){
}else{
$scope.item.handlerPower=true;
}
$scope.handler = function(){
$scope.colobject.grid.appScope.selectRowFunction($scope.item);
// $scope.doComment($scope.item.id);
}
}]);
app.directive('wxincidentoperator', function () {
return {
restrict: 'E',
scope:
{
item: '=',
colobject: '='
},
controller: 'WxincidentOperCtrl',
template: ''
};
});