12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007 |
- 'use strict';
- app.controller('meansapplyListCtrl', ["$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", 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) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.myData = [];
- 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.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.states = [
- { id: 0, name: '待批准' },
- { id: 1, name: '已驳回' },
- { id: 2, name: '待出库' },
- { id: 3, name: '信息更新' },
- { id: 4, name: '信息确认' },
- { id: 5, name: '已关闭' }
- ];
- $scope.type = [
- { id: 1, name: '资产入库' },
- { id: 2, name: '资产归还' },
- { id: 3, name: '资产零用' },
- { id: 4, name: '资产更换' }
- ];
- $scope.application = [
- { id: 1, name: '申请单编号' },
- { id: 2, name: '申请人' },
- { id: 3, name: '领用用途' },
- { id: 4, name: '设备编号' }
- ];
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 50,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'serialNumbe',
- displayName: '申请人编号',
- width: '15%',
- enableSorting: false
- },
- {
- name: 'proposer.name',
- displayName: '申请人',
- width: '10%',
- enableSorting: false
- },
- {
- name: 'area.area',
- displayName: '类型',
- width: '18%',
- enableFiltering: false
- },
- {
- name: 'state.name',
- displayName: '状态',
- width: '8%',
- enableFiltering: false,
- },
- {
- name: 'contactsInformation',
- displayName: '环节处理人',
- width: '15%'
- },
- {
- name: 'acceptDate',
- displayName: '领用用途',
- width: '12%',
- enableFiltering: false
- },
- { name: '操作', enableSorting: false, cellTemplate: '<meansoperator 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.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.chiceIncident = function(parameters, item, stateid) {
- if (stateid && stateid.code) {
- item.statusId = stateid.code;
- }
- var fildata = defaultFilterData;
- $scope.memoryfilterData = fildata;
- if (!fildata.incident) {
- fildata['incident'] = {};
- }
- $scope.gridOptions.paginationCurrentPage = 1;
- if (parameters) {
- angular.extend(fildata, { 'idx': 0, 'sum': $scope.gridOptions.paginationPageSize })
- angular.extend(fildata.incident, { 'acceptDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'), 'acceptDateEnd': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59') })
- }
- // item.state
- // if(item.state){
- // }
- var transitiondata = angular.copy(item);
- // if (transitiondata.searchdatas) {
- // fildata.searchType = item.searchdatas.id;
- // delete transitiondata.searchdatas;
- // }
- // if (key.place) {
- // angular.extend(fildata.incident, { "place": { "id": key.place.id } })
- // }
- angular.extend(fildata.incident, transitiondata)
- $scope.refreshData('expand-right', fildata);
- }
- //区域地点过滤
- $scope.key = {};
- api_user_data.fetchDataList('area', { "idx": 0, "sum": 1000 }).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.outarea = response.list;
- }
- }
- })
- //受理人,处理人
- $scope.searchkeys = {};
- var fieldata = { "idx": 0, "sum": 10, "flag": -1 };
- getUser(fieldata, 3);
- function getUser(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;
- }
- });
- }
- //受理人过滤
- $scope.onChangeacceptUser = function(key) {
- getUser({
- "idx": 0,
- "sum": 10,
- "flag": -1,
- "user": { "flag": -1, "name": key }
- }, 1);
- }
- //处理人过滤
- $scope.onChangehandling = function(key) {
- getuser({
- "idx": 0,
- "sum": 10,
- "flag": -1,
- "user": { "flag": -1, "name": key }
- }, 2);
- }
- //状态
- api_bpm_data.fetchDataList('incidentstatus', { "idx": 0, "sum": 100 }).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.state = response.list;
- }
- }
- })
- //地点区域过滤
- $scope.onChangearea = function(data) {
- delete $scope.searchkeys.place;
- if ($scope.memoryfilterData.incident) {
- delete $scope.memoryfilterData.incident.place;
- }
- var fildata = { "idx": 0, "sum": 1000, "place": { areaId: data.area.id } };
- api_user_data.fetchDataList('place', fildata).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.outplace = response.list;
- }
- }
- })
- };
- $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.areaplace = function(data) {
- if (data.area && data.place) {
- if (data.houseNumber) {
- return data.area.area + ' ' + data.place.place + ' ' + data.houseNumber;
- } else {
- return data.area.area + ' ' + data.place.place;
- }
- } else if (data.area && !data.place) {
- if (data.houseNumber) {
- return data.area.area + ' ' + data.houseNumber;
- } else {
- return data.area.area;
- }
- } else if (!data.area && data.place) {
- if (data.houseNumber) {
- return data.place.place + ' ' + data.houseNumber;
- } else {
- return data.place.place;
- }
- }
- }
- //录音
- $scope.play = function(data) {
- // console.log($scope.item.callID)
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/audio.html',
- controller: function($rootScope, $scope, $modalInstance, $sce) {
- $scope.data = {
- "name": "视频",
- "url": callIp + "/recording/recording?callID=" + data.callID
- };
- $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
- // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $modalInstance.close();
- }
- });
- };
- //列表排序
- $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;
- // sessionStorage.idx = JSON.stringify(newPage-1)
- $scope.refreshData('expand-right', filtersData);
- // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // data.grid.appScope.selected.items = data.entity
- // });
- $scope.Change = function(upTypes) {
- if (angular.isDefined($scope.selected.items)) {
- if (angular.isDefined(upTypes) && upTypes == 'upincident') {
- var data = {
- cancelUrl: 'app.incident.list',
- model: {
- problem: {
- title: $scope.selected.items.title,
- des: $scope.selected.items.description,
- proposePerson: $scope.selected.items.handlerUser,
- source: {
- id: 1,
- code: 1,
- name: ' 事件 '
- },
- incident: $scope.selected.items
- }
- }
- }
- $state.go('app.problem.incident', { pdKey: 'incident', dataId: $scope.selected.items.id, processInstanceId: $scope.selected.items.processInstanceId, 'model': JSON.stringify(data) });
- } else if (angular.isDefined(upTypes) && upTypes == 'upchange') {
- var data = {
- cancelUrl: 'app.incident.list',
- model: {
- change: {
- title: $scope.selected.items.title,
- description: $scope.selected.items.description,
- requestingPerson: $scope.selected.items.handlerUser,
- source: {
- id: 1,
- code: 1,
- name: ' 事件 '
- },
- incident: $scope.selected.items
- }
- }
- }
- // var data={cancelUrl:'app.incident.list'}
- $state.go('app.change.incident', { pdKey: 'incident', dataId: $scope.selected.items.id, processInstanceId: $scope.selected.items.processInstanceId, 'model': JSON.stringify(data) });
- }
- }
- }
- $scope.selected = {
- items: []
- }
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- if ($rootScope.user.group) {
- var filtersData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- idx: 0,
- sum: mun
- };
- } else {
- var filtersData = {
- "assignee": $rootScope.user.id,
- 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 = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- }
- } else {
- $scope.memoryfilterData = defaultFilterData = {
- "assignee": $rootScope.user.id,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- }
- //打印
- $scope.open = function(data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/print.html',
- controller: function($scope, $modalInstance) {
- $scope.printdata = data;
- if (!data.emergency) { data['emergency'] = {}; }
- if (!data.influence) { data['influence'] = {}; }
- if (!data.place) { data['place'] = {}; }
- if (!data.influence) { data['influence'] = {}; }
- if (!data.emergency) { data['emergency'] = {}; }
- if (!data.influence) { data['influence'] = {}; }
- var height = $(".groundborder").height()
- console.log(height)
- $scope.printrequest = [
- { name: "事件单号", value: data.incidentsign },
- { name: "事件主题", value: data.title },
- { name: "事件分类", value: data.category.category },
- { name: "紧急度", value: data.emergency.name },
- { name: "影响度", value: data.influence.name },
- { name: "优先级", value: data.priority.name }
- ];
- $scope.printrequest['requester'] = [{ nameone: "用户姓名", valueone: data.requester.name, nametwo: "联系电话", valuetwo: data.requester.mphone },
- { nameone: "故障地点", valueone: data.place.place, nametwo: "申报时间", valuetwo: data.responseTime }
- ];
- // $scope.printrequest['requester']=[{name:"用户姓名",value:data.requester.name},
- // {name:"联系电话",value:data.requester.mphone},
- // {name:"故障地点",value:data.place.place},
- // {name:"申报时间",value:data.responseTime}];
- $scope.printrequest['incident'] = [{ nameone: "故障工单", valueone: data.incidentsign, nametwo: "故障分类", valuetwo: data.category.category }];
- $scope.printrequest['handler'] = [{ name: "故障描述", value: data.description },
- { name: "处理人", value: data.handlingPersonnelUser ? data.handlingPersonnelUser.name : '' }
- ];
- // {name:"处理结果",value:data.handleResult}];
- // {name:"用户评价",value:''},
- // {name:"满意度",value:''},
- // {name:"用户签字",value:''}];
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg'
- });
- }
- //新建事件
- // $scope.newincident = function(data) {
- // $state.go('app.incident.editor', {});
- // };
- //编辑
- $scope.selectRowFunction = function(data) {
- $state.go('app.means.applyediter', { taskId: data.taskId, processInstanceId: data.processInstanceId });
- };
- //查看
- $scope.onDblClick = function(data) {
- // console.log('data='+JSON.stringify(data));
- //$state.go('app.detail',{taskId:data.taskId,processInstanceId: data.processInstanceId});
- $state.go('app.incident.detail', { formKey: 'incident_back', pdKey: 'incident', dataId: data.entity.id, taskId: data.taskId, processInstanceId: data.entity.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.coordination = function(data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function($scope, $modalInstance, i18nService, $timeout, api_bpm_domain, api_user_data) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = 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];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [
- // { name:'id', width:80, enableFiltering:false},
- { name: 'account', displayName: '账号', width: 140 },
- { name: 'name', displayName: '名称', width: 100 },
- { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
- { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
- { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
- { name: 'dept.dept', displayName: '科室', width: 100, enableFiltering: false },
- { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: 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.loadData(filtersData);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
- scope.grid.appScope.selected.items[0] = scope.entity;
- // $scope.selected.items[0] = scope.entity;
- });
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
- };
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- //console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- $scope.selected = {
- items: []
- }
- var filterData = {
- "idx": 0,
- "sum": 10,
- "user": { "roledata": { "rolecode": 'first-line support' }, "selectType": "1" }
- }
- $scope.loadData = function(filterData) {
- // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
- api_user_data.fetchDataList('user', filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- $scope.loadData({
- idx: 0,
- sum: 10,
- "user": { "roledata": { "rolecode": 'first-line support' }, "selectType": "1" }
- });
- $scope.ok = function() {
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg'
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- var filterData = {
- "assginee": selectedItem[0].id
- }
- api_bpm_domain.delegateTask(data.taskId, filterData).then(function(data) {
- if (data && data.status == 200) {
- SweetAlert.swal("添加成功!", "添加协同人成功", "success")
- $scope.refreshData('expand-right', $scope.memoryfilterData);
- } else {
- SweetAlert.swal("添加失败!", "请稍候重试", "error");
- }
- // var myData = Restangular.stripRestangular(data);
- // $scope.gridOptions.totalItems = myData.totalNum;
- // $scope.myData = myData.list;
- });
- }
- });
- }
- // $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});}
- // };
- /*
- appScopeProvider: {
- onDblClick : function(row) {
- var url = '//google.com';
- $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
- }
- },
- rowTemplate: "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" ui-grid-cell ></div>"
- */
- //删除
- $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");
- }
- });
- };
- //导出
- $scope.export = function() {
- // api_bpm_data.downDataModel("incident", 3, $scope.memoryfilterData).then(function(data) {
- // console.log(data)
- // var file = new Blob([data], {
- // // type: 'application/octet-stream'
- // type: 'application/vnd.ms-excel'
- // });
- // //trick to download store a file having its URL
- // var fileURL = URL.createObjectURL(file);
- // var a = document.createElement('a');
- // a.href = fileURL;
- // a.target = '_blank';
- // a.download = '事件列表.xls';
- // document.body.appendChild(a);
- // a.click();
- // })
- // $scope.ldloading[style.replace('-', '_')] = true;
- var filadata = angular.copy($scope.memoryfilterData);
- filadata.sum = 10000;
- $http({
- url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
- method: 'POST',
- data: JSON.stringify(filadata),
- headers: {
- // 'Content-type': 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = '事件列表.xls';
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- }
- //事件提取
- $scope.acceptTaskAction = function(model) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
- controller: function($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
- var receiveTask = function(receive_code, modelData) {
- var data = {
- 'receive_code': receive_code
- };
- if (modelData) {
- return {
- taskId: modelData.taskId,
- data: data
- };
- } else {
- return 'error';
- }
- };
- $scope.title = "提示";
- $scope.connect = "确认抢单?";
- $scope.ok = function() {
- //接收任务//请求重新指派
- var data = receiveTask($scope.receive_code, modelData);
- APIService.claimAndCompletedTask(data.taskId, { userId: currentUserId, receive_code: "handler" }).then(function(response) {
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else if (response.status == 500) {
- Alert.swal({
- title: "操作失败",
- text: "该事件已被提取,请刷新页面!",
- type: "error"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- APIService: function() {
- return api_bpm_domain;
- },
- modelData: function() {
- return model;
- },
- currentUserId: function() {
- return loginUser.id;
- },
- Alert: function() {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- 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 = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- } else {
- var defaultFilterData = {
- "assignee": $rootScope.user.id,
- "searchType": "todo",
- "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.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.searchstate = 'todo';
- $scope.onChange = function(searchType) {
- $scope.searchstate = 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)) {
- filterData = defaultFilterData;
- }
- // if (angular.isDefined($scope.searchTypes)) {
- // $rootScope['search'] = {};
- // filterData['searchType'] = $scope.searchTypes;
- // $rootScope['search']['incident'] = $scope.searchTypes;
- // }
- // if(sessionStorage.idx){
- // filterData.idx = Number(sessionStorage.idx);
- // $scope.gridOptions.idx = Number(sessionStorage.idx)+1;
- // }
- $scope.myData = [];
- //var start = new Date();
- //var sec = $interval(function () {
- //$scope.callsPending++;
- $scope.gridOptions['sum'] = filterData.sum;
- api_bpm_data.fetchDataList(pdKey, filterData).then(function(data) {
- if (data.status) {
- var myData = Restangular.stripRestangular(data);
- var list = [];
- $scope.gridOptions['totalItems'] = myData.resultCount;
- $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', defaultFilterData);
- }]);
- //操作按钮权限控制
- app.controller('MeansOperCtrl', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
- // console.log('$rootScope.user3='+JSON.stringify($scope.item));
- // if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
- // if ($rootScope.user.id == $scope.item.handlerUser.id) {
- // $scope.item.chaozuoPower = true;
- // if ($scope.item.state.id == 4) {
- // $scope.item.coordination = true;
- // }
- // }
- // }
- // $rootScope.callid = $scope.item.callID;
- // if ($scope.item.callID) {
- // $scope.item.listen = true;
- // } else { $scope.item.listen = false; }
- // if ($scope.item.state.id != 6 && $scope.item.handlerUser == null) {
- // angular.forEach($rootScope.user.group, function(item) {
- // if (item.id == $scope.item.candidateGroups) {
- // $scope.item.tiquPower = true;
- // }
- // })
- // }
- $scope.coordination = function() {
- $scope.colobject.grid.appScope.coordination($scope.item);
- }
- $scope.look = function() {
- //$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: $scope.item.id});
- $scope.colobject.grid.appScope.lookFunction($scope.item);
- // console.log('$scope.item='+JSON.stringify($scope.item));
- //$scope.doEdit($scope.item.id);
- }
- $scope.edit = function() {
- $scope.colobject.grid.appScope.selectRowFunction($scope.item);
- // console.log('$scope.item='+JSON.stringify($scope.item));
- // $scope.doEdit($scope.item.id);
- }
- $scope.print = function() { //print
- $scope.colobject.grid.appScope.open($scope.item);
- // $scope.doEdit($scope.item.id);
- }
- $scope.record = function() { //record
- $scope.colobject.grid.appScope.play($scope.item);
- // $scope.doEdit($scope.item.id);
- }
- $scope.handler = function() {
- $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
- $scope.doComment($scope.item.id);
- }
- $scope.follow = function() {
- $scope.colobject.grid.appScope.followFunction($scope.item);
- }
- // $scope.play = function() {
- // // console.log($scope.item.callID)
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/incident/tpl/audio.html',
- // controller: function($scope, $modalInstance,$sce){
- // $scope.data={
- // "name":"视频",
- // "url":"http://192.168.3.69:8088/recording/recording?callID="+$rootScope.callid
- // };
- // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
- // // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // $modalInstance.close();
- // }
- // });
- // };
- }]);
- //操作按钮
- app.directive('meansoperator', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'MeansOperCtrl',
- template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
- '<a ng-click="look()" tooltip-placement="left">查看</a>' +
- // '<a ng-click="handler()" ng-show="{{item.tiquPower}}" class="handlefont" >抢单</a>' +
- '<a ng-click="edit()" class="bianjifont">编辑</a>' +
- // '<a ng-click="print()" class="printfont" >打印</a>' +
- // '<a ng-click="record()" ng-show="{{item.listen}}" class="luyinfont" >录音</a>' +
- '</div></div>'
- };
- });
|