event_formCtrl.js 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. 'use strict';
  2. app.controller('event_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", "api_event_form", "api_user_data", "api_bpm", "api_category", "$modal", "i18nService", function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_event_form, api_user_data, api_bpm, api_category, $modal, i18nService) {
  3. //默认显示事件总数
  4. $scope.tap = 'SJZS';
  5. //默认无选中,选择日期
  6. $scope.searchstate = 'none';
  7. //默认按日统计
  8. $scope.dateItem = 'day';
  9. //按日
  10. $scope.dayByClick = function () {
  11. $scope.datepickerPopuptime = 'yyyy-MM-dd';//日期格式化
  12. $scope.day(7);//近7天
  13. };
  14. //按月
  15. $scope.monthByClick = function () {
  16. $scope.datepickerPopuptime = 'yyyy-MM';
  17. $scope.month(1);
  18. };
  19. //按年
  20. $scope.yearByClick = function () {
  21. $scope.datepickerPopuptime = 'yyyy';
  22. $scope.year(1);
  23. };
  24. //日期显示格式
  25. $scope.datepickerPopuptime = 'yyyy-MM-dd';
  26. //按日/月/年统计
  27. $scope.dateItemClick = function (str) {
  28. $scope.dateItem = str;
  29. switch (str) {
  30. case 'day':
  31. $scope.dayByClick();
  32. break;
  33. case 'month':
  34. $scope.monthByClick();
  35. break;
  36. case 'year':
  37. $scope.yearByClick();
  38. break;
  39. }
  40. };
  41. // 事件详情
  42. $scope.toDetail= function(rowData, own, searchCriteria, type){
  43. console.log(rowData, own, searchCriteria, type);
  44. var modalInstance = $modal.open({
  45. templateUrl: 'assets/views/incident/tpl/order.tpl.html',
  46. controller: function ($scope, scope, $rootScope, $modalInstance, Alert, api_user_data) {
  47. console.log(rowData, own, type);
  48. $scope.type = type;
  49. $scope.detailsTypeList = [
  50. {type: 'default', name: '事件详情', columnName: '事件详情'},
  51. {type: 'handlingPersonnelUser', name: '人员统计', columnName: '人员姓名'},
  52. {type: 'department', name: '科室统计', columnName: '科室名称'},
  53. {type: 'building', name: '楼栋统计', columnName: '楼栋名称'},
  54. {type: 'floor', name: '楼层统计', columnName: '楼栋楼层名称'},
  55. ];
  56. $scope.detailsType = "default";
  57. $scope.own = {
  58. handlingPersonnelUser: undefined,
  59. department: undefined,
  60. area: undefined,
  61. place: undefined,
  62. }
  63. $scope.columnDefs = [
  64. {
  65. name: 'acceptDate',
  66. displayName: '登记时间',
  67. width: 100,
  68. cellTemplate: '<div style="width: 100%;">' +
  69. '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate, "YYYY-MM-DD")}}<br>{{grid.appScope.transferTime(row.entity.acceptDate, "HH:mm")}}</div>' +
  70. '</div>'
  71. },
  72. {
  73. name: 'incidentsign',
  74. displayName: '单号',
  75. width: 110,
  76. cellTemplate: '<div style="width: 100%;">' +
  77. '<div class="ui-grid-cell-contents table_hover" ng-click="grid.appScope.toIncidentDetail(row.entity)">{{row.entity.incidentsign}}</div>' +
  78. '</div>'
  79. },
  80. {
  81. name: 'department',
  82. displayName: '报修科室',
  83. width: 130,
  84. cellTemplate: '<div style="width: 100%;">' +
  85. '<div class="ui-grid-cell-contents" title="{{row.entity.department ? row.entity.department.dept : \"无\"}}">{{row.entity.department ? row.entity.department.dept : "无"}}</div>' +
  86. '</div>'
  87. },
  88. {
  89. name: 'description',
  90. displayName: '故障描述',
  91. width: 125,
  92. cellTemplate: '<div style="width: 100%;">' +
  93. '<div class="ui-grid-cell-contents" title="{{row.entity.description}}">{{row.entity.description}}</div>' +
  94. '</div>'
  95. },
  96. {
  97. name: 'areaPlace',
  98. displayName: '楼栋楼层',
  99. width: 125,
  100. cellTemplate: '<div style="width: 100%;"><div class="ui-grid-cell-contents" ng-bind-html="grid.appScope.areaplace(row.entity)"></div></div>'
  101. },
  102. {
  103. name: 'groupORHandlerUser',
  104. displayName: '处理人',
  105. width: 85,
  106. },
  107. {
  108. name: 'row8',
  109. displayName: '响应时长',
  110. width: 100,
  111. },
  112. {
  113. name: 'row9',
  114. displayName: '解决时长',
  115. width: 100,
  116. },
  117. {
  118. name: 'degree.name',
  119. displayName: '满意度',
  120. width: 70,
  121. },
  122. ];
  123. $scope.areaplace = function (data) {
  124. var str = '';
  125. str += (data.place ? (data.place.area ? data.place.area.area : '') : '');
  126. str += (data.place ? (data.place.place ? data.place.place : '') : '');
  127. return str || '无';
  128. }
  129. $scope.gridOptions = {};
  130. $scope.gridOptions.columnDefs = $scope.columnDefs;
  131. $scope.gridOptions.rowHeight = 54;
  132. $scope.gridOptions.data = 'myData';
  133. $scope.gridOptions.enableColumnResizing = true;
  134. $scope.gridOptions.enableFiltering = false;
  135. $scope.gridOptions.enableGridMenu = true;
  136. $scope.gridOptions.enableSelectAll = true;
  137. $scope.gridOptions.enableRowSelection = true;
  138. $scope.gridOptions.showGridFooter = true;
  139. $scope.gridOptions.showColumnFooter = false;
  140. $scope.gridOptions.fastWatch = true;
  141. $scope.gridOptions.enableSorting = true;
  142. $scope.gridOptions.useExternalSorting = true;
  143. $scope.gridOptions.useExternalFiltering = false;
  144. $scope.gridOptions.useExternalPagination = true;
  145. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  146. $scope.gridOptions.paginationPageSize = 10;
  147. $scope.gridOptions.multiSelect = true;
  148. $scope.gridOptions.onRegisterApi = function (gridApi) {
  149. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  150. $scope.getData(newPage - 1, pageSize);
  151. });
  152. }
  153. // ---------------start
  154. $scope.columnDefs1 = [
  155. {
  156. name: $scope.detailsType,
  157. displayName: $scope.detailsTypeList.find(v => v.type == $scope.detailsType).columnName,
  158. width: "20%",
  159. cellTemplate: $scope.detailsType === "floor" ? '<div style="width: 100%;">' +
  160. '<div class="ui-grid-cell-contents">{{row.entity.building}} {{row.entity.floor}}</div>' +
  161. '</div>' : '<div style="width: 100%;">' +
  162. '<div class="ui-grid-cell-contents">{{row.entity.'+ $scope.detailsType + '}}</div>' +
  163. '</div>'
  164. },
  165. {
  166. name: 'sum',
  167. displayName: '事件数量',
  168. width: "20%",
  169. },
  170. {
  171. name: 'responseTime',
  172. displayName: '平均响应时长',
  173. width: "20%",
  174. },
  175. {
  176. name: 'resolvedTime',
  177. displayName: '平均解决时长',
  178. width: "20%",
  179. },
  180. {
  181. name: 'proportion',
  182. displayName: '占比',
  183. width: "20%",
  184. },
  185. ];
  186. $scope.gridOptions1 = {};
  187. $scope.gridOptions1.columnDefs = $scope.columnDefs1;
  188. $scope.gridOptions1.rowHeight = 54;
  189. $scope.gridOptions1.data = 'myData1';
  190. $scope.gridOptions1.enableColumnResizing = true;
  191. $scope.gridOptions1.enableFiltering = false;
  192. $scope.gridOptions1.enableGridMenu = true;
  193. $scope.gridOptions1.enableSelectAll = true;
  194. $scope.gridOptions1.enableRowSelection = true;
  195. $scope.gridOptions1.showGridFooter = true;
  196. $scope.gridOptions1.showColumnFooter = false;
  197. $scope.gridOptions1.fastWatch = true;
  198. $scope.gridOptions1.enableSorting = true;
  199. $scope.gridOptions1.useExternalSorting = true;
  200. $scope.gridOptions1.useExternalFiltering = false;
  201. $scope.gridOptions1.useExternalPagination = true;
  202. $scope.gridOptions1.paginationPageSizes = [10, 20, 50, 100];
  203. $scope.gridOptions1.paginationPageSize = 10;
  204. $scope.gridOptions1.multiSelect = true;
  205. // ---------------end
  206. $scope.transferTime = function (time, type) {
  207. if(time){
  208. return moment(time).format(type);
  209. }else{
  210. return '无';
  211. }
  212. }
  213. $scope.toIncidentDetail = function (data) {
  214. $scope.cancel();
  215. // $state.go('app.incident.detail', {
  216. // formKey: 'incident_back',
  217. // pdKey: 'incident',
  218. // dataId: data.id,
  219. // taskId: data.taskId,
  220. // processInstanceId: data.processInstanceId
  221. // });
  222. window.open(location.origin+'/#/app/incident/detail/incident_back/incident/'+data.id+'/'+data.taskId+'/'+data.processInstanceId+'//');
  223. }
  224. // 切换tab
  225. $scope.clickTab = function(item){
  226. $scope.detailsType = item.type;
  227. $scope.getData();
  228. // 故障现象
  229. if(type == 2 && $scope.detailsType != "default"){
  230. $scope.columnDefs1.splice(0, 1 , {
  231. name: $scope.detailsType,
  232. displayName: $scope.detailsTypeList.find(v => v.type == $scope.detailsType).columnName,
  233. width: "20%",
  234. cellTemplate: $scope.detailsType === "floor" ? '<div style="width: 100%;">' +
  235. '<div class="ui-grid-cell-contents">{{row.entity.building}} {{row.entity.floor}}</div>' +
  236. '</div>' : '<div style="width: 100%;">' +
  237. '<div class="ui-grid-cell-contents">{{row.entity.'+ $scope.detailsType + '}}</div>' +
  238. '</div>'
  239. })
  240. }
  241. }
  242. //获取列表数据
  243. $scope.langs = i18nService.getAllLangs();
  244. $scope.lang = 'zh-cn';
  245. i18nService.setCurrentLang($scope.lang);
  246. $scope.langs1 = i18nService.getAllLangs();
  247. $scope.lang1 = 'zh-cn';
  248. i18nService.setCurrentLang($scope.lang1);
  249. $scope.myData1 = [];
  250. $scope.myData = [];
  251. $scope.getData = function (idx = 0, sum = 10) {
  252. // 故障现象
  253. if(type == 2 && $scope.detailsType != "default"){
  254. $rootScope.isMask = true;
  255. api_event_form.fetchSjlxDetail({
  256. "dutyId": own.duty ? own.duty.id : undefined,
  257. "branchId": own.duty ? undefined: (own.branch ? own.branch.id : undefined),
  258. "startTime": moment(searchCriteria.starttimesModel).format('YYYY-MM-DD'),
  259. "endTime": moment(searchCriteria.endtimesModel).format('YYYY-MM-DD'),
  260. "hierarchy": scope.sjSelectedOne.value.id,
  261. "sortData": scope.name,
  262. "sortType": scope.type,
  263. // "sortData": "sum",
  264. // "sortType": "desc",
  265. "detailsType": $scope.detailsType,
  266. "categoryId": rowData.categoryId,
  267. }).then(function (data) {
  268. $rootScope.isMask = false;
  269. if (data.stats) {
  270. $scope.gridOptions1['totalItems'] = data.totalNum;
  271. $scope.myData1 = data.typedataList;//表格列表
  272. } else {
  273. SweetAlert.swal({
  274. title: "系统错误",
  275. text: "请稍后再试!",
  276. type: "error"
  277. });
  278. }
  279. }, function () {
  280. $rootScope.isMask = false;
  281. });
  282. return;
  283. }
  284. var filterData = {
  285. "idx": idx,
  286. "sum": sum,
  287. "incident": {}
  288. };
  289. switch(type){
  290. case 1:
  291. filterData.incident.state = {value: 'close'};
  292. filterData.incident.hasHandlingPersonnelUser = 1;
  293. filterData.incident.acceptDate = moment(rowData.accdate).startOf(searchCriteria.dateItem).format('YYYY-MM-DD HH:mm:ss');
  294. filterData.incident.acceptDateEnd = moment(rowData.accdate).endOf(searchCriteria.dateItem).format('YYYY-MM-DD HH:mm:ss');
  295. filterData.incident.duty = own.duty ? own.duty : undefined;
  296. filterData.incident.branch = own.duty ? undefined : (own.branch ? own.branch.id : undefined);
  297. break;
  298. case 2:
  299. filterData.incident.state = {value: 'close'};
  300. filterData.incident.hasHandlingPersonnelUser = 1;
  301. filterData.incident.acceptDate = moment(searchCriteria.starttimesModel).startOf('day').format('YYYY-MM-DD HH:mm:ss');
  302. filterData.incident.acceptDateEnd = moment(searchCriteria.endtimesModel).endOf('day').format('YYYY-MM-DD HH:mm:ss');
  303. filterData.incident.duty = own.duty ? own.duty : undefined;
  304. filterData.incident.branch = own.duty ? undefined : (own.branch ? own.branch.id : undefined);
  305. filterData.incident.levelCategory = {id: rowData.categoryId};
  306. break;
  307. case 3:
  308. filterData.incident.state = {value: 'close'};
  309. filterData.incident.hasHandlingPersonnelUser = 1;
  310. filterData.incident.acceptDate = moment(searchCriteria.starttimesModel).startOf('day').format('YYYY-MM-DD HH:mm:ss');
  311. filterData.incident.acceptDateEnd = moment(searchCriteria.endtimesModel).endOf('day').format('YYYY-MM-DD HH:mm:ss');
  312. filterData.incident.duty = own.duty ? own.duty : undefined;
  313. filterData.incident.branch = own.duty ? undefined : (own.branch ? own.branch.id : undefined);
  314. filterData.incident.handlingPersonnelUser = {id: rowData.handlingPersonnelUserId};
  315. break;
  316. case 4:
  317. filterData.incident.state = {value: 'close'};
  318. filterData.incident.hasHandlingPersonnelUser = 1;
  319. filterData.incident.acceptDate = moment(searchCriteria.starttimesModel).startOf('day').format('YYYY-MM-DD HH:mm:ss');
  320. filterData.incident.acceptDateEnd = moment(searchCriteria.endtimesModel).endOf('day').format('YYYY-MM-DD HH:mm:ss');
  321. filterData.incident.handlingPersonnelUser = {id: rowData.userId};
  322. break;
  323. }
  324. filterData.incident.handlingPersonnelUser = $scope.own.handlingPersonnelUser;
  325. filterData.incident.department = $scope.own.department;
  326. filterData.incident.area = $scope.own.area;
  327. filterData.incident.place = $scope.own.place;
  328. // debugger;
  329. $rootScope.isMask = true;
  330. api_user_data.fetchDataList('incident', filterData).then(function (data) {
  331. $rootScope.isMask = false;
  332. if (data.list) {
  333. var myData = Restangular.stripRestangular(data);
  334. $scope.gridOptions['totalItems'] = myData.totalNum;
  335. $scope.myData = myData.list;
  336. for (var i = 0; i < $scope.myData.length; i++) {
  337. var row8Minutes = moment($scope.myData[i]['responseHandleTime']).diff(moment($scope.myData[i]['acceptDate']), 'minute');
  338. var row9Minutes = moment($scope.myData[i]['handleTime']).diff(moment($scope.myData[i]['responseHandleTime']), 'minute');
  339. $scope.myData[i]['row8'] = (row8Minutes / 60 >= 1 ? parseInt(row8Minutes / 60) + '小时' : '') + row8Minutes % 60 + '分';
  340. $scope.myData[i]['row9'] = (row9Minutes / 60 >= 1 ? parseInt(row9Minutes / 60)+ '小时' : '') + row9Minutes % 60 + '分';
  341. }
  342. } else {
  343. SweetAlert.swal({
  344. title: "系统错误",
  345. text: "请稍后再试!",
  346. type: "error"
  347. });
  348. }
  349. }, function () {
  350. $rootScope.isMask = false;
  351. });
  352. };
  353. $scope.getData();
  354. // 获取处理人
  355. $scope.getUsers = function(keyWord){
  356. var postData = {
  357. "idx": 0,
  358. "sum": 10,
  359. "user": {
  360. "selectDetails": "1",
  361. "simple": true,
  362. "name": keyWord,
  363. "selectType": "pinyin_qs",
  364. engineer: 1,
  365. }
  366. };
  367. if(own.duty){
  368. postData.user.duty = own.duty;
  369. }else if(own.branch){
  370. postData.user.branch = own.branch;
  371. }
  372. api_user_data.fetchDataList("user", postData).then(function (data) {
  373. $scope.users = data.list || [];
  374. });
  375. }
  376. // 获取报修科室
  377. $scope.getDepts = function(keyWord){
  378. var postData = {
  379. "idx": 0,
  380. "sum": 10,
  381. "department": {
  382. dept: keyWord,
  383. selectType: "pinyin_qs"
  384. }
  385. };
  386. if(own.branch){
  387. postData.department.branch = own.branch.id;
  388. }
  389. api_user_data.fetchDataList("department", postData).then(function (data) {
  390. $scope.depts = data.list || [];
  391. });
  392. }
  393. // 获取楼栋
  394. $scope.getAreas = function(keyWord){
  395. var postData = {
  396. "idx": 0,
  397. "sum": 9999,
  398. "area": {
  399. area: keyWord,
  400. selectType: "pinyin_qs"
  401. }
  402. };
  403. if(own.branch){
  404. postData.area.branch = own.branch.id;
  405. }
  406. api_user_data.fetchDataList("area", postData).then(function (data) {
  407. $scope.areas = data.list || [];
  408. });
  409. }
  410. // 选择楼栋
  411. $scope.changeArea = function(){
  412. $scope.own.place = undefined;
  413. $scope.places = [];
  414. $scope.getPlaces('', $scope.own.area.id)
  415. }
  416. // 获取楼层
  417. $scope.getPlaces = function(keyWord,areaId){
  418. if(!areaId){
  419. $scope.places = [];
  420. return;
  421. }
  422. var postData = {
  423. "idx": 0,
  424. "sum": 9999,
  425. "place": {
  426. areaId: areaId,
  427. place: keyWord,
  428. selectType: "pinyin_qs"
  429. }
  430. };
  431. if(own.branch){
  432. postData.place.branch = own.branch.id;
  433. }
  434. api_user_data.fetchDataList("place", postData).then(function (data) {
  435. $scope.places = data.list || [];
  436. });
  437. }
  438. $scope.reload = function(){
  439. $scope.own = {
  440. handlingPersonnelUser: undefined,
  441. department: undefined,
  442. area: undefined,
  443. place: undefined,
  444. }
  445. $scope.places = [];
  446. $scope.getData();
  447. }
  448. $scope.cancel = function () {
  449. $modalInstance.dismiss('cancel');
  450. }
  451. },
  452. size: 'lg',
  453. resolve: {
  454. Alert: function () {
  455. return SweetAlert;
  456. },
  457. api_user_data: function () {
  458. return api_user_data;
  459. },
  460. scope: function () {
  461. return $scope;
  462. }
  463. }
  464. });
  465. modalInstance.result.then(function (selectedItem) {});
  466. }
  467. // 切换院区
  468. $scope.own = {};
  469. $scope.changeBranch = function(){
  470. console.log($scope.own.branch);
  471. $scope.dutys = [];
  472. $scope.own.duty = null;
  473. $scope.own.branch && $scope.getOwnDuty($scope.own.branch.id);
  474. $scope.groupSelected = [{
  475. id: -2,
  476. groupName: '按组选择'
  477. }, {
  478. id: -1,
  479. groupName: '按人选择'
  480. }];
  481. $scope.groupSelectedOne = {
  482. value: $scope.groupSelected[1]//选中
  483. };
  484. $scope.own.duty && $scope.tap == 'CLRZ' && $scope.mdxquery();
  485. }
  486. // 切换责任科室
  487. $scope.changeDuty = function(){
  488. console.log($scope.own.duty);
  489. $scope.groupSelected = [{
  490. id: -2,
  491. groupName: '按组选择'
  492. }, {
  493. id: -1,
  494. groupName: '按人选择'
  495. }];
  496. $scope.groupSelectedOne = {
  497. value: $scope.groupSelected[1]//选中
  498. };
  499. $scope.own.duty && $scope.tap == 'CLRZ' && $scope.mdxquery();
  500. $scope.companySelected = [];
  501. $scope.companySelectedOne.value = {id:-1,name:''};
  502. $scope.own.duty && $scope.tap == 'SFGS' && $scope.mdxquery();
  503. }
  504. // 获取院区
  505. $scope.branchs = [];
  506. $scope.getOwnBranch = function(){
  507. api_category
  508. .getOwnBranch({})
  509. .then(function (response) {
  510. if (response) {
  511. if ((response.status = 200)) {
  512. $scope.branchs = response.data;
  513. if($rootScope.user.duty){
  514. $scope.own.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  515. $scope.getOwnDuty($rootScope.user.duty.branch, true);
  516. }else if($rootScope.user.branch){
  517. $scope.own.branch = $rootScope.user.branch;
  518. $scope.getOwnDuty($rootScope.user.branch.id, true);
  519. $scope.init();
  520. }
  521. }
  522. }
  523. });
  524. }
  525. $scope.getOwnBranch();
  526. // 获取责任科室
  527. $scope.dutys = [];
  528. $scope.getOwnDuty = function(branchId, isFirst = false, isReload = false){
  529. api_category
  530. .getOwnDuty({branchId: branchId})
  531. .then(function (response) {
  532. if (response) {
  533. if ((response.status = 200)) {
  534. $scope.dutys = response.data;
  535. if(isFirst && $rootScope.user.duty){
  536. $scope.own.duty = $rootScope.user.duty;
  537. // $scope.getGroups($scope.own.duty);
  538. $scope.init();
  539. }
  540. if(isReload){
  541. if($rootScope.user.duty){
  542. $scope.own.duty = $rootScope.user.duty;
  543. }
  544. switch ($scope.tap) {
  545. case 'SJZS'://事件总数
  546. $scope.sortActive = 'accdatetop';
  547. $scope.name = 'accdate';//表格排序,字段名称
  548. $scope.mdxquery('accdate', 'desc');
  549. break;
  550. case 'SJLX'://故障现象
  551. $scope.sortActive = 'sumtop';
  552. $scope.name = 'sum';//表格排序,字段名称
  553. $scope.mdxquery('sum', 'desc');
  554. $scope.sjSelectedOne.value = $scope.sjSelected[0];//故障现象级别
  555. break;
  556. case 'CLRZ'://处理人/组
  557. $scope.sortActive = 'sumtop';
  558. $scope.name = 'sum';//表格排序,字段名称
  559. $scope.mdxquery('sum', 'desc');
  560. $scope.groupSelectedOne.value = $scope.groupSelected[1];//选择处理人/组
  561. break;
  562. case 'SFGS'://三方公司
  563. $scope.sortActive = 'i_totaltop';
  564. $scope.name = 'i_total';//表格排序,字段名称
  565. $scope.mdxquery('i_total', 'desc');
  566. $scope.companySelectedOne.value = {id:-1,name:''};//选择三方公司
  567. break;
  568. case 'QYDD'://区域地点
  569. $scope.sortActive = 'sumtop';
  570. $scope.name = 'sum';//表格排序,字段名称
  571. $scope.mdxquery('sum', 'desc');
  572. $scope.areaSelectedOne.value = $scope.areaSelected[0];//区域/地点
  573. break;
  574. case 'KSTJ'://科室统计
  575. $scope.sortActive = 'sumtop';
  576. $scope.name = 'sum';//表格排序,字段名称
  577. $scope.mdxquery('sum', 'desc');
  578. break;
  579. case 'SJLY'://事件来源
  580. $scope.sortActive = 'sumtop';
  581. $scope.name = 'sum';//表格排序,字段名称
  582. $scope.mdxquery('sum', 'desc');
  583. break;
  584. }
  585. }
  586. }
  587. }
  588. });
  589. }
  590. //切换开始/结束日期
  591. $scope.timesChange = function (str) {
  592. //切换结束日期的时候为年底或月底,方便传参
  593. switch (str) {
  594. case 'month':
  595. $scope.endtimesModel = moment($scope.endtimesModel).endOf('month').toDate();
  596. break;
  597. case 'year':
  598. $scope.endtimesModel = moment($scope.endtimesModel).endOf('year').toDate();
  599. break;
  600. }
  601. $scope.datepickerUpdate(str);
  602. };
  603. //配置项更新
  604. $scope.datepickerUpdate = function (str) {
  605. //开始的datepickerOptions
  606. $scope.datepickerOptionsStart = {
  607. maxDate: moment($scope.endtimesModel).format('YYYY/MM/DD'),
  608. minMode: str,
  609. datepickerMode: str
  610. };
  611. //结束的datepickerOptions
  612. $scope.datepickerOptionsEnd = {
  613. minDate: moment($scope.starttimesModel).format('YYYY/MM/DD'),
  614. maxDate: moment().format('YYYY/MM/DD'),
  615. minMode: str,
  616. datepickerMode: str
  617. };
  618. };
  619. //日期选择
  620. //近N周
  621. $scope.week = function (num) {
  622. num = num > 1 ? num : 1;
  623. $scope.searchstate = "week" + num;
  624. var weeks = new Date().getDay();
  625. $scope.starttimesModel = moment(new Date().getTime() - num * 86400000 * (weeks + 6)).toDate();
  626. $scope.endtimesModel = moment(new Date().getTime() - 86400000 * (weeks)).toDate();
  627. $scope.datepickerUpdate('day');
  628. }
  629. //近N月
  630. $scope.month = function (num) {
  631. num = num > 1 ? num : 1;
  632. $scope.searchstate = "month" + num;
  633. $scope.starttimesModel = moment().startOf('month').add(-num, 'M').toDate();
  634. $scope.endtimesModel = moment().endOf('month').add(-1, 'M').toDate();
  635. $scope.datepickerUpdate('month');
  636. }
  637. //近N年
  638. $scope.year = function (num) {
  639. num = num > 1 ? num : 1;
  640. $scope.searchstate = "year" + num;
  641. $scope.starttimesModel = moment().startOf('year').add(-num, 'y').toDate();
  642. $scope.endtimesModel = moment().endOf('year').add(-1, 'y').toDate();
  643. $scope.datepickerUpdate('year');
  644. }
  645. //近N日
  646. $scope.day = function (num) {
  647. num = num > 1 ? num : 1;
  648. $scope.searchstate = "none";
  649. $scope.starttimesModel = moment().subtract(num, "days").toDate();
  650. $scope.endtimesModel = moment().subtract(1, "days").toDate();
  651. $scope.datepickerUpdate('day');
  652. }
  653. //选择上一周,上个月,去年等等快捷方式
  654. $scope.chooseDate = function (date) {
  655. switch (date) {
  656. case 'week1'://上周
  657. $scope.week(1);
  658. break;
  659. case 'month1'://上个月
  660. $scope.month(1);
  661. break;
  662. case 'month3'://近三月
  663. $scope.month(3);
  664. break;
  665. case 'month6'://近六月
  666. $scope.month(6);
  667. break;
  668. case 'year1'://去年
  669. $scope.year(1);
  670. break;
  671. case 'year3'://近三年
  672. $scope.year(3);
  673. break;
  674. case 'year5'://近五年
  675. $scope.year(5);
  676. break;
  677. }
  678. };
  679. // 故障现象级别
  680. $scope.sjSelected = [{
  681. name: '一级分类',
  682. id: 1
  683. }, {
  684. name: '二级分类',
  685. id: 2
  686. }, {
  687. name: '三级分类',
  688. id: 3
  689. }];
  690. $scope.sjSelectedOne = {
  691. value: $scope.sjSelected[0]//选中
  692. };
  693. // 处理人/组
  694. $scope.groupSelected = [{
  695. id: -2,
  696. groupName: '按组选择'
  697. }, {
  698. id: -1,
  699. groupName: '按人选择'
  700. }];
  701. $scope.groupSelectedOne = {
  702. value: $scope.groupSelected[1]//选中
  703. };
  704. $scope.tableGroupSelectedOne = '';//处理组或人
  705. // 三方公司
  706. $scope.companySelected = [];
  707. $scope.companySelectedOne = {
  708. value: {id:-1,name:""}//选中
  709. };
  710. // 区域地点
  711. $scope.areaSelected = [{
  712. name: '区域',
  713. id: 1
  714. }, {
  715. name: '地点',
  716. id: 2
  717. }];
  718. $scope.areaSelectedOne = {
  719. value: $scope.areaSelected[0]//选中
  720. };
  721. /**
  722. *日历
  723. */
  724. //打开开始日期选择框
  725. $scope.startOpen = function ($event) {
  726. console.log(1)
  727. $event.preventDefault();
  728. $event.stopPropagation();
  729. $scope.endOpened = false;
  730. $scope.startOpened = !$scope.startOpened;
  731. };
  732. //打开结束日期选择框
  733. $scope.endOpen = function ($event) {
  734. $event.preventDefault();
  735. $event.stopPropagation();
  736. $scope.startOpened = false;
  737. $scope.endOpened = !$scope.endOpened;
  738. };
  739. //重置
  740. $scope.reload = function () {
  741. $scope.dateItemClick('day');
  742. $scope.type = 'desc';//表格排序,排序方式desc,asc
  743. $scope.direction = 'top';//箭头方向 top,bottom
  744. if($rootScope.user.duty){
  745. $scope.own.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  746. $scope.getOwnDuty($rootScope.user.duty.branch, false, true);
  747. }else if($rootScope.user.branch){
  748. $scope.own.branch = $rootScope.user.branch;
  749. $scope.getOwnDuty($rootScope.user.branch.id, false, true);
  750. }
  751. };
  752. //选择类型,事件总数,故障现象,处理人/组,区域地点
  753. $scope.active = function (name) {
  754. $scope.tap = name;
  755. $scope.reload();
  756. };
  757. //事件总数,无限滚动加载
  758. $scope.topEndComplete = function () {
  759. console.log('滚动');
  760. };
  761. //表格排序------------------------------------------------
  762. $scope.sortActive = '';//表格排序,箭头高亮选中状态
  763. $scope.type = '';//表格排序,排序方式desc,asc
  764. $scope.name = '';//表格排序,字段名称
  765. $scope.direction = '';//箭头方向 top,bottom
  766. /**
  767. * 表格排序
  768. *
  769. * @param {string} name 字段名称
  770. * @param {string} type 排序方式desc,asc
  771. * @param {string} direction 箭头方向 top,bottom
  772. */
  773. $scope.tableSort = function (name, type, direction) {
  774. if ($scope.name == name) {
  775. $scope.type = $scope.type == 'desc' ? 'asc' : 'desc';
  776. $scope.direction = $scope.direction == 'top' ? 'bottom' : 'top';
  777. } else {
  778. $scope.type = 'desc';
  779. $scope.direction = 'top';
  780. }
  781. $scope.name = name;
  782. $scope.sortActive = name + $scope.direction;
  783. $scope.mdxquery(name, $scope.type);
  784. };
  785. //搜索----------------------------------------------------
  786. //loading
  787. $scope.isArrays = function (arr) {
  788. return Array.isArray(arr);
  789. };
  790. //事件总数
  791. $scope.sjzs_list = null;//表格列表
  792. $scope.sjzs_num = 0;//事件总数数量
  793. $scope.sjzs_responseTime = '0分';//平均响应时间
  794. $scope.sjzs_resolvedTime = '0分';//平均解决时间
  795. $scope.sjzs_satisfactionRatio = 0;//满意度
  796. //故障现象
  797. $scope.sjlx_list = null;//表格列表
  798. $scope.sjlx_num = 0;//事件总数数量
  799. //处理人/组
  800. $scope.clrz_list = null;//表格列表
  801. $scope.clrz_num = 0;//事件总数数量
  802. $scope.clrz_responseTime = '0分';//平均响应时间
  803. $scope.clrz_resolvedTime = '0分';//平均解决时间
  804. $scope.clrz_satisfactionRatio = 0;//满意度
  805. //三方公司
  806. $scope.sfgs_list = null;//表格列表
  807. $scope.sfgs_c_total = 0;//公司总数
  808. $scope.sfgs_u_total = 0;//人员总数
  809. $scope.sfgs_p_total = 0;//解决事件总数
  810. $scope.sfgs_p_time = '0分';//平均解决时长
  811. //区域地点
  812. $scope.qydd_list = null;//表格列表
  813. $scope.qydd_num = 0;//事件总数数量
  814. //科室统计
  815. $scope.kstj_list = null;//表格列表
  816. $scope.kstj_num = 0;//事件总数数量
  817. //事件来源
  818. $scope.sjly_list = null;//表格列表
  819. $scope.sjly_num = 0;//事件总数数量
  820. /**
  821. *
  822. *
  823. * @param {string} name 排序字段
  824. * @param {string} type 排序方式 desc,asc
  825. */
  826. $scope.mdxquery = function (name, type) {
  827. if (!name) {
  828. if($scope.tap == 'SJZS'){
  829. name = 'accdate';
  830. }else if($scope.tap == 'SFGS'){
  831. name = 'i_total';
  832. }else{
  833. name = 'sum';
  834. }
  835. }
  836. type = type || 'desc';
  837. switch ($scope.tap) {
  838. case 'SJZS'://事件总数
  839. $scope.sjzs_list = null;
  840. // 请求列表
  841. api_event_form.fetchSjzsList({
  842. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  843. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  844. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  845. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  846. "type": $scope.dateItem,
  847. "sortData": name,
  848. "sortType": type
  849. }).then(function (res) {
  850. if (res.stats == 200) {
  851. $scope.sjzs_list = res.dataList;//表格列表
  852. $scope.sjzs_num = res.sum;//事件总数数量
  853. $scope.sjzs_responseTime = res.responseTime;//平均响应时间
  854. $scope.sjzs_resolvedTime = res.resolvedTime;//平均解决时间
  855. $scope.sjzs_satisfactionRatio = res.satisfactionRatio;//满意度
  856. }
  857. })
  858. break;
  859. case 'SJLX'://故障现象
  860. $scope.sjlx_list = null;
  861. // 请求列表
  862. api_event_form.fetchSjlxList({
  863. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  864. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  865. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  866. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  867. "hierarchy": $scope.sjSelectedOne.value.id,
  868. "sortData": name,
  869. "sortType": type
  870. }).then(function (res) {
  871. if (res.stats == 200) {
  872. $scope.sjlx_list = res.typedataList;//表格列表
  873. $scope.sjlx_num = res.data.sum;//事件总数数量
  874. }
  875. })
  876. // 请求事件总数数量
  877. // api_event_form.getSjNum({
  878. // "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  879. // "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  880. // "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  881. // "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  882. // }).then(function (res) {
  883. // if (res.stats == 200) {
  884. // $scope.sjlx_num = res.data[0].sum;//事件总数数量
  885. // }
  886. // })
  887. break;
  888. case 'CLRZ'://处理人/组
  889. $scope.clrz_list = null;
  890. //获取组
  891. api_user_data.fetchDataList('group', {
  892. idx: 0,
  893. sum: 1000,
  894. group: {
  895. duty: $scope.own.duty || undefined,
  896. selectType: "nouser"
  897. }
  898. }).then(res => {
  899. if (res.status == 200) {
  900. var groupList = [{
  901. id: -2,
  902. groupName: '按组选择'
  903. }, {
  904. id: -1,
  905. groupName: '按人选择'
  906. }];
  907. groupList.push(...res.list);
  908. $scope.groupSelected = groupList;//下拉框数据
  909. // 请求列表
  910. if ($scope.groupSelectedOne.value.id == -2) {//按组
  911. var params = {
  912. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  913. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  914. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  915. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  916. "type": 1,
  917. "sortData": name,
  918. "sortType": type
  919. };
  920. } else if ($scope.groupSelectedOne.value.id == -1) {//按人
  921. var params = {
  922. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  923. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  924. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  925. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  926. "type": 2,
  927. "sortData": name,
  928. "sortType": type
  929. };
  930. } else {
  931. var params = {
  932. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  933. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  934. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  935. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  936. "type": 3,
  937. "groupid": $scope.groupSelectedOne.value.id,
  938. "sortData": name,
  939. "sortType": type
  940. };
  941. }
  942. api_event_form.fetchClrzList(params).then(function (res) {
  943. if (res.stats == 200) {
  944. $scope.tableGroupSelectedOne = params.type;//处理人或组
  945. $scope.clrz_list = res.listData;//表格列表
  946. $scope.clrz_num = res.sum;//事件总数量
  947. $scope.clrz_responseTime = res.responseTime;//平均响应时间
  948. $scope.clrz_resolvedTime = res.resolvedTime;//平均解决时间
  949. $scope.clrz_satisfactionRatio = res.satisfactionRatio;//满意度
  950. }
  951. })
  952. }
  953. })
  954. break;
  955. case 'SFGS'://三方公司
  956. $scope.sfgs_list = null;
  957. //获取三方公司
  958. api_user_data.fetchDataList('company', {
  959. idx: 0,
  960. sum: 1000,
  961. company: {
  962. "duty": $scope.own.duty || undefined,
  963. }
  964. }).then(res => {
  965. if (res.status == 200) {
  966. $scope.companySelected = res.list;//下拉框数据
  967. // 请求列表
  968. var postData = {
  969. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  970. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  971. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  972. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  973. "sortData": name,
  974. "sortType": type
  975. }
  976. if($scope.companySelectedOne.value.id > 0){
  977. postData.companyId = $scope.companySelectedOne.value.id;
  978. }
  979. api_event_form.fetchSfgsList(postData).then(function (res) {
  980. if (res.stats == 200) {
  981. $scope.sfgs_list = res.dataList;//表格列表
  982. $scope.sfgs_c_total = res.title.c_total;//公司总数
  983. $scope.sfgs_u_total = res.title.u_total;//人员总数
  984. $scope.sfgs_p_total = res.title.p_total;//解决事件总数
  985. $scope.sfgs_p_time = res.title.p_time;//平均解决时长
  986. }
  987. })
  988. }
  989. })
  990. break;
  991. case 'QYDD'://区域地点
  992. $scope.qydd_list = null;
  993. // 请求列表
  994. api_event_form.fetchQyddList({
  995. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  996. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  997. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  998. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  999. "type": $scope.areaSelectedOne.value.id,
  1000. "sortData": name,
  1001. "sortType": type
  1002. }).then(function (res) {
  1003. if (res.stats == 200) {
  1004. $scope.qydd_list = res.listData;//表格列表
  1005. $scope.qydd_num = res.data.sum;//事件总数数量
  1006. }
  1007. })
  1008. // 请求事件总数数量
  1009. // api_event_form.getSjNum({
  1010. // "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1011. // "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1012. // "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1013. // "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD')
  1014. // }).then(function (res) {
  1015. // if (res.stats == 200) {
  1016. // $scope.qydd_num = res.data[0].sum;//事件总数数量
  1017. // }
  1018. // })
  1019. break;
  1020. case 'KSTJ'://科室统计
  1021. $scope.kstj_list = null;
  1022. // 请求列表
  1023. api_event_form.fetchKstjList({
  1024. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1025. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1026. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1027. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  1028. "sortData": name,
  1029. "sortType": type
  1030. }).then(function (res) {
  1031. if (res.stats == 200) {
  1032. $scope.kstj_list = res.dataList;//表格列表
  1033. $scope.kstj_num = res.data.sum;//事件总数数量
  1034. }
  1035. })
  1036. break;
  1037. case 'SJLY'://事件来源
  1038. $scope.sjly_list = null;
  1039. // 请求列表
  1040. api_event_form.fetchSjlyList({
  1041. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1042. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1043. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1044. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  1045. "sortData": name,
  1046. "sortType": type
  1047. }).then(function (res) {
  1048. if (res.stats == 200) {
  1049. $scope.sjly_list = res.listData;//表格列表
  1050. $scope.sjly_num = res.data.sum;//事件总数数量
  1051. }
  1052. })
  1053. // 请求事件总数数量
  1054. // api_event_form.getSjNum({
  1055. // "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1056. // "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1057. // "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1058. // "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD')
  1059. // }).then(function (res) {
  1060. // if (res.stats == 200) {
  1061. // $scope.sjly_num = res.data[0].sum;//事件总数数量
  1062. // }
  1063. // })
  1064. break;
  1065. }
  1066. };
  1067. // 请求人
  1068. // api_user_data.fetchDataList('requester', {
  1069. // "idx": 0,
  1070. // "sum": 10
  1071. // }).then(function (response) {
  1072. // if (response) {
  1073. // if (response.status = 200) {
  1074. // $scope.requester = response.list;
  1075. // }
  1076. // }
  1077. // })
  1078. //导出
  1079. $scope.export = function () {
  1080. var postData = {
  1081. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1082. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  1083. "sortData": $scope.name,
  1084. "sortType": $scope.type,
  1085. report: {}
  1086. }
  1087. switch ($scope.tap) {
  1088. case 'SJZS'://事件总数
  1089. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1090. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1091. postData.type = $scope.dateItem;
  1092. postData.key = 'mdv2_incident_repot_sum';
  1093. if($scope.own.duty && $scope.own.duty.addSummary == 1){
  1094. postData.titles = ['时间', '事件数量', '平均响应时间', '平均解决时间', '耗材费用', '工时费用', '总费用'];
  1095. }else{
  1096. postData.titles = ['时间', '事件数量', '平均响应时间', '平均解决时间'];
  1097. }
  1098. break;
  1099. case 'SJLX'://故障现象
  1100. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1101. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1102. postData.hierarchy = $scope.sjSelectedOne.value.id;
  1103. postData.key = 'mdv2_incident_repot_type';
  1104. if($scope.own.duty && $scope.own.duty.addSummary == 1){
  1105. postData.titles = ['故障现象', '类型数量', '类型占比', '平均响应时间', '平均解决时间', '耗材费用', '工时费用', '总费用'];
  1106. }else{
  1107. postData.titles = ['故障现象', '类型数量', '类型占比', '平均响应时间', '平均解决时间'];
  1108. }
  1109. break;
  1110. case 'CLRZ'://处理人/组
  1111. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1112. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1113. let CLRZ_TYPE = ''
  1114. if ($scope.groupSelectedOne.value.id == -2) {//按组
  1115. postData.type = 1;
  1116. CLRZ_TYPE = '处理组';
  1117. postData.titles = [CLRZ_TYPE, '协同处理数', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)'];
  1118. } else if ($scope.groupSelectedOne.value.id == -1) {//按人
  1119. postData.type = 2;
  1120. CLRZ_TYPE = '处理人';
  1121. postData.titles = [CLRZ_TYPE, '协同处理数', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)', '耗材费用', '工时费用', '总费用'];
  1122. } else {
  1123. postData.type = 3;
  1124. CLRZ_TYPE = '处理人';
  1125. postData.titles = [CLRZ_TYPE, '协同处理数', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)', '耗材费用', '工时费用', '总费用'];
  1126. }
  1127. postData.key = 'mdv2_incident_repot_handle';
  1128. break;
  1129. case 'SFGS'://三方公司
  1130. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1131. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1132. postData.key = 'mdv2_incident_repot_company';
  1133. postData.titles = [($scope.sfgs_list[0]&&$scope.sfgs_list[0].userName)?'人员名称':'公司名称', '人员总数', '事件数量', '平均响应时长', '平均解决时长'];
  1134. if($scope.sfgs_list[0]&&$scope.sfgs_list[0].userName){
  1135. postData.titles.splice(1,1);
  1136. }
  1137. break;
  1138. case 'QYDD'://区域地点
  1139. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1140. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1141. postData.type = $scope.areaSelectedOne.value.id;
  1142. postData.key = 'mdv2_incident_repot_area_place';
  1143. postData.titles = ['区域/地点', '事件数量', '事件占比'];
  1144. break;
  1145. case 'KSTJ'://科室统计
  1146. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1147. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1148. postData.key = 'mdv2_incident_repot_dept';
  1149. if($scope.own.duty && $scope.own.duty.addSummary == 1){
  1150. postData.titles = ['科室名称', '事件数量', '事件占比', '耗材费用', '工时费用', '总费用'];
  1151. }else{
  1152. postData.titles = ['科室名称', '事件数量', '事件占比'];
  1153. }
  1154. break;
  1155. case 'SJLY'://事件来源
  1156. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1157. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1158. postData.key = 'mdv2_incident_repot_source';
  1159. postData.titles = ['事件来源', '事件数量', '事件来源占比'];
  1160. break;
  1161. }
  1162. var wt_url = api_bpm.downDataModel('report', 1).getRequestedUrl()
  1163. $http({
  1164. url: wt_url,
  1165. method: 'POST',
  1166. data: JSON.stringify(postData),
  1167. headers: {
  1168. 'Accept': '*/*'
  1169. },
  1170. responseType: 'arraybuffer'
  1171. }).success(function (data, status, headers, config) {
  1172. var fileName = '';
  1173. switch ($scope.tap) {
  1174. case 'SJZS'://事件总数
  1175. fileName = '事件总数';
  1176. break;
  1177. case 'SJLX'://故障现象
  1178. fileName = '故障现象';
  1179. break;
  1180. case 'CLRZ'://处理人/组
  1181. fileName = '处理人/组';
  1182. break;
  1183. case 'SFGS'://三方公司
  1184. fileName = '三方公司';
  1185. break;
  1186. case 'QYDD'://区域地点
  1187. fileName = '区域地点';
  1188. break;
  1189. case 'KSTJ'://科室统计
  1190. fileName = '科室统计';
  1191. break;
  1192. case 'SJLY'://事件来源
  1193. fileName = '事件来源';
  1194. break;
  1195. }
  1196. // var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
  1197. var file = new Blob([data], {
  1198. type: 'application/vnd.ms-excel'
  1199. });
  1200. var fileURL = URL.createObjectURL(file);
  1201. var a = document.createElement('a');
  1202. a.href = fileURL;
  1203. a.target = '_blank';
  1204. a.download = fileName + '.xls';
  1205. document.body.appendChild(a);
  1206. a.click();
  1207. }).error(function (data, status, headers, config) {
  1208. });
  1209. };
  1210. //初始化
  1211. $scope.init = function(){
  1212. $scope.dateItemClick('day');
  1213. $scope.mdxquery('accdate', 'desc');
  1214. $scope.sortActive = 'accdatetop';
  1215. $scope.name = 'accdate';//表格排序,字段名称
  1216. $scope.type = 'desc';//表格排序,排序方式desc,asc
  1217. $scope.direction = 'top';//箭头方向 top,bottom
  1218. }
  1219. }])