specimen-view2.component.ts 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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. orderPromptModalShow = false; //弹窗开关
  172. workId = ""; //支助人员ID
  173. showOrderList(data) {
  174. clearInterval(this.logTimer);
  175. this.workId = data.workerid;
  176. this.orderPromptModalShow = true;
  177. }
  178. // 关闭工单列表弹窗
  179. closeModelOrder(e) {
  180. this.orderPromptModalShow = JSON.parse(e).show;
  181. this.autoUpdate(false);
  182. }
  183. // 自动刷新倒计时
  184. autoUpdate(flag = true) {
  185. if (flag) {
  186. this.logTime = this.logTimeConst;
  187. }
  188. clearInterval(this.logTimer);
  189. this.logTimer = setInterval(() => {
  190. this.logTime--;
  191. if (this.logTime === 0) {
  192. this.logTime = this.logTimeConst;
  193. // 代收急查标本(标本信息)列表
  194. this.getPharmacyList(0, 'delegation', this.printPharmacySearchKey);
  195. // 已收取(工单信息)列表
  196. this.getPharmacyList(0, 'take', this.waitPharmacySearchKey);
  197. // 中转标本(标本统计信息)列表
  198. this.getPharmacyList(0, 'trans', this.pharmacySearchKey);
  199. // 中转配送中(工单信息)列表
  200. this.getPharmacyList(0, 'trans_send', this.distributionSearchKey);
  201. // 异常标本(标本信息)列表
  202. this.getPharmacyList(0, 'error', this.completedSearchKey);
  203. }
  204. }, 1000);
  205. }
  206. // 药房端药房列表查询、搜索
  207. // 1为pc待打印状态、2为pc配药中、3为pc核对中、4为pc配送中
  208. // searchKey 为搜索的关键字,没有就不传
  209. loading1 = false;
  210. loading2 = false;
  211. loading3 = false;
  212. loading4 = false;
  213. loading5 = false;
  214. getPharmacyList(idx, type, searchKey) {
  215. let hosId = JSON.parse(localStorage.getItem("user")).user.currentHospital.id;
  216. switch (type) {
  217. case 'delegation':
  218. this.loading1 = true;
  219. break;
  220. case 'take':
  221. this.loading2 = true;
  222. break;
  223. case 'trans':
  224. this.loading3 = true;
  225. break;
  226. case 'trans_send':
  227. this.loading4 = true;
  228. break;
  229. case 'error':
  230. this.loading5 = true;
  231. break;
  232. }
  233. let postData = {
  234. viewType: type,
  235. keyWord: searchKey,
  236. hosId,
  237. };
  238. this.mainService
  239. .specimenView2(postData)
  240. .subscribe((result) => {
  241. switch (type) {
  242. case 'delegation':
  243. this.loading1 = false;
  244. break;
  245. case 'take':
  246. this.loading2 = false;
  247. break;
  248. case 'trans':
  249. this.loading3 = false;
  250. break;
  251. case 'trans_send':
  252. this.loading4 = false;
  253. break;
  254. case 'error':
  255. this.loading5 = false;
  256. break;
  257. }
  258. if (result["state"] == 200) {
  259. switch (type) {
  260. case 'delegation':
  261. // 总数
  262. this.printPharmacyTotal = result.totalNum;
  263. // 隐藏按钮的loading
  264. this.printPharmacyLoad = false;
  265. // 查看更多,是否显示
  266. if (result["data"].length < 10) {
  267. this.printPharmacyFlag = false;
  268. } else if (result["data"].length === 0 && idx === 0) {
  269. this.printPharmacyFlag = false;
  270. } else {
  271. this.printPharmacyFlag = true;
  272. }
  273. // 列表数据合并
  274. if (idx === 0) {
  275. this.printPharmacyList = result["data"];
  276. } else {
  277. this.printPharmacyList = [
  278. ...this.printPharmacyList,
  279. ...result["data"],
  280. ];
  281. }
  282. break;
  283. case 'take':
  284. this.waitPharmacyTotal = result.totalNum;
  285. this.waitPharmacyLoad = false;
  286. if (result["data"].length < 10) {
  287. this.waitPharmacyFlag = false;
  288. } else if (result["data"].length === 0 && idx === 0) {
  289. this.waitPharmacyFlag = false;
  290. } else {
  291. this.waitPharmacyFlag = true;
  292. }
  293. if (idx === 0) {
  294. this.waitPharmacyList = result["data"];
  295. } else {
  296. this.waitPharmacyList = [
  297. ...this.waitPharmacyList,
  298. ...result["data"],
  299. ];
  300. }
  301. break;
  302. case 'trans':
  303. this.pharmacyTotal = result.totalNum;
  304. this.pharmacyLoad = false;
  305. if (result["data"].length < 10) {
  306. this.pharmacyFlag = false;
  307. } else if (result["data"].length === 0 && idx === 0) {
  308. this.pharmacyFlag = false;
  309. } else {
  310. this.pharmacyFlag = true;
  311. }
  312. if (idx === 0) {
  313. this.pharmacyList = result["data"];
  314. } else {
  315. this.pharmacyList = [...this.pharmacyList, ...result["data"]];
  316. }
  317. break;
  318. case 'trans_send':
  319. this.distributionTotal = result.totalNum;
  320. this.distributionLoad = false;
  321. if (result["data"].length < 10) {
  322. this.distributionFlag = false;
  323. } else if (result["data"].length === 0 && idx === 0) {
  324. this.distributionFlag = false;
  325. } else {
  326. this.distributionFlag = true;
  327. }
  328. // 处理数据
  329. result["data"].forEach(v=>{
  330. v.deptList = v.deptList?v.deptList.join(','):'';
  331. })
  332. if (idx === 0) {
  333. this.distributionList = result["data"];
  334. } else {
  335. this.distributionList = [
  336. ...this.distributionList,
  337. ...result["data"],
  338. ];
  339. }
  340. break;
  341. case 'error':
  342. this.completedTotal = result.totalNum;
  343. this.completedLoad = false;
  344. if (result["data"].length < 10) {
  345. this.completedFlag = false;
  346. } else if (result["data"].length === 0 && idx === 0) {
  347. this.completedFlag = false;
  348. } else {
  349. this.completedFlag = true;
  350. }
  351. if (idx === 0) {
  352. this.completedList = result["data"];
  353. } else {
  354. this.completedList = [...this.completedList, ...result["data"]];
  355. }
  356. break;
  357. }
  358. }
  359. });
  360. }
  361. // 加载更多
  362. loadMore(type) {
  363. switch (type) {
  364. case 'delegation':
  365. this.printPharmacyIdx++;
  366. this.printPharmacyLoad = true;
  367. this.getPharmacyList(
  368. this.printPharmacyIdx,
  369. type,
  370. this.printPharmacySearchKey
  371. );
  372. break;
  373. case 'take':
  374. this.waitPharmacyIdx++;
  375. this.waitPharmacyLoad = true;
  376. this.getPharmacyList(
  377. this.waitPharmacyIdx,
  378. type,
  379. this.waitPharmacySearchKey
  380. );
  381. break;
  382. case 'trans':
  383. this.pharmacyIdx++;
  384. this.pharmacyLoad = true;
  385. this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
  386. break;
  387. case 'trans_send':
  388. this.distributionIdx++;
  389. this.distributionLoad = true;
  390. this.getPharmacyList(
  391. this.distributionIdx,
  392. type,
  393. this.distributionSearchKey
  394. );
  395. break;
  396. case 'error':
  397. this.completedIdx++;
  398. this.completedLoad = true;
  399. this.getPharmacyList(this.completedIdx, type, this.completedSearchKey);
  400. break;
  401. }
  402. }
  403. // 搜索关键词
  404. searchKeyHandle(type) {
  405. switch (type) {
  406. case 'delegation':
  407. this.printPharmacyIdx = 0; //页码重置
  408. this.printPharmacyList = []; //列表重置
  409. this.getPharmacyList(
  410. this.printPharmacyIdx,
  411. type,
  412. this.printPharmacySearchKey
  413. );
  414. break;
  415. case 'take':
  416. this.waitPharmacyIdx = 0; //页码重置
  417. this.waitPharmacyList = []; //列表重置
  418. this.getPharmacyList(
  419. this.waitPharmacyIdx,
  420. type,
  421. this.waitPharmacySearchKey
  422. );
  423. break;
  424. case 'trans':
  425. this.pharmacyIdx = 0; //页码重置
  426. this.pharmacyList = []; //列表重置
  427. this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
  428. break;
  429. case 'trans_send':
  430. this.distributionIdx = 0; //页码重置
  431. this.distributionList = []; //列表重置
  432. this.getPharmacyList(
  433. this.distributionIdx,
  434. type,
  435. this.distributionSearchKey
  436. );
  437. break;
  438. case 'error':
  439. this.completedIdx = 0; //页码重置
  440. this.completedList = []; //列表重置
  441. this.getPharmacyList(this.completedIdx, type, this.completedSearchKey);
  442. break;
  443. }
  444. }
  445. // 退出
  446. logOut(): void {
  447. // 假退出
  448. localStorage.removeItem("user");
  449. localStorage.removeItem("menu");
  450. localStorage.removeItem("phones");
  451. localStorage.removeItem("index");
  452. this.router.navigateByUrl("login");
  453. // 假退出
  454. this.mainService.logOut().subscribe((data) => {
  455. if (data.status == 200) {
  456. localStorage.removeItem("user");
  457. localStorage.removeItem("menu");
  458. localStorage.removeItem("phones");
  459. localStorage.removeItem("index");
  460. this.router.navigateByUrl("login");
  461. }
  462. });
  463. }
  464. // 右侧菜单
  465. showLastItems: boolean = false;
  466. // 下拉
  467. fixedMenuXiala() {
  468. this.showLastItems = true;
  469. }
  470. // 上拉
  471. fixedMenuShangla() {
  472. this.showLastItems = false;
  473. }
  474. mainRole: boolean = false; //回到系统管理权限
  475. initRole() {
  476. let menus = JSON.parse(localStorage.getItem("menu"));
  477. console.log("菜单数量" + menus.length);
  478. if (menus.length >= 2) {
  479. this.mainRole = true;
  480. return;
  481. }
  482. }
  483. // 切换右侧菜单Tab
  484. fixedTab: string = "";
  485. checkFixedTab(type: string) {
  486. if (type == "toSystem") {
  487. this.router.navigateByUrl("main");
  488. }
  489. if (this.fixedTab == type) {
  490. this.fixedTab = "";
  491. } else {
  492. this.fixedTab = type;
  493. }
  494. }
  495. //药房端科室切换
  496. changeShow = true;
  497. closeTime = 3;
  498. closeTimeFlag = 0;
  499. hsPromptModalShow: boolean = true; //科室切换提示框是否展示
  500. timerCloseTime = null;
  501. deptDisplay = 1; //护士端是否显示可以别名,1是显示科室名称,2是显示科室别名
  502. //子传父接收
  503. closeModelHs(e) {
  504. this.hsPromptModalShow = JSON.parse(e).show;
  505. this.changeShow = JSON.parse(e).changeShow;
  506. }
  507. //子传父接收
  508. clearModelHs(e) {
  509. if (JSON.parse(e).clear === true) {
  510. clearInterval(this.timerCloseTime);
  511. }
  512. this.changeShow = JSON.parse(e).changeShow;
  513. }
  514. // 头部切换科室
  515. changeKsNow() {
  516. this.hsPromptModalShow = true;
  517. clearInterval(this.timerCloseTime);
  518. this.changeShow = false;
  519. }
  520. // 切换科室
  521. changeKs() {
  522. this.hsPromptModalShow = true;
  523. // (1) 当用户设置为正数时,用户必须查看此窗体指定秒数。
  524. // (2) 当用户设置为负数时,用户可点击知道了也可倒计时自动关闭。
  525. // (3) 如果用户填写0则为无自动关闭和强制查看时间。
  526. if (this.closeTimeFlag === 0) {
  527. return;
  528. }
  529. this.closeTime = Math.abs(this.closeTimeFlag);
  530. clearInterval(this.timerCloseTime);
  531. this.timerCloseTime = setInterval(() => {
  532. this.closeTime = Math.max(--this.closeTime, 0);
  533. if (this.closeTime === 0) {
  534. if (this.closeTimeFlag <= 0) {
  535. this.hsPromptModalShow = false;
  536. }
  537. clearInterval(this.timerCloseTime);
  538. }
  539. }, 1000);
  540. }
  541. }