inspect-auto.component.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute } from "@angular/router";
  3. import { NzMessageService } from "ng-zorro-antd/message";
  4. import { MainService } from "../../services/main.service";
  5. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  6. import { ToolService } from "../../services/tool.service";
  7. @Component({
  8. selector: "app-inspect-auto",
  9. templateUrl: "./inspect-auto.component.html",
  10. styleUrls: ["./inspect-auto.component.less"],
  11. })
  12. export class InspectAutoComponent implements OnInit {
  13. constructor(
  14. private route: ActivatedRoute,
  15. private mainService: MainService,
  16. private msg: NzMessageService,
  17. private tool: ToolService
  18. ) {}
  19. @ViewChild("osComponentRef1", {
  20. read: OverlayScrollbarsComponent,
  21. static: false,
  22. })
  23. osComponentRef1: OverlayScrollbarsComponent;
  24. @ViewChild("osComponentRef2", {
  25. read: OverlayScrollbarsComponent,
  26. static: false,
  27. })
  28. osComponentRef2: OverlayScrollbarsComponent;
  29. ngOnInit() {
  30. this.hosId = this.tool.getCurrentHospital().id;
  31. this.coopBtns = this.tool.initCoopBtns(this.route);
  32. this.getInspectAutoList();
  33. this.getInspectType();
  34. this.getLevelOfCare();
  35. this.getStateOfAnIllness();
  36. }
  37. checkedInspectAuto: any = {}; //选中班次
  38. inspectAutoList: Array<any> = []; //检查自动建单的班次信息
  39. hosId: any; //当前选择的院区id
  40. promptContent: string; //操作提示框提示信息
  41. ifSuccess: boolean; //操作成功/失败
  42. promptInfo: string; //操作结果提示信息
  43. promptModalShow: boolean; //是否展示提示框
  44. saveLoading: boolean = false; //批量打印按钮loading状态
  45. // 初始化增删改按钮
  46. coopBtns: any = {};
  47. // 取消选中状态
  48. cancelStatus(arr: any[]) {
  49. arr.forEach((item) => (item.checked = false));
  50. return arr;
  51. }
  52. // 选择急查或者普查
  53. changeInspect(flag, type) {
  54. if (!flag) {
  55. if (type === "urgencyInspect") {
  56. //急查
  57. this.inspectTypeList_u = this.cancelStatus(this.inspectTypeList_u);
  58. this.levelOfCareList_u = this.cancelStatus(this.levelOfCareList_u);
  59. this.stateOfAnIllnessList_u = this.cancelStatus(
  60. this.stateOfAnIllnessList_u
  61. );
  62. this.inspectType_u = false;
  63. this.levelOfCare_u = false;
  64. this.stateOfAnIllness_u = false;
  65. } else if (type === "ordinaryInspect") {
  66. //普查
  67. this.inspectTypeList_o = this.cancelStatus(this.inspectTypeList_o);
  68. this.levelOfCareList_o = this.cancelStatus(this.levelOfCareList_o);
  69. this.stateOfAnIllnessList_o = this.cancelStatus(
  70. this.stateOfAnIllnessList_o
  71. );
  72. this.inspectType_o = false;
  73. this.levelOfCare_o = false;
  74. this.stateOfAnIllness_o = false;
  75. }
  76. }
  77. }
  78. /**
  79. *
  80. * @param classId 班次Id
  81. */
  82. loading2 = false;
  83. getRules() {
  84. let postData = {
  85. idx: 0,
  86. sum: 9999,
  87. autoCreateOrderRule: {
  88. hosId: this.hosId,
  89. classesId: this.checkedInspectAuto.id, //班次id
  90. taskTypeId: this.taskTypeId, //任务类型id
  91. deleted: 0,
  92. },
  93. };
  94. this.loading2 = true;
  95. this.mainService
  96. .getFetchDataList("simple/data", "autoCreateOrderRule", postData)
  97. .subscribe((result) => {
  98. this.loading2 = false;
  99. if (result.status == 200) {
  100. result.list.forEach((item) => {
  101. if (item.extra1 === "1") {
  102. //急查
  103. this.urgencyInspect = true;
  104. this.inspectType_u = this.inspectTypeList_u.some((v) => {
  105. if (v.id == item.typeId) {
  106. v.checked = true;
  107. }
  108. return v.id == item.typeId;
  109. });
  110. this.levelOfCare_u = this.levelOfCareList_u.some((v) => {
  111. if (v.id == item.typeId2) {
  112. v.checked = true;
  113. }
  114. return v.id == item.typeId2;
  115. });
  116. this.stateOfAnIllness_u = this.stateOfAnIllnessList_u.some(
  117. (v) => {
  118. if (v.id == item.typeId3) {
  119. v.checked = true;
  120. }
  121. return v.id == item.typeId3;
  122. }
  123. );
  124. }
  125. if (item.extra1 === "0") {
  126. //普查
  127. this.ordinaryInspect = true;
  128. this.inspectType_o = this.inspectTypeList_o.some((v) => {
  129. if (v.id == item.typeId) {
  130. v.checked = true;
  131. }
  132. return v.id == item.typeId;
  133. });
  134. this.levelOfCare_o = this.levelOfCareList_o.some((v) => {
  135. if (v.id == item.typeId2) {
  136. v.checked = true;
  137. }
  138. return v.id == item.typeId2;
  139. });
  140. this.stateOfAnIllness_o = this.stateOfAnIllnessList_o.some(
  141. (v) => {
  142. if (v.id == item.typeId3) {
  143. v.checked = true;
  144. }
  145. return v.id == item.typeId3;
  146. }
  147. );
  148. }
  149. });
  150. }
  151. });
  152. }
  153. // 任务类型下班次列表
  154. loading1 = false;
  155. taskTypeId; //当前选中班次的任务类型ID
  156. taskTypeName; //当前选中班次的任务类型名称
  157. getInspectAutoList() {
  158. let data = {
  159. idx: 0,
  160. sum: 1,
  161. taskType: {
  162. hosIds: this.hosId,
  163. associationType: { id: 260 },
  164. },
  165. };
  166. this.loading1 = true;
  167. this.mainService
  168. .getFetchDataList("configuration", "taskType", data)
  169. .subscribe((data1) => {
  170. this.loading1 = false;
  171. if (data1.list.length) {
  172. this.inspectAutoList = data1.list[0].classesIds; //班次信息
  173. this.taskTypeId = data1.list[0].id;
  174. this.taskTypeName = data1.list[0].taskName;
  175. if (Object.keys(this.checkedInspectAuto).length) {
  176. this.inspectAutoList.forEach((item) => {
  177. if (item.id == this.checkedInspectAuto.id) {
  178. this.checkInspectAuto(item);
  179. }
  180. });
  181. } else {
  182. this.checkInspectAuto(this.inspectAutoList[0]);
  183. }
  184. } else {
  185. this.msg.warning("请配置患者配件业务的任务类型!");
  186. }
  187. });
  188. }
  189. // 检查类型列表
  190. inspectTypeList_u = []; //检查类型列表(急查)
  191. inspectTypeList_o = []; //检查类型列表(普查)
  192. getInspectType() {
  193. this.mainService
  194. .getDictionary("list", "inspect_check_type")
  195. .subscribe((result) => {
  196. this.inspectTypeList_u = JSON.parse(JSON.stringify(result));
  197. this.inspectTypeList_o = JSON.parse(JSON.stringify(result));
  198. });
  199. }
  200. // 护理等级列表
  201. levelOfCareList_u = []; //班次列表(急查)
  202. levelOfCareList_o = []; //班次列表(普查)
  203. getLevelOfCare() {
  204. this.mainService
  205. .getDictionary("list", "levelOfCare")
  206. .subscribe((result) => {
  207. this.levelOfCareList_u = JSON.parse(JSON.stringify(result));
  208. this.levelOfCareList_o = JSON.parse(JSON.stringify(result));
  209. });
  210. }
  211. // 病情级别列表
  212. stateOfAnIllnessList_u = []; //病情级别列表(急查)
  213. stateOfAnIllnessList_o = []; //病情级别列表(普查)
  214. getStateOfAnIllness() {
  215. this.mainService
  216. .getDictionary("list", "stateOfAnIllness")
  217. .subscribe((result) => {
  218. this.stateOfAnIllnessList_u = JSON.parse(JSON.stringify(result));
  219. this.stateOfAnIllnessList_o = JSON.parse(JSON.stringify(result));
  220. });
  221. }
  222. //选择检查类型
  223. inspectType_u = false; //是否选择检查类型(急查)
  224. inspectType_o = false; //是否选择检查类型(普查)
  225. selectInspectType(ids, type) {
  226. switch (type) {
  227. case "urgencyInspect": //急查
  228. this.inspectType_u = ids.length > 0;
  229. if (this.inspectType_u) {
  230. this.inspectTypeList_u = this.cancelStatus(this.inspectTypeList_u);
  231. ids.forEach((item) => {
  232. this.inspectTypeList_u.forEach((v) => {
  233. if (v.id == item) {
  234. v.checked = true;
  235. }
  236. });
  237. });
  238. } else {
  239. this.levelOfCareList_u = this.cancelStatus(this.levelOfCareList_u);
  240. this.stateOfAnIllnessList_u = this.cancelStatus(
  241. this.stateOfAnIllnessList_u
  242. );
  243. this.inspectType_u = false;
  244. this.levelOfCare_u = false;
  245. this.stateOfAnIllness_u = false;
  246. }
  247. break;
  248. case "ordinaryInspect": //普查
  249. this.inspectType_o = ids.length > 0;
  250. if (this.inspectType_o) {
  251. this.inspectTypeList_o = this.cancelStatus(this.inspectTypeList_o);
  252. ids.forEach((item) => {
  253. this.inspectTypeList_o.forEach((v) => {
  254. if (v.id == item) {
  255. v.checked = true;
  256. }
  257. });
  258. });
  259. } else {
  260. this.levelOfCareList_o = this.cancelStatus(this.levelOfCareList_o);
  261. this.stateOfAnIllnessList_o = this.cancelStatus(
  262. this.stateOfAnIllnessList_o
  263. );
  264. this.inspectType_o = false;
  265. this.levelOfCare_o = false;
  266. this.stateOfAnIllness_o = false;
  267. }
  268. break;
  269. }
  270. }
  271. //选择护理等级
  272. levelOfCare_u = false; //是否选择护理等级(急查)
  273. levelOfCare_o = false; //是否选择护理等级(普查)
  274. selectLevelOfCare(ids, type) {
  275. switch (type) {
  276. case "urgencyInspect": //急查
  277. this.levelOfCareList_u.forEach((item) => {
  278. item.checked = false;
  279. });
  280. ids.forEach((item) => {
  281. this.levelOfCareList_u.forEach((v) => {
  282. if (v.id == item) {
  283. v.checked = true;
  284. }
  285. });
  286. });
  287. this.levelOfCare_u = ids.length > 0;
  288. break;
  289. case "ordinaryInspect": //普查
  290. this.levelOfCareList_o.forEach((item) => {
  291. item.checked = false;
  292. });
  293. ids.forEach((item) => {
  294. this.levelOfCareList_o.forEach((v) => {
  295. if (v.id == item) {
  296. v.checked = true;
  297. }
  298. });
  299. });
  300. this.levelOfCare_o = ids.length > 0;
  301. break;
  302. }
  303. }
  304. //选择病情级别
  305. stateOfAnIllness_u = false; //是否选择病情级别(急查)
  306. stateOfAnIllness_o = false; //是否选择病情级别(普查)
  307. selectStateOfAnIllness(ids, type) {
  308. switch (type) {
  309. case "urgencyInspect": //急查
  310. this.stateOfAnIllnessList_u.forEach((item) => {
  311. item.checked = false;
  312. });
  313. ids.forEach((item) => {
  314. this.stateOfAnIllnessList_u.forEach((v) => {
  315. if (v.id == item) {
  316. v.checked = true;
  317. }
  318. });
  319. });
  320. this.stateOfAnIllness_u = ids.length > 0;
  321. break;
  322. case "ordinaryInspect": //普查
  323. this.stateOfAnIllnessList_o.forEach((item) => {
  324. item.checked = false;
  325. });
  326. ids.forEach((item) => {
  327. this.stateOfAnIllnessList_o.forEach((v) => {
  328. if (v.id == item) {
  329. v.checked = true;
  330. }
  331. });
  332. });
  333. this.stateOfAnIllness_o = ids.length > 0;
  334. break;
  335. }
  336. }
  337. // 选中班次
  338. checkInspectAuto(data) {
  339. this.checkedInspectAuto = data ? data : {};
  340. this.urgencyInspect = false;
  341. this.ordinaryInspect = false;
  342. this.changeInspect(false, "urgencyInspect");
  343. this.changeInspect(false, "ordinaryInspect");
  344. this.getRules();
  345. }
  346. // 保存
  347. urgencyInspect = false; //是否选择急查
  348. ordinaryInspect = false; //是否选择普查
  349. save() {
  350. // 规则验证 start
  351. //没有选择急查或普查
  352. // if (!this.urgencyInspect && !this.ordinaryInspect) {
  353. // this.msg.info("没有选择急查或普查,无法保存!");
  354. // return;
  355. // }
  356. // 选择了急查,没有选择普查
  357. if (this.urgencyInspect && !this.ordinaryInspect) {
  358. if (!this.inspectType_u) {
  359. //没有选择检查类型
  360. this.msg.info("没有选择急查里的检查类型,无法保存!");
  361. return;
  362. } else {
  363. // 选择了检查类型,没有选择护理等级
  364. if (!this.levelOfCare_u) {
  365. this.msg.info("没有选择急查里的护理等级,无法保存!");
  366. return;
  367. }
  368. // 选择了检查类型,没有选择病情级别
  369. if (!this.stateOfAnIllness_u) {
  370. this.msg.info("没有选择急查里的病情级别,无法保存!");
  371. return;
  372. }
  373. }
  374. }
  375. // 选择了普查,没有选择急查
  376. if (!this.urgencyInspect && this.ordinaryInspect) {
  377. if (!this.inspectType_o) {
  378. //没有选择检查类型
  379. this.msg.info("没有选择普查里的检查类型,无法保存!");
  380. return;
  381. } else {
  382. // 选择了检查类型,没有选择护理等级
  383. if (!this.levelOfCare_o) {
  384. this.msg.info("没有选择普查里的护理等级,无法保存!");
  385. return;
  386. }
  387. // 选择了检查类型,没有选择病情级别
  388. if (!this.stateOfAnIllness_o) {
  389. this.msg.info("没有选择普查里的病情级别,无法保存!");
  390. return;
  391. }
  392. }
  393. }
  394. // 选择了急查和普查
  395. if (this.urgencyInspect && this.ordinaryInspect) {
  396. if (this.urgencyInspect) {
  397. //选择了急查,没有选择检查类型
  398. if (!this.inspectType_u) {
  399. this.msg.info("没有选择急查里的检查类型,无法保存!");
  400. return;
  401. } else {
  402. // 选择了检查类型,没有选择护理等级
  403. if (!this.levelOfCare_u) {
  404. this.msg.info("没有选择急查里的护理等级,无法保存!");
  405. return;
  406. }
  407. // 选择了检查类型,没有选择病情级别
  408. if (!this.stateOfAnIllness_u) {
  409. this.msg.info("没有选择急查里的病情级别,无法保存!");
  410. return;
  411. }
  412. }
  413. }
  414. if (this.ordinaryInspect) {
  415. //选择了普查,没有选择检查类型
  416. if (!this.inspectType_o) {
  417. this.msg.info("没有选择普查里的检查类型,无法保存!");
  418. return;
  419. } else {
  420. // 选择了检查类型,没有选择护理等级
  421. if (!this.levelOfCare_o) {
  422. this.msg.info("没有选择普查里的护理等级,无法保存!");
  423. return;
  424. }
  425. // 选择了检查类型,没有选择病情级别
  426. if (!this.stateOfAnIllness_o) {
  427. this.msg.info("没有选择普查里的病情级别,无法保存!");
  428. return;
  429. }
  430. }
  431. }
  432. }
  433. // 规则验证 end
  434. let postData = [];
  435. // 组装数据 start
  436. if (!this.urgencyInspect && !this.ordinaryInspect) {
  437. postData = [
  438. {
  439. hosId: this.hosId,
  440. taskTypeId: this.taskTypeId,
  441. classesId: this.checkedInspectAuto.id,
  442. deleted: true,
  443. },
  444. ];
  445. } else {
  446. // 急查数据
  447. if (this.urgencyInspect) {
  448. let inspectTypeList_u = this.inspectTypeList_u
  449. .filter((item) => item.checked)
  450. .map((item) => item.id);
  451. let levelOfCareList_u = this.levelOfCareList_u
  452. .filter((item) => item.checked)
  453. .map((item) => item.id);
  454. let stateOfAnIllnessList_u = this.stateOfAnIllnessList_u
  455. .filter((item) => item.checked)
  456. .map((item) => item.id);
  457. // 三层循环,感觉有些傻,无奈后端非要这么传-后端陈肖让我记录的
  458. inspectTypeList_u.forEach((item) => {
  459. levelOfCareList_u.forEach((value) => {
  460. stateOfAnIllnessList_u.forEach((v) => {
  461. postData.push({
  462. classesId: this.checkedInspectAuto.id, //班次id
  463. taskTypeId: this.taskTypeId, //任务类型id
  464. extra1: 1, //急查1,普查0
  465. typeId: item, //检查类型id
  466. typeId2: value, //护理等级id
  467. typeId3: v, //病情级别id
  468. hosId: this.hosId, //院区id
  469. deleted: false, //删除true,显示false
  470. });
  471. });
  472. });
  473. });
  474. }
  475. // 普查数据
  476. if (this.ordinaryInspect) {
  477. let inspectTypeList_o = this.inspectTypeList_o
  478. .filter((item) => item.checked)
  479. .map((item) => item.id);
  480. let levelOfCareList_o = this.levelOfCareList_o
  481. .filter((item) => item.checked)
  482. .map((item) => item.id);
  483. let stateOfAnIllnessList_o = this.stateOfAnIllnessList_o
  484. .filter((item) => item.checked)
  485. .map((item) => item.id);
  486. // 三层循环,感觉有些傻,无奈后端非要这么传-后端陈肖让我记录的
  487. inspectTypeList_o.forEach((item) => {
  488. levelOfCareList_o.forEach((value) => {
  489. stateOfAnIllnessList_o.forEach((v) => {
  490. postData.push({
  491. classesId: this.checkedInspectAuto.id, //班次id
  492. taskTypeId: this.taskTypeId, //任务类型id
  493. extra1: 0, //急查1,普查0
  494. typeId: item, //检查类型id
  495. typeId2: value, //护理等级id
  496. typeId3: v, //病情级别id
  497. hosId: this.hosId, //院区id
  498. deleted: false, //删除true,显示false
  499. });
  500. });
  501. });
  502. });
  503. }
  504. }
  505. // 组装数据 end
  506. this.saveLoading = true;
  507. this.mainService
  508. .simplePost("addListData", "autoCreateOrderRule", postData)
  509. .subscribe((data) => {
  510. this.saveLoading = false;
  511. if (data.status == 200) {
  512. this.showPromptModal("保存", true, "");
  513. } else {
  514. this.showPromptModal("保存", false, data.msg);
  515. }
  516. });
  517. }
  518. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  519. showPromptModal(con, success, promptInfo?) {
  520. this.promptModalShow = false;
  521. this.promptContent = con;
  522. this.ifSuccess = success;
  523. this.promptInfo = promptInfo;
  524. setTimeout(() => {
  525. this.promptModalShow = true;
  526. this.getInspectAutoList();
  527. this.getRules();
  528. }, 100);
  529. }
  530. }