'use strict';
app.controller('chartCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data", "api_text", "api_user_data", function($scope, i18nService, $rootScope, $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data, api_text, api_user_data) {
$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 = false;
$scope.gridOptions.enableRowSelection = true;
$scope.gridOptions.showGridFooter = true;
$scope.gridOptions.showColumnFooter = false;
$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: 'item',
displayName: '序号',
width: 50,
cellTemplate: '' +
'
{{row.entity.item}}
' +
'
'
}, {
name: 'incidentDescription',
displayName: '事件描述',
width: '12%',
cellTemplate: '' +
'
{{row.entity.incidentDescription}}
' +
'
'
},
// {
// name: 'incidentDescription1',
// displayName: '报修科室',
// width: '12%',
// cellTemplate: '' +
// '
{{row.entity.incidentDescription1}}
' +
// '
'
// },
{
name: 'address',
displayName: '地点',
width: '10%',
cellTemplate: '' +
'
{{row.entity.place.place||""}} {{row.entity.address}}
' +
'
'
}, {
name: 'contacts',
displayName: '联系人',
width: '10%',
cellTemplate: '' +
'
{{row.entity.contacts}}
' +
'
'
}, , {
name: 'contactsInformation',
displayName: '联系电话',
width: '10%',
cellTemplate: '' +
'
{{row.entity.contactsInformation}}
' +
'
'
},
// {
// name: 'requester.name',
// displayName: '报修人',
// width: '10%',
// cellTemplate: '' +
// '
{{row.entity.requester.name}}
' +
// '
'
// },
{
name: 'state',
displayName: '状态',
width: '8%',
cellTemplate: '' +
'
{{row.entity.state}}
' +
'
'
}, {
name: 'createTime',
displayName: '创建时间',
width: '12%',
cellTemplate: '' +
'
{{row.entity.createTime}}
' +
'
'
// },
// {
// name: '生成事件',
// width: 80,
// cellTemplate: ''
},
{ name: '操作', cellTemplate: '', enableFiltering: false }
];
$scope.value = 10;
$scope.decrement = function() {
$scope.value = $scope.value - 1;
};
$scope.searchstate = '未转换';
$scope.searchkeys = {};
$scope.onChange = function(searchType) {
$scope.searchstate = searchType;
defaultFilterData = $scope.memoryfilterData;
defaultFilterData.wxincident['state'] = searchType;
// sessionStorage.searchchart.state = searchType;
$scope.refreshData('expand-right', defaultFilterData);
}
$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;
};
var getUser = function(fieldatas) {
api_user_data.fetchDataList('requester', fieldatas).then(function(data) {
$scope.requester = data.list;
});
}
$scope.onChangehandling = function(key) {
var filuser = {
"idx": 0,
"sum": 10,
"requester": { "name": key }
}
getUser(filuser);
}
getUser({ "idx": 0, "sum": 10 });
$scope.chiceIncident = function(item) {
var fildata = {};
if (sessionStorage.searchincident) {
fildata = JSON.parse(sessionStorage.getItem("searchchart"));
$scope.gridOptions.paginationCurrentPage = 1;
fildata.idx = 0;
} else {
fildata = defaultFilterData;
}
if (!fildata.incident) {
fildata['wxincident'] = {};
}
if (item.createTime) {
item.createTime = moment(item.createTime).format('YYYY-MM-DD HH:mm:ss');
}
if (item.createTimeEnd) {
item.createTimeEnd = moment(new Date(item.createTimeEnd).getTime() + 86399999).format('YYYY-MM-DD HH:mm:ss');
}
angular.extend(fildata.wxincident, item)
sessionStorage['searchchart'] = angular.copy(JSON.stringify(fildata));
$scope.memoryfilterData = fildata;
$scope.refreshData('expand-right', fildata);
}
$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;
if (JSON.parse(sessionStorage.getItem("searchchart")).idx != filtersData.idx) {
$scope.refreshData('expand-right', filtersData);
}
// $scope.refreshData('expand-right', filtersData);
});
$scope.selected = {
items: []
}
};
$scope.memoryfilterData = defaultFilterData = {
// "assignee":$rootScope.user.id,
// "candidateGroups":$rootScope.user.group[0].id,
"idx": 0,
"wxincident": { "state": "未转换" },
"sum": mun
};
$scope.selectRowFunction = function(data) {
var formdata = {
'model': {
'incident': {
'requester': data.requester,
'area': data.area,
'place': data.place,
'houseNumber': data.address,
'contacts': data.contacts,
'contactsInformation': data.contactsInformation,
// 'category': data.wxIncidentClassifyDTO.category,
'description': data.incidentDescription,
'source': { 'id': 4 },
'sourceType': data.sourceType,
'fileUrl': data.fileUrl
},
'requestershow': data.requester,
'flow': data.id
}
}
// if (data.requester.requesterTypeDTO && data.requester.requesterTypeDTO.id == 2) {
// angular.extend(formdata.model.incident, { 'priority': { 'id': 2 } });
// }
$state.go('app.incident.chart', { 'model': JSON.stringify(formdata) });
};
$scope.lookFunction = function(data) {
// var data = row.entity;
var formdata = {
'model': {
'incident': {
'requester': data.requester,
'area': data.area,
'place': data.place,
'houseNumber': data.address,
'contacts': data.contacts,
'contactsInformation': data.contactsInformation,
// 'category': data.wxIncidentClassifyDTO.category,
'description': data.incidentDescription,
'source': { 'id': 4 },
'sourceType': data.sourceType,
'fileUrl': data.fileUrl
},
'requestershow': data.requester,
'flow': data.id
}
}
var modelfile = { model: { incident: data } };
// if (data.state == "未转换") {
angular.extend(modelfile.model, { 'gourl': 'app.incident.chart', 'state_model': formdata })
angular.extend(modelfile.model.incident, { status: 1 })
// } else {
// angular.extend(modelfile.model.incident, { status: 0 })
// }
$state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
};
// $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) {
var data = row.entity;
var formdata = {
'model': {
'incident': {
'requester': data.requester,
'area': data.area,
'place': data.place,
'houseNumber': data.address,
'contacts': data.contacts,
'contactsInformation': data.contactsInformation,
// 'category': data.wxIncidentClassifyDTO.category,
'description': data.incidentDescription,
'source': { 'id': 4 },
'sourceType': data.sourceType,
'fileUrl': data.fileUrl
},
'requestershow': data.requester,
'flow': data.id
}
}
var modelfile = { model: { incident: row.entity } };
if (row.entity.state == "未转换") {
angular.extend(modelfile.model, { 'gourl': 'app.incident.chart', 'state_model': formdata })
angular.extend(modelfile.model.incident, { status: 1 })
} else {
angular.extend(modelfile.model.incident, { status: 0 })
}
$state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
};
var defaultFilterData = {
// "assignee":$rootScope.user.id,
// "candidateGroups":$rootScope.user.group[0].id,
"idx": 0,
"wxincident": { "state": "未转换" },
"sum": mun
};
$scope.ldloading = {};
$scope.refreshData = function(style, filterData) {
$scope.ldloading[style.replace('-', '_')] = true;
// if (angular.isUndefined(filterData)) {
// filterData = defaultFilterData;
// }
if (angular.isUndefined(filterData)) {
if (sessionStorage.searchchart) {
filterData = JSON.parse(sessionStorage.getItem("searchchart"));
$scope.searchkeys = filterData.wxincident;
// $scope.searchstate = filterData.state;
$scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
$scope.searchstate = filterData.wxincident.searchType;
} else {
filterData = defaultFilterData;
}
}
$scope.myData = [];
$scope.gridOptions['sum'] = filterData.sum;
sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData));
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
}
// console.log($scope.myData)
$scope.ldloading[style.replace('-', '_')] = false;
}, function() {
$scope.ldloading[style.replace('-', '_')] = false;
});
};
$scope.refreshData('expand-right');
}]);
app.controller('Wechatoperator', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
$scope.handle = false;
if ($scope.item.state == "未转换") {
$scope.handle = true;
} else { $scope.handle = false; }
$scope.edit = function() {
$scope.colobject.grid.appScope.selectRowFunction($scope.item);
$scope.doEdit($scope.item.id);
}
$scope.look = function() {
$scope.colobject.grid.appScope.lookFunction($scope.item);
$scope.doEdit($scope.item.id);
}
}]);
app.directive('wechatoperator', function() {
return {
restrict: 'E',
scope: {
item: '=',
colobject: '='
},
controller: 'Wechatoperator',
template: '' +
// '
' +
'
生成事件' +
// '
查看' +
'
查看' +
// '
' +
'
'
};
});
// app.factory('myFactory', function() {
// //定义factory返回对象
// var myServices = {};
// //定义参数对象
// var myObject = {};
// var _set = function(data) {
// myObject = data;
// };
// })