fengxiang
2018-01-10 3517e796f650b8aed52165c1a5905456f54033ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { DatePipe } from '@angular/common/src/pipes/date_pipe';
import { Types } from './../enum/types.enum';
 
import { Pipe, PipeTransform } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { NzDatePipe } from 'ng-zorro-antd/src/util/nz-date.pipe';
import { DateService } from '@business/services/util/date.service';
import { Column } from '@business/entity/grid';
 
 
 
@Pipe({
  name: 'tyepHandle'
})
export class TyepHandlePipe implements PipeTransform {
  constructor(private dateService: DateService) {
  }
 
  transform(value: any, col?: Column, row?: any ): any {
       const t = Types.Date;
       const type  = col.type;
       if ( value != null && value !== '' && type != null && type.name != null) {
         value = this.transformHandle(value, type.name, type.format);
       }
       if (col.format !== null && col.format instanceof Function ) {
            value = col.format(value, col, row);
       }
       return value;
  }
  private transformHandle(value: any, type: Types, format: any): any {
        switch (type) {
           case Types.Date:
           return this.dateService.date_format(value, format);
        }
  }
}