main.component.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core";
  2. import { NavigationEnd, Router } from "@angular/router";
  3. import { MainService } from "../../services/main.service";
  4. import { NzMessageService } from "ng-zorro-antd/message";
  5. import { WebsocketMainService } from "../../services/websocket-main.service";
  6. import http from "../../../assets/js/http";
  7. import { NzNotificationService } from "ng-zorro-antd/notification";
  8. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  9. import { ToolService } from "../../services/tool.service";
  10. import { filter } from "rxjs/operators";
  11. @Component({
  12. selector: "app-main",
  13. templateUrl: "./main.component.html",
  14. styleUrls: ["./main.component.less"],
  15. })
  16. export class MainComponent implements OnInit {
  17. userInfo: any = JSON.parse(localStorage.getItem("user"));
  18. menus: any = JSON.parse(localStorage.getItem("menu"));
  19. currentHospital; //当前院区
  20. routerEventsListener; //监听路由
  21. deskRole: boolean = false; //调度台权限
  22. nurseRole: boolean = false; //护士端权限
  23. pharmacyRole: boolean = false; //药房端权限
  24. largeScreenRole: boolean = false; //大屏端权限
  25. largeScreenRole2: boolean = false; //大屏端权限
  26. specimenViewRole: boolean = false; //业务视图权限
  27. specimenViewRole2: boolean = false; //标本视图权限
  28. specimenRoomView: boolean = false; //标本间权限
  29. pathology: boolean = false; //病理科权限
  30. sampling: boolean = false; //门诊病理采样端权限
  31. communicationBook: boolean = false; //病理交接本权限
  32. disinfectionSupplyRole: boolean = false; //全局业务查看权限
  33. realtimeBroadcastRole: boolean = false; //全局业务查看权限
  34. incidentConfigRole: boolean = false; //事件配置权限
  35. otherConfigRole: boolean = false; //三方配置权限
  36. pageConfigRole: boolean = false; //业务页面控制权限
  37. nurseConfigRole: boolean = false; //护士端配置控制权限
  38. PCCommutesToWork: boolean = false; //PC上下班权限
  39. newStatisticsRole: boolean = false; //新版统计权限
  40. @ViewChild("osComponentRef1", {
  41. read: OverlayScrollbarsComponent,
  42. static: false,
  43. })
  44. osComponentRef1: OverlayScrollbarsComponent;
  45. constructor(
  46. public router: Router,
  47. private mainService: MainService,
  48. private msg: NzMessageService,
  49. private notification: NzNotificationService,
  50. private webs: WebsocketMainService,
  51. public tool: ToolService
  52. ) {}
  53. ngOnInit() {
  54. this.highlightMenuByUrl();
  55. this.routerEventsListener = this.router.events
  56. .pipe(filter((event) => event instanceof NavigationEnd))
  57. .subscribe((event) => {
  58. this.highlightMenuByUrl();
  59. });
  60. this.currentHospital = this.tool.getCurrentHospital();
  61. this.initLogin();
  62. this.initMenu();
  63. this.getWebsocket();
  64. }
  65. // 离开管理端
  66. ngOnDestroy() {
  67. //取消路由监听
  68. this.routerEventsListener.unsubscribe();
  69. // 断掉连接
  70. this.webs.closeWs(true);
  71. }
  72. // 菜单图标名称是否包含transport-
  73. isTransportIcon(icon:any) {
  74. if(icon){
  75. return icon.indexOf("transport-") > -1;
  76. }else{
  77. return false;
  78. }
  79. }
  80. //上下班
  81. loading3 = false;
  82. workModal: boolean = false; //模态框
  83. showWorkModal() {
  84. this.workModal = true;
  85. }
  86. hideWorkModal() {
  87. this.workModal = false;
  88. }
  89. confirmWork() {
  90. this.loading3 = true;
  91. if (this.userInfo.user.online) {
  92. // 判断当前启用的工作方案是自主还是综合排班
  93. this.getUserWorkDept().then((ress:any) => {
  94. if (ress.status == 200) {
  95. let workType = ress.settings ? ress.settings.workType : -1; //1是综合,2是自主
  96. // 自主下班,并且是科室绑定人员,科室绑定分组,绑定分组
  97. if (workType == 2) {
  98. this.loading3 = false;
  99. this.msg.info('不支持此上班模式!');
  100. } else {
  101. this.mainService.onOrOffLine({
  102. type: "off",
  103. }).subscribe((res:any) => {
  104. if (res.status == 200) {
  105. this.getCurrentUserNow();
  106. } else {
  107. this.loading3 = false;
  108. this.msg.error('操作失败');
  109. }
  110. });
  111. }
  112. } else if (ress.status == 500) {
  113. //500的时候自选下班
  114. this.customOff();
  115. } else {
  116. this.loading3 = false;
  117. this.msg.error('操作失败');
  118. }
  119. });
  120. } else {
  121. this.getWorkScheme();
  122. }
  123. }
  124. // 获取启动中的工作分配方案
  125. workSchemeType:any = ""; //启动中工作分配方案类型
  126. getWorkScheme() {
  127. let postData = {
  128. idx: 0,
  129. workScheme: {
  130. status: 1,
  131. hosId: this.currentHospital.id
  132. },
  133. sum: 1,
  134. };
  135. this.mainService.getFetchDataList("simple/data", "workScheme", postData).subscribe((res) => {
  136. if (res.status == 200) {
  137. if(Array.isArray(res.list) && res.list.length){
  138. this.workSchemeType = res.list[0].workType;
  139. if (this.workSchemeType == 2) {
  140. this.loading3 = false;
  141. this.msg.info('不支持此上班模式!');
  142. } else if (this.workSchemeType == 1) {
  143. this.mainService.onOrOffLine({
  144. type: "on",
  145. }).subscribe((res:any) => {
  146. if (res.status == 200) {
  147. this.getCurrentUserNow();
  148. } else {
  149. this.loading3 = false;
  150. this.msg.error('操作失败');
  151. }
  152. });
  153. }
  154. }
  155. } else {
  156. this.loading3 = false;
  157. this.msg.error('操作失败');
  158. }
  159. });
  160. }
  161. // 下班
  162. customOff() {
  163. this.mainService.onOrOffLine({
  164. type: "off",
  165. customWorking: "off",
  166. }).subscribe((res:any) => {
  167. if (res.status == 200) {
  168. this.getCurrentUserNow();
  169. } else {
  170. this.loading3 = false;
  171. this.msg.error('操作失败');
  172. }
  173. });
  174. }
  175. // 获取执行中列表
  176. getWorkingNum() {
  177. return this.mainService.coopWorkerOrder("executingOrders", {
  178. idx: 0,
  179. sum: 1,
  180. }).toPromise();
  181. }
  182. // 获取启动中的工作分配方案
  183. getUserWorkDept() {
  184. return this.mainService.getUserWorkDept({}).toPromise();
  185. }
  186. // 获取当前用户信息
  187. getCurrentUserNow() {
  188. this.mainService.getCurrentUser1().subscribe((data:any) => {
  189. this.loading3 = false;
  190. if (data.status == 200) {
  191. let user = JSON.parse(localStorage.getItem("user"));
  192. user.user = data.data;
  193. this.userInfo.user = data.data;
  194. localStorage.setItem("user", JSON.stringify(user));
  195. this.hideWorkModal();
  196. this.msg.success('操作成功!');
  197. }
  198. });
  199. }
  200. // 上下班
  201. types = "";
  202. async GoWork() {
  203. let workingNum = 0;
  204. if (this.userInfo.user.online) {
  205. this.maskFlag = this.msg.loading("正在加载中..", {
  206. nzDuration: 0,
  207. }).messageId;
  208. let workingNumResult = await this.getWorkingNum();
  209. this.msg.remove(this.maskFlag);
  210. this.maskFlag = false;
  211. if (workingNumResult.status == 200) {
  212. workingNum = workingNumResult.data.data.length;
  213. }
  214. if (workingNum) {
  215. this.types = "您还<b style='color:red'>有未完成的工单</b>,确定下班后,<b style='color:red'>未完成工单将不计算积分。</b>";
  216. } else {
  217. this.types = "确定是否下班 ?";
  218. }
  219. } else {
  220. this.types = "确定是否上班 ?";
  221. }
  222. this.showWorkModal();
  223. }
  224. // 根据url高亮菜单baba
  225. highlightMenuByUrl() {
  226. console.log(this.router.url);
  227. let navOne, navTwo;
  228. let link = this.router.url.split("/").slice(-1)[0];
  229. let menus = JSON.parse(localStorage.getItem("menu"));
  230. if (link == "home") {
  231. this.toMenu("首页");
  232. } else {
  233. menus.forEach((oneNav) => {
  234. if (oneNav.childrens) {
  235. let findTwoNav = oneNav.childrens.find(
  236. (twoNav) => twoNav.link == link
  237. );
  238. if (findTwoNav) {
  239. navTwo = findTwoNav;
  240. navOne = oneNav;
  241. this.toMenu(navTwo.title, navTwo, navOne);
  242. }
  243. }
  244. });
  245. }
  246. }
  247. // 一级导航点击
  248. clickMenuOne(data) {
  249. let menus = JSON.parse(localStorage.getItem("menu"));
  250. data.flag = !data.flag;
  251. menus.find((item) => item.id == data.id).flag = data.flag;
  252. localStorage.setItem("menu", JSON.stringify(menus));
  253. }
  254. initMenu() {
  255. let menus = JSON.parse(localStorage.getItem("menu"));
  256. let arr = [];
  257. menus.forEach((e) => {
  258. if (e.link == "nurse") {
  259. this.nurseRole = true;
  260. console.log("护士端权限");
  261. }
  262. if (e.link == "dispatchingDesk") {
  263. this.deskRole = true;
  264. console.log("调度台权限");
  265. }
  266. if (e.link == "pharmacy") {
  267. this.pharmacyRole = true;
  268. console.log("药房端权限");
  269. }
  270. if (e.link == "largeScreen") {
  271. this.largeScreenRole = true;
  272. console.log("大屏端权限");
  273. }
  274. if (e.link == "largeScreen2") {
  275. this.largeScreenRole2 = true;
  276. console.log("大屏端2权限");
  277. }
  278. if (e.link == "specimenView") {
  279. this.specimenViewRole = true;
  280. console.log("业务视图权限");
  281. }
  282. if (e.link == "specimenView2") {
  283. this.specimenViewRole2 = true;
  284. console.log("标本视图权限");
  285. }
  286. if (e.link == "specimenRoomView") {
  287. this.specimenRoomView = true;
  288. console.log("标本间权限");
  289. }
  290. if (e.link == "pathology") {
  291. this.pathology = true;
  292. console.log("病理科权限");
  293. }
  294. if (e.link == "pathologySample") {
  295. this.sampling = true;
  296. console.log("门诊病理采样端权限");
  297. }
  298. if (e.link == "pathologyCommunicationBook") {
  299. this.communicationBook = true;
  300. console.log("病理交接本权限");
  301. }
  302. if (e.link == "disinfectionSupply") {
  303. this.disinfectionSupplyRole = true;
  304. console.log("全局业务查看权限");
  305. }
  306. if (e.link == "realtimeBroadcast") {
  307. this.realtimeBroadcastRole = true;
  308. console.log("故障实时播报权限");
  309. }
  310. if (e.link == "incidentConfig") {
  311. this.incidentConfigRole = true;
  312. console.log("事件配置权限");
  313. }
  314. if (e.link == "otherConfig") {
  315. this.otherConfigRole = true;
  316. console.log("三方配置权限");
  317. }
  318. if (e.link == "pageConfig") {
  319. this.pageConfigRole = true;
  320. console.log("业务页面控制权限");
  321. }
  322. if (e.link == "nurseConfig") {
  323. this.nurseConfigRole = true;
  324. console.log("护士端配置控制权限");
  325. }
  326. if (e.link == "PCCommutesToWork") {
  327. this.PCCommutesToWork = true;
  328. console.log("PC上下班");
  329. }
  330. if (e.type == "newStatistics") {
  331. this.newStatisticsRole = true;
  332. console.log("新版统计");
  333. }
  334. if (!e.link) {
  335. arr.push(e);
  336. }
  337. });
  338. this.menus = arr.filter(v => v.type === 'default');
  339. }
  340. // 判断登录是否已失效
  341. initLogin() {
  342. if (!this.userInfo) {
  343. this.msg.error("您的登录已失效,请重新登录!", {
  344. nzDuration: 3000,
  345. });
  346. setTimeout(() => {
  347. this.router.navigateByUrl("login");
  348. }, 2000);
  349. return;
  350. }
  351. }
  352. // 新密码失去焦点
  353. enoughRegFlag = true; //弱
  354. mediumRegFlag = false; //中
  355. strongRegFlag = false; //强
  356. blurNewPwd(){
  357. let enoughReg = /^.{0,6}$/;//密码强度-弱
  358. let strongReg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\!\@\#\$\%\^\&\*]).{9,}$/;//密码强度-强
  359. this.enoughRegFlag = enoughReg.test(this.upModalData.newPwd);
  360. this.strongRegFlag = strongReg.test(this.upModalData.newPwd);
  361. this.mediumRegFlag = !this.enoughRegFlag && !this.strongRegFlag;
  362. console.log(this.enoughRegFlag,this.mediumRegFlag,this.strongRegFlag);
  363. }
  364. // 跳转页面
  365. menuLabel: string; //当前菜单名称
  366. indexFlag = localStorage.getItem("index") === "true" ? true : false; //首页高亮
  367. toMenu(title, item?, data?) {
  368. sessionStorage.setItem("title", title);
  369. this.menuLabel = sessionStorage.getItem("title");
  370. if (item && data) {
  371. // 首页取消高亮
  372. this.indexFlag = false;
  373. localStorage.setItem("index", "false");
  374. // 操作本地存储
  375. let menus = JSON.parse(localStorage.getItem("menu"));
  376. menus.forEach((item1) => {
  377. item1.flagBg = false;
  378. if (item1.childrens) {
  379. item1.childrens.forEach((value) => {
  380. value.flag = false;
  381. });
  382. }
  383. });
  384. let obj = menus.find((value) => value.id == data.id);
  385. obj.flagBg = true;
  386. obj.flag = true;
  387. obj.childrens.find((value) => value.id == item.id).flag = true;
  388. localStorage.setItem("menu", JSON.stringify(menus));
  389. // 操作菜单一级 二级
  390. this.menus = menus.filter((item) => !item.link);
  391. } else {
  392. // 首页高亮
  393. this.indexFlag = true;
  394. localStorage.setItem("index", "true");
  395. // 操作本地存储
  396. let menus = JSON.parse(localStorage.getItem("menu"));
  397. menus.forEach((item1) => {
  398. item1.flagBg = false;
  399. // item1.flag = false;
  400. if (item1.childrens) {
  401. item1.childrens.forEach((value) => {
  402. value.flag = false;
  403. });
  404. }
  405. });
  406. localStorage.setItem("menu", JSON.stringify(menus));
  407. // 操作菜单一级 二级
  408. this.menus = menus.filter((item) => !item.link);
  409. }
  410. }
  411. // 子路由跳转事件
  412. activeRoute() {
  413. this.menuLabel = sessionStorage.getItem("title");
  414. }
  415. // 调度台
  416. toFuwutai(): void {
  417. this.router.navigateByUrl("dispatchingDesk");
  418. }
  419. // 护士建单
  420. toHuShi(): void {
  421. this.router.navigateByUrl("nurse");
  422. }
  423. // 药房端
  424. toPharmacy(): void {
  425. this.router.navigateByUrl("pharmacy");
  426. }
  427. // 药房端2
  428. toPharmacy2(): void {
  429. this.router.navigateByUrl("pharmacy2");
  430. }
  431. // 标本视图
  432. toSpecimenView2(): void {
  433. this.router.navigateByUrl("specimenView2");
  434. }
  435. // 标本间
  436. toSpecimenRoomView(): void {
  437. this.router.navigateByUrl("specimenRoomView");
  438. }
  439. // 病理科
  440. toPathology(): void {
  441. this.router.navigateByUrl("pathology");
  442. }
  443. // 门诊病理采样端
  444. toSampling(): void {
  445. this.router.navigateByUrl("pathologySample");
  446. }
  447. // 病理交接本
  448. toCommunicationBook(): void {
  449. this.router.navigateByUrl("pathologyCommunicationBook");
  450. }
  451. // 全局业务查看
  452. toDisinfectionSupply(): void {
  453. this.router.navigateByUrl("disinfectionSupply");
  454. }
  455. // 故障实时播报
  456. toRealtimeBroadcast(): void {
  457. this.router.navigateByUrl("realtimeBroadcast");
  458. }
  459. // 配置中心
  460. toConfigurationCenter(): void {
  461. this.iShowMenuModal = true;
  462. // this.router.navigateByUrl("configurationCenter");
  463. }
  464. // 统计
  465. toNewStatistics(): void {
  466. let menus = JSON.parse(localStorage.getItem("menu"));
  467. let firstMenu = menus.find((item) => item.type == "newStatistics");
  468. this.router.navigateByUrl(`newStatistics/${firstMenu.link}/${firstMenu.childrens[0].link}`);
  469. }
  470. // 大屏端或视图端
  471. screenType;
  472. hosFlag = false;
  473. toBigScreen(type): void {
  474. this.screenType = type;
  475. this.submitFormHand(this.currentHospital.id);
  476. }
  477. submitFormHand(id) {
  478. if (this.screenType === "largeScreen") {
  479. window.open(http.bigScreenHost + "/#/" + id);
  480. } else if (this.screenType === "largeScreen2") {
  481. window.open(http.bigScreenHost2 + "/#/" + id);
  482. } else if (this.screenType === "specimenView") {
  483. window.open(http.specimenViewHost + "/#/" + id);
  484. }
  485. }
  486. //获取系统设置中的科室类型
  487. getTypeByDept(id) {
  488. let postData = {
  489. idx: 0,
  490. sum: 1,
  491. systemConfiguration: { keyconfig: "busiViewDeptId" },
  492. };
  493. this.maskFlag = this.msg.loading("正在加载中..", {
  494. nzDuration: 0,
  495. }).messageId;
  496. this.mainService
  497. .getFetchDataList("simple/data", "systemConfiguration", postData)
  498. .subscribe((result) => {
  499. this.msg.remove(this.maskFlag);
  500. this.maskFlag = false;
  501. if (result.status == 200) {
  502. let remember = JSON.parse(localStorage.getItem("remember"));
  503. window.open(
  504. http.specimenViewHost +
  505. "/#/" +
  506. id +
  507. "/" +
  508. encodeURIComponent(remember.username) +
  509. "/" +
  510. encodeURIComponent(remember.password) +
  511. "/" +
  512. result.list[0].valueconfig
  513. );
  514. }
  515. });
  516. }
  517. hosFlagHand(flag) {
  518. if (!flag) {
  519. this.hosFlag = false;
  520. }
  521. }
  522. // 选择菜单-知道了
  523. iShowMenuModal:boolean = false;
  524. cancelMenuModal(flag) {
  525. this.iShowMenuModal = false;
  526. }
  527. // 下拉
  528. showDropdown:boolean = false;
  529. showDropdown1:boolean = false;
  530. // 选择院区
  531. selectHospital(){
  532. this.hosFlag1 = true
  533. }
  534. // 退出
  535. logOut(): void {
  536. // 假退出
  537. let hospital = this.tool.getCurrentHospital();
  538. if(hospital){
  539. this.router.navigate(["login", hospital.id]);
  540. }else{
  541. this.router.navigateByUrl("login");
  542. }
  543. localStorage.removeItem("user");
  544. localStorage.removeItem("menu");
  545. localStorage.removeItem("index");
  546. // 假退出
  547. this.mainService.logOut().subscribe((data) => {
  548. if (data.status == 200) {
  549. if(hospital){
  550. this.router.navigate(["login", hospital.id]);
  551. }else{
  552. this.router.navigateByUrl("login");
  553. }
  554. localStorage.removeItem("user");
  555. localStorage.removeItem("menu");
  556. localStorage.removeItem("index");
  557. }
  558. });
  559. }
  560. // 连接websocket
  561. getWebsocket() {
  562. this.webs
  563. .connectWs(http.mainWs, { userCount: this.userInfo.user.account })
  564. .subscribe((data) => {
  565. console.log(data);
  566. if (data && data.content) {
  567. this.createBasicNotification(data);
  568. }
  569. });
  570. }
  571. @ViewChild("msgTemplate1", { static: false }) msgTemplate1: TemplateRef<any>; //消息通知模板
  572. // 消息提醒
  573. createBasicNotification(msgs): void {
  574. this.notification.template(this.msgTemplate1, {
  575. nzDuration: 0,
  576. nzData: msgs,
  577. });
  578. }
  579. //打开修改密码弹窗
  580. pwdAfterOpen(){
  581. this.passwordVisible = false;
  582. this.pwdIsOkLoading = false;
  583. this.enoughRegFlag = true; //弱
  584. this.mediumRegFlag = false; //中
  585. this.strongRegFlag = false; //强
  586. this.upModalData = {
  587. userid: "",
  588. pwdOld: "",
  589. newPwd: "",
  590. newPwd2: "",
  591. };
  592. }
  593. // 修改密码
  594. passwordVisible = false;
  595. password?: string;
  596. isPwdVisible = false;
  597. pwdIsOkLoading = false;
  598. upModalData = {
  599. userid: "",
  600. pwdOld: "",
  601. newPwd: "",
  602. newPwd2: "",
  603. };
  604. upPwd(): void {
  605. if(this.upModalData.pwdOld.trim() === ''){
  606. this.msg.error('请填写原始密码!', {
  607. nzDuration: 5000,
  608. });
  609. return;
  610. }
  611. if(!this.strongRegFlag){
  612. this.msg.error('新密码不符合要求!', {
  613. nzDuration: 5000,
  614. });
  615. return;
  616. }
  617. if(this.upModalData.newPwd !== this.upModalData.newPwd2){
  618. this.msg.error('新密码与确认新密码不一致!', {
  619. nzDuration: 5000,
  620. });
  621. return;
  622. }
  623. this.pwdIsOkLoading = true;
  624. let userid = JSON.parse(localStorage.getItem("user")).user.id;
  625. this.upModalData.userid = userid;
  626. this.mainService.upPwd(this.upModalData).subscribe((data) => {
  627. if (data.status == 200) {
  628. this.isPwdVisible = false;
  629. this.pwdIsOkLoading = false;
  630. this.msg.success("修改成功!", {
  631. nzDuration: 5000,
  632. });
  633. } else {
  634. this.pwdIsOkLoading = false;
  635. this.msg.error(data.error, {
  636. nzDuration: 5000,
  637. });
  638. }
  639. });
  640. }
  641. showUpPwd(): void {
  642. this.isPwdVisible = true;
  643. }
  644. pwdHandleOk(): void {
  645. this.upPwd();
  646. }
  647. pwdHandleCancel(): void {
  648. this.isPwdVisible = false;
  649. }
  650. delModal = false;
  651. tipsMsg1 = "是否确定离开该界面,如果未点击生效,数据可能会遗失?";
  652. navInfo = {};
  653. // 隐藏模态框
  654. hideDelModal() {
  655. this.delModal = false;
  656. }
  657. // 模态框确认
  658. confirmDel() {
  659. this.delModal = false;
  660. if (this.navInfo["title"] == "首页") {
  661. this.router.navigateByUrl("/main/home");
  662. this.toMenu("首页");
  663. } else {
  664. this.router.navigateByUrl("/main/" + this.navInfo["item"].link);
  665. this.toMenu(
  666. this.navInfo["title"],
  667. this.navInfo["item"],
  668. this.navInfo["data"]
  669. );
  670. }
  671. }
  672. //前往菜单连接(拦截版)
  673. totoMenu(title, item?, data?) {
  674. let url = location.href.split("#")[1];
  675. if (url.includes("/main/quickCombination")) {
  676. //拦截
  677. this.delModal = true;
  678. this.navInfo = {
  679. title,
  680. item,
  681. data,
  682. };
  683. } else {
  684. //正常情况
  685. if (title == "首页") {
  686. this.router.navigateByUrl("/main/home");
  687. this.toMenu("首页");
  688. } else {
  689. this.router.navigateByUrl("/main/" + item.link);
  690. this.toMenu(title, item, data);
  691. }
  692. }
  693. }
  694. // 切换院区
  695. maskFlag: any = false;
  696. hosFlag1 = false;
  697. submitFormHand1(id) {
  698. if(this.currentHospital.id == id){
  699. return;
  700. }
  701. this.maskFlag = this.msg.loading("正在加载中..", {
  702. nzDuration: 0,
  703. }).messageId;
  704. this.mainService
  705. .changeHospital({ currentHosId: +id, loginType: "PC" })
  706. .subscribe((result) => {
  707. this.msg.remove(this.maskFlag);
  708. this.maskFlag = false;
  709. if (result.status == 200) {
  710. localStorage.setItem("user", JSON.stringify(result.user));
  711. location.reload(true);
  712. } else {
  713. this.msg.create("error", "切换院区失败");
  714. }
  715. });
  716. }
  717. hosFlagHand1(flag) {
  718. if (!flag) {
  719. this.hosFlag1 = false;
  720. }
  721. }
  722. }