hour-quality-control-statistics.component.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. import { TabService } from './../../services/tab.service';
  2. import { NzMessageService } from 'ng-zorro-antd/message';
  3. import { Component, OnInit, HostListener, AfterViewInit, ViewChild } from "@angular/core";
  4. import { MainService } from 'src/app/services/main.service';
  5. import { ActivatedRoute, Router } from '@angular/router';
  6. import { ToolService } from "../../../../services/tool.service";
  7. import { CustomChangeDateComponent } from '../../components/custom-change-date/custom-change-date.component';
  8. @Component({
  9. selector: "app-hour-quality-control-statistics",
  10. templateUrl: "./hour-quality-control-statistics.component.html",
  11. styleUrls: ["./hour-quality-control-statistics.component.less"],
  12. })
  13. export class HourQualityControlStatisticsComponent implements OnInit, AfterViewInit {
  14. @ViewChild('customChangeDate', { static: false }) customChangeDateComponent!: CustomChangeDateComponent;
  15. constructor(
  16. private mainService: MainService,
  17. private message: NzMessageService,
  18. private route: ActivatedRoute,
  19. private router: Router,
  20. private tabService: TabService,
  21. private tool: ToolService,
  22. ) {}
  23. listOfData: any[] = []; //表格数据
  24. listOfDataEnd: any[] = []; //表格合计
  25. pageIndex: number = 1; //表格当前页码
  26. pageSize: number = 30; //表格每页展示条数
  27. listLength: number = 0; //表格总数据量
  28. statisticsTypeId;//统计分类id
  29. ngOnInit() {}
  30. ngAfterViewInit(){
  31. this.initSessionData();
  32. this.getQueryParams();
  33. setTimeout(() => {
  34. this.search();
  35. }, 0)
  36. this.onResize();
  37. }
  38. tableHeight:number = 0;
  39. @HostListener('window:resize')
  40. onResize(): void {
  41. setTimeout(() => {
  42. this.tableHeight = window.innerHeight - (document.querySelector('.searchDataWrap') as HTMLElement).offsetHeight - 64 - 36 - 48 - 8 - (document.querySelector('.ant-table-header') as HTMLElement).offsetHeight - 55 - this.getMoreFilter + 14;
  43. }, 0)
  44. }
  45. // 数据下钻
  46. viewDetail1(data, type){
  47. let query = null
  48. if(type=='all'){
  49. query = {
  50. startDate: this.customChangeDateComponent.startDate || undefined,
  51. endDate: this.customChangeDateComponent.endDate || undefined,
  52. statisticsTypeId: this.statisticsTypeId || undefined,
  53. searchQuery:{
  54. statusValue: 'close',
  55. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  56. deptId: this.fieldConfig.fields.deptId || undefined,
  57. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  58. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  59. groupId: this.fieldConfig.fields.groupId || undefined,
  60. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  61. userId: this.fieldConfig.fields.userId || undefined,
  62. userDTO: this.fieldConfig.fields.userDTO || undefined,
  63. buildingId: this.fieldConfig.fields.buildingId || undefined,
  64. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  65. }
  66. }
  67. }else{
  68. query = {
  69. startDate: this.customChangeDateComponent.startDate || undefined,
  70. endDate: this.customChangeDateComponent.endDate || undefined,
  71. statisticsTypeId: this.statisticsTypeId || undefined,
  72. searchQuery:{
  73. statusValue: 'close',
  74. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  75. deptId: this.fieldConfig.fields.deptId || undefined,
  76. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  77. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  78. groupId: this.fieldConfig.fields.groupId || undefined,
  79. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  80. userId: this.fieldConfig.fields.userId || undefined,
  81. userDTO: this.fieldConfig.fields.userDTO || undefined,
  82. buildingId: this.fieldConfig.fields.buildingId || undefined,
  83. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  84. timeFrameId: data.date || undefined,
  85. timeFrameDTO:{
  86. "name": data.date,
  87. "id": data.date
  88. }
  89. }
  90. }
  91. }
  92. let path = '/newStatistics/distributionInspectionStatistics/incidentList'
  93. let flag = this.tabService.tabs.some(v => v.path === path);
  94. flag && this.tabService.deleteRouteSnapshot(path);
  95. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  96. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  97. sessionStorage.setItem('distributionData', JSON.stringify(query))
  98. this.router.navigate([path], { replaceUrl: true });
  99. }
  100. viewDetail2(data, type){
  101. let query = null
  102. if(type=='all'){
  103. query = {
  104. startDate: this.customChangeDateComponent.startDate || undefined,
  105. endDate: this.customChangeDateComponent.endDate || undefined,
  106. statisticsTypeId: this.statisticsTypeId || undefined,
  107. searchQuery:{
  108. statusValue: 'close',
  109. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  110. deptId: this.fieldConfig.fields.deptId || undefined,
  111. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  112. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  113. groupId: this.fieldConfig.fields.groupId || undefined,
  114. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  115. userId: this.fieldConfig.fields.userId || undefined,
  116. userDTO: this.fieldConfig.fields.userDTO || undefined,
  117. buildingId: this.fieldConfig.fields.buildingId || undefined,
  118. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  119. minuteClose: 5,
  120. minuteDTO: 5,
  121. }
  122. }
  123. }else{
  124. query = {
  125. startDate: this.customChangeDateComponent.startDate || undefined,
  126. endDate: this.customChangeDateComponent.endDate || undefined,
  127. statisticsTypeId: data.statisticsTypeId || undefined,
  128. searchQuery:{
  129. statusValue: 'close',
  130. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  131. deptId: this.fieldConfig.fields.deptId || undefined,
  132. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  133. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  134. groupId: this.fieldConfig.fields.groupId || undefined,
  135. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  136. userId: this.fieldConfig.fields.userId || undefined,
  137. userDTO: this.fieldConfig.fields.userDTO || undefined,
  138. buildingId: this.fieldConfig.fields.buildingId || undefined,
  139. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  140. minuteClose: 5,
  141. minuteDTO: 5,
  142. timeFrameId: data.date || undefined,
  143. timeFrameDTO:{
  144. "name": data.date,
  145. "id": data.date
  146. }
  147. }
  148. }
  149. }
  150. let path = '/newStatistics/distributionInspectionStatistics/incidentList'
  151. let flag = this.tabService.tabs.some(v => v.path === path);
  152. flag && this.tabService.deleteRouteSnapshot(path);
  153. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  154. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  155. sessionStorage.setItem('distributionData', JSON.stringify(query))
  156. this.router.navigate([path], { replaceUrl: true });
  157. }
  158. viewDetail3(data, type){
  159. let query = null
  160. if(type=='all'){
  161. query = {
  162. startDate: this.customChangeDateComponent.startDate || undefined,
  163. endDate: this.customChangeDateComponent.endDate || undefined,
  164. statisticsTypeId: this.statisticsTypeId || undefined,
  165. searchQuery:{
  166. statusValue: 'close',
  167. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  168. deptId: this.fieldConfig.fields.deptId || undefined,
  169. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  170. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  171. groupId: this.fieldConfig.fields.groupId || undefined,
  172. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  173. userId: this.fieldConfig.fields.userId || undefined,
  174. userDTO: this.fieldConfig.fields.userDTO || undefined,
  175. buildingId: this.fieldConfig.fields.buildingId || undefined,
  176. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  177. specialId: 1,
  178. specialDTO: {
  179. "name": "是",
  180. "id": 1
  181. },
  182. }
  183. }
  184. }else{
  185. query = {
  186. startDate: this.customChangeDateComponent.startDate || undefined,
  187. endDate: this.customChangeDateComponent.endDate || undefined,
  188. statisticsTypeId: this.statisticsTypeId || undefined,
  189. searchQuery:{
  190. statusValue: 'close',
  191. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  192. deptId: this.fieldConfig.fields.deptId || undefined,
  193. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  194. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  195. groupId: this.fieldConfig.fields.groupId || undefined,
  196. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  197. userId: this.fieldConfig.fields.userId || undefined,
  198. userDTO: this.fieldConfig.fields.userDTO || undefined,
  199. buildingId: this.fieldConfig.fields.buildingId || undefined,
  200. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  201. specialId: 1,
  202. specialDTO: {
  203. "name": "是",
  204. "id": 1
  205. },
  206. timeFrameId: data.date || undefined,
  207. timeFrameDTO:{
  208. "name": data.date,
  209. "id": data.date
  210. }
  211. }
  212. }
  213. }
  214. let path = '/newStatistics/distributionInspectionStatistics/incidentList'
  215. let flag = this.tabService.tabs.some(v => v.path === path);
  216. flag && this.tabService.deleteRouteSnapshot(path);
  217. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  218. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  219. sessionStorage.setItem('distributionData', JSON.stringify(query))
  220. this.router.navigate([path], { replaceUrl: true });
  221. }
  222. viewDetail4(data, type){
  223. let query = null
  224. if(type=='all'){
  225. query = {
  226. startDate: this.customChangeDateComponent.startDate || undefined,
  227. endDate: this.customChangeDateComponent.endDate || undefined,
  228. statisticsTypeId: this.statisticsTypeId || undefined,
  229. searchQuery:{
  230. statusValue: 'close',
  231. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  232. deptId: this.fieldConfig.fields.deptId || undefined,
  233. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  234. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  235. groupId: this.fieldConfig.fields.groupId || undefined,
  236. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  237. userId: this.fieldConfig.fields.userId || undefined,
  238. userDTO: this.fieldConfig.fields.userDTO || undefined,
  239. buildingId: this.fieldConfig.fields.buildingId || undefined,
  240. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  241. emergencyTypeId: 300,
  242. emergencyTypeDTO: {
  243. "name": "是",
  244. "id": 300
  245. },
  246. }
  247. }
  248. }else{
  249. query = {
  250. startDate: this.customChangeDateComponent.startDate || undefined,
  251. endDate: this.customChangeDateComponent.endDate || undefined,
  252. statisticsTypeId: this.statisticsTypeId || undefined,
  253. searchQuery:{
  254. statusValue: 'close',
  255. deptDTO: this.fieldConfig.fields.deptDTO || undefined,
  256. deptId: this.fieldConfig.fields.deptId || undefined,
  257. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  258. taskTypeDTO: this.fieldConfig.fields.taskTypeDTO || undefined,
  259. groupId: this.fieldConfig.fields.groupId || undefined,
  260. groupDTO: this.fieldConfig.fields.groupDTO || undefined,
  261. userId: this.fieldConfig.fields.userId || undefined,
  262. userDTO: this.fieldConfig.fields.userDTO || undefined,
  263. buildingId: this.fieldConfig.fields.buildingId || undefined,
  264. buildingDTO: this.fieldConfig.fields.buildingDTO || undefined,
  265. emergencyTypeId: 300,
  266. emergencyTypeDTO: {
  267. "name": "是",
  268. "id": 300
  269. },
  270. timeFrameId: data.date || undefined,
  271. timeFrameDTO:{
  272. "name": data.date,
  273. "id": data.date
  274. }
  275. }
  276. }
  277. }
  278. let path = '/newStatistics/distributionInspectionStatistics/incidentList'
  279. let flag = this.tabService.tabs.some(v => v.path === path);
  280. flag && this.tabService.deleteRouteSnapshot(path);
  281. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  282. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  283. sessionStorage.setItem('distributionData', JSON.stringify(query))
  284. this.router.navigate([path], { replaceUrl: true });
  285. }
  286. getQueryParams(){
  287. let queryParams = this.tabService.getQueryParams();
  288. this.tabService.clearQueryParams();
  289. if(queryParams.dateRange){
  290. this.dateRange = queryParams.dateRange;
  291. this.customChangeDateComponent.initByDate(this.dateRange);
  292. }
  293. }
  294. get getMoreFilter(){
  295. let flag = this.fieldConfig.fields.groupDTO || this.fieldConfig.fields.userDTO || this.fieldConfig.fields.deptDTO || this.fieldConfig.fields.buildingDTO || this.fieldConfig.fields.taskTypeDTO;
  296. return flag ? 37 : 0;
  297. }
  298. // 初始化缓存数据
  299. queryType:any;
  300. hosId:any;
  301. dutyId:any;
  302. parentDutyId:any;
  303. initSessionData(){
  304. let newStatistics = JSON.parse(sessionStorage.getItem('newStatistics'));
  305. let queryType:any = newStatistics.queryType;
  306. let hosId:any = newStatistics.hospitalId;
  307. let dutyId:any = newStatistics.dutyId;
  308. queryType = queryType ? +queryType : undefined;
  309. hosId = hosId ? +hosId : undefined;
  310. dutyId = dutyId ? +dutyId : undefined;
  311. this.queryType = queryType;
  312. if(queryType == 1){
  313. this.hosId = undefined;
  314. this.dutyId = undefined;
  315. this.parentDutyId = undefined;
  316. }else if(queryType == 2){
  317. this.hosId = hosId;
  318. this.dutyId = undefined;
  319. this.parentDutyId = undefined;
  320. }else if(queryType == 3){
  321. this.hosId = undefined;
  322. this.dutyId = dutyId;
  323. this.parentDutyId = undefined;
  324. }else if(queryType == 4){
  325. this.hosId = undefined;
  326. this.dutyId = undefined;
  327. this.parentDutyId = dutyId;
  328. }
  329. }
  330. get getHosId(){
  331. return this.parentDutyId || this.dutyId || this.hosId;
  332. }
  333. // 表格数据
  334. loading1 = false;
  335. getList(num?: number, field?: string, sort?: string) {
  336. if (num !== undefined) {
  337. this.pageIndex = num;
  338. }
  339. let postData:any = {
  340. idx: this.pageIndex - 1,
  341. sum: this.pageSize,
  342. statisticsTypeId: this.statisticsTypeId || undefined,
  343. buildingId: this.fieldConfig.fields.buildingId || undefined,
  344. startDate: this.customChangeDateComponent.startDate || undefined,
  345. endDate: this.customChangeDateComponent.endDate || undefined,
  346. hosId: this.getHosId,
  347. groupId: this.fieldConfig.fields.userId ? undefined : (this.fieldConfig.fields.groupId || undefined),
  348. userId: this.fieldConfig.fields.userId || undefined,
  349. deptId: this.fieldConfig.fields.deptId || undefined,
  350. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  351. };
  352. if (field && sort) {
  353. postData.sort = `${field} ${sort === "ascend" ? `asc` : `desc`}`
  354. }
  355. this.loading1 = true;
  356. this.mainService
  357. .postCustom("itsm/report", "hourTransOrderQc", postData)
  358. .subscribe((result) => {
  359. this.loading1 = false;
  360. this.listOfData = result.dataList.filter((v, i) => { return i != result.dataList.length - 1 });
  361. this.listOfDataEnd = result.dataList.filter((v, i) => { return i == result.dataList.length - 1 });
  362. this.listLength = result.totalCount;
  363. });
  364. }
  365. // 列表排序
  366. sortCurrent:any = {};
  367. sortCurrentKey: string = "";
  368. sortCurrentValue: string | null = "";
  369. sort(e) {
  370. const { key, value } = e;
  371. this.sortCurrentKey = key;
  372. this.sortCurrentValue = value;
  373. this.getList(this.pageIndex, this.sortCurrentKey, this.sortCurrentValue);
  374. }
  375. // 搜索
  376. search() {
  377. this.getList(1, this.sortCurrentKey, this.sortCurrentValue);
  378. }
  379. // 日期选择
  380. dateRange: any = [];
  381. // 导出
  382. excelExportLoading:any = false;
  383. excelExport(){
  384. this.excelExportLoading = this.message.loading("导出中..", {
  385. nzDuration: 0,
  386. }).messageId;
  387. let postData:any = {
  388. statisticsTypeId: this.statisticsTypeId || undefined,
  389. buildingId: this.fieldConfig.fields.buildingId || undefined,
  390. startDate: this.customChangeDateComponent.startDate || undefined,
  391. endDate: this.customChangeDateComponent.endDate || undefined,
  392. hosId: this.getHosId,
  393. groupId: this.fieldConfig.fields.userId ? undefined : (this.fieldConfig.fields.groupId || undefined),
  394. userId: this.fieldConfig.fields.userId || undefined,
  395. deptId: this.fieldConfig.fields.deptId || undefined,
  396. taskTypeId: this.fieldConfig.fields.taskTypeId || undefined,
  397. };
  398. if (this.sortCurrentKey && this.sortCurrentValue) {
  399. postData.sort = `${this.sortCurrentKey} ${this.sortCurrentValue === "ascend" ? `asc` : `desc`}`
  400. }
  401. this.mainService
  402. .postExportCustom("itsm/export", "hourTransOrderQc", postData)
  403. .subscribe((data) => {
  404. this.message.remove(this.excelExportLoading);
  405. this.excelExportLoading = false;
  406. this.message.success('导出成功');
  407. var file = new Blob([data], {
  408. type: "application/vnd.ms-excel",
  409. });
  410. //trick to download store a file having its URL
  411. var fileURL = URL.createObjectURL(file);
  412. var a = document.createElement("a");
  413. a.href = fileURL;
  414. a.target = "_blank";
  415. a.download = `${this.route.parent.routeConfig.data.title}.xls`;
  416. document.body.appendChild(a);
  417. a.click();
  418. },(err) => {
  419. this.message.remove(this.excelExportLoading);
  420. this.excelExportLoading = false;
  421. this.message.error('导出失败');
  422. });
  423. }
  424. // 重置
  425. reset(){
  426. this.sortCurrentKey = "";
  427. this.sortCurrentValue = "";
  428. this.sortCurrent = {};
  429. this.dateRange = []
  430. this.statisticsTypeId = undefined;
  431. this.fieldConfig.fields = {groupId: undefined, userId: undefined, deptId: undefined, buildingId: undefined, taskTypeId: undefined};
  432. this.customChangeDateComponent.resetByDate();
  433. setTimeout(_=>{
  434. this.search();
  435. })
  436. }
  437. // 防抖
  438. isLoading = false;
  439. openChangeStatisticsType(flag){
  440. flag && this.getStatisticsTypeList();
  441. }
  442. // 获取统计分类列表
  443. statisticsTypeList:any[] = [];
  444. getStatisticsTypeList(keyword?) {
  445. this.isLoading = true;
  446. this.mainService
  447. .getDictionary("list", "statistics_date_type")
  448. .subscribe((data) => {
  449. this.isLoading = false;
  450. this.statisticsTypeList = data;
  451. });
  452. }
  453. // 详细搜索
  454. fieldConfig:any = {
  455. fields: {groupId: undefined, userId: undefined, deptId: undefined, buildingId: undefined, taskTypeId: undefined},
  456. config: {groupAndUser: true, dept: true, building: true, taskType: true},
  457. }
  458. showSearchMore:boolean = false;
  459. showMore(){
  460. this.showSearchMore = true;
  461. }
  462. cancelEvent(){
  463. this.showSearchMore = false;
  464. }
  465. submitEvent(fields){
  466. this.showSearchMore = false;
  467. this.fieldConfig.fields = fields;
  468. console.log('this.fieldConfig.fields:', this.fieldConfig.fields)
  469. this.search();
  470. this.onResize();
  471. }
  472. }