123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- import { Component, OnInit } from "@angular/core";
- import { MainService } from "../../../services/main.service";
- import { ToolService } from 'src/app/services/tool.service';
- import { NzMessageService } from 'ng-zorro-antd';
- import { Subject } from 'rxjs';
- import { debounceTime } from 'rxjs/operators';
- @Component({
- selector: "app-configuration-specimen",
- templateUrl: "./configuration-specimen.component.html",
- styleUrls: ["./configuration-specimen.component.less"],
- })
- export class ConfigurationSpecimenComponent implements OnInit {
- loading:boolean = false; //页面加载的loading
- btnLoading:boolean = false; //提交按钮的loading
- tabModalName:string = 'characteristics'; //当前选中的tab
- hosId = this.tool.getCurrentHospital().id; //当前院区
- // 扫描时指定科室不提醒勾选项
- deptNotAlert:any[] = [
- {label:'是否开启',value: 0}
- ];
- // 收取时需扫描二维码
- arriveScanCode:any[] = [
- {label:'是否开启',value: 0}
- ];
- // 必须扫描动态二维码
- arriveScanDynamicCode:any[] = [
- {label:'是否开启',value: 0}
- ];
- // 配置
- configs:any = {};
- // 任务类型
- tasktype:any = {};
- searchTimerSubject = new Subject();
- constructor(private mainService: MainService,private tool: ToolService,private msg: NzMessageService) {}
- ngOnInit():void {
- // todo
- this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
- let fun = v[0];
- fun.call(this, v[1]);
- });
- this.getDeptList();
- this.getTaskType();
- }
- // 扫描时指定科室不提醒勾选项
- changeDeptNotAlert(e){
- console.log(e);
- if(!e[0].checked){
- this.deptNotAlertIds = [];
- }
- }
- // 收取时需扫描二维码
- changeArriveScanCode(e){
- console.log(e);
- if(!e[0].checked){
- this.arriveScanDynamicCode[0].checked = false;
- }
- }
- // 用户输入搜索
- isLoading: boolean = false;
- deptNotAlertIds:any[] = [];
- deptList:any[] = [];
- changeDept(e) {
- this.searchTimer(this.getDeptList, e);
- }
- // 边输入边搜索节流阀
- searchTimer(fun, e) {
- this.isLoading = true;
- this.searchTimerSubject.next([fun, e]);
- }
- openDeptList(flag){
- if(flag){
- this.getDeptList();
- }
- }
- //获取科室列表
- getDeptList(e:string = '') {
- let postData:any = {
- idx: 0,
- sum: 20,
- department: {
- searchType: 1,// 简单查询
- hospital: { id: this.hosId },
- dept: e,
- }
- };
- this.isLoading = true;
- this.mainService.getFetchDataList("simple/data", "department", postData)
- .subscribe((result) => {
- this.isLoading = false;
- if (result.status == 200) {
- this.deptList = result.list || [];
- }
- });
- }
- // 切换tab
- tabModal(tabModalName:string){
- this.tabModalName = tabModalName;
- }
- // 保存
- submitForm() {
- if(!this.tasktype.id){
- this.msg.create("warning", "请先配置患者陪检任务类型!");
- return;
- }
- if(this.deptNotAlert[0].checked && !this.deptNotAlertIds.length){
- this.msg.create("warning", "请选择科室!");
- return;
- }
- let postData:any = {
- id: this.configs.id,
- taskType: this.tasktype.id,
- hosId: this.hosId,
- deptNotAlert: this.deptNotAlert[0].checked ? 1 : 0,
- arriveScanCode: this.arriveScanCode[0].checked ? 1 : 0,
- arriveScanDynamicCode: this.arriveScanDynamicCode[0].checked ? 1 : 0,
- deptNotAlertIds: this.deptNotAlertIds.length ? this.deptNotAlertIds.toString() : undefined,
- };
- this.btnLoading = true;
- this.mainService
- .simplePost("addData", "taskTypeConfig", postData)
- .subscribe((result) => {
- this.btnLoading = false;
- if (result.status == 200) {
- this.getConfig();
- }
- });
- }
- //获取任务类型
- getTaskType() {
- let postData = {
- idx: 0,
- sum: 10,
- taskType: {
- simpleQuery: true,
- hosId: {
- id: this.hosId
- },
- associationType: {
- key:"association_types",
- value: 'specimen'
- }
- }
- };
- this.mainService
- .getFetchDataList("simple/data", "taskType", postData)
- .subscribe((result) => {
- if (result.status == 200) {
- this.tasktype = result.list[0] || {};
- this.getConfig();
- }
- });
- }
- // 获取配置
- getConfig() {
- this.loading = true;
- let postData = {
- idx: 0,
- sum: 10,
- taskTypeConfig: {
- taskTypeDTO: {
- hosId: {
- id: this.hosId
- },
- associationType: this.tasktype.associationType
- }
- }
- };
- this.mainService
- .getFetchDataList("simple/data", "taskTypeConfig", postData)
- .subscribe((result) => {
- this.loading = false;
- if (result.status == 200) {
- this.configs = result.list[0] || {};
- this.deptNotAlert[0].checked = this.configs.deptNotAlert == 1;
- this.arriveScanCode[0].checked = this.configs.arriveScanCode == 1;
- this.arriveScanDynamicCode[0].checked = this.configs.arriveScanDynamicCode == 1;
- this.deptNotAlertIds = this.configs.deptNotAlertIds ? this.configs.deptNotAlertIds.split(',').map(v => +v) : [];
- this.deptList = this.configs.deptNotAlertList || [];
- }
- });
- }
- }
|