detail-drug.component.ts 6.2 KB

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