event_formCtrl.js 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  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. }
  501. // 获取院区
  502. $scope.branchs = [];
  503. $scope.getOwnBranch = function(){
  504. api_category
  505. .getOwnBranch({})
  506. .then(function (response) {
  507. if (response) {
  508. if ((response.status = 200)) {
  509. $scope.branchs = response.data;
  510. if($rootScope.user.duty){
  511. $scope.own.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  512. $scope.getOwnDuty($rootScope.user.duty.branch, true);
  513. }else if($rootScope.user.branch){
  514. $scope.own.branch = $rootScope.user.branch;
  515. $scope.getOwnDuty($rootScope.user.branch.id, true);
  516. $scope.init();
  517. }
  518. }
  519. }
  520. });
  521. }
  522. $scope.getOwnBranch();
  523. // 获取责任科室
  524. $scope.dutys = [];
  525. $scope.getOwnDuty = function(branchId, isFirst = false, isReload = false){
  526. api_category
  527. .getOwnDuty({branchId: branchId})
  528. .then(function (response) {
  529. if (response) {
  530. if ((response.status = 200)) {
  531. $scope.dutys = response.data;
  532. if(isFirst && $rootScope.user.duty){
  533. $scope.own.duty = $rootScope.user.duty;
  534. // $scope.getGroups($scope.own.duty);
  535. $scope.init();
  536. }
  537. if(isReload){
  538. if($rootScope.user.duty){
  539. $scope.own.duty = $rootScope.user.duty;
  540. }
  541. switch ($scope.tap) {
  542. case 'SJZS'://事件总数
  543. $scope.sortActive = 'accdatetop';
  544. $scope.name = 'accdate';//表格排序,字段名称
  545. $scope.mdxquery('accdate', 'desc');
  546. break;
  547. case 'SJLX'://故障现象
  548. $scope.sortActive = 'sumtop';
  549. $scope.name = 'sum';//表格排序,字段名称
  550. $scope.mdxquery('sum', 'desc');
  551. $scope.sjSelectedOne.value = $scope.sjSelected[0];//故障现象级别
  552. break;
  553. case 'CLRZ'://处理人/组
  554. $scope.sortActive = 'sumtop';
  555. $scope.name = 'sum';//表格排序,字段名称
  556. $scope.mdxquery('sum', 'desc');
  557. $scope.groupSelectedOne.value = $scope.groupSelected[1];//选择处理人/组
  558. break;
  559. case 'SFGS'://三方公司
  560. $scope.sortActive = 'i_totaltop';
  561. $scope.name = 'i_total';//表格排序,字段名称
  562. $scope.mdxquery('i_total', 'desc');
  563. $scope.companySelectedOne.value = {id:-1,name:''};//选择三方公司
  564. break;
  565. case 'QYDD'://区域地点
  566. $scope.sortActive = 'sumtop';
  567. $scope.name = 'sum';//表格排序,字段名称
  568. $scope.mdxquery('sum', 'desc');
  569. $scope.areaSelectedOne.value = $scope.areaSelected[0];//区域/地点
  570. break;
  571. case 'KSTJ'://科室统计
  572. $scope.sortActive = 'sumtop';
  573. $scope.name = 'sum';//表格排序,字段名称
  574. $scope.mdxquery('sum', 'desc');
  575. break;
  576. case 'SJLY'://事件来源
  577. $scope.sortActive = 'sumtop';
  578. $scope.name = 'sum';//表格排序,字段名称
  579. $scope.mdxquery('sum', 'desc');
  580. break;
  581. }
  582. }
  583. }
  584. }
  585. });
  586. }
  587. //切换开始/结束日期
  588. $scope.timesChange = function (str) {
  589. //切换结束日期的时候为年底或月底,方便传参
  590. switch (str) {
  591. case 'month':
  592. $scope.endtimesModel = moment($scope.endtimesModel).endOf('month').toDate();
  593. break;
  594. case 'year':
  595. $scope.endtimesModel = moment($scope.endtimesModel).endOf('year').toDate();
  596. break;
  597. }
  598. $scope.datepickerUpdate(str);
  599. };
  600. //配置项更新
  601. $scope.datepickerUpdate = function (str) {
  602. //开始的datepickerOptions
  603. $scope.datepickerOptionsStart = {
  604. maxDate: moment($scope.endtimesModel).format('YYYY/MM/DD'),
  605. minMode: str,
  606. datepickerMode: str
  607. };
  608. //结束的datepickerOptions
  609. $scope.datepickerOptionsEnd = {
  610. minDate: moment($scope.starttimesModel).format('YYYY/MM/DD'),
  611. maxDate: moment().format('YYYY/MM/DD'),
  612. minMode: str,
  613. datepickerMode: str
  614. };
  615. };
  616. //日期选择
  617. //近N周
  618. $scope.week = function (num) {
  619. num = num > 1 ? num : 1;
  620. $scope.searchstate = "week" + num;
  621. var weeks = new Date().getDay();
  622. $scope.starttimesModel = moment(new Date().getTime() - num * 86400000 * (weeks + 6)).toDate();
  623. $scope.endtimesModel = moment(new Date().getTime() - 86400000 * (weeks)).toDate();
  624. $scope.datepickerUpdate('day');
  625. }
  626. //近N月
  627. $scope.month = function (num) {
  628. num = num > 1 ? num : 1;
  629. $scope.searchstate = "month" + num;
  630. $scope.starttimesModel = moment().startOf('month').add(-num, 'M').toDate();
  631. $scope.endtimesModel = moment().endOf('month').add(-1, 'M').toDate();
  632. $scope.datepickerUpdate('month');
  633. }
  634. //近N年
  635. $scope.year = function (num) {
  636. num = num > 1 ? num : 1;
  637. $scope.searchstate = "year" + num;
  638. $scope.starttimesModel = moment().startOf('year').add(-num, 'y').toDate();
  639. $scope.endtimesModel = moment().endOf('year').add(-1, 'y').toDate();
  640. $scope.datepickerUpdate('year');
  641. }
  642. //近N日
  643. $scope.day = function (num) {
  644. num = num > 1 ? num : 1;
  645. $scope.searchstate = "none";
  646. $scope.starttimesModel = moment().subtract(num, "days").toDate();
  647. $scope.endtimesModel = moment().subtract(1, "days").toDate();
  648. $scope.datepickerUpdate('day');
  649. }
  650. //选择上一周,上个月,去年等等快捷方式
  651. $scope.chooseDate = function (date) {
  652. switch (date) {
  653. case 'week1'://上周
  654. $scope.week(1);
  655. break;
  656. case 'month1'://上个月
  657. $scope.month(1);
  658. break;
  659. case 'month3'://近三月
  660. $scope.month(3);
  661. break;
  662. case 'month6'://近六月
  663. $scope.month(6);
  664. break;
  665. case 'year1'://去年
  666. $scope.year(1);
  667. break;
  668. case 'year3'://近三年
  669. $scope.year(3);
  670. break;
  671. case 'year5'://近五年
  672. $scope.year(5);
  673. break;
  674. }
  675. };
  676. // 故障现象级别
  677. $scope.sjSelected = [{
  678. name: '一级分类',
  679. id: 1
  680. }, {
  681. name: '二级分类',
  682. id: 2
  683. }, {
  684. name: '三级分类',
  685. id: 3
  686. }];
  687. $scope.sjSelectedOne = {
  688. value: $scope.sjSelected[0]//选中
  689. };
  690. // 处理人/组
  691. $scope.groupSelected = [{
  692. id: -2,
  693. groupName: '按组选择'
  694. }, {
  695. id: -1,
  696. groupName: '按人选择'
  697. }];
  698. $scope.groupSelectedOne = {
  699. value: $scope.groupSelected[1]//选中
  700. };
  701. $scope.tableGroupSelectedOne = '';//处理组或人
  702. // 三方公司
  703. $scope.companySelected = [];
  704. $scope.companySelectedOne = {
  705. value: {id:-1,name:""}//选中
  706. };
  707. // 区域地点
  708. $scope.areaSelected = [{
  709. name: '区域',
  710. id: 1
  711. }, {
  712. name: '地点',
  713. id: 2
  714. }];
  715. $scope.areaSelectedOne = {
  716. value: $scope.areaSelected[0]//选中
  717. };
  718. /**
  719. *日历
  720. */
  721. //打开开始日期选择框
  722. $scope.startOpen = function ($event) {
  723. console.log(1)
  724. $event.preventDefault();
  725. $event.stopPropagation();
  726. $scope.endOpened = false;
  727. $scope.startOpened = !$scope.startOpened;
  728. };
  729. //打开结束日期选择框
  730. $scope.endOpen = function ($event) {
  731. $event.preventDefault();
  732. $event.stopPropagation();
  733. $scope.startOpened = false;
  734. $scope.endOpened = !$scope.endOpened;
  735. };
  736. //重置
  737. $scope.reload = function () {
  738. $scope.dateItemClick('day');
  739. $scope.type = 'desc';//表格排序,排序方式desc,asc
  740. $scope.direction = 'top';//箭头方向 top,bottom
  741. if($rootScope.user.duty){
  742. $scope.own.branch = {id: $rootScope.user.duty.branch, hosName: $rootScope.user.duty.branchName};
  743. $scope.getOwnDuty($rootScope.user.duty.branch, false, true);
  744. }else if($rootScope.user.branch){
  745. $scope.own.branch = $rootScope.user.branch;
  746. $scope.getOwnDuty($rootScope.user.branch.id, false, true);
  747. }
  748. };
  749. //选择类型,事件总数,故障现象,处理人/组,区域地点
  750. $scope.active = function (name) {
  751. $scope.tap = name;
  752. $scope.reload();
  753. };
  754. //事件总数,无限滚动加载
  755. $scope.topEndComplete = function () {
  756. console.log('滚动');
  757. };
  758. //表格排序------------------------------------------------
  759. $scope.sortActive = '';//表格排序,箭头高亮选中状态
  760. $scope.type = '';//表格排序,排序方式desc,asc
  761. $scope.name = '';//表格排序,字段名称
  762. $scope.direction = '';//箭头方向 top,bottom
  763. /**
  764. * 表格排序
  765. *
  766. * @param {string} name 字段名称
  767. * @param {string} type 排序方式desc,asc
  768. * @param {string} direction 箭头方向 top,bottom
  769. */
  770. $scope.tableSort = function (name, type, direction) {
  771. if ($scope.name == name) {
  772. $scope.type = $scope.type == 'desc' ? 'asc' : 'desc';
  773. $scope.direction = $scope.direction == 'top' ? 'bottom' : 'top';
  774. } else {
  775. $scope.type = 'desc';
  776. $scope.direction = 'top';
  777. }
  778. $scope.name = name;
  779. $scope.sortActive = name + $scope.direction;
  780. $scope.mdxquery(name, $scope.type);
  781. };
  782. //搜索----------------------------------------------------
  783. //loading
  784. $scope.isArrays = function (arr) {
  785. return Array.isArray(arr);
  786. };
  787. //事件总数
  788. $scope.sjzs_list = null;//表格列表
  789. $scope.sjzs_num = 0;//事件总数数量
  790. $scope.sjzs_responseTime = '0分';//平均响应时间
  791. $scope.sjzs_resolvedTime = '0分';//平均解决时间
  792. $scope.sjzs_satisfactionRatio = 0;//满意度
  793. //故障现象
  794. $scope.sjlx_list = null;//表格列表
  795. $scope.sjlx_num = 0;//事件总数数量
  796. //处理人/组
  797. $scope.clrz_list = null;//表格列表
  798. $scope.clrz_num = 0;//事件总数数量
  799. $scope.clrz_responseTime = '0分';//平均响应时间
  800. $scope.clrz_resolvedTime = '0分';//平均解决时间
  801. $scope.clrz_satisfactionRatio = 0;//满意度
  802. //三方公司
  803. $scope.sfgs_list = null;//表格列表
  804. $scope.sfgs_c_total = 0;//公司总数
  805. $scope.sfgs_u_total = 0;//人员总数
  806. $scope.sfgs_p_total = 0;//解决事件总数
  807. $scope.sfgs_p_time = '0分';//平均解决时长
  808. //区域地点
  809. $scope.qydd_list = null;//表格列表
  810. $scope.qydd_num = 0;//事件总数数量
  811. //科室统计
  812. $scope.kstj_list = null;//表格列表
  813. $scope.kstj_num = 0;//事件总数数量
  814. //事件来源
  815. $scope.sjly_list = null;//表格列表
  816. $scope.sjly_num = 0;//事件总数数量
  817. /**
  818. *
  819. *
  820. * @param {string} name 排序字段
  821. * @param {string} type 排序方式 desc,asc
  822. */
  823. $scope.mdxquery = function (name, type) {
  824. if (!name) {
  825. if($scope.tap == 'SJZS'){
  826. name = 'accdate';
  827. }else if($scope.tap == 'SFGS'){
  828. name = 'i_total';
  829. }else{
  830. name = 'sum';
  831. }
  832. }
  833. type = type || 'desc';
  834. switch ($scope.tap) {
  835. case 'SJZS'://事件总数
  836. $scope.sjzs_list = null;
  837. // 请求列表
  838. api_event_form.fetchSjzsList({
  839. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  840. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  841. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  842. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  843. "type": $scope.dateItem,
  844. "sortData": name,
  845. "sortType": type
  846. }).then(function (res) {
  847. if (res.stats == 200) {
  848. $scope.sjzs_list = res.dataList;//表格列表
  849. $scope.sjzs_num = res.sum;//事件总数数量
  850. $scope.sjzs_responseTime = res.responseTime;//平均响应时间
  851. $scope.sjzs_resolvedTime = res.resolvedTime;//平均解决时间
  852. $scope.sjzs_satisfactionRatio = res.satisfactionRatio;//满意度
  853. }
  854. })
  855. break;
  856. case 'SJLX'://故障现象
  857. $scope.sjlx_list = null;
  858. // 请求列表
  859. api_event_form.fetchSjlxList({
  860. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  861. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  862. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  863. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  864. "hierarchy": $scope.sjSelectedOne.value.id,
  865. "sortData": name,
  866. "sortType": type
  867. }).then(function (res) {
  868. if (res.stats == 200) {
  869. $scope.sjlx_list = res.typedataList;//表格列表
  870. $scope.sjlx_num = res.data.sum;//事件总数数量
  871. }
  872. })
  873. // 请求事件总数数量
  874. // api_event_form.getSjNum({
  875. // "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  876. // "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  877. // "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  878. // "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  879. // }).then(function (res) {
  880. // if (res.stats == 200) {
  881. // $scope.sjlx_num = res.data[0].sum;//事件总数数量
  882. // }
  883. // })
  884. break;
  885. case 'CLRZ'://处理人/组
  886. $scope.clrz_list = null;
  887. //获取组
  888. api_user_data.fetchDataList('group', {
  889. idx: 0,
  890. sum: 1000,
  891. group: {
  892. duty: $scope.own.duty || undefined,
  893. selectType: "nouser"
  894. }
  895. }).then(res => {
  896. if (res.status == 200) {
  897. var groupList = [{
  898. id: -2,
  899. groupName: '按组选择'
  900. }, {
  901. id: -1,
  902. groupName: '按人选择'
  903. }];
  904. groupList.push(...res.list);
  905. $scope.groupSelected = groupList;//下拉框数据
  906. // 请求列表
  907. if ($scope.groupSelectedOne.value.id == -2) {//按组
  908. var params = {
  909. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  910. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  911. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  912. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  913. "type": 1,
  914. "sortData": name,
  915. "sortType": type
  916. };
  917. } else if ($scope.groupSelectedOne.value.id == -1) {//按人
  918. var params = {
  919. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  920. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  921. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  922. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  923. "type": 2,
  924. "sortData": name,
  925. "sortType": type
  926. };
  927. } else {
  928. var params = {
  929. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  930. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  931. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  932. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  933. "type": 3,
  934. "groupid": $scope.groupSelectedOne.value.id,
  935. "sortData": name,
  936. "sortType": type
  937. };
  938. }
  939. api_event_form.fetchClrzList(params).then(function (res) {
  940. if (res.stats == 200) {
  941. $scope.tableGroupSelectedOne = params.type;//处理人或组
  942. $scope.clrz_list = res.listData;//表格列表
  943. $scope.clrz_num = res.sum;//事件总数量
  944. $scope.clrz_responseTime = res.responseTime;//平均响应时间
  945. $scope.clrz_resolvedTime = res.resolvedTime;//平均解决时间
  946. $scope.clrz_satisfactionRatio = res.satisfactionRatio;//满意度
  947. }
  948. })
  949. }
  950. })
  951. break;
  952. case 'SFGS'://三方公司
  953. $scope.sfgs_list = null;
  954. //获取三方公司
  955. api_user_data.fetchDataList('company', {
  956. idx: 0,
  957. sum: 1000,
  958. company: {}
  959. }).then(res => {
  960. if (res.status == 200) {
  961. $scope.companySelected = res.list;//下拉框数据
  962. // 请求列表
  963. var postData = {
  964. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  965. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  966. "sortData": name,
  967. "sortType": type
  968. }
  969. if($scope.companySelectedOne.value.id > 0){
  970. postData.companyId = $scope.companySelectedOne.value.id;
  971. }
  972. api_event_form.fetchSfgsList(postData).then(function (res) {
  973. if (res.stats == 200) {
  974. $scope.sfgs_list = res.dataList;//表格列表
  975. $scope.sfgs_c_total = res.title.c_total;//公司总数
  976. $scope.sfgs_u_total = res.title.u_total;//人员总数
  977. $scope.sfgs_p_total = res.title.p_total;//解决事件总数
  978. $scope.sfgs_p_time = res.title.p_time;//平均解决时长
  979. }
  980. })
  981. }
  982. })
  983. break;
  984. case 'QYDD'://区域地点
  985. $scope.qydd_list = null;
  986. // 请求列表
  987. api_event_form.fetchQyddList({
  988. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  989. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  990. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  991. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  992. "type": $scope.areaSelectedOne.value.id,
  993. "sortData": name,
  994. "sortType": type
  995. }).then(function (res) {
  996. if (res.stats == 200) {
  997. $scope.qydd_list = res.listData;//表格列表
  998. $scope.qydd_num = res.data.sum;//事件总数数量
  999. }
  1000. })
  1001. // 请求事件总数数量
  1002. // api_event_form.getSjNum({
  1003. // "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1004. // "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1005. // "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1006. // "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD')
  1007. // }).then(function (res) {
  1008. // if (res.stats == 200) {
  1009. // $scope.qydd_num = res.data[0].sum;//事件总数数量
  1010. // }
  1011. // })
  1012. break;
  1013. case 'KSTJ'://科室统计
  1014. $scope.kstj_list = null;
  1015. // 请求列表
  1016. api_event_form.fetchKstjList({
  1017. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1018. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1019. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1020. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  1021. "sortData": name,
  1022. "sortType": type
  1023. }).then(function (res) {
  1024. if (res.stats == 200) {
  1025. $scope.kstj_list = res.dataList;//表格列表
  1026. $scope.kstj_num = res.data.sum;//事件总数数量
  1027. }
  1028. })
  1029. break;
  1030. case 'SJLY'://事件来源
  1031. $scope.sjly_list = null;
  1032. // 请求列表
  1033. api_event_form.fetchSjlyList({
  1034. "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1035. "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1036. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1037. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  1038. "sortData": name,
  1039. "sortType": type
  1040. }).then(function (res) {
  1041. if (res.stats == 200) {
  1042. $scope.sjly_list = res.listData;//表格列表
  1043. $scope.sjly_num = res.data.sum;//事件总数数量
  1044. }
  1045. })
  1046. // 请求事件总数数量
  1047. // api_event_form.getSjNum({
  1048. // "dutyId": $scope.own.duty ? $scope.own.duty.id : undefined,
  1049. // "branchId": $scope.own.duty ? undefined: ($scope.own.branch ? $scope.own.branch.id : undefined),
  1050. // "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1051. // "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD')
  1052. // }).then(function (res) {
  1053. // if (res.stats == 200) {
  1054. // $scope.sjly_num = res.data[0].sum;//事件总数数量
  1055. // }
  1056. // })
  1057. break;
  1058. }
  1059. };
  1060. // 请求人
  1061. // api_user_data.fetchDataList('requester', {
  1062. // "idx": 0,
  1063. // "sum": 10
  1064. // }).then(function (response) {
  1065. // if (response) {
  1066. // if (response.status = 200) {
  1067. // $scope.requester = response.list;
  1068. // }
  1069. // }
  1070. // })
  1071. //导出
  1072. $scope.export = function () {
  1073. var postData = {
  1074. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  1075. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  1076. "sortData": $scope.name,
  1077. "sortType": $scope.type,
  1078. report: {}
  1079. }
  1080. switch ($scope.tap) {
  1081. case 'SJZS'://事件总数
  1082. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1083. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1084. postData.type = $scope.dateItem;
  1085. postData.key = 'mdv2_incident_repot_sum';
  1086. if($scope.own.duty && $scope.own.duty.addSummary == 1){
  1087. postData.titles = ['时间', '事件数量', '平均响应时间', '平均解决时间', '耗材费用', '工时费用', '总费用'];
  1088. }else{
  1089. postData.titles = ['时间', '事件数量', '平均响应时间', '平均解决时间'];
  1090. }
  1091. break;
  1092. case 'SJLX'://故障现象
  1093. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1094. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1095. postData.hierarchy = $scope.sjSelectedOne.value.id;
  1096. postData.key = 'mdv2_incident_repot_type';
  1097. if($scope.own.duty && $scope.own.duty.addSummary == 1){
  1098. postData.titles = ['故障现象', '类型数量', '类型占比', '平均响应时间', '平均解决时间', '耗材费用', '工时费用', '总费用'];
  1099. }else{
  1100. postData.titles = ['故障现象', '类型数量', '类型占比', '平均响应时间', '平均解决时间'];
  1101. }
  1102. break;
  1103. case 'CLRZ'://处理人/组
  1104. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1105. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1106. let CLRZ_TYPE = ''
  1107. if ($scope.groupSelectedOne.value.id == -2) {//按组
  1108. postData.type = 1;
  1109. CLRZ_TYPE = '处理组';
  1110. postData.titles = [CLRZ_TYPE, '协同处理数', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)'];
  1111. } else if ($scope.groupSelectedOne.value.id == -1) {//按人
  1112. postData.type = 2;
  1113. CLRZ_TYPE = '处理人';
  1114. postData.titles = [CLRZ_TYPE, '协同处理数', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)', '耗材费用', '工时费用', '总费用'];
  1115. } else {
  1116. postData.type = 3;
  1117. CLRZ_TYPE = '处理人';
  1118. postData.titles = [CLRZ_TYPE, '协同处理数', '事件数量', '事件占比', '按时响应', '超时响应', '平均响应时间', '超时响应占比', '按时解决', '超时解决', '平均解决时间', '超时解决占比', '满意度(%)', '耗材费用', '工时费用', '总费用'];
  1119. }
  1120. postData.key = 'mdv2_incident_repot_handle';
  1121. break;
  1122. case 'SFGS'://三方公司
  1123. postData.key = 'mdv2_incident_repot_company';
  1124. postData.titles = [($scope.sfgs_list[0]&&$scope.sfgs_list[0].userName)?'人员名称':'公司名称', '人员总数', '事件数量', '平均响应时长', '平均解决时长'];
  1125. if($scope.sfgs_list[0]&&$scope.sfgs_list[0].userName){
  1126. postData.titles.splice(1,1);
  1127. }
  1128. break;
  1129. case 'QYDD'://区域地点
  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.type = $scope.areaSelectedOne.value.id;
  1133. postData.key = 'mdv2_incident_repot_area_place';
  1134. postData.titles = ['区域/地点', '事件数量', '事件占比'];
  1135. break;
  1136. case 'KSTJ'://科室统计
  1137. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1138. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1139. postData.key = 'mdv2_incident_repot_dept';
  1140. if($scope.own.duty && $scope.own.duty.addSummary == 1){
  1141. postData.titles = ['科室名称', '事件数量', '事件占比', '耗材费用', '工时费用', '总费用'];
  1142. }else{
  1143. postData.titles = ['科室名称', '事件数量', '事件占比'];
  1144. }
  1145. break;
  1146. case 'SJLY'://事件来源
  1147. postData.dutyId = $scope.own.duty ? $scope.own.duty.id : undefined;
  1148. postData.branchId = $scope.own.duty ? undefined : ($scope.own.branch ? $scope.own.branch.id : undefined);
  1149. postData.key = 'mdv2_incident_repot_source';
  1150. postData.titles = ['事件来源', '事件数量', '事件来源占比'];
  1151. break;
  1152. }
  1153. var wt_url = api_bpm.downDataModel('report', 1).getRequestedUrl()
  1154. $http({
  1155. url: wt_url,
  1156. method: 'POST',
  1157. data: JSON.stringify(postData),
  1158. headers: {
  1159. 'Accept': '*/*'
  1160. },
  1161. responseType: 'arraybuffer'
  1162. }).success(function (data, status, headers, config) {
  1163. var fileName = '';
  1164. switch ($scope.tap) {
  1165. case 'SJZS'://事件总数
  1166. fileName = '事件总数';
  1167. break;
  1168. case 'SJLX'://故障现象
  1169. fileName = '故障现象';
  1170. break;
  1171. case 'CLRZ'://处理人/组
  1172. fileName = '处理人/组';
  1173. break;
  1174. case 'SFGS'://三方公司
  1175. fileName = '三方公司';
  1176. break;
  1177. case 'QYDD'://区域地点
  1178. fileName = '区域地点';
  1179. break;
  1180. case 'KSTJ'://科室统计
  1181. fileName = '科室统计';
  1182. break;
  1183. case 'SJLY'://事件来源
  1184. fileName = '事件来源';
  1185. break;
  1186. }
  1187. // var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
  1188. var file = new Blob([data], {
  1189. type: 'application/vnd.ms-excel'
  1190. });
  1191. var fileURL = URL.createObjectURL(file);
  1192. var a = document.createElement('a');
  1193. a.href = fileURL;
  1194. a.target = '_blank';
  1195. a.download = fileName + '.xls';
  1196. document.body.appendChild(a);
  1197. a.click();
  1198. }).error(function (data, status, headers, config) {
  1199. });
  1200. };
  1201. //初始化
  1202. $scope.init = function(){
  1203. $scope.dateItemClick('day');
  1204. $scope.mdxquery('accdate', 'desc');
  1205. $scope.sortActive = 'accdatetop';
  1206. $scope.name = 'accdate';//表格排序,字段名称
  1207. $scope.type = 'desc';//表格排序,排序方式desc,asc
  1208. $scope.direction = 'top';//箭头方向 top,bottom
  1209. }
  1210. }])