event_formCtrl.js 58 KB

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