order-detail.component.ts 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import { Component, OnInit, OnDestroy, ViewChild } from "@angular/core";
  2. import { ActivatedRoute } from "@angular/router";
  3. import {
  4. FormBuilder,
  5. Validators,
  6. FormGroup,
  7. FormControl,
  8. } from "@angular/forms";
  9. import { MainService } from "../../services/main.service";
  10. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  11. import { NzMessageService } from "ng-zorro-antd";
  12. import { forkJoin } from "rxjs";
  13. @Component({
  14. selector: "app-order-detail",
  15. templateUrl: "./order-detail.component.html",
  16. styleUrls: ["./order-detail.component.less"],
  17. })
  18. export class OrderDetailComponent implements OnInit {
  19. @ViewChild("osComponentRef1", {
  20. read: OverlayScrollbarsComponent,
  21. static: false,
  22. })
  23. osComponentRef1: OverlayScrollbarsComponent;
  24. @ViewChild("osComponentRef2", {
  25. read: OverlayScrollbarsComponent,
  26. static: false,
  27. })
  28. osComponentRef2: OverlayScrollbarsComponent;
  29. @ViewChild("osComponentRef3", {
  30. read: OverlayScrollbarsComponent,
  31. static: false,
  32. })
  33. osComponentRef3: OverlayScrollbarsComponent;
  34. @ViewChild("osComponentRef4", {
  35. read: OverlayScrollbarsComponent,
  36. static: false,
  37. })
  38. osComponentRef4: OverlayScrollbarsComponent;
  39. @ViewChild("osComponentRef5", {
  40. read: OverlayScrollbarsComponent,
  41. static: false,
  42. })
  43. osComponentRef5: OverlayScrollbarsComponent;
  44. @ViewChild("osComponentRef6", {
  45. read: OverlayScrollbarsComponent,
  46. static: false,
  47. })
  48. osComponentRef6: OverlayScrollbarsComponent;
  49. @ViewChild("osComponentRef7", {
  50. read: OverlayScrollbarsComponent,
  51. static: false,
  52. })
  53. osComponentRef7: OverlayScrollbarsComponent;
  54. @ViewChild("osComponentRef8", {
  55. read: OverlayScrollbarsComponent,
  56. static: false,
  57. })
  58. osComponentRef8: OverlayScrollbarsComponent;
  59. @ViewChild("osComponentRef9", {
  60. read: OverlayScrollbarsComponent,
  61. static: false,
  62. })
  63. osComponentRef9: OverlayScrollbarsComponent;
  64. constructor(
  65. private message: NzMessageService,
  66. private fb: FormBuilder,
  67. private route: ActivatedRoute,
  68. private mainService: MainService
  69. ) {}
  70. maskFlag: any = false;
  71. id: number; //工单id
  72. orderInfo: any; //工单详情信息
  73. endDepts = ""; //工单详情目标科室
  74. showCoop: boolean = true; //是否展示详情页操作按钮
  75. promptContent: string; //操作提示框提示信息
  76. ifSuccess: boolean; //操作成功/失败
  77. promptInfo: string; //操作结果提示信息
  78. promptModalShow: boolean; //是否展示提示框
  79. urgentLoading: boolean = false; //确认加急按钮loading状态
  80. recLoading: boolean = false; //撤回并删除按钮loading状态
  81. btnLoading: boolean = false; //确认按钮loading状态
  82. amplificationShow = true;
  83. ngOnInit() {
  84. this.tabType = this.route.snapshot.params.type || 1;
  85. this.getInfo();
  86. this.initForm();
  87. }
  88. ngOnDestroy() {}
  89. // 放大
  90. amplification(){
  91. this.amplificationShow = !this.amplificationShow;
  92. }
  93. // 获取工单详情
  94. middleDept = []; //中间科室数组
  95. getInfo() {
  96. this.id = +this.route.snapshot.paramMap.get("id");
  97. this.maskFlag = this.message.loading("正在加载中..", {
  98. nzDuration: 0,
  99. }).messageId;
  100. this.mainService
  101. .getFetchData("api", "workOrder", this.id)
  102. .subscribe((data) => {
  103. this.orderInfo = data.data;
  104. if (data.data.middleDept) {
  105. this.middleDept = data.data.middleDept.map((item) => item.dept);
  106. } else {
  107. this.middleDept = [];
  108. }
  109. this.endDepts = data.data.endDepts.map((item) => item.dept).join();
  110. let log$ = this.getLog();
  111. let record$ = this.getWorkOrderRecord();
  112. forkJoin(log$, record$).subscribe((res) => {
  113. this.message.remove(this.maskFlag);
  114. this.maskFlag = false;
  115. // getLog
  116. this.logList = res[0]["data"];
  117. // getWorkOrderRecord
  118. if (res[1]["status"] == 200) {
  119. this.workOrderRecord = res[1]["data"];
  120. }
  121. });
  122. });
  123. }
  124. // 预览图片
  125. imgs = [];
  126. isPreview = false;
  127. previewImageHandler(data) {
  128. this.isPreview = false;
  129. this.mainService.getPreviewImage(data.bindType,data.bindId).subscribe((result:any)=>{
  130. if (result.status == 200) {
  131. this.imgs = result.data.map((v) => location.origin + '/file' + v.relativeFilePath);
  132. this.isPreview = true;
  133. } else {
  134. this.imgs = [];
  135. }
  136. })
  137. }
  138. // 获取历史记录
  139. workOrderRecord: any = [];
  140. getWorkOrderRecord() {
  141. return this.mainService.getWorkOrderRecord({ gdid: this.id });
  142. }
  143. // 切换tab栏
  144. tabType: number = 1; //tab栏
  145. checkTab(type) {
  146. this.tabType = type;
  147. }
  148. // 关闭弹框
  149. close() {
  150. history.go(-1);
  151. }
  152. // 查看业务数据
  153. businessDataModalShow = false; //业务数据弹窗开关
  154. businessDataModalType = ''; //业务数据类型
  155. orderId = ""; //查看业务数据携带
  156. viewDetail(data, type) {
  157. this.orderId = data.id;
  158. this.businessDataModalType = type;
  159. this.businessDataModalShow = true;
  160. }
  161. // 关闭业务数据弹窗
  162. closeModelBlood(e) {
  163. this.businessDataModalShow = JSON.parse(e).show;
  164. }
  165. // 获取工单历史记录
  166. logList = []; //工单历史记录
  167. getLog() {
  168. return this.mainService.getWorkOrderLog(this.id);
  169. }
  170. // 初始化新增form表单
  171. validateForm: FormGroup; //新增/编辑表单
  172. initForm() {
  173. this.validateForm = this.fb.group({
  174. reason: [null, [Validators.required]],
  175. process: [null, [Validators.required]],
  176. handleType: [null, [Validators.required]],
  177. improve: [null, [Validators.required]],
  178. });
  179. }
  180. // 新增表单提交
  181. submitForm(): void {
  182. var that = this;
  183. for (const i in that.validateForm.controls) {
  184. that.validateForm.controls[i].markAsDirty();
  185. that.validateForm.controls[i].updateValueAndValidity();
  186. }
  187. if (that.validateForm.invalid) return;
  188. that.btnLoading = true;
  189. let postData = {
  190. badEvaluationHandle: {
  191. id: that.id,
  192. reasonAndEventProcess: that.validateForm.value.reason,
  193. mediationProcess: that.validateForm.value.process,
  194. handleType: { id: that.validateForm.value.handleType },
  195. advice: that.validateForm.value.improve,
  196. handleStatus: { key: "bad_evaluation_handle_status", value: "2" },
  197. },
  198. };
  199. that.mainService
  200. .postCustom("adviceCollection", "updData/badEvaluationHandle", postData)
  201. .subscribe((data) => {
  202. that.btnLoading = false;
  203. if (data.status == 200) {
  204. that.showPromptModal("调解", true, "");
  205. that.getInfo();
  206. // that.initForm();
  207. } else {
  208. that.showPromptModal("调解", false, data.msg);
  209. }
  210. });
  211. }
  212. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  213. showPromptModal(con, success, promptInfo?) {
  214. this.promptModalShow = false;
  215. this.promptContent = con;
  216. this.ifSuccess = success;
  217. this.promptInfo = promptInfo;
  218. setTimeout(() => {
  219. this.promptModalShow = true;
  220. }, 100);
  221. }
  222. // 格式化时分秒
  223. // (时间小于一分钟则显示秒,时间大于一分钟则显示分钟数,如超出一小时则显示小时和分钟。)time单位:秒
  224. formatTime(time) {
  225. let timeStr = "";
  226. if (time >= 0 && time < 60) {
  227. // 秒
  228. timeStr = time + "秒";
  229. } else if (time >= 60 && time < 3600) {
  230. // 分钟
  231. timeStr = Math.floor(time / 60) + "分钟";
  232. } else if (time >= 3600) {
  233. // 时 + 分
  234. let h = "";
  235. let m = "";
  236. h = Math.floor(time / 3600) + "小时";
  237. m = time % 3600 >= 60 ? Math.floor((time % 3600) / 60) + "分钟" : "";
  238. timeStr = h + m;
  239. }
  240. return timeStr;
  241. }
  242. // 计算历史记录耗时
  243. filterTime(step) {
  244. // step = [{ difTime: 2 }, { difTime: 6 }]
  245. let num = 0;
  246. step.forEach((e) => {
  247. num += e.difTime;
  248. });
  249. return this.formatTime(num / 1000);
  250. }
  251. }