| | |
| | | import { CoorPicker, Device } from '@business/entity/data'; |
| | | import { AdjustConfigComponent } from './adjust-config/adjust-config.component'; |
| | | import { DeviceEditComponent } from './device-edit/device-edit.component'; |
| | | import { ModalHelper } from '@delon/theme'; |
| | | import { ModalHelper, _HttpClient } from '@delon/theme'; |
| | | import { NzModalService, NzMessageService } from 'ng-zorro-antd'; |
| | | import { PageBean, ResultBean } from '@business/entity/grid'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; |
| | | import { SimpleTableColumn } from '@delon/abc'; |
| | | import { SimpleTableColumn, SimpleTableComponent } from '@delon/abc'; |
| | | import { Subject } from 'rxjs/Subject'; |
| | | import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component'; |
| | | import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; |
| | | import { OrganizationService } from '@business/services/http/organization.service'; |
| | | import { ExampleService } from '@business/services/util/example.service'; |
| | | import { ExampleService, Criteria } from '@business/services/util/example.service'; |
| | | |
| | | @Component({ |
| | | selector: 'app-basic-info', |
| | |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private coorPickerService: CoorPickerService, |
| | | private organizationService: OrganizationService |
| | | private organizationService: OrganizationService, |
| | | private http: _HttpClient |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | |
| | | }); |
| | | } |
| | | load() { |
| | | this.extraParams.queryParams = this.deviceService.getSqlParams(this.queryMap); |
| | | const example = this.initQueryExample(); |
| | | this.extraParams.queryParams = example.getSqlParam(); |
| | | this.selectedRows = []; |
| | | this.simpleTable.load(); |
| | | this.deviceService.countByExample(example).subscribe( |
| | | res => { |
| | | if (!!res && !!res.code) { |
| | | setTimeout(() => { |
| | | const count = res.data; |
| | | const pages = Math.ceil(count / this.simpleTable.ps); |
| | | const pi = this.simpleTable.pi > pages ? pages : this.simpleTable.pi; |
| | | this.simpleTable.load(pi); |
| | | }, 1); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | } |
| | | private initQueryExample() { |
| | | const example = new ExampleService(); |
| | | const orgId = !!this.queryMap.orgId ? this.queryMap.orgId : null; |
| | | const mpointId = !!this.queryMap.mpointId ? this.queryMap.mpointId : null; |
| | | const devMacOrName = !!this.queryMap.devMacOrName && !!(<string>this.queryMap.devMacOrName).trim() ? this.queryMap.devMacOrName : null; |
| | | let criWithMac: Criteria = null; |
| | | let criWithName: Criteria = null; |
| | | if (!!devMacOrName) { |
| | | criWithName = example.or().andLike({name: 'name', value: '%' + devMacOrName + '%'}); |
| | | criWithMac = example.or().andLike({name: 'mac', value: '%' + devMacOrName + '%'}); |
| | | } |
| | | if (!!mpointId) { |
| | | if (!!devMacOrName) { |
| | | criWithName.andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | criWithMac.andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | }else { |
| | | example.or().andEqualTo({name: 'monitorPointId', value: mpointId}); |
| | | } |
| | | } else if (!!orgId) { |
| | | if (!!devMacOrName) { |
| | | criWithName.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | criWithMac.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | }else { |
| | | example.or().andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`); |
| | | } |
| | | } |
| | | return example; |
| | | } |
| | | delete(...id: number[]) { |
| | | this.deviceService.delete(...id).subscribe( |
| | |
| | | } |
| | | ); |
| | | } |
| | | @ViewChild('simpleTable') simpleTable: { load: Function }; |
| | | @ViewChild('simpleTable') simpleTable: SimpleTableComponent; |
| | | queryTextChanged(event) { |
| | | this.queryTextStream.next(this.queryText); |
| | | } |