|
@@ -349,7 +349,7 @@ export class ConfigurationCategoryComponent implements OnInit {
|
349
|
349
|
categoryLoading1:boolean = false;
|
350
|
350
|
categoryLoading2:boolean = false;
|
351
|
351
|
categoryLoading3:boolean = false;
|
352
|
|
- getCategoryList(type:number, parentId = 0) {
|
|
352
|
+ getCategoryList(type:number, parentId = 0, isEdit = false, isOnly = false) {
|
353
|
353
|
setTimeout(() => {
|
354
|
354
|
this['categoryLoading' + type] = true;
|
355
|
355
|
}, 0)
|
|
@@ -363,6 +363,13 @@ export class ConfigurationCategoryComponent implements OnInit {
|
363
|
363
|
this.mainService.incidentPost("listIncidentCategory", postData).subscribe(res => {
|
364
|
364
|
this['categoryLoading' + type] = false;
|
365
|
365
|
this['categoryList' + type] = res.data || [];
|
|
366
|
+ if(isEdit){
|
|
367
|
+ this['activeCategory' + type] = this['categoryList' + type].find(v => v.id == this['activeCategory' + type].id);
|
|
368
|
+ }
|
|
369
|
+
|
|
370
|
+ if(isOnly){
|
|
371
|
+ this['activeCategory' + type] = this['categoryList' + type].find(v => v.id == this.validateCategoryForm.value['category' + type]);
|
|
372
|
+ }
|
366
|
373
|
})
|
367
|
374
|
}
|
368
|
375
|
|
|
@@ -385,23 +392,51 @@ export class ConfigurationCategoryComponent implements OnInit {
|
385
|
392
|
|
386
|
393
|
// 初始化新增form表单
|
387
|
394
|
validateCategoryForm: FormGroup; //新增/编辑表单
|
388
|
|
- initCategoryForm() {
|
389
|
|
- this.validateCategoryForm = this.fb.group({
|
390
|
|
- name: [null, [Validators.required]],//名称
|
391
|
|
- });
|
|
395
|
+ initCategoryForm(isEdit = false) {
|
|
396
|
+ if(isEdit){
|
|
397
|
+ if(this.coopType === 1){
|
|
398
|
+ this.validateCategoryForm = this.fb.group({
|
|
399
|
+ name: [null, [Validators.required]],//名称
|
|
400
|
+ });
|
|
401
|
+ }else if(this.coopType === 2){
|
|
402
|
+ this.validateCategoryForm = this.fb.group({
|
|
403
|
+ category1: [null, [Validators.required]],//一级故障现象
|
|
404
|
+ name: [null, [Validators.required]],//名称
|
|
405
|
+ });
|
|
406
|
+ }else if(this.coopType === 3){
|
|
407
|
+ this.validateCategoryForm = this.fb.group({
|
|
408
|
+ category1: [null, [Validators.required]],//一级故障现象
|
|
409
|
+ category2: [null, [Validators.required]],//二级故障现象
|
|
410
|
+ name: [null, [Validators.required]],//名称
|
|
411
|
+ });
|
|
412
|
+ }
|
|
413
|
+ }else{
|
|
414
|
+ this.validateCategoryForm = this.fb.group({
|
|
415
|
+ name: [null, [Validators.required]],//名称
|
|
416
|
+ });
|
|
417
|
+ }
|
|
418
|
+
|
392
|
419
|
console.log(this.validateCategoryForm.controls)
|
393
|
420
|
}
|
394
|
421
|
|
395
|
422
|
// 编辑
|
396
|
|
- // editCategory(data) {
|
397
|
|
- // console.log(data);
|
398
|
|
- // this.modelName = "编辑";
|
399
|
|
- // this.add = false;
|
400
|
|
- // this.modalCategory = true;
|
401
|
|
- // this.initCategoryForm();
|
402
|
|
- // this.coopData = data;
|
403
|
|
- // this.validateCategoryForm.controls.name.setValue(data.name);
|
404
|
|
- // }
|
|
423
|
+ editCategory(type, data) {
|
|
424
|
+ console.log(data);
|
|
425
|
+ this.coopType = type;
|
|
426
|
+ this.modelName = "编辑";
|
|
427
|
+ this.add = false;
|
|
428
|
+ this.modalCategory = true;
|
|
429
|
+ this.initCategoryForm(true);
|
|
430
|
+ this.coopData = data;
|
|
431
|
+
|
|
432
|
+ this.validateCategoryForm.controls.name.setValue(data.category);
|
|
433
|
+ if(type === 2){
|
|
434
|
+ this.validateCategoryForm.controls.category1.setValue(this.activeCategory1.id);
|
|
435
|
+ }else if(type === 3){
|
|
436
|
+ this.validateCategoryForm.controls.category1.setValue(this.activeCategory1.id);
|
|
437
|
+ this.validateCategoryForm.controls.category2.setValue(this.activeCategory2.id);
|
|
438
|
+ }
|
|
439
|
+ }
|
405
|
440
|
|
406
|
441
|
// 新增/编辑表单提交
|
407
|
442
|
btnLoading: boolean = false; //提交按钮loading状态
|
|
@@ -416,34 +451,52 @@ export class ConfigurationCategoryComponent implements OnInit {
|
416
|
451
|
console.log(this.validateCategoryForm.value);
|
417
|
452
|
this.btnLoading = true;
|
418
|
453
|
// -----------------------------------
|
419
|
|
- let postData:any = {
|
420
|
|
- category: {
|
421
|
|
- hosId: this.currentHospital.id,
|
422
|
|
- parent: this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)],
|
|
454
|
+ if(this.add){
|
|
455
|
+ // 新增
|
|
456
|
+ let postData:any = {
|
|
457
|
+ category: {
|
|
458
|
+ hosId: this.currentHospital.id,
|
|
459
|
+ parent: this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)],
|
|
460
|
+ category: this.validateCategoryForm.value.name,
|
|
461
|
+ hierarchy: this.coopType,
|
|
462
|
+ dutyIds: this.hospitalConfig === 1 ? this.currentHospital.id.toString() : undefined,
|
|
463
|
+ },
|
|
464
|
+ };
|
|
465
|
+ this.mainService
|
|
466
|
+ .incidentPost("checkIncidentCategory", postData)
|
|
467
|
+ .subscribe((result) => {
|
|
468
|
+ if (result.status == 200) {
|
|
469
|
+ this.submitCategoryAddForm();
|
|
470
|
+ } else if(result.status == 502) {
|
|
471
|
+ this.btnLoading = false;
|
|
472
|
+ this.showDelModal(null, result.msg, '', 'relevance');
|
|
473
|
+ } else {
|
|
474
|
+ this.btnLoading = false;
|
|
475
|
+ this.showPromptModal('新增', false, result.msg);
|
|
476
|
+ }
|
|
477
|
+ });
|
|
478
|
+ }else{
|
|
479
|
+ // 编辑
|
|
480
|
+ console.log(this['activeCategory' + this.coopType])
|
|
481
|
+ //编辑
|
|
482
|
+ let postData = {
|
|
483
|
+ ...this.coopData,
|
|
484
|
+ parent: this.coopType === 1 ? undefined : (this.coopType === 2 ? { id: this.validateCategoryForm.value.category1 } : { id: this.validateCategoryForm.value.category2 }),
|
423
|
485
|
category: this.validateCategoryForm.value.name,
|
424
|
|
- hierarchy: this.coopType,
|
425
|
|
- dutyIds: this.hospitalConfig === 1 ? this.currentHospital.id.toString() : undefined,
|
426
|
|
- },
|
427
|
|
- };
|
428
|
|
- this.mainService
|
429
|
|
- .incidentPost("checkIncidentCategory", postData)
|
430
|
|
- .subscribe((result) => {
|
431
|
|
- let msg = "";
|
432
|
|
- if (this.add) {
|
433
|
|
- msg = "新增";
|
434
|
|
- } else {
|
435
|
|
- msg = "修改";
|
436
|
|
- }
|
437
|
|
- if (result.status == 200) {
|
438
|
|
- this.submitCategoryAddForm();
|
439
|
|
- } else if(result.status == 502) {
|
440
|
|
- this.btnLoading = false;
|
441
|
|
- this.showDelModal(null, result.msg, '', 'relevance');
|
442
|
|
- } else {
|
|
486
|
+ };
|
|
487
|
+ console.log(postData);
|
|
488
|
+ this.mainService
|
|
489
|
+ .simplePost("addData", "incidentCategory", postData)
|
|
490
|
+ .subscribe((result) => {
|
443
|
491
|
this.btnLoading = false;
|
444
|
|
- this.showPromptModal(msg, false, result.msg);
|
445
|
|
- }
|
446
|
|
- });
|
|
492
|
+ this.hideCategoryModal();
|
|
493
|
+ if (result.status == 200) {
|
|
494
|
+ this.showPromptModal('编辑', true, '');
|
|
495
|
+ } else {
|
|
496
|
+ this.showPromptModal('编辑', false, result.msg);
|
|
497
|
+ }
|
|
498
|
+ });
|
|
499
|
+ }
|
447
|
500
|
// -----------------------------------
|
448
|
501
|
}
|
449
|
502
|
|
|
@@ -704,6 +757,12 @@ export class ConfigurationCategoryComponent implements OnInit {
|
704
|
757
|
this.validateConfigForm.get(name)!.updateValueAndValidity();
|
705
|
758
|
}
|
706
|
759
|
|
|
760
|
+ // 修改故障现象
|
|
761
|
+ changeOneCategory(id){
|
|
762
|
+ this.validateCategoryForm.controls.category2.setValue(null);
|
|
763
|
+ this.getCategoryList(2, id);
|
|
764
|
+ }
|
|
765
|
+
|
707
|
766
|
// 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
708
|
767
|
promptContent: string; //操作提示框提示信息
|
709
|
768
|
ifSuccess: boolean; //操作成功/失败
|
|
@@ -717,13 +776,28 @@ export class ConfigurationCategoryComponent implements OnInit {
|
717
|
776
|
setTimeout(() => {
|
718
|
777
|
this.promptModalShow = true;
|
719
|
778
|
}, 100);
|
720
|
|
- if(this.coopType !== 0){
|
721
|
|
- this.getCategoryList(this.coopType, this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)].id);
|
|
779
|
+ if(con === '编辑'){
|
|
780
|
+ if(success){
|
|
781
|
+ if(this.coopType === 1){
|
|
782
|
+ this.getCategoryList(1, 0, true);
|
|
783
|
+ }else if(this.coopType === 2){
|
|
784
|
+ this.getCategoryList(1, 0, false, true);
|
|
785
|
+ this.getCategoryList(2, this.validateCategoryForm.value.category1, true);
|
|
786
|
+ }else if(this.coopType === 3){
|
|
787
|
+ this.getCategoryList(1, 0, false, true);
|
|
788
|
+ this.getCategoryList(2, this.validateCategoryForm.value.category1, false, true);
|
|
789
|
+ this.getCategoryList(3, this.validateCategoryForm.value.category2, true);
|
|
790
|
+ }
|
|
791
|
+ }
|
722
|
792
|
}else{
|
723
|
|
- this.getCategoryList(this.currentCategoryIndex, this.currentCategoryIndex === 1 ? undefined : this['activeCategory' + (this.currentCategoryIndex - 1)].id);
|
724
|
|
- }
|
725
|
|
- if(this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id){
|
726
|
|
- this.getCategoryConfigList(this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id);
|
|
793
|
+ if(this.coopType !== 0){
|
|
794
|
+ this.getCategoryList(this.coopType, this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)].id);
|
|
795
|
+ }else{
|
|
796
|
+ this.getCategoryList(this.currentCategoryIndex, this.currentCategoryIndex === 1 ? undefined : this['activeCategory' + (this.currentCategoryIndex - 1)].id);
|
|
797
|
+ }
|
|
798
|
+ if(this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id){
|
|
799
|
+ this.getCategoryConfigList(this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id);
|
|
800
|
+ }
|
727
|
801
|
}
|
728
|
802
|
}
|
729
|
803
|
}
|