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; //表格中执行操作的id
- 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; //提交按钮loading状态
- 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";
- }
- // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
- 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",
- });
- //trick to download store a file having its URL
- 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]);
- }
- // 截取意见内容(ie内核截取)
- spliceContent(con) {
- if (con.length >= 41 && navigator.userAgent.indexOf("Trident") > -1) {
- return con.slice(0, 20) + "...";
- } else {
- return con;
- }
- }
- // 选中表格单列
- mapOfCheckedId: { [key: string]: boolean } = {};
- checkedDepIds = []; //已选中单列id
- 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();
- }
- }
|