specimen-package.component.ts 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. import { Component, OnInit } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { FormBuilder, Validators, FormGroup } from "@angular/forms";
  4. import { MainService } from "../../services/main.service";
  5. import { ToolService } from "../../services/tool.service";
  6. import { NzMessageService } from 'ng-zorro-antd';
  7. import { Subject } from 'rxjs';
  8. import { debounceTime } from 'rxjs/operators';
  9. import { startOfDay, endOfDay, format } from 'date-fns';
  10. @Component({
  11. selector: "app-specimen-package",
  12. templateUrl: "./specimen-package.component.html",
  13. styleUrls: ["./specimen-package.component.less"],
  14. })
  15. export class SpecimenPackageComponent implements OnInit {
  16. constructor(
  17. private fb: FormBuilder,
  18. private mainService: MainService,
  19. private route: ActivatedRoute,
  20. private router: Router,
  21. private tool: ToolService,
  22. private message: NzMessageService,
  23. ) {}
  24. listOfData: any[] = []; //表格数据
  25. pageIndex: number = 1; //表格当前页码
  26. pageSize: number = 10; //表格每页展示条数
  27. listLength: number = 10; //表格总数据量
  28. modal: boolean = false; //新增/编辑模态框
  29. add: boolean; //true:新增;false:编辑
  30. validateForm: FormGroup; //新增/编辑表单
  31. coopData: any; //当前操作列
  32. currentHospital; //当前院区
  33. btnLoading: boolean = false; //提交按钮loading状态
  34. promptContent: string; //操作提示框提示信息
  35. ifSuccess: boolean; //操作成功/失败
  36. promptInfo: string; //操作结果提示信息
  37. promptModalShow: boolean; //操作提示框是否展示
  38. modelName = ""; //模态框名称
  39. searchTimerSubject = new Subject(); //防抖
  40. showDropdown:boolean = false;
  41. dateRange: any = []; //发起时间
  42. ngOnInit() {
  43. //防抖
  44. this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
  45. let fun = v[0];
  46. fun.call(this, v[1]);
  47. });
  48. this.currentHospital = this.tool.getCurrentHospital();
  49. this.coopBtns = this.tool.initCoopBtns(this.route);
  50. this.getList(1);
  51. this.getStatus();
  52. }
  53. // 初始化增删改按钮
  54. coopBtns: any = {};
  55. // 日期选择
  56. onCalendarChangeDate(dateArr){
  57. if(dateArr.length == 2){
  58. this.dateRange = [startOfDay(dateArr[0]), endOfDay(dateArr[1])];
  59. }
  60. }
  61. // 搜索
  62. search() {
  63. this.getList(1);
  64. }
  65. // 重置
  66. reset() {
  67. this.searchDto = {};
  68. this.dateRange = [];
  69. this.getList(1);
  70. }
  71. // 表格数据
  72. searchDto: any = {};
  73. loading1 = false;
  74. getList(type) {
  75. if (type == 1) {
  76. this.pageIndex = 1;
  77. }
  78. let data = {
  79. idx: this.pageIndex - 1,
  80. sum: this.pageSize,
  81. pathologyPackInfo: {
  82. hosId: this.currentHospital.id,
  83. busiType: 'specimen',//标本打包
  84. status: this.searchDto.status ? { id: this.searchDto.status } : undefined,
  85. deliveryUser: this.searchDto.deliveryUser || undefined,
  86. packDept: this.searchDto.packDept || undefined,
  87. startTime: this.dateRange.length ? format(this.dateRange[0], 'yyyy-MM-dd HH:mm:ss') : undefined,
  88. endTime: this.dateRange.length ? format(this.dateRange[1], 'yyyy-MM-dd HH:mm:ss') : undefined,
  89. },
  90. };
  91. this.loading1 = true;
  92. this.mainService
  93. .getFetchDataList("simple/data", "pathologyPackInfo", data)
  94. .subscribe((data) => {
  95. this.loading1 = false;
  96. if (data.status == 200) {
  97. let listOfData = data.list || [];
  98. listOfData.forEach((v) => {
  99. if(v.endDeptList){
  100. v.endDeptNames = v.endDeptList.map(v => v.dept).toString();
  101. }else{
  102. v.endDeptNames = "";
  103. }
  104. })
  105. this.listOfData = listOfData;
  106. this.listLength = data.totalNum;
  107. }else{
  108. this.message.error(data.msg || "请求数据失败");
  109. }
  110. });
  111. }
  112. // 防抖
  113. isLoading = false;
  114. isSelecting:boolean = false; // 是否在选中状态
  115. searchTimer(fun, e) {
  116. if (this.isSelecting) {
  117. this.isSelecting = false; // 重置标志
  118. return; // 跳过处理
  119. }
  120. this.isLoading = true;
  121. this.searchTimerSubject.next([fun, e]);
  122. }
  123. // 搜索
  124. changeInp(type, e) {
  125. if(type === 'department'){
  126. this.searchTimer(this.getDeptList, e);
  127. }else if(type === 'patient'){
  128. this.searchTimer(this.getDeliveryUserList, e);
  129. }
  130. }
  131. // 设置标志
  132. setIsSelecting(flag){
  133. this.isSelecting = flag; // 设置标志
  134. }
  135. openChangeDept(flag){
  136. flag && this.setIsSelecting(false);
  137. flag && this.getDeptList();
  138. }
  139. // 获取科室
  140. deptList: any = [];
  141. getDeptList(e = undefined) {
  142. let postData = {
  143. idx: 0,
  144. sum: 20,
  145. department: {
  146. searchType: 1,// 简单查询
  147. cascadeHosId: this.currentHospital.id,
  148. dept: e,
  149. }
  150. };
  151. this.isLoading = true;
  152. this.mainService
  153. .getFetchDataList("simple/data", "department", postData)
  154. .subscribe((data) => {
  155. this.isLoading = false;
  156. this.deptList = data.list || [];
  157. });
  158. }
  159. openChangePatient(flag){
  160. flag && this.setIsSelecting(false);
  161. flag && this.getDeliveryUserList();
  162. }
  163. // 获取送达人
  164. deliveryUserList: any = [];
  165. getDeliveryUserList(e = undefined) {
  166. let postData = {
  167. idx: 0,
  168. sum: 20,
  169. user: {
  170. hospital: { id: this.currentHospital.id },
  171. name: e,
  172. }
  173. };
  174. this.isLoading = true;
  175. this.mainService
  176. .getFetchDataList("simple/data", "user", postData)
  177. .subscribe((data) => {
  178. this.isLoading = false;
  179. this.deliveryUserList = data.list || [];
  180. });
  181. }
  182. //获取状态
  183. stateList:any[] = [];
  184. getStatus() {
  185. this.mainService
  186. .getDictionary('list', 'pathology_pack_status')
  187. .subscribe((data) => {
  188. this.stateList = data || [];
  189. });
  190. }
  191. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  192. showPromptModal(con, success, promptInfo?) {
  193. this.promptModalShow = false;
  194. this.promptContent = con;
  195. this.ifSuccess = success;
  196. this.promptInfo = promptInfo;
  197. setTimeout(() => {
  198. this.promptModalShow = true;
  199. }, 100);
  200. this.getList(0);
  201. }
  202. // 查看日志弹窗
  203. logPromptModalShow = false; //弹窗开关
  204. packId = ""; //查看记录携带id
  205. showLogs(data) {
  206. this.packId = data.id;
  207. this.logPromptModalShow = true;
  208. }
  209. // 关闭日志弹窗
  210. closeModelLog(e) {
  211. this.logPromptModalShow = JSON.parse(e).show;
  212. }
  213. // 查看
  214. detail(e, id) {
  215. e.stopPropagation();
  216. this.router.navigateByUrl(`/main/specimenPackage/orderDetail/${id}`);
  217. }
  218. delModal: boolean = false; //删除模态框
  219. tipsMsg1: string; //提示框信息
  220. tipsMsg2: string; //操作后信息
  221. confirmDelType: string; //确认的类型(启用/停用,删除)
  222. showDelModal(
  223. data,
  224. tipsMsg1: string,
  225. tipsMsg2: string,
  226. type: string,
  227. ) {
  228. this.confirmDelType = type;
  229. this.delModal = true;
  230. this.coopData = data;
  231. this.tipsMsg1 = tipsMsg1;
  232. this.tipsMsg2 = tipsMsg2;
  233. }
  234. // 隐藏删除框
  235. hideDelModal() {
  236. this.delModal = false;
  237. }
  238. // 确认删除
  239. confirmDel() {
  240. this.btnLoading = true;
  241. if (this.confirmDelType === "del") {
  242. //删除
  243. this.mainService
  244. .simplePost("rmvData", "pathologyPackInfo", [this.coopData.id])
  245. .subscribe((data) => {
  246. this.btnLoading = false;
  247. this.delModal = false;
  248. if (data.status == 200) {
  249. this.showPromptModal(this.tipsMsg2, true, "");
  250. } else {
  251. this.showPromptModal(this.tipsMsg2, false, data.msg);
  252. }
  253. });
  254. }
  255. }
  256. }