specimen-view2.component.ts 16 KB

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