detail-sample.component.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import { Component, OnInit, ViewChild } 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. import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
  8. @Component({
  9. selector: "app-detail-sample",
  10. templateUrl: "./detail-sample.component.html",
  11. styleUrls: ["./detail-sample.component.less"],
  12. })
  13. export class DetailSampleComponent implements OnInit {
  14. @ViewChild("osComponentRef1", {
  15. read: OverlayScrollbarsComponent,
  16. static: false,
  17. })
  18. osComponentRef1: OverlayScrollbarsComponent;
  19. constructor(
  20. private message: NzMessageService,
  21. private route: ActivatedRoute,
  22. private router: Router,
  23. private tool: ToolService,
  24. private mainService: MainService
  25. ) {}
  26. id: number; //工单id
  27. orderInfo: any; //工单详情信息
  28. endDepts = ""; //工单详情目标科室
  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. this.endDepts = res[1]["data"].endDepts
  63. .map((item) =>
  64. !this.showCoop && this.deptDisplay == 2 ? item.deptalias : item.dept
  65. )
  66. .join();
  67. });
  68. }
  69. // 放大
  70. amplification(){
  71. this.amplificationShow = !this.amplificationShow;
  72. }
  73. // 获取工单详情
  74. getDetail() {
  75. return this.mainService.getFetchData("api", "workOrder", this.id);
  76. }
  77. // 确认加急
  78. urgent() {
  79. let that = this;
  80. that.urgentLoading = true;
  81. let postData = {
  82. urgentDetails: {
  83. workerOrder: this.orderInfo["id"],
  84. checkStatus: {
  85. id: 330,
  86. },
  87. urgentReason: this.orderInfo["urgentDetails"].urgentReason,
  88. id: this.orderInfo["urgentDetails"].id,
  89. },
  90. };
  91. that.mainService.coopWorkerOrder("urge", postData).subscribe((data) => {
  92. that.urgentLoading = false;
  93. if (data.status == 200) {
  94. that.showPromptModal("加急", true, "");
  95. } else {
  96. that.showPromptModal("加急", false, data.msg);
  97. }
  98. });
  99. }
  100. // 获取工单历史记录
  101. logList = []; //工单历史记录
  102. getLog() {
  103. return this.mainService.getWorkOrderLog(this.id);
  104. }
  105. // 派单
  106. allotWorker() {
  107. this.router.navigateByUrl(
  108. "dispatchingDesk/allotWorker/" +
  109. this.id +
  110. "/" +
  111. this.orderInfo["gdState"]["id"]
  112. );
  113. }
  114. // 撤回
  115. recallOrderShow: boolean = false;
  116. openRecallModal(): void {
  117. this.recallOrderShow = true;
  118. }
  119. // 确认撤回
  120. confirmRec() {
  121. let that = this;
  122. that.btnLoading = true;
  123. let postData = {
  124. workOrder: {
  125. id: that.id,
  126. },
  127. };
  128. that.mainService
  129. .coopWorkerOrder("excuteWorkOrder/recall", postData)
  130. .subscribe((data) => {
  131. that.btnLoading = false;
  132. that.closeRecallOrderModal();
  133. if (data.status == 200) {
  134. that.showPromptModal("撤回", true, "");
  135. } else {
  136. that.showPromptModal("撤回", false, data.msg);
  137. }
  138. });
  139. }
  140. // 撤回并删除
  141. recAndDel() {
  142. let that = this;
  143. that.recLoading = true;
  144. that.mainService.delOrder(that.id).subscribe((data) => {
  145. console.log(data);
  146. that.recLoading = false;
  147. that.closeDelOrderModal();
  148. if (data.status == 200) {
  149. that.showPromptModal("删除", true, "");
  150. } else {
  151. that.showPromptModal("删除", false, data.msg);
  152. }
  153. });
  154. }
  155. // 关闭撤回弹框
  156. closeRecallOrderModal() {
  157. this.recallOrderShow = false;
  158. }
  159. // 关闭弹框
  160. close() {
  161. // this.router.navigateByUrl('dispatchingDesk');
  162. history.go(-1);
  163. }
  164. // 删除
  165. // 打开模态框
  166. delOrderShow: boolean = false;
  167. openDelModal() {
  168. this.delOrderShow = true;
  169. }
  170. // 确认删除
  171. confirmDel() {
  172. let that = this;
  173. that.btnLoading = true;
  174. that.mainService.delOrder(that.id).subscribe((data) => {
  175. that.btnLoading = 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. closeDelOrderModal() {
  186. this.delOrderShow = false;
  187. }
  188. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  189. showPromptModal(con, success, promptInfo?) {
  190. this.promptModalShow = false;
  191. this.promptContent = con;
  192. this.ifSuccess = success;
  193. this.promptInfo = promptInfo;
  194. setTimeout(() => {
  195. this.promptModalShow = true;
  196. }, 100);
  197. }
  198. // 格式化时分秒
  199. // (时间小于一分钟则显示秒,时间大于一分钟则显示分钟数,如超出一小时则显示小时和分钟。)time单位:秒
  200. formatTime(time) {
  201. let timeStr = "";
  202. if (time >= 0 && time < 60) {
  203. // 秒
  204. timeStr = time + "秒";
  205. } else if (time >= 60 && time < 3600) {
  206. // 分钟
  207. timeStr = Math.floor(time / 60) + "分钟";
  208. } else if (time >= 3600) {
  209. // 时 + 分
  210. let h = "";
  211. let m = "";
  212. h = Math.floor(time / 3600) + "小时";
  213. m = time % 3600 >= 60 ? Math.floor((time % 3600) / 60) + "分钟" : "";
  214. timeStr = h + m;
  215. }
  216. return timeStr;
  217. }
  218. // 计算历史记录耗时
  219. filterTime(step) {
  220. // step = [{ difTime: 2 }, { difTime: 6 }]
  221. let num = 0;
  222. step.forEach((e) => {
  223. num += e.difTime;
  224. });
  225. return this.formatTime(num / 1000);
  226. }
  227. }