123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- import { Component, OnInit, ViewChild, OnDestroy } from "@angular/core";
- import { MainService } from "../../services/main.service";
- import { Router } from "@angular/router";
- import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
- import { startOfDay, format, endOfDay } from "date-fns";
- import { ToolService } from 'src/app/services/tool.service';
- @Component({
- selector: "app-specimen-view2",
- templateUrl: "./specimen-view2.component.html",
- styleUrls: ["./specimen-view2.component.less"],
- })
- export class SpecimenView2Component implements OnInit, OnDestroy {
- @ViewChild("osComponentRef1", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef1: OverlayScrollbarsComponent;
- @ViewChild("osComponentRef2", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef2: OverlayScrollbarsComponent;
- @ViewChild("osComponentRef3", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef3: OverlayScrollbarsComponent;
- @ViewChild("osComponentRef4", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef4: OverlayScrollbarsComponent;
- @ViewChild("osComponentRef5", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef5: OverlayScrollbarsComponent;
- constructor(private mainService: MainService, public router: Router, public tool: ToolService) {}
-
- todayTotal: undefined;
-
- todayComplete: undefined;
-
-
- printPharmacyList = [];
- printPharmacyIdx = 0;
- printPharmacyTotal = 0;
- printPharmacyFlag = false;
- printPharmacySearchKey = "";
- printPharmacyLoad = false;
-
- waitPharmacyList = [];
- waitPharmacyIdx = 0;
- waitPharmacyTotal = 0;
- waitPharmacyFlag = false;
- waitPharmacySearchKey = "";
- waitPharmacyLoad = false;
-
- pharmacyList = [];
- pharmacyIdx = 0;
- pharmacyTotal = 0;
- pharmacyFlag = false;
- pharmacySearchKey = "";
- pharmacyLoad = false;
-
- distributionList = [];
- distributionIdx = 0;
- distributionTotal = 0;
- distributionFlag = false;
- distributionSearchKey = "";
- distributionLoad = false;
-
- completedList = [];
- completedIdx = 0;
- completedTotal = 0;
- completedFlag = false;
- completedSearchKey = "";
- completedLoad = false;
-
- loginUser: any = localStorage.getItem("user")
- ? JSON.parse(localStorage.getItem("user")).user
- : null;
- logTimer = null;
- logTime = 0;
- logTimeConst = 60;
- time = new Date().getTime();
- timer = null;
- ngOnDestroy() {
- clearTimeout(this.timer);
- clearTimeout(this.logTimer);
- }
- ngOnInit() {
- this.runTime();
-
- this.total();
-
- this.changeKs();
-
- this.getPharmacyList(this.printPharmacyIdx, 'delegation', this.printPharmacySearchKey);
-
- this.getPharmacyList(this.waitPharmacyIdx, 'take', this.waitPharmacySearchKey);
-
- this.getPharmacyList(this.pharmacyIdx, 'trans', this.pharmacySearchKey);
-
- this.getPharmacyList(this.distributionIdx, 'trans_send', this.distributionSearchKey);
-
- this.getPharmacyList(this.completedIdx, 'error', this.completedSearchKey);
- this.initRole();
-
- this.autoUpdate();
-
- }
-
- runTime() {
- clearTimeout(this.timer);
- this.timer = setTimeout(() => {
- this.time = Date.now();
- this.runTime();
- }, 500);
- }
-
- total() {
- let launch = JSON.parse(localStorage.getItem("user")).user.dept.id;
- let startTime = format(startOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
- let endTime = format(endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
- let postData = {
- startTime,
- endTime,
- launch,
- };
- this.mainService.getDrugsBagStateCount(postData).subscribe((res: any) => {
- if (res.status == 200) {
- this.todayTotal = res.countMap.todayTotal;
- this.todayComplete = res.countMap.todayComplete;
- }
- });
- }
-
- goToOrderDetail(item){
- console.log(item);
- this.router.navigateByUrl(`specimenView2/detailSample/${item.id}`);
- }
-
- logPromptModalShow = false;
- scode = "";
- showLogs(data) {
- clearInterval(this.logTimer);
- this.scode = data.scode;
- this.logPromptModalShow = true;
- }
-
- closeModelLog(e) {
- this.logPromptModalShow = JSON.parse(e).show;
- this.autoUpdate(false);
- }
-
- spePromptModalShow = false;
- checkDeptId = "";
- printDate = "";
- showSpeList(data) {
- clearInterval(this.logTimer);
- this.checkDeptId = data.check_dept_id;
- this.printDate = data.startTime;
- this.spePromptModalShow = true;
- }
-
- closeModelSpe(e) {
- this.spePromptModalShow = JSON.parse(e).show;
- this.autoUpdate(false);
- }
-
- orderPromptModalShow = false;
- workId = "";
- showOrderList(data) {
- clearInterval(this.logTimer);
- this.workId = data.workerid;
- this.orderPromptModalShow = true;
- }
-
- closeModelOrder(e) {
- this.orderPromptModalShow = JSON.parse(e).show;
- this.autoUpdate(false);
- }
-
- autoUpdate(flag = true) {
- if (flag) {
- this.logTime = this.logTimeConst;
- }
- clearInterval(this.logTimer);
- this.logTimer = setInterval(() => {
- this.logTime--;
- if (this.logTime === 0) {
- this.logTime = this.logTimeConst;
-
- this.getPharmacyList(0, 'delegation', this.printPharmacySearchKey);
-
- this.getPharmacyList(0, 'take', this.waitPharmacySearchKey);
-
- this.getPharmacyList(0, 'trans', this.pharmacySearchKey);
-
- this.getPharmacyList(0, 'trans_send', this.distributionSearchKey);
-
- this.getPharmacyList(0, 'error', this.completedSearchKey);
- }
- }, 1000);
- }
-
-
-
- loading1 = false;
- loading2 = false;
- loading3 = false;
- loading4 = false;
- loading5 = false;
- getPharmacyList(idx, type, searchKey) {
- let hosId = JSON.parse(localStorage.getItem("user")).user.currentHospital.id;
- switch (type) {
- case 'delegation':
- this.loading1 = true;
- break;
- case 'take':
- this.loading2 = true;
- break;
- case 'trans':
- this.loading3 = true;
- break;
- case 'trans_send':
- this.loading4 = true;
- break;
- case 'error':
- this.loading5 = true;
- break;
- }
- let postData = {
- viewType: type,
- keyWord: searchKey,
- hosId,
- };
- this.mainService
- .specimenView2(postData)
- .subscribe((result) => {
- switch (type) {
- case 'delegation':
- this.loading1 = false;
- break;
- case 'take':
- this.loading2 = false;
- break;
- case 'trans':
- this.loading3 = false;
- break;
- case 'trans_send':
- this.loading4 = false;
- break;
- case 'error':
- this.loading5 = false;
- break;
- }
- if (result["state"] == 200) {
- switch (type) {
- case 'delegation':
-
- this.printPharmacyTotal = result.totalNum;
-
- this.printPharmacyLoad = false;
-
- if (result["data"].length < 10) {
- this.printPharmacyFlag = false;
- } else if (result["data"].length === 0 && idx === 0) {
- this.printPharmacyFlag = false;
- } else {
- this.printPharmacyFlag = true;
- }
-
- if (idx === 0) {
- this.printPharmacyList = result["data"];
- } else {
- this.printPharmacyList = [
- ...this.printPharmacyList,
- ...result["data"],
- ];
- }
- break;
- case 'take':
- this.waitPharmacyTotal = result.totalNum;
- this.waitPharmacyLoad = false;
- if (result["data"].length < 10) {
- this.waitPharmacyFlag = false;
- } else if (result["data"].length === 0 && idx === 0) {
- this.waitPharmacyFlag = false;
- } else {
- this.waitPharmacyFlag = true;
- }
- if (idx === 0) {
- this.waitPharmacyList = result["data"];
- } else {
- this.waitPharmacyList = [
- ...this.waitPharmacyList,
- ...result["data"],
- ];
- }
- break;
- case 'trans':
- this.pharmacyTotal = result.totalNum;
- this.pharmacyLoad = false;
- if (result["data"].length < 10) {
- this.pharmacyFlag = false;
- } else if (result["data"].length === 0 && idx === 0) {
- this.pharmacyFlag = false;
- } else {
- this.pharmacyFlag = true;
- }
- if (idx === 0) {
- this.pharmacyList = result["data"];
- } else {
- this.pharmacyList = [...this.pharmacyList, ...result["data"]];
- }
- break;
- case 'trans_send':
- this.distributionTotal = result.totalNum;
- this.distributionLoad = false;
- if (result["data"].length < 10) {
- this.distributionFlag = false;
- } else if (result["data"].length === 0 && idx === 0) {
- this.distributionFlag = false;
- } else {
- this.distributionFlag = true;
- }
-
- result["data"].forEach(v=>{
- v.deptList = v.deptList?v.deptList.join(','):'';
- })
- if (idx === 0) {
- this.distributionList = result["data"];
- } else {
- this.distributionList = [
- ...this.distributionList,
- ...result["data"],
- ];
- }
- break;
- case 'error':
- this.completedTotal = result.totalNum;
- this.completedLoad = false;
- if (result["data"].length < 10) {
- this.completedFlag = false;
- } else if (result["data"].length === 0 && idx === 0) {
- this.completedFlag = false;
- } else {
- this.completedFlag = true;
- }
- if (idx === 0) {
- this.completedList = result["data"];
- } else {
- this.completedList = [...this.completedList, ...result["data"]];
- }
- break;
- }
- }
- });
- }
-
- loadMore(type) {
- switch (type) {
- case 'delegation':
- this.printPharmacyIdx++;
- this.printPharmacyLoad = true;
- this.getPharmacyList(
- this.printPharmacyIdx,
- type,
- this.printPharmacySearchKey
- );
- break;
- case 'take':
- this.waitPharmacyIdx++;
- this.waitPharmacyLoad = true;
- this.getPharmacyList(
- this.waitPharmacyIdx,
- type,
- this.waitPharmacySearchKey
- );
- break;
- case 'trans':
- this.pharmacyIdx++;
- this.pharmacyLoad = true;
- this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
- break;
- case 'trans_send':
- this.distributionIdx++;
- this.distributionLoad = true;
- this.getPharmacyList(
- this.distributionIdx,
- type,
- this.distributionSearchKey
- );
- break;
- case 'error':
- this.completedIdx++;
- this.completedLoad = true;
- this.getPharmacyList(this.completedIdx, type, this.completedSearchKey);
- break;
- }
- }
-
- searchKeyHandle(type) {
- switch (type) {
- case 'delegation':
- this.printPharmacyIdx = 0;
- this.printPharmacyList = [];
- this.getPharmacyList(
- this.printPharmacyIdx,
- type,
- this.printPharmacySearchKey
- );
- break;
- case 'take':
- this.waitPharmacyIdx = 0;
- this.waitPharmacyList = [];
- this.getPharmacyList(
- this.waitPharmacyIdx,
- type,
- this.waitPharmacySearchKey
- );
- break;
- case 'trans':
- this.pharmacyIdx = 0;
- this.pharmacyList = [];
- this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
- break;
- case 'trans_send':
- this.distributionIdx = 0;
- this.distributionList = [];
- this.getPharmacyList(
- this.distributionIdx,
- type,
- this.distributionSearchKey
- );
- break;
- case 'error':
- this.completedIdx = 0;
- this.completedList = [];
- this.getPharmacyList(this.completedIdx, type, this.completedSearchKey);
- break;
- }
- }
-
- logOut(): void {
-
- let hospital = this.tool.getCurrentHospital();
- if(hospital){
- this.router.navigate(["login", hospital.id]);
- }else{
- this.router.navigateByUrl("login");
- }
- localStorage.removeItem("user");
- localStorage.removeItem("menu");
- localStorage.removeItem("index");
-
- this.mainService.logOut().subscribe((data) => {
- if (data.status == 200) {
- if(hospital){
- this.router.navigate(["login", hospital.id]);
- }else{
- this.router.navigateByUrl("login");
- }
- localStorage.removeItem("user");
- localStorage.removeItem("menu");
- localStorage.removeItem("index");
- }
- });
- }
-
- showLastItems: boolean = false;
-
- fixedMenuXiala() {
- this.showLastItems = true;
- }
-
- fixedMenuShangla() {
- this.showLastItems = false;
- }
- mainRole: boolean = false;
- initRole() {
- let menus = JSON.parse(localStorage.getItem("menu"));
- console.log("菜单数量" + menus.length);
- if (menus.length >= 2) {
- this.mainRole = true;
- return;
- }
- }
-
- fixedTab: string = "";
- checkFixedTab(type: string) {
- if (type == "toSystem") {
- this.router.navigateByUrl("main");
- }
- if (this.fixedTab == type) {
- this.fixedTab = "";
- } else {
- this.fixedTab = type;
- }
- }
-
- changeShow = true;
- closeTime = 3;
- closeTimeFlag = 0;
- hsPromptModalShow: boolean = true;
- timerCloseTime = null;
- deptDisplay = 1;
-
- closeModelHs(e) {
- this.hsPromptModalShow = JSON.parse(e).show;
- this.changeShow = JSON.parse(e).changeShow;
- }
-
- clearModelHs(e) {
- if (JSON.parse(e).clear === true) {
- clearInterval(this.timerCloseTime);
- }
- this.changeShow = JSON.parse(e).changeShow;
- }
-
- changeKsNow() {
- this.hsPromptModalShow = true;
- clearInterval(this.timerCloseTime);
- this.changeShow = false;
- }
-
- changeKs() {
- this.hsPromptModalShow = true;
-
-
-
- if (this.closeTimeFlag === 0) {
- return;
- }
- this.closeTime = Math.abs(this.closeTimeFlag);
- clearInterval(this.timerCloseTime);
- this.timerCloseTime = setInterval(() => {
- this.closeTime = Math.max(--this.closeTime, 0);
- if (this.closeTime === 0) {
- if (this.closeTimeFlag <= 0) {
- this.hsPromptModalShow = false;
- }
- clearInterval(this.timerCloseTime);
- }
- }, 1000);
- }
- }
|