123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- import { Component, OnInit, ViewChild } from "@angular/core";
- import { ActivatedRoute } from "@angular/router";
- import { NzMessageService } from "ng-zorro-antd/message";
- import { MainService } from "../../services/main.service";
- import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
- import { ToolService } from "../../services/tool.service";
- @Component({
- selector: "app-inspect-auto",
- templateUrl: "./inspect-auto.component.html",
- styleUrls: ["./inspect-auto.component.less"],
- })
- export class InspectAutoComponent implements OnInit {
- constructor(
- private route: ActivatedRoute,
- private mainService: MainService,
- private msg: NzMessageService,
- private tool: ToolService
- ) {}
- @ViewChild("osComponentRef1", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef1: OverlayScrollbarsComponent;
- @ViewChild("osComponentRef2", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef2: OverlayScrollbarsComponent;
- ngOnInit() {
- this.hosId = this.tool.getCurrentHospital().id;
- this.coopBtns = this.tool.initCoopBtns(this.route);
- this.getInspectAutoList();
- this.getInspectType();
- this.getLevelOfCare();
- this.getStateOfAnIllness();
- }
- checkedInspectAuto: any = {};
- inspectAutoList: Array<any> = [];
- hosId: any;
- promptContent: string;
- ifSuccess: boolean;
- promptInfo: string;
- promptModalShow: boolean;
- saveLoading: boolean = false;
-
- coopBtns: any = {};
-
- cancelStatus(arr: any[]) {
- arr.forEach((item) => (item.checked = false));
- return arr;
- }
-
- changeInspect(flag, type) {
- if (!flag) {
- if (type === "urgencyInspect") {
-
- this.inspectTypeList_u = this.cancelStatus(this.inspectTypeList_u);
- this.levelOfCareList_u = this.cancelStatus(this.levelOfCareList_u);
- this.stateOfAnIllnessList_u = this.cancelStatus(
- this.stateOfAnIllnessList_u
- );
- this.inspectType_u = false;
- this.levelOfCare_u = false;
- this.stateOfAnIllness_u = false;
- } else if (type === "ordinaryInspect") {
-
- this.inspectTypeList_o = this.cancelStatus(this.inspectTypeList_o);
- this.levelOfCareList_o = this.cancelStatus(this.levelOfCareList_o);
- this.stateOfAnIllnessList_o = this.cancelStatus(
- this.stateOfAnIllnessList_o
- );
- this.inspectType_o = false;
- this.levelOfCare_o = false;
- this.stateOfAnIllness_o = false;
- }
- }
- }
-
- loading2 = false;
- getRules() {
- let postData = {
- idx: 0,
- sum: 9999,
- autoCreateOrderRule: {
- hosId: this.hosId,
- classesId: this.checkedInspectAuto.id,
- taskTypeId: this.taskTypeId,
- deleted: 0,
- },
- };
- this.loading2 = true;
- this.mainService
- .getFetchDataList("simple/data", "autoCreateOrderRule", postData)
- .subscribe((result) => {
- this.loading2 = false;
- if (result.status == 200) {
- result.list.forEach((item) => {
- if (item.extra1 === "1") {
-
- this.urgencyInspect = true;
- this.inspectType_u = this.inspectTypeList_u.some((v) => {
- if (v.id == item.typeId) {
- v.checked = true;
- }
- return v.id == item.typeId;
- });
- this.levelOfCare_u = this.levelOfCareList_u.some((v) => {
- if (v.id == item.typeId2) {
- v.checked = true;
- }
- return v.id == item.typeId2;
- });
- this.stateOfAnIllness_u = this.stateOfAnIllnessList_u.some(
- (v) => {
- if (v.id == item.typeId3) {
- v.checked = true;
- }
- return v.id == item.typeId3;
- }
- );
- }
- if (item.extra1 === "0") {
-
- this.ordinaryInspect = true;
- this.inspectType_o = this.inspectTypeList_o.some((v) => {
- if (v.id == item.typeId) {
- v.checked = true;
- }
- return v.id == item.typeId;
- });
- this.levelOfCare_o = this.levelOfCareList_o.some((v) => {
- if (v.id == item.typeId2) {
- v.checked = true;
- }
- return v.id == item.typeId2;
- });
- this.stateOfAnIllness_o = this.stateOfAnIllnessList_o.some(
- (v) => {
- if (v.id == item.typeId3) {
- v.checked = true;
- }
- return v.id == item.typeId3;
- }
- );
- }
- });
- }
- });
- }
-
- loading1 = false;
- taskTypeId;
- taskTypeName;
- getInspectAutoList() {
- let data = {
- idx: 0,
- sum: 1,
- taskType: {
- hosIds: this.hosId,
- associationType: { id: 260 },
- },
- };
- this.loading1 = true;
- this.mainService
- .getFetchDataList("configuration", "taskType", data)
- .subscribe((data1) => {
- this.loading1 = false;
- if (data1.list.length) {
- this.inspectAutoList = data1.list[0].classesIds;
- this.taskTypeId = data1.list[0].id;
- this.taskTypeName = data1.list[0].taskName;
- if (Object.keys(this.checkedInspectAuto).length) {
- this.inspectAutoList.forEach((item) => {
- if (item.id == this.checkedInspectAuto.id) {
- this.checkInspectAuto(item);
- }
- });
- } else {
- this.checkInspectAuto(this.inspectAutoList[0]);
- }
- } else {
- this.msg.warning("请配置患者配件业务的任务类型!");
- }
- });
- }
-
- inspectTypeList_u = [];
- inspectTypeList_o = [];
- getInspectType() {
- this.mainService
- .getDictionary("list", "inspect_check_type")
- .subscribe((result) => {
- this.inspectTypeList_u = JSON.parse(JSON.stringify(result));
- this.inspectTypeList_o = JSON.parse(JSON.stringify(result));
- });
- }
-
- levelOfCareList_u = [];
- levelOfCareList_o = [];
- getLevelOfCare() {
- this.mainService
- .getDictionary("list", "levelOfCare")
- .subscribe((result) => {
- this.levelOfCareList_u = JSON.parse(JSON.stringify(result));
- this.levelOfCareList_o = JSON.parse(JSON.stringify(result));
- });
- }
-
- stateOfAnIllnessList_u = [];
- stateOfAnIllnessList_o = [];
- getStateOfAnIllness() {
- this.mainService
- .getDictionary("list", "stateOfAnIllness")
- .subscribe((result) => {
- this.stateOfAnIllnessList_u = JSON.parse(JSON.stringify(result));
- this.stateOfAnIllnessList_o = JSON.parse(JSON.stringify(result));
- });
- }
-
- inspectType_u = false;
- inspectType_o = false;
- selectInspectType(ids, type) {
- switch (type) {
- case "urgencyInspect":
- this.inspectType_u = ids.length > 0;
- if (this.inspectType_u) {
- this.inspectTypeList_u = this.cancelStatus(this.inspectTypeList_u);
- ids.forEach((item) => {
- this.inspectTypeList_u.forEach((v) => {
- if (v.id == item) {
- v.checked = true;
- }
- });
- });
- } else {
- this.levelOfCareList_u = this.cancelStatus(this.levelOfCareList_u);
- this.stateOfAnIllnessList_u = this.cancelStatus(
- this.stateOfAnIllnessList_u
- );
- this.inspectType_u = false;
- this.levelOfCare_u = false;
- this.stateOfAnIllness_u = false;
- }
- break;
- case "ordinaryInspect":
- this.inspectType_o = ids.length > 0;
- if (this.inspectType_o) {
- this.inspectTypeList_o = this.cancelStatus(this.inspectTypeList_o);
- ids.forEach((item) => {
- this.inspectTypeList_o.forEach((v) => {
- if (v.id == item) {
- v.checked = true;
- }
- });
- });
- } else {
- this.levelOfCareList_o = this.cancelStatus(this.levelOfCareList_o);
- this.stateOfAnIllnessList_o = this.cancelStatus(
- this.stateOfAnIllnessList_o
- );
- this.inspectType_o = false;
- this.levelOfCare_o = false;
- this.stateOfAnIllness_o = false;
- }
- break;
- }
- }
-
- levelOfCare_u = false;
- levelOfCare_o = false;
- selectLevelOfCare(ids, type) {
- switch (type) {
- case "urgencyInspect":
- this.levelOfCareList_u.forEach((item) => {
- item.checked = false;
- });
- ids.forEach((item) => {
- this.levelOfCareList_u.forEach((v) => {
- if (v.id == item) {
- v.checked = true;
- }
- });
- });
- this.levelOfCare_u = ids.length > 0;
- break;
- case "ordinaryInspect":
- this.levelOfCareList_o.forEach((item) => {
- item.checked = false;
- });
- ids.forEach((item) => {
- this.levelOfCareList_o.forEach((v) => {
- if (v.id == item) {
- v.checked = true;
- }
- });
- });
- this.levelOfCare_o = ids.length > 0;
- break;
- }
- }
-
- stateOfAnIllness_u = false;
- stateOfAnIllness_o = false;
- selectStateOfAnIllness(ids, type) {
- switch (type) {
- case "urgencyInspect":
- this.stateOfAnIllnessList_u.forEach((item) => {
- item.checked = false;
- });
- ids.forEach((item) => {
- this.stateOfAnIllnessList_u.forEach((v) => {
- if (v.id == item) {
- v.checked = true;
- }
- });
- });
- this.stateOfAnIllness_u = ids.length > 0;
- break;
- case "ordinaryInspect":
- this.stateOfAnIllnessList_o.forEach((item) => {
- item.checked = false;
- });
- ids.forEach((item) => {
- this.stateOfAnIllnessList_o.forEach((v) => {
- if (v.id == item) {
- v.checked = true;
- }
- });
- });
- this.stateOfAnIllness_o = ids.length > 0;
- break;
- }
- }
-
- checkInspectAuto(data) {
- this.checkedInspectAuto = data ? data : {};
- this.urgencyInspect = false;
- this.ordinaryInspect = false;
- this.changeInspect(false, "urgencyInspect");
- this.changeInspect(false, "ordinaryInspect");
- this.getRules();
- }
-
- urgencyInspect = false;
- ordinaryInspect = false;
- save() {
-
-
-
-
-
-
-
- if (this.urgencyInspect && !this.ordinaryInspect) {
- if (!this.inspectType_u) {
-
- this.msg.info("没有选择急查里的检查类型,无法保存!");
- return;
- } else {
-
- if (!this.levelOfCare_u) {
- this.msg.info("没有选择急查里的护理等级,无法保存!");
- return;
- }
-
- if (!this.stateOfAnIllness_u) {
- this.msg.info("没有选择急查里的病情级别,无法保存!");
- return;
- }
- }
- }
-
- if (!this.urgencyInspect && this.ordinaryInspect) {
- if (!this.inspectType_o) {
-
- this.msg.info("没有选择普查里的检查类型,无法保存!");
- return;
- } else {
-
- if (!this.levelOfCare_o) {
- this.msg.info("没有选择普查里的护理等级,无法保存!");
- return;
- }
-
- if (!this.stateOfAnIllness_o) {
- this.msg.info("没有选择普查里的病情级别,无法保存!");
- return;
- }
- }
- }
-
- if (this.urgencyInspect && this.ordinaryInspect) {
- if (this.urgencyInspect) {
-
- if (!this.inspectType_u) {
- this.msg.info("没有选择急查里的检查类型,无法保存!");
- return;
- } else {
-
- if (!this.levelOfCare_u) {
- this.msg.info("没有选择急查里的护理等级,无法保存!");
- return;
- }
-
- if (!this.stateOfAnIllness_u) {
- this.msg.info("没有选择急查里的病情级别,无法保存!");
- return;
- }
- }
- }
- if (this.ordinaryInspect) {
-
- if (!this.inspectType_o) {
- this.msg.info("没有选择普查里的检查类型,无法保存!");
- return;
- } else {
-
- if (!this.levelOfCare_o) {
- this.msg.info("没有选择普查里的护理等级,无法保存!");
- return;
- }
-
- if (!this.stateOfAnIllness_o) {
- this.msg.info("没有选择普查里的病情级别,无法保存!");
- return;
- }
- }
- }
- }
-
- let postData = [];
-
- if (!this.urgencyInspect && !this.ordinaryInspect) {
- postData = [
- {
- hosId: this.hosId,
- taskTypeId: this.taskTypeId,
- classesId: this.checkedInspectAuto.id,
- deleted: true,
- },
- ];
- } else {
-
- if (this.urgencyInspect) {
- let inspectTypeList_u = this.inspectTypeList_u
- .filter((item) => item.checked)
- .map((item) => item.id);
- let levelOfCareList_u = this.levelOfCareList_u
- .filter((item) => item.checked)
- .map((item) => item.id);
- let stateOfAnIllnessList_u = this.stateOfAnIllnessList_u
- .filter((item) => item.checked)
- .map((item) => item.id);
-
- inspectTypeList_u.forEach((item) => {
- levelOfCareList_u.forEach((value) => {
- stateOfAnIllnessList_u.forEach((v) => {
- postData.push({
- classesId: this.checkedInspectAuto.id,
- taskTypeId: this.taskTypeId,
- extra1: 1,
- typeId: item,
- typeId2: value,
- typeId3: v,
- hosId: this.hosId,
- deleted: false,
- });
- });
- });
- });
- }
-
- if (this.ordinaryInspect) {
- let inspectTypeList_o = this.inspectTypeList_o
- .filter((item) => item.checked)
- .map((item) => item.id);
- let levelOfCareList_o = this.levelOfCareList_o
- .filter((item) => item.checked)
- .map((item) => item.id);
- let stateOfAnIllnessList_o = this.stateOfAnIllnessList_o
- .filter((item) => item.checked)
- .map((item) => item.id);
-
- inspectTypeList_o.forEach((item) => {
- levelOfCareList_o.forEach((value) => {
- stateOfAnIllnessList_o.forEach((v) => {
- postData.push({
- classesId: this.checkedInspectAuto.id,
- taskTypeId: this.taskTypeId,
- extra1: 0,
- typeId: item,
- typeId2: value,
- typeId3: v,
- hosId: this.hosId,
- deleted: false,
- });
- });
- });
- });
- }
- }
-
- this.saveLoading = true;
- this.mainService
- .simplePost("addListData", "autoCreateOrderRule", postData)
- .subscribe((data) => {
- this.saveLoading = false;
- if (data.status == 200) {
- this.showPromptModal("保存", true, "");
- } else {
- this.showPromptModal("保存", false, data.msg);
- }
- });
- }
-
- showPromptModal(con, success, promptInfo?) {
- this.promptModalShow = false;
- this.promptContent = con;
- this.ifSuccess = success;
- this.promptInfo = promptInfo;
- setTimeout(() => {
- this.promptModalShow = true;
- this.getInspectAutoList();
- this.getRules();
- }, 100);
- }
- }
|