123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- import { Component, OnInit } from "@angular/core";
- import { ActivatedRoute, Router } from "@angular/router";
- import { FormBuilder, Validators, FormGroup } from "@angular/forms";
- import { MainService } from "../../services/main.service";
- import { ToolService } from "../../services/tool.service";
- import { NzMessageService } from 'ng-zorro-antd';
- import { Subject } from 'rxjs';
- import { debounceTime } from 'rxjs/operators';
- import { startOfDay, endOfDay, format } from 'date-fns';
- @Component({
- selector: "app-specimen-package",
- templateUrl: "./specimen-package.component.html",
- styleUrls: ["./specimen-package.component.less"],
- })
- export class SpecimenPackageComponent implements OnInit {
- constructor(
- private fb: FormBuilder,
- private mainService: MainService,
- private route: ActivatedRoute,
- private router: Router,
- private tool: ToolService,
- private message: NzMessageService,
- ) {}
- listOfData: any[] = []; //表格数据
- pageIndex: number = 1; //表格当前页码
- pageSize: number = 10; //表格每页展示条数
- listLength: number = 10; //表格总数据量
- modal: boolean = false; //新增/编辑模态框
- add: boolean; //true:新增;false:编辑
- validateForm: FormGroup; //新增/编辑表单
- coopData: any; //当前操作列
- currentHospital; //当前院区
- btnLoading: boolean = false; //提交按钮loading状态
- promptContent: string; //操作提示框提示信息
- ifSuccess: boolean; //操作成功/失败
- promptInfo: string; //操作结果提示信息
- promptModalShow: boolean; //操作提示框是否展示
- modelName = ""; //模态框名称
- searchTimerSubject = new Subject(); //防抖
- showDropdown:boolean = false;
- dateRange: any = []; //发起时间
- ngOnInit() {
- //防抖
- this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
- let fun = v[0];
- fun.call(this, v[1]);
- });
- this.currentHospital = this.tool.getCurrentHospital();
- this.coopBtns = this.tool.initCoopBtns(this.route);
- this.getList(1);
- this.getStatus();
- }
- // 初始化增删改按钮
- coopBtns: any = {};
- // 日期选择
- onCalendarChangeDate(dateArr){
- if(dateArr.length == 2){
- this.dateRange = [startOfDay(dateArr[0]), endOfDay(dateArr[1])];
- }
- }
- // 搜索
- search() {
- this.getList(1);
- }
- // 重置
- reset() {
- this.searchDto = {};
- this.dateRange = [];
- this.getList(1);
- }
- // 表格数据
- searchDto: any = {};
- loading1 = false;
- getList(type) {
- if (type == 1) {
- this.pageIndex = 1;
- }
- let data = {
- idx: this.pageIndex - 1,
- sum: this.pageSize,
- pathologyPackInfo: {
- hosId: this.currentHospital.id,
- busiType: 'specimen',//标本打包
- status: this.searchDto.status ? { id: this.searchDto.status } : undefined,
- deliveryUser: this.searchDto.deliveryUser || undefined,
- packDept: this.searchDto.packDept || undefined,
- startTime: this.dateRange.length ? format(this.dateRange[0], 'yyyy-MM-dd HH:mm:ss') : undefined,
- endTime: this.dateRange.length ? format(this.dateRange[1], 'yyyy-MM-dd HH:mm:ss') : undefined,
- },
- };
- this.loading1 = true;
- this.mainService
- .getFetchDataList("simple/data", "pathologyPackInfo", data)
- .subscribe((data) => {
- this.loading1 = false;
- if (data.status == 200) {
- let listOfData = data.list || [];
- listOfData.forEach((v) => {
- if(v.endDeptList){
- v.endDeptNames = v.endDeptList.map(v => v.dept).toString();
- }else{
- v.endDeptNames = "";
- }
- })
- this.listOfData = listOfData;
- this.listLength = data.totalNum;
- }else{
- this.message.error(data.msg || "请求数据失败");
- }
- });
- }
- // 防抖
- isLoading = false;
- isSelecting:boolean = false; // 是否在选中状态
- searchTimer(fun, e) {
- if (this.isSelecting) {
- this.isSelecting = false; // 重置标志
- return; // 跳过处理
- }
- this.isLoading = true;
- this.searchTimerSubject.next([fun, e]);
- }
- // 搜索
- changeInp(type, e) {
- if(type === 'department'){
- this.searchTimer(this.getDeptList, e);
- }else if(type === 'patient'){
- this.searchTimer(this.getDeliveryUserList, e);
- }
- }
- // 设置标志
- setIsSelecting(flag){
- this.isSelecting = flag; // 设置标志
- }
- openChangeDept(flag){
- flag && this.setIsSelecting(false);
- flag && this.getDeptList();
- }
- // 获取科室
- deptList: any = [];
- getDeptList(e = undefined) {
- let postData = {
- idx: 0,
- sum: 20,
- department: {
- searchType: 1,// 简单查询
- cascadeHosId: this.currentHospital.id,
- dept: e,
- }
- };
- this.isLoading = true;
- this.mainService
- .getFetchDataList("simple/data", "department", postData)
- .subscribe((data) => {
- this.isLoading = false;
- this.deptList = data.list || [];
- });
- }
- openChangePatient(flag){
- flag && this.setIsSelecting(false);
- flag && this.getDeliveryUserList();
- }
- // 获取送达人
- deliveryUserList: any = [];
- getDeliveryUserList(e = undefined) {
- let postData = {
- idx: 0,
- sum: 20,
- user: {
- hospital: { id: this.currentHospital.id },
- name: e,
- }
- };
- this.isLoading = true;
- this.mainService
- .getFetchDataList("simple/data", "user", postData)
- .subscribe((data) => {
- this.isLoading = false;
- this.deliveryUserList = data.list || [];
- });
- }
- //获取状态
- stateList:any[] = [];
- getStatus() {
- this.mainService
- .getDictionary('list', 'pathology_pack_status')
- .subscribe((data) => {
- this.stateList = data || [];
- });
- }
- // 展示信息提示框(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(0);
- }
- // 查看日志弹窗
- logPromptModalShow = false; //弹窗开关
- packId = ""; //查看记录携带id
- showLogs(data) {
- this.packId = data.id;
- this.logPromptModalShow = true;
- }
- // 关闭日志弹窗
- closeModelLog(e) {
- this.logPromptModalShow = JSON.parse(e).show;
- }
- // 查看
- detail(e, id) {
- e.stopPropagation();
- this.router.navigateByUrl(`/main/specimenPackage/orderDetail/${id}`);
- }
- delModal: boolean = false; //删除模态框
- tipsMsg1: string; //提示框信息
- tipsMsg2: string; //操作后信息
- confirmDelType: string; //确认的类型(启用/停用,删除)
- showDelModal(
- data,
- tipsMsg1: string,
- tipsMsg2: string,
- type: string,
- ) {
- this.confirmDelType = type;
- this.delModal = true;
- this.coopData = data;
- this.tipsMsg1 = tipsMsg1;
- this.tipsMsg2 = tipsMsg2;
- }
- // 隐藏删除框
- hideDelModal() {
- this.delModal = false;
- }
- // 确认删除
- confirmDel() {
- this.btnLoading = true;
- if (this.confirmDelType === "del") {
- //删除
- this.mainService
- .simplePost("rmvData", "pathologyPackInfo", [this.coopData.id])
- .subscribe((data) => {
- this.btnLoading = false;
- this.delModal = false;
- if (data.status == 200) {
- this.showPromptModal(this.tipsMsg2, true, "");
- } else {
- this.showPromptModal(this.tipsMsg2, false, data.msg);
- }
- });
- }
- }
- }
|