event_formCtrl.js 57 KB

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