fengxiang
2018-01-25 8570af7c6051c3d9a516f39d597ff49e1e1e2840
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
37
38
39
40
41
42
43
import { Organization, AlarmConfig } from '@business/entity/data';
import { ExampleService } from '@business/services/util/example.service';
import { _HttpClient } from '@delon/theme';
import { environment } from 'environments/environment';
import { RouteConfigLoadStart } from '@angular/router';
import { Injectable } from '@angular/core';
import { equal } from 'assert';
import { Observable } from 'rxjs/Observable';
import {  PageBean, ResultBean } from '@business/entity/grid';
 
 
@Injectable()
export class OrganizationService {
  handle: 'list'|'config' = 'list';
  config: {pageBean: PageBean,resultBean: ResultBean<AlarmConfig>};
  data: Organization;
  title: '组织列表'|'组织配置' = '组织列表';
  private urls = {
      list: environment.SERVER_BASH_URL + '/organization/page-list',
      save: environment.SERVER_BASH_URL + '/organization/add-or-modify',
      delete: environment.SERVER_BASH_URL + '/organization/delete-by-ids'
  };
  constructor(private http: _HttpClient) { }
   public getPagingList(page: PageBean, queryText: string): Observable<PageBean> {
    const example = new ExampleService();
    if (queryText != null && queryText !== '') {
      example.or().andLike({name: 'name', value: '%' + queryText + '%'});
    }
    let orderByClause = '';
    if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) {
      orderByClause = page.getOrderByClause();
    }
    const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, 
        queryParams: example.getSqlParam(), orderByClause: orderByClause};
        return this.http.get(this.urls.list, param);
  }
  public save(data: any): Observable<any> {
        return this.http.post(this.urls.save, data);
  }
  public delete(...ids: number[]): Observable<any> {             
        return this.http.post(this.urls.delete, ids);
  }
}