From 27bd4a08bf807f4f6132bb524da33490b6d22f87 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Tue, 19 Jun 2018 11:45:11 +0800
Subject: [PATCH] 省市区兼容旧版本
---
src/app/business/services/util/tools.service.ts | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/app/business/services/util/tools.service.ts b/src/app/business/services/util/tools.service.ts
index affe82f..243051f 100644
--- a/src/app/business/services/util/tools.service.ts
+++ b/src/app/business/services/util/tools.service.ts
@@ -3,29 +3,38 @@
@Injectable()
export class ToolsService {
- public static markAsDirty(controlSet:FormGroup|FormArray){
+ public static markAsDirty(controlSet: FormGroup|FormArray) {
const controls = controlSet.controls;
Object.values(controls).forEach(
- (control:AbstractControl) => {
- if(control instanceof FormGroup || control instanceof FormArray){
+ (control: AbstractControl) => {
+ if (control instanceof FormGroup || control instanceof FormArray) {
ToolsService.markAsDirty(control);
- }else{
+ } else {
control.markAsDirty();
}
}
- )
+ );
}
- public static removePrivate(obj:object){
+ public static removePrivate(obj: object) {
Object.keys(obj).forEach(
- (key:string) => {
- if(key.startsWith('_')){
+ (key: string) => {
+ if (key.startsWith('_')) {
delete obj[key];
- }else{
- if(obj[key] instanceof Object){
+ } else {
+ if (obj[key] instanceof Object) {
ToolsService.removePrivate(obj[key]);
}
}
}
);
}
+ 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;
+ }
}
--
Gitblit v1.8.0