123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- import { Component, OnInit } from "@angular/core";
- import { ActivatedRoute, Router } from "@angular/router";
- import { MainService } from "../../services/main.service";
- import { ToolService } from "../../services/tool.service";
- import { Subject } from "rxjs";
- import { debounceTime } from "rxjs/operators";
- @Component({
- selector: "app-order-management",
- templateUrl: "./order-management.component.html",
- styleUrls: ["./order-management.component.less"],
- })
- export class OrderManagementComponent implements OnInit {
- constructor(
- public route: ActivatedRoute,
- private router: Router,
- private mainService: MainService,
- private tool: ToolService
- ) {}
- searchTimerSubject = new Subject();
- ngOnInit() {
- this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
- let fun = v[0];
- fun.call(this, v[1]);
- });
- this.initOrderType();
- this.coopBtns = this.tool.initCoopBtns(this.route);
- if (this.coopBtns.deleted) {
-
- this.checkOptionsOne.push({
- label: "已删除",
- value: "3",
- checked: false,
- });
- }
- this.getAllHos();
- this.getGdStates();
- }
- loginUser: any = localStorage.getItem("user")
- ? JSON.parse(localStorage.getItem("user")).user
- : null;
- listOfData: any[] = [];
- modal: boolean = false;
- coopId: string;
- hospital: string;
- gdcode: string = "";
- association: number;
- allAssociation: any = [];
- department: any;
- alldepart: any = [];
- worker: number;
- tasktype: number;
- allWorker: any = [];
- allTasktype: any = [];
- gdState: number;
- specialCloseFlag: any;
- dateRange: any = [];
- gdStates: any;
- pageIndex: number = 1;
- listLength: number = 10;
- pageSize: number = 10;
- promptContent: string;
- ifSuccess: boolean;
- promptInfo: string;
- promptModalShow: boolean;
- btnLoading: boolean = false;
- checkOptionsOne: Array<any> = [
- { label: "超时工单", value: "0", checked: false },
- { label: "异常工单", value: "1", checked: false },
- { label: "24小时未完成", value: "2", checked: false },
- ];
-
- initOrderType() {
- let that = this;
- console.log(that.route);
- if (that.route.snapshot.fragment == "yc") {
- that.checkOptionsOne[1].checked = true;
- }
- }
-
- coopBtns: any = {};
-
- search() {
- this.pageIndex = 1;
- this.getList();
- }
-
- reset() {
- this.pageIndex = 1;
- this.association = null;
- this.worker = null;
- this.tasktype = null;
- if (this.loginUser.usertype.value != 1) {
-
- this.department = null;
- }
- this.gdcode = "";
- this.gdState = null;
- this.specialCloseFlag = null;
- this.dateRange = [];
- this.changeDate();
- this.getList();
- }
-
- getAllHos() {
- this.hospital = this.tool.getCurrentHospital().id + "";
- this.changeHos();
- }
-
- changeHos() {
- this.department = null;
- this.worker = null;
- this.tasktype = null;
- this.association = null;
- this.getDeparts();
- this.getAssociation();
- this.getAllWorker();
- this.getAllTasktype();
- }
-
- getAssociation() {
- let that = this;
- console.log(that.mainService.getDictionary("list", "association_types"));
- that.mainService
- .getDictionary("list", "association_types")
- .subscribe((data) => {
- that.allAssociation = data;
- });
- }
-
- getAllWorker(e?, those?) {
- let that = those || this;
- let postData = {
- user: {
- name: e || "",
- hospital: { id: that.hospital },
- usertype: { id: 106 },
- },
- idx: 0,
- sum: 20,
- };
- that.isLoading = true;
- that.mainService
- .getFetchDataList("data", "user", postData)
- .subscribe((data) => {
- that.allWorker = data.list;
- that.isLoading = false;
- });
- }
-
- getAllTasktype(e?, those?) {
- let that = those || this;
- let postData: any = {
- idx: 0,
- sum: 10,
- taskType: {
- taskName: e || "",
- hosIds: that.hospital,
- simpleQuery: true,
- },
- };
- if (that.association) {
- postData.taskType.associationType = { id: that.association };
- }
- that.isLoading = true;
- that.mainService
- .getFetchDataList("configuration", "taskType", postData)
- .subscribe((data) => {
- that.allTasktype = data.list;
- that.isLoading = false;
- });
- }
-
- selectAssociation(e) {
- this.association = e;
- this.changeTasktype("");
- this.tasktype = null;
- }
-
- loading1 = false;
- getList() {
- var that = this;
- let data: any = {
- idx: that.pageIndex - 1,
- sum: that.pageSize,
- workOrder: {
- worker: { id: that.worker },
- gdState: { id: that.gdState },
- gdcode: this.gdcode,
- specialCloseFlag: that.specialCloseFlag,
- createDept: that.department,
- hosId: that.hospital,
- abnormityType: that.checkOptionsOne[1].checked ? 1 : 0,
- timeOut: that.checkOptionsOne[0].checked ? 1 : 0,
- },
- };
- if (that.checkOptionsOne[3]) {
- if (that.checkOptionsOne[3].checked) {
- data.workOrder.deleteFlag = 1;
- } else {
- delete data.workOrder.deleteFlag;
- }
- }
- if (that.association) {
- data.workOrder.taskType = {
- associationType: { id: that.association },
- };
- }
- if (that.tasktype) {
- data.workOrder.serTaskTypes = that.tasktype;
- }
- if (!data.workOrder.worker.id) {
- delete data.workOrder.worker;
- }
- if (!data.workOrder.gdState.id) {
- delete data.workOrder.gdState;
- }
- if (
- data.workOrder.specialCloseFlag === undefined ||
- data.workOrder.specialCloseFlag === null
- ) {
- delete data.workOrder.specialCloseFlag;
- }
- if (!data.workOrder.createDept) {
- delete data.workOrder.createDept;
- }
- delete data.workOrder.overdueTime24;
- delete data.workOrder.startTime1;
- delete data.workOrder.endTime1;
- if (that.checkOptionsOne[2].checked) {
- data.workOrder.overdueTime24 = true;
- } else if (that.startDate && that.endDate) {
- data.workOrder.startTime1 = that.startDate;
- data.workOrder.endTime1 = that.endDate;
- }
- that.mapOfCheckedId = {};
- that.checkedDepIds = [];
- that.isAllDisplayDataChecked = false;
- that.loading1 = true;
- that.mainService
- .getFetchDataList("data", "workOrder", data)
- .subscribe((result) => {
- that.loading1 = false;
- that.listOfData = result.list;
- that.listLength = result.totalNum;
- });
- }
-
- getDeparts(dept?) {
- let data = {
- department: {
- hospital: { id: this.hospital },
- dept: dept,
- },
- idx: 0,
- sum: 20,
- };
- this.isLoading = true;
- this.mainService
- .getFetchDataList("data", "department", data)
- .subscribe((data) => {
- this.alldepart = data.list;
- this.isLoading = false;
- if (dept === undefined && this.loginUser.usertype.value == 1) {
-
- this.alldepart = [this.loginUser.dept];
- this.department = this.loginUser.dept.id;
- this.getList();
- }else{
- this.getList();
- }
- });
- }
-
- getGdStates() {
- var that = this;
- that.mainService.getDictionary("list", "gdstate").subscribe((data) => {
- that.gdStates = data;
- });
- }
-
- log(value: object[]): void {
- console.log(value);
- this.getList();
- }
-
- startDate: string;
- endDate: string;
- changeDate(result?): void {
- if (!result) {
- this.startDate = this.endDate = "";
- return;
- }
- this.startDate =
- result[0].getFullYear() +
- "-" +
- (result[0].getMonth() + 1) +
- "-" +
- result[0].getDate() +
- " " +
- "00:00:00";
- this.endDate =
- result[1].getFullYear() +
- "-" +
- (result[1].getMonth() + 1) +
- "-" +
- result[1].getDate() +
- " " +
- "23:59:59";
- }
-
- showPromptModal(con, success, promptInfo?) {
- this.promptModalShow = false;
- this.promptContent = con;
- this.ifSuccess = success;
- this.promptInfo = promptInfo;
- setTimeout(() => {
- this.promptModalShow = true;
- }, 100);
- this.getList();
- }
-
- detail(e, id) {
- e.stopPropagation();
- this.router.navigateByUrl("/main/orderManagement/orderDetail/" + id);
- }
-
- showDelModals(e) {
- let ids = this.checkedDepIds.join(",");
- this.showDelModal(e, ids);
- }
-
- loading3 = false;
- delModal: boolean = false;
- showDelModal(e, id) {
- e.stopPropagation();
- this.delModal = true;
- this.coopId = id + "";
- }
- hideDelModal() {
- this.delModal = false;
- }
- confirmDel() {
- this.loading3 = true;
- this.mainService[this.coopId.includes(",") ? "delOrders" : "delOrder"](
- this.coopId
- ).subscribe((data) => {
- this.loading3 = false;
- this.delModal = false;
- if (data.status == 200) {
- if (
- this.listOfData.length == 1 &&
- this.pageIndex == Math.ceil(this.listLength / this.pageSize)
- ) {
- this.listLength--;
- this.pageIndex = Math.ceil(this.listLength / this.pageSize);
- }
- this.showPromptModal("删除", true, "");
- } else {
- this.showPromptModal("删除", false, data.msg);
- }
- });
- }
-
- loading2 = false;
- export() {
- let that = this;
- let postData: any = {
- idx: that.pageIndex - 1,
- sum: that.pageSize,
- workOrder: {
- worker: { id: that.worker },
- gdState: { id: that.gdState },
- createDept: that.department,
- hosId: that.hospital,
- abnormityType: that.checkOptionsOne[1].checked ? 1 : 0,
- timeOut: that.checkOptionsOne[0].checked ? 1 : 0,
- },
- };
- if (that.association) {
- postData.workOrder.taskType = {
- associationType: { id: that.association },
- };
- }
- if (that.tasktype) {
- postData.workOrder.serTaskTypes = that.tasktype;
- }
- if (!postData.workOrder.worker.id) {
- delete postData.workOrder.worker;
- }
- if (!postData.workOrder.gdState.id) {
- delete postData.workOrder.gdState;
- }
- if (!postData.workOrder.createDept) {
- delete postData.workOrder.createDept;
- }
- delete postData.workOrder.overdueTime24;
- delete postData.workOrder.startTime1;
- delete postData.workOrder.endTime1;
- if (that.checkOptionsOne[2].checked) {
- postData.workOrder.overdueTime24 = true;
- } else if (that.startDate && that.endDate) {
- postData.workOrder.startTime1 = that.startDate;
- postData.workOrder.endTime1 = that.endDate;
- }
- this.loading2 = true;
- that.mainService.dataExport("workOrder", postData).subscribe(
- (data) => {
- this.loading2 = false;
- this.showPromptModal("导出", true, "");
- var file = new Blob([data], {
- type: "application/vnd.ms-excel",
- });
-
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement("a");
- a.href = fileURL;
- a.target = "_blank";
- a.download = "工单列表.xls";
- document.body.appendChild(a);
- a.click();
- },
- (err) => {
- this.loading2 = false;
- this.showPromptModal("导出", false, "");
- }
- );
- }
-
- isLoading = false;
- changeInp(e) {
- this.searchTimer(this.getDeparts, e);
- }
-
- changeUser(e) {
- this.searchTimer(this.getAllWorker, e);
- }
-
- changeTasktype(e) {
- this.searchTimer(this.getAllTasktype, e);
- }
-
- searchTimer(fun, e) {
- this.isLoading = true;
- this.searchTimerSubject.next([fun, e]);
- }
-
- spliceContent(con) {
- if (con.length >= 41 && navigator.userAgent.indexOf("Trident") > -1) {
- return con.slice(0, 20) + "...";
- } else {
- return con;
- }
- }
-
- mapOfCheckedId: { [key: string]: boolean } = {};
- checkedDepIds = [];
- refreshStatus(): void {
- let listOfData = this.listOfData.filter(
- (item) => item.gdState.value != 6 && item.gdState.value != 7
- );
- this.isAllDisplayDataChecked = listOfData.every(
- (item) => this.mapOfCheckedId[item.id]
- );
- let arr = [];
- for (var k in this.mapOfCheckedId) {
- if (this.mapOfCheckedId[k]) {
- arr.push(Number(k));
- }
- }
- this.checkedDepIds = arr;
- }
-
- selectedListData(data) {
- if (data.gdState.value == 6 || data.gdState.value == 7) {
- return;
- }
- this.mapOfCheckedId[data.id] = !this.mapOfCheckedId[data.id];
- this.refreshStatus();
- }
-
- isAllDisplayDataChecked = false;
- checkAll(value: boolean): void {
- this.listOfData.forEach((item) => {
- if (item.gdState.value != 6 && item.gdState.value != 7) {
- this.mapOfCheckedId[item.id] = value;
- }
- });
- this.refreshStatus();
- }
- }
|