From 309d1f9d649daa08bb9b068af014749f6d4a5bce Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 06 Jul 2018 14:00:45 +0800 Subject: [PATCH] 设备和监控点父页面 筛选条件不予 编辑页面联动 --- src/app/business/services/util/tools.service.ts | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/app/business/services/util/tools.service.ts b/src/app/business/services/util/tools.service.ts index 3facff7..3841b8f 100644 --- a/src/app/business/services/util/tools.service.ts +++ b/src/app/business/services/util/tools.service.ts @@ -15,6 +15,13 @@ } ); } + public static getValueFormControl(controlSet: FormGroup, name: string) { + return controlSet.controls[name].value; + } + public static setValueToControl(controlSet: FormGroup, name: string, value: any) { + controlSet.controls[name].setValue(value); + controlSet.controls[name].updateValueAndValidity(); + } public static removePrivate(obj: object) { Object.keys(obj).forEach( (key: string) => { @@ -28,4 +35,16 @@ } ); } + public static toThousands(number: string): string { + let num = (number || 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; + } + public static getObjById<T>(id: number, list: T[]): T { + return list.find(item => item['id'] === id); + } } -- Gitblit v1.8.0