seimin месяцев назад: 5
Родитель
Сommit
2707e3f2e5

+ 3 - 3
src/app/components/configurationCenter/configuration-category/configuration-category.component.html

@@ -194,7 +194,7 @@
194 194
           <nz-form-label nzFor="category1" nzRequired [nzSpan]="6">一级故障现象</nz-form-label>
195 195
           <nz-form-control [nzSpan]="24" nzErrorTip="请选择一级故障现象!">
196 196
 						<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzPlaceHolder="请选择一级故障现象" formControlName="category1" (ngModelChange)="changeOneCategory($event)">
197
-						  <ng-container *ngFor="let option of categoryList1">
197
+						  <ng-container *ngFor="let option of categoryListP1">
198 198
 						    <nz-option *ngIf="!isLoading" [nzLabel]="option.category" [nzValue]="option.id"></nz-option>
199 199
 						  </ng-container>
200 200
 						  <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
@@ -204,10 +204,10 @@
204 204
           </nz-form-control>
205 205
         </nz-form-item>
206 206
         <nz-form-item *ngIf="!add && coopType === 3">
207
-          <nz-form-label nzFor="category2" nzRequired [nzSpan]="6">二级故障现象</nz-form-label>
207
+          <nz-form-label nzFor="category2" nzRequired [nzSpan]="6">{{activeCategory2.id}}二级故障现象</nz-form-label>
208 208
           <nz-form-control [nzSpan]="24" nzErrorTip="请选择二级故障现象!">
209 209
 						<nz-select class="formItem" [nzDropdownMatchSelectWidth]="false" nzPlaceHolder="请选择二级故障现象" formControlName="category2">
210
-						  <ng-container *ngFor="let option of categoryList2">
210
+						  <ng-container *ngFor="let option of categoryListP2">
211 211
 						    <nz-option *ngIf="!isLoading" [nzLabel]="option.category" [nzValue]="option.id"></nz-option>
212 212
 						  </ng-container>
213 213
 						  <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>

+ 31 - 5
src/app/components/configurationCenter/configuration-category/configuration-category.component.ts

@@ -6,6 +6,7 @@ import { MainService } from "../../../services/main.service";
6 6
 import { Validators, FormGroup, FormBuilder } from '@angular/forms';
7 7
 import { ToolService } from 'src/app/services/tool.service';
8 8
 import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
9
+import cloneDeep from 'lodash-es/cloneDeep'
9 10
 
10 11
 @Component({
11 12
   selector: "app-configuration-category",
@@ -363,6 +364,7 @@ export class ConfigurationCategoryComponent implements OnInit {
363 364
     this.mainService.incidentPost("listIncidentCategory", postData).subscribe(res => {
364 365
       this['categoryLoading' + type] = false;
365 366
       this['categoryList' + type] = res.data || [];
367
+      this['categoryListP' + type] = cloneDeep(this['categoryList' + type]);
366 368
       if(isEdit){
367 369
         this['activeCategory' + type] = this['categoryList' + type].find(v => v.id == this['activeCategory' + type].id);
368 370
       }
@@ -373,6 +375,25 @@ export class ConfigurationCategoryComponent implements OnInit {
373 375
     })
374 376
   }
375 377
 
378
+  // 弹窗-故障现象查询
379
+  categoryListP1: any[] = [];
380
+  categoryListP2: any[] = [];
381
+  categoryListP3: any[] = [];
382
+  getCategoryListP(type:number, parentId = 0) {
383
+    this.isLoading = true;
384
+    let postData = {
385
+      category: {
386
+        hierarchy: type === 1 ? 1 : undefined,
387
+        dutyIds: this.hospitalConfig === 1 ? this.currentHospital.id.toString()  : undefined,
388
+        parent: type === 1 ? undefined : { id: parentId },
389
+      },
390
+    };
391
+    this.mainService.incidentPost("listIncidentCategory", postData).subscribe(res => {
392
+      this.isLoading = false;
393
+      this['categoryListP' + type] = res.data || [];
394
+    })
395
+  }
396
+
376 397
   // 新增故障现象弹框
377 398
   modelName = ""; //模态框名称
378 399
   add: boolean; //true:新增;false:编辑
@@ -431,8 +452,11 @@ export class ConfigurationCategoryComponent implements OnInit {
431 452
 
432 453
     this.validateCategoryForm.controls.name.setValue(data.category);
433 454
     if(type === 2){
455
+      this.categoryListP1 = cloneDeep(this.categoryList1);
434 456
       this.validateCategoryForm.controls.category1.setValue(this.activeCategory1.id);
435 457
     }else if(type === 3){
458
+      this.categoryListP1 = cloneDeep(this.categoryList1);
459
+      this.categoryListP2 = cloneDeep(this.categoryList2);
436 460
       this.validateCategoryForm.controls.category1.setValue(this.activeCategory1.id);
437 461
       this.validateCategoryForm.controls.category2.setValue(this.activeCategory2.id);
438 462
     }
@@ -480,13 +504,15 @@ export class ConfigurationCategoryComponent implements OnInit {
480 504
       console.log(this['activeCategory' + this.coopType])
481 505
       //编辑
482 506
       let postData = {
483
-        ...this.coopData,
484
-        parent: this.coopType === 1 ? undefined : (this.coopType === 2 ? { id: this.validateCategoryForm.value.category1 } : { id: this.validateCategoryForm.value.category2 }),
485
-        category: this.validateCategoryForm.value.name,
507
+        incidentCategory: {
508
+          ...this.coopData,
509
+          parent: this.coopType === 1 ? undefined : (this.coopType === 2 ? { id: this.validateCategoryForm.value.category1 } : { id: this.validateCategoryForm.value.category2 }),
510
+          category: this.validateCategoryForm.value.name,
511
+        }
486 512
       };
487 513
       console.log(postData);
488 514
       this.mainService
489
-        .simplePost("addData", "incidentCategory", postData)
515
+        .coopData("updData", "incidentCategory", postData)
490 516
         .subscribe((result) => {
491 517
           this.btnLoading = false;
492 518
           this.hideCategoryModal();
@@ -760,7 +786,7 @@ export class ConfigurationCategoryComponent implements OnInit {
760 786
   // 修改故障现象
761 787
   changeOneCategory(id){
762 788
     this.validateCategoryForm.controls.category2.setValue(null);
763
-    this.getCategoryList(2, id);
789
+    this.getCategoryListP(2, id);
764 790
   }
765 791
 
766 792
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)