detail-patients.component.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { MainService } from "../../services/main.service";
  4. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  5. import { NzMessageService } from "ng-zorro-antd";
  6. import { forkJoin } from "rxjs";
  7. import { ToolService } from "src/app/services/tool.service";
  8. import { startOfDay, endOfDay, format, startOfMinute, addMinutes } from 'date-fns';
  9. @Component({
  10. selector: "app-detail-patients",
  11. templateUrl: "./detail-patients.component.html",
  12. styleUrls: ["./detail-patients.component.less"],
  13. })
  14. export class DetailPatientsComponent implements OnInit {
  15. @ViewChild("osComponentRef1", {
  16. read: OverlayScrollbarsComponent,
  17. static: false,
  18. })
  19. osComponentRef1: OverlayScrollbarsComponent;
  20. constructor(
  21. private message: NzMessageService,
  22. private route: ActivatedRoute,
  23. private router: Router,
  24. private tool: ToolService,
  25. private mainService: MainService
  26. ) {}
  27. id: number; //工单id
  28. orderInfo: any; //工单详情信息
  29. showCoop: boolean = true; //是否展示详情页操作按钮
  30. promptContent: string; //操作提示框提示信息
  31. ifSuccess: boolean; //操作成功/失败
  32. promptInfo: string; //操作结果提示信息
  33. promptModalShow: boolean; //是否展示提示框
  34. urgentLoading: boolean = false; //确认加急按钮loading状态
  35. recLoading: boolean = false; //撤回并删除按钮loading状态
  36. btnLoading: boolean = false; //确认按钮loading状态
  37. maskFlag: any = false;
  38. deptDisplay; //护士端是否显示可以别名,1是显示科室名称,2是显示科室别名
  39. amplificationShow = true;
  40. ngOnInit() {
  41. this.tool.getDeptDisplay().subscribe((result) => {
  42. if (result.status == 200) {
  43. this.deptDisplay = result.list[0].valueconfig;
  44. }
  45. });
  46. if (this.route.snapshot.parent.parent.routeConfig.path == "nurse") {
  47. this.showCoop = false;
  48. }
  49. this.id = +this.route.snapshot.paramMap.get("id");
  50. let log$ = this.getLog();
  51. let detail$ = this.getDetail();
  52. this.maskFlag = this.message.loading("正在加载中..", {
  53. nzDuration: 0,
  54. }).messageId;
  55. forkJoin(log$, detail$).subscribe((res) => {
  56. this.message.remove(this.maskFlag);
  57. this.maskFlag = false;
  58. // getLog
  59. this.logList = res[0]["data"];
  60. // getDetail
  61. this.orderInfo = res[1]["data"];
  62. if (this.orderInfo["checkList"] && this.orderInfo["checkList"].length) {
  63. // let arr = [];
  64. // let orderInfo = this.orderInfo["checkList"].filter(
  65. // (item) => item.yyTime
  66. // );
  67. // if (orderInfo.length) {
  68. // arr = orderInfo.map((item) => [
  69. // new Date(item.yyTime).getTime() - new Date().getTime(),
  70. // item.yyTime,
  71. // ]);
  72. // arr.sort((a, b) => a - b);
  73. // this.orderInfo["yyTime"] = arr[0][1];
  74. // } else {
  75. // this.orderInfo["yyTime"] = "";
  76. // }
  77. this.orderInfo["checkList"].forEach(i =>{
  78. i.newTime = format(new Date(i.yyTime), 'MM-dd HH:mm')
  79. if(i.endCheckTime){
  80. i.newTime2 = format(new Date(i.endCheckTime), 'HH:mm')
  81. i.yyEndTime = i.newTime + '--' + i.newTime2
  82. }else{
  83. i.yyEndTime = i.newTime
  84. }
  85. })
  86. }
  87. if (res[1]["data"].middleDept) {
  88. this.middleDept = res[1]["data"].middleDept.map((item) =>
  89. !this.showCoop && this.deptDisplay == 2 ? item.deptalias : item.dept
  90. );
  91. } else {
  92. this.middleDept = [];
  93. }
  94. });
  95. }
  96. // 放大
  97. amplification(){
  98. this.amplificationShow = !this.amplificationShow;
  99. }
  100. // 获取工单详情
  101. middleDept = []; //中间科室数组
  102. getDetail() {
  103. return this.mainService.getFetchData("api", "workOrder", this.id);
  104. }
  105. // 获取工单历史记录
  106. logList = []; //工单历史记录
  107. getLog() {
  108. return this.mainService.getWorkOrderLog(this.id);
  109. }
  110. // 加急
  111. urgent() {
  112. let that = this;
  113. that.urgentLoading = true;
  114. let postData = {
  115. urgentDetails: {
  116. workerOrder: that.id,
  117. checkStatus: { id: 330 },
  118. urgentReason: that.orderInfo["urgentDetails"]["urgentReason"],
  119. id: that.orderInfo["urgentDetails"]["id"],
  120. },
  121. };
  122. that.mainService
  123. .postCustom("workerOrder", "urge", postData)
  124. .subscribe((data) => {
  125. console.log(data);
  126. that.urgentLoading = false;
  127. if (data.status == 200) {
  128. that.showPromptModal("加急", true, "");
  129. } else {
  130. that.showPromptModal("加急", false, data.msg);
  131. }
  132. });
  133. }
  134. // 派单
  135. allotWorker() {
  136. this.router.navigateByUrl(
  137. "dispatchingDesk/allotWorker/" +
  138. this.id +
  139. "/" +
  140. this.orderInfo["gdState"]["id"]
  141. );
  142. }
  143. // 撤回
  144. recallOrderShow: boolean = false;
  145. openRecallModal(): void {
  146. this.recallOrderShow = true;
  147. }
  148. // 确认撤回
  149. confirmRec() {
  150. let that = this;
  151. that.btnLoading = true;
  152. let postData = {
  153. workOrder: {
  154. id: that.id,
  155. },
  156. };
  157. that.mainService
  158. .coopWorkerOrder("excuteWorkOrder/recall", postData)
  159. .subscribe((data) => {
  160. that.btnLoading = false;
  161. that.closeRecallOrderModal();
  162. if (data.status == 200) {
  163. that.showPromptModal("撤回", true, "");
  164. } else {
  165. that.showPromptModal("撤回", false, data.msg);
  166. }
  167. });
  168. }
  169. // 撤回并删除
  170. recAndDel() {
  171. let that = this;
  172. that.recLoading = true;
  173. that.mainService.delOrder(that.id).subscribe((data) => {
  174. console.log(data);
  175. that.recLoading = false;
  176. that.closeDelOrderModal();
  177. if (data.status == 200) {
  178. that.showPromptModal("删除", true, "");
  179. } else {
  180. that.showPromptModal("删除", false, data.msg);
  181. }
  182. });
  183. }
  184. // 关闭撤回弹框
  185. closeRecallOrderModal() {
  186. this.recallOrderShow = false;
  187. }
  188. // 关闭弹框
  189. close() {
  190. // this.router.navigateByUrl('dispatchingDesk');
  191. history.go(-1);
  192. }
  193. // 删除
  194. // 打开模态框
  195. delOrderShow: boolean = false;
  196. openDelModal() {
  197. this.delOrderShow = true;
  198. }
  199. // 确认删除
  200. confirmDel() {
  201. let that = this;
  202. that.btnLoading = true;
  203. that.mainService.delOrder(that.id).subscribe((data) => {
  204. that.closeDelOrderModal();
  205. that.btnLoading = false;
  206. if (data.status == 200) {
  207. that.showPromptModal("删除", true, "");
  208. } else {
  209. that.showPromptModal("删除", false, data.msg);
  210. }
  211. });
  212. }
  213. // 关闭模态框
  214. closeDelOrderModal() {
  215. this.delOrderShow = false;
  216. }
  217. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  218. showPromptModal(con, success, promptInfo?) {
  219. this.promptModalShow = false;
  220. this.promptContent = con;
  221. this.ifSuccess = success;
  222. this.promptInfo = promptInfo;
  223. setTimeout(() => {
  224. this.promptModalShow = true;
  225. }, 100);
  226. }
  227. // 格式化时分秒
  228. // (时间小于一分钟则显示秒,时间大于一分钟则显示分钟数,如超出一小时则显示小时和分钟。)time单位:秒
  229. formatTime(time) {
  230. let timeStr = "";
  231. if (time >= 0 && time < 60) {
  232. // 秒
  233. timeStr = time + "秒";
  234. } else if (time >= 60 && time < 3600) {
  235. // 分钟
  236. timeStr = Math.floor(time / 60) + "分钟";
  237. } else if (time >= 3600) {
  238. // 时 + 分
  239. let h = "";
  240. let m = "";
  241. h = Math.floor(time / 3600) + "小时";
  242. m = time % 3600 >= 60 ? Math.floor((time % 3600) / 60) + "分钟" : "";
  243. timeStr = h + m;
  244. }
  245. return timeStr;
  246. }
  247. // 计算历史记录耗时
  248. filterTime(step) {
  249. // step = [{ difTime: 2 }, { difTime: 6 }]
  250. let num = 0;
  251. step.forEach((e) => {
  252. num += e.difTime;
  253. });
  254. return this.formatTime(num / 1000);
  255. }
  256. }