From 0d8b1828eea6bb027bbf71ddcd9c28a7bcf0ca3b Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Fri, 26 Jan 2018 14:38:12 +0800
Subject: [PATCH] 组织配置

---
 src/app/business/services/util/tools.service.ts |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/src/app/business/services/util/tools.service.ts b/src/app/business/services/util/tools.service.ts
index b2eb6f8..affe82f 100644
--- a/src/app/business/services/util/tools.service.ts
+++ b/src/app/business/services/util/tools.service.ts
@@ -1,6 +1,31 @@
+import { FormGroup, FormArray, AbstractControl } from '@angular/forms';
 import { Injectable } from '@angular/core';
 
 @Injectable()
 export class ToolsService {
-
+      public static markAsDirty(controlSet:FormGroup|FormArray){
+         const controls = controlSet.controls;
+         Object.values(controls).forEach(
+             (control:AbstractControl) => {
+                    if(control instanceof FormGroup || control instanceof FormArray){
+                        ToolsService.markAsDirty(control);
+                    }else{
+                          control.markAsDirty();
+                    }
+             }
+         )
+      }
+      public static removePrivate(obj:object){
+            Object.keys(obj).forEach(
+                 (key:string) => {
+                        if(key.startsWith('_')){
+                            delete obj[key];
+                        }else{
+                            if(obj[key] instanceof Object){
+                                ToolsService.removePrivate(obj[key]);
+                            }
+                        }
+                 }
+                );
+      }
 }

--
Gitblit v1.8.0