specimen-view2.component.ts 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. import { Component, OnInit, ViewChild, OnDestroy } from "@angular/core";
  2. import { MainService } from "../../services/main.service";
  3. import { Router } from "@angular/router";
  4. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  5. import { startOfDay, format, endOfDay } from "date-fns";
  6. import { ToolService } from 'src/app/services/tool.service';
  7. @Component({
  8. selector: "app-specimen-view2",
  9. templateUrl: "./specimen-view2.component.html",
  10. styleUrls: ["./specimen-view2.component.less"],
  11. })
  12. export class SpecimenView2Component implements OnInit, OnDestroy {
  13. @ViewChild("osComponentRef1", {
  14. read: OverlayScrollbarsComponent,
  15. static: false,
  16. })
  17. osComponentRef1: OverlayScrollbarsComponent;
  18. @ViewChild("osComponentRef2", {
  19. read: OverlayScrollbarsComponent,
  20. static: false,
  21. })
  22. osComponentRef2: OverlayScrollbarsComponent;
  23. @ViewChild("osComponentRef3", {
  24. read: OverlayScrollbarsComponent,
  25. static: false,
  26. })
  27. osComponentRef3: OverlayScrollbarsComponent;
  28. @ViewChild("osComponentRef4", {
  29. read: OverlayScrollbarsComponent,
  30. static: false,
  31. })
  32. osComponentRef4: OverlayScrollbarsComponent;
  33. @ViewChild("osComponentRef5", {
  34. read: OverlayScrollbarsComponent,
  35. static: false,
  36. })
  37. osComponentRef5: OverlayScrollbarsComponent;
  38. constructor(private mainService: MainService, public router: Router, public tool: ToolService) {}
  39. // 今日药单量
  40. todayTotal: undefined;
  41. // 今日已完成
  42. todayComplete: undefined;
  43. //待配药数据
  44. // 待配药
  45. printPharmacyList = []; //数据列表
  46. printPharmacyIdx = 0; //页码
  47. printPharmacyTotal = 0; //总数
  48. printPharmacyFlag = false; //是否查看更多
  49. printPharmacySearchKey = ""; //搜索的内容
  50. printPharmacyLoad = false; //按钮的loading
  51. // 配药中列表
  52. waitPharmacyList = [];
  53. waitPharmacyIdx = 0;
  54. waitPharmacyTotal = 0;
  55. waitPharmacyFlag = false;
  56. waitPharmacySearchKey = "";
  57. waitPharmacyLoad = false;
  58. // 核对中列表
  59. pharmacyList = [];
  60. pharmacyIdx = 0;
  61. pharmacyTotal = 0;
  62. pharmacyFlag = false;
  63. pharmacySearchKey = "";
  64. pharmacyLoad = false;
  65. // 配送中列表
  66. distributionList = [];
  67. distributionIdx = 0;
  68. distributionTotal = 0;
  69. distributionFlag = false;
  70. distributionSearchKey = "";
  71. distributionLoad = false;
  72. // 已完成列表
  73. completedList = [];
  74. completedIdx = 0;
  75. completedTotal = 0;
  76. completedFlag = false;
  77. completedSearchKey = "";
  78. completedLoad = false;
  79. // other
  80. loginUser: any = localStorage.getItem("user")
  81. ? JSON.parse(localStorage.getItem("user")).user
  82. : null; //登录人信息
  83. logTimer = null; //定时器
  84. logTime = 0; //自动刷新秒数
  85. logTimeConst = 60; //自动刷新秒数
  86. time = new Date().getTime(); // 时间戳
  87. timer = null; // 时间定时器
  88. ngOnDestroy() {
  89. clearTimeout(this.timer);
  90. clearTimeout(this.logTimer);
  91. }
  92. ngOnInit() {
  93. this.runTime();
  94. // 统计
  95. this.total();
  96. // 切换科室
  97. this.changeKs();
  98. // 代收急查标本(标本信息)列表
  99. this.getPharmacyList(this.printPharmacyIdx, 'delegation', this.printPharmacySearchKey);
  100. // 已收取(工单信息)列表
  101. this.getPharmacyList(this.waitPharmacyIdx, 'take', this.waitPharmacySearchKey);
  102. // 中转标本(标本统计信息)列表
  103. this.getPharmacyList(this.pharmacyIdx, 'trans', this.pharmacySearchKey);
  104. // 中转配送中(工单信息)列表
  105. this.getPharmacyList(this.distributionIdx, 'trans_send', this.distributionSearchKey);
  106. // 异常标本(标本信息)列表
  107. this.getPharmacyList(this.completedIdx, 'error', this.completedSearchKey);
  108. this.initRole();
  109. // 自动刷新倒计时 start
  110. this.autoUpdate();
  111. // 自动刷新倒计时 end
  112. }
  113. // 当前时间日期
  114. runTime() {
  115. clearTimeout(this.timer);
  116. this.timer = setTimeout(() => {
  117. this.time = Date.now();
  118. this.runTime();
  119. }, 500);
  120. }
  121. // 统计
  122. total() {
  123. let launch = JSON.parse(localStorage.getItem("user")).user.dept.id;
  124. let startTime = format(startOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
  125. let endTime = format(endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
  126. let postData = {
  127. startTime,
  128. endTime,
  129. launch,
  130. };
  131. this.mainService.getDrugsBagStateCount(postData).subscribe((res: any) => {
  132. if (res.status == 200) {
  133. this.todayTotal = res.countMap.todayTotal;
  134. this.todayComplete = res.countMap.todayComplete;
  135. }
  136. });
  137. }
  138. // 查看工单详情
  139. goToOrderDetail(item){
  140. console.log(item);
  141. this.router.navigateByUrl(`specimenView2/detailSample/${item.id}`);
  142. }
  143. // 查看流程信息弹窗
  144. logPromptModalShow = false; //弹窗开关
  145. scode = ""; //查看记录携带
  146. showLogs(data) {
  147. clearInterval(this.logTimer);
  148. this.scode = data.scode;
  149. this.logPromptModalShow = true;
  150. }
  151. // 关闭流程信息弹窗
  152. closeModelLog(e) {
  153. this.logPromptModalShow = JSON.parse(e).show;
  154. this.autoUpdate(false);
  155. }
  156. // 查看标本列表弹窗
  157. spePromptModalShow = false; //弹窗开关
  158. checkDeptId = ""; //检查科室id
  159. printDate = ""; //采集日期
  160. showSpeList(data) {
  161. clearInterval(this.logTimer);
  162. this.checkDeptId = data.check_dept_id;
  163. this.printDate = data.startTime;
  164. this.spePromptModalShow = true;
  165. }
  166. // 关闭标本列表弹窗
  167. closeModelSpe(e) {
  168. this.spePromptModalShow = JSON.parse(e).show;
  169. this.autoUpdate(false);
  170. }
  171. // 查看工单列表弹窗
  172. orderPromptModalShow = false; //弹窗开关
  173. workId = ""; //配送人员ID
  174. showOrderList(data) {
  175. clearInterval(this.logTimer);
  176. this.workId = data.workerid;
  177. this.orderPromptModalShow = true;
  178. }
  179. // 关闭工单列表弹窗
  180. closeModelOrder(e) {
  181. this.orderPromptModalShow = JSON.parse(e).show;
  182. this.autoUpdate(false);
  183. }
  184. // 自动刷新倒计时
  185. autoUpdate(flag = true) {
  186. if (flag) {
  187. this.logTime = this.logTimeConst;
  188. }
  189. clearInterval(this.logTimer);
  190. this.logTimer = setInterval(() => {
  191. this.logTime--;
  192. if (this.logTime === 0) {
  193. this.logTime = this.logTimeConst;
  194. // 代收急查标本(标本信息)列表
  195. this.getPharmacyList(0, 'delegation', this.printPharmacySearchKey);
  196. // 已收取(工单信息)列表
  197. this.getPharmacyList(0, 'take', this.waitPharmacySearchKey);
  198. // 中转标本(标本统计信息)列表
  199. this.getPharmacyList(0, 'trans', this.pharmacySearchKey);
  200. // 中转配送中(工单信息)列表
  201. this.getPharmacyList(0, 'trans_send', this.distributionSearchKey);
  202. // 异常标本(标本信息)列表
  203. this.getPharmacyList(0, 'error', this.completedSearchKey);
  204. }
  205. }, 1000);
  206. }
  207. // 药房端药房列表查询、搜索
  208. // 1为pc待打印状态、2为pc配药中、3为pc核对中、4为pc配送中
  209. // searchKey 为搜索的关键字,没有就不传
  210. loading1 = false;
  211. loading2 = false;
  212. loading3 = false;
  213. loading4 = false;
  214. loading5 = false;
  215. getPharmacyList(idx, type, searchKey) {
  216. let hosId = JSON.parse(localStorage.getItem("user")).user.currentHospital.id;
  217. switch (type) {
  218. case 'delegation':
  219. this.loading1 = true;
  220. break;
  221. case 'take':
  222. this.loading2 = true;
  223. break;
  224. case 'trans':
  225. this.loading3 = true;
  226. break;
  227. case 'trans_send':
  228. this.loading4 = true;
  229. break;
  230. case 'error':
  231. this.loading5 = true;
  232. break;
  233. }
  234. let postData = {
  235. viewType: type,
  236. keyWord: searchKey,
  237. hosId,
  238. };
  239. this.mainService
  240. .specimenView2(postData)
  241. .subscribe((result) => {
  242. switch (type) {
  243. case 'delegation':
  244. this.loading1 = false;
  245. break;
  246. case 'take':
  247. this.loading2 = false;
  248. break;
  249. case 'trans':
  250. this.loading3 = false;
  251. break;
  252. case 'trans_send':
  253. this.loading4 = false;
  254. break;
  255. case 'error':
  256. this.loading5 = false;
  257. break;
  258. }
  259. if (result["state"] == 200) {
  260. switch (type) {
  261. case 'delegation':
  262. // 总数
  263. this.printPharmacyTotal = result.totalNum;
  264. // 隐藏按钮的loading
  265. this.printPharmacyLoad = false;
  266. // 查看更多,是否显示
  267. if (result["data"].length < 10) {
  268. this.printPharmacyFlag = false;
  269. } else if (result["data"].length === 0 && idx === 0) {
  270. this.printPharmacyFlag = false;
  271. } else {
  272. this.printPharmacyFlag = true;
  273. }
  274. // 列表数据合并
  275. if (idx === 0) {
  276. this.printPharmacyList = result["data"];
  277. } else {
  278. this.printPharmacyList = [
  279. ...this.printPharmacyList,
  280. ...result["data"],
  281. ];
  282. }
  283. break;
  284. case 'take':
  285. this.waitPharmacyTotal = result.totalNum;
  286. this.waitPharmacyLoad = false;
  287. if (result["data"].length < 10) {
  288. this.waitPharmacyFlag = false;
  289. } else if (result["data"].length === 0 && idx === 0) {
  290. this.waitPharmacyFlag = false;
  291. } else {
  292. this.waitPharmacyFlag = true;
  293. }
  294. if (idx === 0) {
  295. this.waitPharmacyList = result["data"];
  296. } else {
  297. this.waitPharmacyList = [
  298. ...this.waitPharmacyList,
  299. ...result["data"],
  300. ];
  301. }
  302. break;
  303. case 'trans':
  304. this.pharmacyTotal = result.totalNum;
  305. this.pharmacyLoad = false;
  306. if (result["data"].length < 10) {
  307. this.pharmacyFlag = false;
  308. } else if (result["data"].length === 0 && idx === 0) {
  309. this.pharmacyFlag = false;
  310. } else {
  311. this.pharmacyFlag = true;
  312. }
  313. if (idx === 0) {
  314. this.pharmacyList = result["data"];
  315. } else {
  316. this.pharmacyList = [...this.pharmacyList, ...result["data"]];
  317. }
  318. break;
  319. case 'trans_send':
  320. this.distributionTotal = result.totalNum;
  321. this.distributionLoad = false;
  322. if (result["data"].length < 10) {
  323. this.distributionFlag = false;
  324. } else if (result["data"].length === 0 && idx === 0) {
  325. this.distributionFlag = false;
  326. } else {
  327. this.distributionFlag = true;
  328. }
  329. // 处理数据
  330. result["data"].forEach(v=>{
  331. v.deptList = v.deptList?v.deptList.join(','):'';
  332. })
  333. if (idx === 0) {
  334. this.distributionList = result["data"];
  335. } else {
  336. this.distributionList = [
  337. ...this.distributionList,
  338. ...result["data"],
  339. ];
  340. }
  341. break;
  342. case 'error':
  343. this.completedTotal = result.totalNum;
  344. this.completedLoad = false;
  345. if (result["data"].length < 10) {
  346. this.completedFlag = false;
  347. } else if (result["data"].length === 0 && idx === 0) {
  348. this.completedFlag = false;
  349. } else {
  350. this.completedFlag = true;
  351. }
  352. if (idx === 0) {
  353. this.completedList = result["data"];
  354. } else {
  355. this.completedList = [...this.completedList, ...result["data"]];
  356. }
  357. break;
  358. }
  359. }
  360. });
  361. }
  362. // 加载更多
  363. loadMore(type) {
  364. switch (type) {
  365. case 'delegation':
  366. this.printPharmacyIdx++;
  367. this.printPharmacyLoad = true;
  368. this.getPharmacyList(
  369. this.printPharmacyIdx,
  370. type,
  371. this.printPharmacySearchKey
  372. );
  373. break;
  374. case 'take':
  375. this.waitPharmacyIdx++;
  376. this.waitPharmacyLoad = true;
  377. this.getPharmacyList(
  378. this.waitPharmacyIdx,
  379. type,
  380. this.waitPharmacySearchKey
  381. );
  382. break;
  383. case 'trans':
  384. this.pharmacyIdx++;
  385. this.pharmacyLoad = true;
  386. this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
  387. break;
  388. case 'trans_send':
  389. this.distributionIdx++;
  390. this.distributionLoad = true;
  391. this.getPharmacyList(
  392. this.distributionIdx,
  393. type,
  394. this.distributionSearchKey
  395. );
  396. break;
  397. case 'error':
  398. this.completedIdx++;
  399. this.completedLoad = true;
  400. this.getPharmacyList(this.completedIdx, type, this.completedSearchKey);
  401. break;
  402. }
  403. }
  404. // 搜索关键词
  405. searchKeyHandle(type) {
  406. switch (type) {
  407. case 'delegation':
  408. this.printPharmacyIdx = 0; //页码重置
  409. this.printPharmacyList = []; //列表重置
  410. this.getPharmacyList(
  411. this.printPharmacyIdx,
  412. type,
  413. this.printPharmacySearchKey
  414. );
  415. break;
  416. case 'take':
  417. this.waitPharmacyIdx = 0; //页码重置
  418. this.waitPharmacyList = []; //列表重置
  419. this.getPharmacyList(
  420. this.waitPharmacyIdx,
  421. type,
  422. this.waitPharmacySearchKey
  423. );
  424. break;
  425. case 'trans':
  426. this.pharmacyIdx = 0; //页码重置
  427. this.pharmacyList = []; //列表重置
  428. this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
  429. break;
  430. case 'trans_send':
  431. this.distributionIdx = 0; //页码重置
  432. this.distributionList = []; //列表重置
  433. this.getPharmacyList(
  434. this.distributionIdx,
  435. type,
  436. this.distributionSearchKey
  437. );
  438. break;
  439. case 'error':
  440. this.completedIdx = 0; //页码重置
  441. this.completedList = []; //列表重置
  442. this.getPharmacyList(this.completedIdx, type, this.completedSearchKey);
  443. break;
  444. }
  445. }
  446. // 退出
  447. logOut(): void {
  448. // 假退出
  449. let hospital = this.tool.getCurrentHospital();
  450. if(hospital){
  451. this.router.navigate(["login", hospital.id]);
  452. }else{
  453. this.router.navigateByUrl("login");
  454. }
  455. localStorage.removeItem("user");
  456. localStorage.removeItem("menu");
  457. localStorage.removeItem("index");
  458. // 假退出
  459. this.mainService.logOut().subscribe((data) => {
  460. if (data.status == 200) {
  461. if(hospital){
  462. this.router.navigate(["login", hospital.id]);
  463. }else{
  464. this.router.navigateByUrl("login");
  465. }
  466. localStorage.removeItem("user");
  467. localStorage.removeItem("menu");
  468. localStorage.removeItem("index");
  469. }
  470. });
  471. }
  472. // 右侧菜单
  473. showLastItems: boolean = false;
  474. // 下拉
  475. fixedMenuXiala() {
  476. this.showLastItems = true;
  477. }
  478. // 上拉
  479. fixedMenuShangla() {
  480. this.showLastItems = false;
  481. }
  482. mainRole: boolean = false; //回到系统管理权限
  483. initRole() {
  484. let menus = JSON.parse(localStorage.getItem("menu"));
  485. console.log("菜单数量" + menus.length);
  486. if (menus.length >= 2) {
  487. this.mainRole = true;
  488. return;
  489. }
  490. }
  491. // 切换右侧菜单Tab
  492. fixedTab: string = "";
  493. checkFixedTab(type: string) {
  494. if (type == "toSystem") {
  495. this.router.navigateByUrl("main");
  496. }
  497. if (this.fixedTab == type) {
  498. this.fixedTab = "";
  499. } else {
  500. this.fixedTab = type;
  501. }
  502. }
  503. //药房端科室切换
  504. changeShow = true;
  505. closeTime = 3;
  506. closeTimeFlag = 0;
  507. hsPromptModalShow: boolean = true; //科室切换提示框是否展示
  508. timerCloseTime = null;
  509. deptDisplay = 1; //护士端是否显示可以别名,1是显示科室名称,2是显示科室别名
  510. //子传父接收
  511. closeModelHs(e) {
  512. this.hsPromptModalShow = JSON.parse(e).show;
  513. this.changeShow = JSON.parse(e).changeShow;
  514. }
  515. //子传父接收
  516. clearModelHs(e) {
  517. if (JSON.parse(e).clear === true) {
  518. clearInterval(this.timerCloseTime);
  519. }
  520. this.changeShow = JSON.parse(e).changeShow;
  521. }
  522. // 头部切换科室
  523. changeKsNow() {
  524. this.hsPromptModalShow = true;
  525. clearInterval(this.timerCloseTime);
  526. this.changeShow = false;
  527. }
  528. // 切换科室
  529. changeKs() {
  530. this.hsPromptModalShow = true;
  531. // (1) 当用户设置为正数时,用户必须查看此窗体指定秒数。
  532. // (2) 当用户设置为负数时,用户可点击知道了也可倒计时自动关闭。
  533. // (3) 如果用户填写0则为无自动关闭和强制查看时间。
  534. if (this.closeTimeFlag === 0) {
  535. return;
  536. }
  537. this.closeTime = Math.abs(this.closeTimeFlag);
  538. clearInterval(this.timerCloseTime);
  539. this.timerCloseTime = setInterval(() => {
  540. this.closeTime = Math.max(--this.closeTime, 0);
  541. if (this.closeTime === 0) {
  542. if (this.closeTimeFlag <= 0) {
  543. this.hsPromptModalShow = false;
  544. }
  545. clearInterval(this.timerCloseTime);
  546. }
  547. }, 1000);
  548. }
  549. }