emergency-info.component.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { FormBuilder, Validators, FormGroup } from "@angular/forms";
  4. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  5. import { ToolService } from "../../services/tool.service";
  6. import { Subject } from "rxjs";
  7. import { debounceTime } from "rxjs/operators";
  8. import { EmergencyInfoService } from './emergency-info.service';
  9. import { format, startOfDay, endOfDay } from 'date-fns';
  10. import { NzMessageService } from "ng-zorro-antd";
  11. import { MainService } from 'src/app/services/main.service';
  12. @Component({
  13. selector: "app-emergency-info",
  14. templateUrl: "./emergency-info.component.html",
  15. styleUrls: ["./emergency-info.component.less"],
  16. })
  17. export class EmergencyInfoComponent implements OnInit {
  18. @ViewChild("osComponentRef1", {
  19. read: OverlayScrollbarsComponent,
  20. static: false,
  21. })
  22. osComponentRef1: OverlayScrollbarsComponent;
  23. constructor(
  24. private message: NzMessageService,
  25. private fb: FormBuilder,
  26. private route: ActivatedRoute,
  27. private router: Router,
  28. private tool: ToolService,
  29. private quickOrderAcceptanceService: EmergencyInfoService,
  30. private mainService: MainService,
  31. ) {}
  32. listOfData: any[] = []; //表格数据
  33. modal: boolean = false; //新增/编辑模态框
  34. add: boolean; //true:新增;false:编辑
  35. validateForm: FormGroup; //新增/编辑表单
  36. coopId: number; //表格中执行操作的id
  37. department: any; //所属科室
  38. hosId: any; //院区(搜索)
  39. typeList: Array<any>; //快捷类型
  40. taskTypeList: Array<any>; //所有任务类型
  41. deptList: Array<any>; //所有科室
  42. pageIndex: number = 1; //页码
  43. listLength: number = 10; //总条数
  44. pageSize: number = 10; //每页条数
  45. promptContent: string; //操作提示框提示信息
  46. ifSuccess: boolean; //操作成功/失败
  47. promptInfo: string; //操作结果提示信息
  48. promptModalShow: boolean; //操作提示框是否展示
  49. btnLoading: boolean = false; //提交按钮loading状态
  50. changeInpSubject = new Subject(); //防抖
  51. changeInpDeptSubject = new Subject(); //防抖
  52. // 初始化增删改按钮
  53. coopBtns: any = {};
  54. alarmStatus:any;
  55. incidentStatus:any;
  56. alarmIp:any;
  57. alarmUrgency:any;
  58. dateRange:any = [];
  59. ngOnInit() {
  60. // 全局监听
  61. this.tool.getEventEndObservable().subscribe(res => {
  62. console.log('全局的监听触发2222', res);
  63. let data:any = res;
  64. if(data.message == '关单'){
  65. this.getList(true)
  66. }
  67. });
  68. //防抖
  69. this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
  70. this.getTasktype(v[0]);
  71. });
  72. //防抖
  73. this.changeInpDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
  74. this.getDept(v[0]);
  75. });
  76. this.coopBtns = this.tool.initCoopBtns(this.route);
  77. this.initForm();
  78. this.hosId = this.tool.getCurrentHospital().id;
  79. this.getList(true);
  80. this.getGdList();
  81. }
  82. // 日期选择
  83. startDate: string; //发起时间开始
  84. endDate: string; //发起时间结束
  85. changeDate(result?): void {
  86. if (result.length==0) {
  87. this.startDate = this.endDate = null;
  88. return;
  89. }
  90. this.startDate = format(result[0], 'yyyy-MM-dd HH:mm:ss');
  91. this.endDate = format(result[1], 'yyyy-MM-dd HH:mm:ss');
  92. this.dateRange = [this.startDate,this.endDate]
  93. }
  94. onCalendarChangeDate(dateArr){
  95. console.log(dateArr)
  96. if(dateArr.length == 2){
  97. let dateStart = new Date(dateArr[0]);
  98. let dateEnd = new Date(dateArr[1]);
  99. dateStart.setHours(0,0,0);
  100. dateEnd.setHours(23,59,59);
  101. this.dateRange = [dateStart,dateEnd];
  102. }
  103. }
  104. // 获取工单状态
  105. gdList:any = [];
  106. alarmList:any = [];
  107. urgencyList:any = [];
  108. getGdList() {
  109. this.isLoading = true;
  110. this.quickOrderAcceptanceService.getDictionary("incident_status").subscribe((res) => {
  111. this.isLoading = false;
  112. this.gdList = res || [];
  113. });
  114. this.quickOrderAcceptanceService.getDictionary("alarm_status").subscribe((res) => {
  115. this.isLoading = false;
  116. this.alarmList = res || [];
  117. });
  118. this.quickOrderAcceptanceService.getDictionary("alarm_urgency").subscribe((res) => {
  119. this.isLoading = false;
  120. this.urgencyList = res || [];
  121. });
  122. }
  123. // 搜索
  124. search() {
  125. this.getList(true);
  126. }
  127. // 重置
  128. reset() {
  129. this.alarmStatus = null;
  130. this.incidentStatus = null;
  131. this.alarmIp = null;
  132. this.alarmUrgency = null;
  133. this.startDate = null;
  134. this.endDate = null;
  135. this.dateRange = [];
  136. this.getList(true);
  137. }
  138. // 表格数据
  139. loading1 = false;
  140. getList(isResetPageIndex = false, type?) {
  141. isResetPageIndex && (this.pageIndex = 1);
  142. let data = {
  143. pageIndex: this.pageIndex,
  144. pageSize: this.pageSize,
  145. alarm:{
  146. hosId: this.hosId,
  147. alarmStatus:{
  148. id:this.alarmStatus
  149. },
  150. incidentStatus:this.incidentStatus,
  151. alarmIp:this.alarmIp,
  152. alarmUrgency:{
  153. id:this.alarmUrgency,
  154. },
  155. startTime: this.startDate || undefined,
  156. endTime: this.endDate || undefined,
  157. }
  158. };
  159. if(this.alarmStatus){
  160. data.alarm.alarmStatus.id = this.alarmStatus
  161. }else{
  162. delete data.alarm.alarmStatus
  163. }
  164. if(this.alarmUrgency){
  165. data.alarm.alarmUrgency.id = this.alarmUrgency
  166. }else{
  167. delete data.alarm.alarmUrgency
  168. }
  169. this.loading1 = true;
  170. if(type!='page'){
  171. this.mapOfCheckedId = {};
  172. this.checkedDepIds = [];
  173. }
  174. this.isAllDisplayDataChecked = false;
  175. this.quickOrderAcceptanceService
  176. .query(data)
  177. .subscribe((result) => {
  178. this.loading1 = false;
  179. this.listOfData = result.list;
  180. this.listLength = result.totalNum;
  181. });
  182. }
  183. // 获取任务类型列表
  184. getTasktype(keywords = '') {
  185. let hosId = this.tool.getCurrentHospital().id;
  186. this.isLoading = true;
  187. this.quickOrderAcceptanceService.queryTasktype({
  188. hosId,
  189. keywords,
  190. }).subscribe((res) => {
  191. this.isLoading = false;
  192. this.taskTypeList = res.list || [];
  193. });
  194. }
  195. // 获取科室列表
  196. getDept(keywords = '') {
  197. let hosId = this.tool.getCurrentHospital().id;
  198. this.isLoading = true;
  199. this.quickOrderAcceptanceService.queryDept({
  200. hosId,
  201. keywords,
  202. }).subscribe((res) => {
  203. this.isLoading = false;
  204. this.deptList = res.list || [];
  205. });
  206. }
  207. // 获取快捷类型
  208. getTypeList() {
  209. this.isLoading = true;
  210. this.quickOrderAcceptanceService.getDictionary("receiveRuleType").subscribe((res) => {
  211. this.isLoading = false;
  212. this.typeList = res || [];
  213. });
  214. }
  215. // 新增弹框
  216. showModal() {
  217. this.add = true;
  218. this.modal = true;
  219. this.initForm();
  220. }
  221. hideModal() {
  222. this.modal = false;
  223. this.initForm();
  224. }
  225. // 初始化新增form表单
  226. initForm() {
  227. if (this.add) {
  228. this.typeList = [];
  229. this.taskTypeList = [];
  230. this.deptList = [];
  231. }
  232. this.validateForm = this.fb.group({
  233. title: ['', [Validators.required]],
  234. taskTypeIds: [null, [Validators.required]],
  235. deptIds: [null, [Validators.required]],
  236. type: [null, [Validators.required]],
  237. });
  238. }
  239. // 表单提交
  240. submitForm(): void {
  241. for (const i in this.validateForm.controls) {
  242. this.validateForm.controls[i].markAsDirty({ onlySelf: true });
  243. this.validateForm.controls[i].updateValueAndValidity();
  244. }
  245. if (this.validateForm.invalid) return;
  246. this.btnLoading = true;
  247. if(this.add){
  248. this.quickOrderAcceptanceService
  249. .add({
  250. title: this.validateForm.value.title,
  251. taskTypeIds: this.validateForm.value.taskTypeIds,
  252. deptIds: this.validateForm.value.deptIds,
  253. type: {id: this.validateForm.value.type},
  254. hosId: this.hosId,
  255. })
  256. .subscribe((data) => {
  257. this.btnLoading = false;
  258. this.hideModal();
  259. this.initForm();
  260. this.operateType = 'no'
  261. if (data.status == 200) {
  262. this.showPromptModal(this.add ? "新增" : "编辑", true, "");
  263. } else {
  264. this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
  265. }
  266. });
  267. }else{
  268. this.quickOrderAcceptanceService
  269. .update({
  270. title: this.validateForm.value.title,
  271. taskTypeIds: this.validateForm.value.taskTypeIds,
  272. deptIds: this.validateForm.value.deptIds,
  273. type: {id: this.validateForm.value.type},
  274. coopData: this.coopData,
  275. })
  276. .subscribe((data) => {
  277. this.btnLoading = false;
  278. this.hideModal();
  279. this.initForm();
  280. this.operateType = 'no'
  281. if (data.status == 200) {
  282. this.showPromptModal(this.add ? "新增" : "编辑", true, "");
  283. } else {
  284. this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
  285. }
  286. });
  287. }
  288. }
  289. // 批量恢复
  290. infoContent:any;
  291. optModal:boolean = false;
  292. operationType:any;
  293. batchRecover(){
  294. if(this.checkedDepIds.length==0){
  295. this.message.error('请勾选告警列表')
  296. return
  297. }
  298. this.operationType = 'batchRecovery'
  299. this.infoContent=`您确认要恢复${this.checkedDepIds.length}项告警吗?`
  300. this.optModal = true
  301. }
  302. // 批量不处理
  303. batchNo(){
  304. if(this.checkedDepIds.length==0){
  305. this.message.error('请勾选告警列表')
  306. return
  307. }
  308. this.operationType = 'batchUnprocessed'
  309. this.infoContent=`您确认要不处理${this.checkedDepIds.length}项告警吗?`
  310. this.optModal = true
  311. }
  312. // 确认
  313. confirmOpt() {
  314. this.btnLoading = true;
  315. this.quickOrderAcceptanceService
  316. .operation({
  317. operationType: this.operationType,
  318. ids: this.checkedDepIds,
  319. })
  320. .subscribe((data) => {
  321. this.btnLoading = false;
  322. this.hideOptModal();
  323. this.operateType = 'no'
  324. if (data.status == 200) {
  325. this.showPromptModal("操作", true, "");
  326. } else {
  327. this.showPromptModal("操作", false, data.msg);
  328. }
  329. });
  330. }
  331. // 关闭模态框
  332. hideOptModal() {
  333. this.optModal = false;
  334. }
  335. // 消息发送
  336. sendModal:boolean = false;
  337. tipsMsg2:any = '您确定要发送消息吗?';
  338. send(data){
  339. this.itemData = data;
  340. this.sendModal = true;
  341. }
  342. hideSendModal(){
  343. this.sendModal = false;
  344. }
  345. // 确定发送消息
  346. operateType:any;
  347. confirmSend(){
  348. let data = {
  349. alarm:{
  350. operationType: 'sendMsg',
  351. id: this.itemData.id,
  352. }
  353. };
  354. this.btnLoading = true;
  355. this.mainService
  356. .dataPost("updData", "alarm", data)
  357. .subscribe((data) => {
  358. this.btnLoading = false;
  359. this.sendModal = false;
  360. if (data.status == 200) {
  361. this.operateType = 'send'
  362. this.showPromptModal("操作", true, "");
  363. } else {
  364. this.showPromptModal("操作", false, data.msg);
  365. }
  366. });
  367. }
  368. // 建单
  369. addOrder(data){
  370. this.tool.triggerEvent({
  371. message:'建单',
  372. data: data
  373. })
  374. }
  375. // 查看工单
  376. detailModalShow = false; //弹窗开关
  377. detail(e, data) {
  378. e.stopPropagation();
  379. if(!data.incidentSign){
  380. return
  381. }
  382. this.coopData = data;
  383. this.detailModalShow = true;
  384. }
  385. // 关闭弹窗
  386. closeDetailModelOrder(e) {
  387. this.detailModalShow = JSON.parse(e).show;
  388. }
  389. // 弹窗确定
  390. confirmDetailModelOrder(e){
  391. console.log(e);
  392. this.detailModalShow = false;
  393. this.getList(true);
  394. }
  395. refreshList(){
  396. }
  397. // 查看列表
  398. itemData:any;
  399. lookModal:boolean = false;
  400. look(data){
  401. this.itemData = data;
  402. this.lookModal = true
  403. }
  404. // 关闭查看
  405. close(){
  406. this.lookModal = false
  407. }
  408. // 选中表格中科室
  409. mapOfCheckedId: { [key: string]: boolean } = {};
  410. checkedDepIds = []; //已选中科室id
  411. refreshStatus(): void {
  412. this.isAllDisplayDataChecked = this.listOfData.every(
  413. (item) => this.mapOfCheckedId[item.id]
  414. );
  415. let arr = [];
  416. for (var k in this.mapOfCheckedId) {
  417. if (this.mapOfCheckedId[k]) {
  418. arr.push(Number(k));
  419. }
  420. }
  421. this.checkedDepIds = arr;
  422. console.log(this.checkedDepIds);
  423. }
  424. //表格整行选中
  425. selectedListData(id) {
  426. this.mapOfCheckedId[id] = !this.mapOfCheckedId[id];
  427. this.refreshStatus();
  428. }
  429. // 全选
  430. isAllDisplayDataChecked = false; //当前页是否全选
  431. checkAll(value: boolean): void {
  432. this.listOfData.forEach((item) => (this.mapOfCheckedId[item.id] = value));
  433. this.refreshStatus();
  434. }
  435. // 编辑
  436. maskFlag: any = false;
  437. coopData = {};
  438. edit(data) {
  439. this.validateForm.controls.title.setValue(data.title);
  440. this.validateForm.controls.type.setValue(data.type ? data.type.id : null);
  441. this.validateForm.controls.taskTypeIds.setValue(data.taskTypeList ? data.taskTypeList.map(v => v.id) : null);
  442. this.validateForm.controls.deptIds.setValue(data.deptList ? data.deptList.map(v => v.id) : null);
  443. this.modal = true;
  444. this.add = false;
  445. this.coopId = data.id;
  446. this.coopData = data;
  447. this.getTasktype();
  448. this.getDept();
  449. this.getTypeList();
  450. }
  451. // 删除
  452. delModal: boolean = false; //删除模态框
  453. del(data) {
  454. this.coopId = data.id;
  455. this.delModal = true;
  456. }
  457. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  458. showPromptModal(con, success, promptInfo?) {
  459. this.promptModalShow = false;
  460. this.promptContent = con;
  461. this.ifSuccess = success;
  462. this.promptInfo = promptInfo;
  463. setTimeout(() => {
  464. this.promptModalShow = true;
  465. }, 100);
  466. if(this.operateType = 'send'){
  467. this.getList();
  468. }else{
  469. this.getList(true);
  470. }
  471. }
  472. // 边输边搜节流阀
  473. isLoading = false;
  474. changeInp(e) {
  475. this.changeInpSubject.next([e]);
  476. }
  477. // 边输边搜节流阀
  478. changeDeptInp(e) {
  479. this.changeInpDeptSubject.next([e]);
  480. }
  481. // 打开任务类型
  482. openTasktype(e){
  483. if(e){
  484. this.getTasktype();
  485. }
  486. }
  487. // 打开科室
  488. openDept(e){
  489. if(e){
  490. this.getDept();
  491. }
  492. }
  493. // 打开班次
  494. openSchedule(e){
  495. if(e){
  496. this.getTypeList();
  497. }
  498. }
  499. }