From c83b053ccb952e95fad848c914126cbfadce5d26 Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Tue, 12 Jun 2018 08:50:04 +0800 Subject: [PATCH] 报表查询 增加镇村选项 --- src/app/business/services/util/tools.service.ts | 36 +++++++++++++++++++++++++++++++++++- 1 files changed, 35 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..825acf1 100644 --- a/src/app/business/services/util/tools.service.ts +++ b/src/app/business/services/util/tools.service.ts @@ -1,6 +1,40 @@ +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]); + } + } + } + ); + } + public static toThousands(num: string): string { + var num = (num || 0).toString(), result = ''; + while (num.length > 3) { + result = ',' + num.slice(-3) + result; + num = num.slice(0, num.length - 3); + } + if (num) { result = num + result; } + return result; + } } -- Gitblit v1.8.0