configuration-closedData.component.ts 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. import { Component, OnInit, ElementRef, ViewChild } from "@angular/core";
  2. import { MainService } from "../../../services/main.service";
  3. import { ToolService } from 'src/app/services/tool.service';
  4. import { NzMessageService } from 'ng-zorro-antd';
  5. import { Subject } from 'rxjs';
  6. import { debounceTime } from 'rxjs/operators';
  7. import { format } from 'date-fns';
  8. @Component({
  9. selector: "app-configuration-closedData",
  10. templateUrl: "./configuration-closedData.component.html",
  11. styleUrls: ["./configuration-closedData.component.less"],
  12. })
  13. export class ConfigurationClosedDataComponent implements OnInit {
  14. @ViewChild('scrollContainer', {static: false}) scrollContainer: ElementRef;
  15. loading:boolean = false; //页面加载的loading
  16. btnLoading:boolean = false; //提交按钮的loading
  17. tabModalName:string = 'course'; //当前选中的tab
  18. hosId = this.tool.getCurrentHospital().id; //当前院区
  19. // tab类型
  20. dictionaryKeyList:any[] = [
  21. {
  22. name:'检验标本',key:'specimen'
  23. },
  24. {
  25. name:'病理申请单',key:'pathology'
  26. },
  27. {
  28. name:'药品',key:'drugsBag'
  29. },
  30. {
  31. name:'血制品',key:'blood'
  32. },
  33. {
  34. name:'预约检查',key:'subscribe'
  35. }
  36. ];
  37. btnLoading1:boolean = false;
  38. btnLoading2:boolean = false;
  39. btnLoading3:boolean = false;
  40. // 是否关联工单
  41. bindOrder:any = 0;
  42. // 同步开始时间
  43. dateRange:any = [];
  44. // 业务状态
  45. transState:any;
  46. // 目标状态
  47. completeState:any = 2;
  48. // 收取时间间隔区间
  49. arriveStartMinute:any;
  50. // 收取时间间隔区间
  51. arriveEndMinute:any;
  52. // 送达时间间隔区间
  53. sendStartMinute:any;
  54. // 送达时间间隔区间
  55. sendEndMinute:any;
  56. code:any;
  57. // 配置
  58. configs:any = {};
  59. // 任务类型
  60. tasktype:any = {};
  61. searchTimerSubject = new Subject();
  62. constructor(private mainService: MainService,private tool: ToolService,private msg: NzMessageService) {}
  63. ngOnInit():void {
  64. // todo
  65. this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
  66. let fun = v[0];
  67. fun.call(this, v[1]);
  68. });
  69. this.getSpeDic();
  70. this.getUsers();
  71. }
  72. // 点击数据字典key
  73. activeDictionaryKey:any = 'specimen';
  74. clickDictionaryKey(item){
  75. this.activeDictionaryKey = item.key;
  76. this.getSpeDic();
  77. this.resetForm();
  78. }
  79. onCalendarChangeDate(dateArr){
  80. console.log(dateArr)
  81. if(dateArr.length == 2){
  82. let dateStart = new Date(dateArr[0]);
  83. let dateEnd = new Date(dateArr[1]);
  84. dateStart.setHours(0,0,0);
  85. dateEnd.setHours(23,59,59);
  86. this.dateRange = [dateStart,dateEnd];
  87. }
  88. }
  89. // 日期选择
  90. startDate: string; //发起时间开始
  91. endDate: string; //发起时间结束
  92. changeDate(result?): void {
  93. if (!result) {
  94. this.startDate = this.endDate = "";
  95. return;
  96. }
  97. this.startDate = format(result[0], 'yyyy-MM-dd HH:mm:ss');
  98. this.endDate = format(result[1], 'yyyy-MM-dd HH:mm:ss');
  99. }
  100. // 切换tab
  101. tabModal(tabModalName:string){
  102. this.tabModalName = tabModalName;
  103. }
  104. // 生成数据
  105. queryNum:any;
  106. generateModal:boolean = false;
  107. generateForm(){
  108. if(!this.startDate || !this.endDate){
  109. this.msg.error("同步开始时间不能为空");
  110. return
  111. }
  112. if(!this.arriveStartMinute || !this.arriveEndMinute){
  113. this.msg.error("收取时间间隔区间不能为空");
  114. return
  115. }
  116. if(!this.sendStartMinute || !this.sendEndMinute){
  117. this.msg.error("送达时间间隔区间不能为空");
  118. return
  119. }
  120. if(this.userIds.length==0){
  121. this.msg.error("配送人员不能为空");
  122. return
  123. }
  124. this.generateModal = true
  125. }
  126. hideGenerateModal() {
  127. this.generateModal = false;
  128. this.btnLoading1 = false;
  129. }
  130. showGenerate:boolean = false;
  131. generateObj:any;
  132. confirmGenerate() {
  133. var that = this;
  134. let list = this.drugStatusList.find(i=> i.id == this.transState)
  135. let postData:any = {
  136. patchDataConfig:{
  137. hosId: this.hosId,
  138. bindOrder: this.bindOrder,
  139. transStartTime: this.startDate || undefined,
  140. transEndTime: this.endDate || undefined,
  141. transState: list || undefined,
  142. transType: {
  143. value: this.activeDictionaryKey || undefined
  144. },
  145. code: this.code || undefined,
  146. completeState: this.completeState,
  147. arriveStartMinute: this.arriveStartMinute || undefined,
  148. arriveEndMinute: this.arriveEndMinute || undefined,
  149. sendStartMinute: this.sendStartMinute || undefined,
  150. sendEndMinute: this.sendEndMinute || undefined,
  151. userIds: this.userIds.length>0 ? this.userIds.join(',') : undefined
  152. }
  153. };
  154. this.btnLoading1 = true;
  155. this.mainService
  156. .generateData( postData).subscribe((result:any) => {
  157. this.btnLoading1 = false;
  158. if (result.state == 200) {
  159. this.hideGenerateModal()
  160. this.showNum = false
  161. this.showGenerate = true
  162. this.generateObj = result.data
  163. setTimeout(_=>{
  164. this.scrollContainer.nativeElement.scrollTop = this.scrollContainer.nativeElement.scrollHeight;
  165. },100)
  166. }
  167. });
  168. }
  169. // 查询
  170. showNum:boolean = false;
  171. submitForm() {
  172. if(!this.startDate || !this.endDate){
  173. this.msg.error("同步开始时间不能为空");
  174. return
  175. }
  176. if(!this.arriveStartMinute || !this.arriveEndMinute){
  177. this.msg.error("收取时间间隔区间不能为空");
  178. return
  179. }
  180. if(!this.sendStartMinute || !this.sendEndMinute){
  181. this.msg.error("送达时间间隔区间不能为空");
  182. return
  183. }
  184. if(this.userIds.length==0){
  185. this.msg.error("配送人员不能为空");
  186. return
  187. }
  188. let list = this.drugStatusList.find(i=> i.id == this.transState)
  189. let postData:any = {
  190. patchDataConfig:{
  191. hosId: this.hosId,
  192. bindOrder: this.bindOrder,
  193. transStartTime: this.startDate || undefined,
  194. transEndTime: this.endDate || undefined,
  195. transState: list || undefined,
  196. transType: {
  197. value: this.activeDictionaryKey || undefined
  198. },
  199. code: this.code || undefined,
  200. completeState: this.completeState,
  201. arriveStartMinute: this.arriveStartMinute || undefined,
  202. arriveEndMinute: this.arriveEndMinute || undefined,
  203. sendStartMinute: this.sendStartMinute || undefined,
  204. sendEndMinute: this.sendEndMinute || undefined,
  205. userIds: this.userIds.length>0 ? this.userIds.join(',') : undefined
  206. }
  207. };
  208. this.btnLoading2 = true;
  209. this.mainService
  210. .queryCount( postData).subscribe((result:any) => {
  211. this.btnLoading2 = false;
  212. if (result.state == 200) {
  213. this.showNum = true
  214. this.showGenerate = false
  215. this.queryNum = result.data
  216. setTimeout(_=>{
  217. this.scrollContainer.nativeElement.scrollTop = this.scrollContainer.nativeElement.scrollHeight;
  218. },100)
  219. }
  220. });
  221. }
  222. // 重置
  223. resetForm(){
  224. this.showNum = false;
  225. this.showGenerate = false;
  226. this.bindOrder = 0;
  227. this.startDate = "";
  228. this.endDate = "";
  229. this.dateRange = [];
  230. this.code = undefined;
  231. this.transState = undefined;
  232. this.completeState = 2;
  233. this.arriveStartMinute = undefined;
  234. this.arriveEndMinute = undefined;
  235. this.sendStartMinute = undefined;
  236. this.sendEndMinute = undefined;
  237. this.userIds = [];
  238. }
  239. // 获取字典
  240. drugStatusList:any = [];
  241. getSpeDic(){
  242. let key = null;
  243. if(this.activeDictionaryKey=='specimen'){
  244. key = 'speState'
  245. }else if (this.activeDictionaryKey=='drugsBag'){
  246. key = 'drug_state'
  247. }else{
  248. key = 'blood_trans_state'
  249. }
  250. this.mainService.getDictionary("list", key).subscribe((data) => {
  251. this.drugStatusList = data
  252. });
  253. }
  254. // 人员边输边搜节流阀
  255. changeUser(e) {
  256. this.searchTimer(this.getUsers, e);
  257. }
  258. // 边输入边搜索节流阀
  259. searchTimer(fun, e) {
  260. this.isLoading = true;
  261. this.searchTimerSubject.next([fun, e]);
  262. }
  263. // 配送人员
  264. userIds:any = [];
  265. distributionList:any;
  266. isLoading:boolean = false;
  267. getUsers(e?) {
  268. let postData = {
  269. user: {
  270. name: e,
  271. hospital: { id: this.hosId },
  272. simpleQuery: true,
  273. },
  274. idx: 0,
  275. sum: 20,
  276. };
  277. this.isLoading = true;
  278. this.mainService
  279. .getFetchDataList("data", "user", postData)
  280. .subscribe((data) => {
  281. this.isLoading = false;
  282. this.distributionList = data.list;
  283. });
  284. }
  285. }