fengxiang
2018-06-25 27cd36be226ca2434f06b1ae9e4d43f1fea639ab
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
44
45
46
47
48
49
50
51
import { Organization, AlarmConfig, OrganizationSensorUnit, SensorUnit } 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'|'unit'|'screen' = 'list';
  config: {pageBean?: PageBean, resultBean?: ResultBean<AlarmConfig|any>} = {};
  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);
  }
  public getResultBeanData(key: string) {
        if (!!this.config.resultBean 
          && !!this.config.resultBean.code 
          && !!this.config.resultBean.data) {
          return this.config.resultBean.data[key];
       }
       return null;
  }
}