| | |
| | | import { Injectable } from '@angular/core'; |
| | | import { ResultBean, PageBean } from '@business/entity/grid'; |
| | | import { Observable } from 'rxjs/Observable'; |
| | | import { ExampleService } from '@business/services/util/example.service'; |
| | | import { ExampleService, Criteria } from '@business/services/util/example.service'; |
| | | import { Device } from '@business/entity/data'; |
| | | |
| | | @Injectable() |
| | |
| | | public getListUrl () { |
| | | return this.urls.list; |
| | | } |
| | | public getSqlParams(queryText: string) { |
| | | public getSqlParams(queryMap: {[key: string]: number|string}) { |
| | | const example = new ExampleService(); |
| | | if (queryText != null && queryText !== '') { |
| | | example.or().andLike({name: 'name', value: '%' + queryText + '%'}); |
| | | example.or().andLike({name: 'mac', value: '%' + queryText + '%'}); |
| | | const orgId = !!queryMap.orgId ? queryMap.orgId : null; |
| | | const mpointId = !!queryMap.mpointId ? queryMap.mpointId : null; |
| | | const devMacOrName = !!queryMap.devMacOrName && !!(<string>queryMap.devMacOrName).trim() ? 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.getSqlParam(); |
| | | } |
| | |
| | | }; |
| | | constructor(private http: _HttpClient) { } |
| | | public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { |
| | | queryText = !!queryText && !!queryText.trim() ? queryText : null; |
| | | const example = new ExampleService(); |
| | | if (queryText != null && queryText !== '') { |
| | | example.or().andLike({name: 'name', value: '%' + queryText + '%'}); |
| | |
| | | return this.conditions; |
| | | } |
| | | |
| | | public addCondition(condition: string, colName: string, ...values: any[]) { |
| | | private addCondition(condition: string, colName: string, ...values: any[]) { |
| | | const split = Criteria.CONDITION_SPLIT; // '||' |
| | | this.conditions.push(condition + split + colName + split + values.join(split)); |
| | | let conditionStr = condition + split + colName; |
| | | if (!!values && values.length > 0) { |
| | | conditionStr += split + values.join(split); |
| | | } |
| | | this.conditions.push(conditionStr); |
| | | } |
| | | public andCondition(condition: string) { |
| | | this.addCondition('andCondition', condition); |
| | | } |
| | | public andLike(col: { name: string, value: any}): Criteria { |
| | | this.addCondition('andLike', col.name, col.value); |
| | |
| | | return encodeURI(whereSql); |
| | | } |
| | | constructor() { } |
| | | public or() { |
| | | public or(): Criteria { |
| | | const cri = new Criteria(); |
| | | this.criterion.push(cri); |
| | | return cri; |
| | |
| | | if (num) { result = num + result; } |
| | | return result; |
| | | } |
| | | public static getObjById<T>(id: number, list: T[]): T { |
| | | return list.find(item => item['id'] === id); |
| | | } |
| | | } |
| | |
| | | </h1> |
| | | </div> |
| | | <nz-card [nzBordered]="false"> |
| | | <div class="mb-md"> |
| | | <div nz-row class="mb-sm"> |
| | | <div nz-col [nzSpan]="4"> |
| | | <button nz-button (click)="addOrModify($event)" [nzType]="'primary'" [nzSize]="'large'"> |
| | | <i class="anticon anticon-plus"></i><span>新建</span> |
| | | </button> |
| | | <ng-container *ngIf="selectedRows.length > 0"> |
| | | <ng-container *ngIf="selectedRows.length > 0"> |
| | | <button nz-button [nzSize]="'large'" (click)="deleteSelected()">批量删除</button> |
| | | </ng-container> |
| | | <nz-input [ngStyle]="{'width': '280px','float':'right'}" [(ngModel)]="queryText" name="" [nzPlaceHolder]="'请输入名称或mac'" |
| | | </div> |
| | | <div nz-col [nzSpan]="7"> |
| | | <span style="padding: 5px 10px;"> |
| | | 组织: |
| | | </span> |
| | | <nz-select style="width: 79%;" [(ngModel)]="queryMap.orgId" (ngModelChange)="setOrgId($event)" [nzPlaceHolder]="'选择 组织(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="orgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="7"> |
| | | <span style="padding: 5px 10px;"> |
| | | 监控站: |
| | | </span> |
| | | <nz-select style="width: 75%;" [(ngModel)]="queryMap.mpointId" (ngModelChange)="setMpointId($event)" [nzPlaceHolder]="'选择 监控站名称(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="monitorPointChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of monitorPoints" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="6"> |
| | | <nz-input [ngStyle]="{'width': '240px','float':'right'}" [(ngModel)]="queryText" name="" [nzPlaceHolder]="'请输入设备名称或设备mac'" |
| | | (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> |
| | | </div> |
| | | <div class="mb-md"> |
| | | <nz-alert *ngIf="selectedRows.length > 0" [nzType]="'info'" [nzShowIcon]="true"> |
| | | <span alert-body> |
| | | 已选择<strong class="text-primary">{{selectedRows.length}}</strong>项 |
| | | </span> |
| | | </nz-alert> |
| | | </div> |
| | | </div> |
| | | <div class="mb-md"> |
| | | <nz-alert *ngIf="selectedRows.length > 0" [nzType]="'info'" [nzShowIcon]="true"> |
| | | <span alert-body> |
| | | 已选择<strong class="text-primary">{{selectedRows.length}}</strong>项 |
| | | </span> |
| | | </nz-alert> |
| | | </div> |
| | | <simple-table #simpleTable [data]="listUrl" [extraParams]="extraParams" [columns]="columns" [showTotal]="true" |
| | | [reqReName]="{pi: 'pageIndex',ps: 'pageSize'}" (checkboxChange)="checkboxChange($event)" [ps]="10" [resReName]="{list: 'data',total: 'total'}"></simple-table> |
| | | </nz-card> |
| | |
| | | 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'; |
| | | |
| | | @Component({ |
| | | selector: 'app-basic-info', |
| | |
| | | } |
| | | ]; |
| | | queryTextStream: Subject<string> = new Subject<string>(); |
| | | private queryMap: {orgId?: number, mpointId?: number, devMacOrName?: string} |
| | | = {orgId: null, mpointId: null, devMacOrName: ''}; |
| | | extraParams = { queryParams: null }; |
| | | public orgOptions = []; |
| | | public monitorPoints = []; |
| | | constructor( |
| | | private monitorPointService: MonitorPointService, |
| | | private deviceService: DeviceService, |
| | | private confirmServ: NzModalService, |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private coorPickerService: CoorPickerService |
| | | private coorPickerService: CoorPickerService, |
| | | private organizationService: OrganizationService |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | |
| | | .debounceTime(900) |
| | | .distinctUntilChanged() |
| | | .subscribe(value => { |
| | | this.extraParams.queryParams = this.deviceService.getSqlParams(value); |
| | | this.queryMap.devMacOrName = value; |
| | | this.load(); |
| | | }); |
| | | this.orgSelectChange(); |
| | | } |
| | | get listUrl() { |
| | | return this.deviceService.getListUrl(); |
| | | } |
| | | extraParams = { queryParams: null }; |
| | | queryText: string; |
| | | selectedRows: any[] = []; |
| | | checkboxChange(list: any[]) { |
| | |
| | | }); |
| | | } |
| | | load() { |
| | | this.extraParams.queryParams = this.deviceService.getSqlParams(this.queryMap); |
| | | this.selectedRows = []; |
| | | this.simpleTable.load(); |
| | | } |
| | |
| | | if (d != null) { |
| | | Object.assign(data, d); |
| | | } |
| | | this.modalHelper.static(DeviceEditComponent, { data }).subscribe( |
| | | const configMap = this.queryMap; |
| | | // Object.assign(configMap, this.queryMap); |
| | | if (!!configMap['mpointId'] && !d['monitorPoint']) { |
| | | data['monitorPoint'] = this.getMonitorPoint(configMap['mpointId']); |
| | | } |
| | | this.modalHelper.static(DeviceEditComponent, { data, configMap }).subscribe( |
| | | (ret: { data: any, close: Function }) => { |
| | | // 修改状态 |
| | | if (ret.data['id'] != null) { |
| | |
| | | } |
| | | ); |
| | | }); |
| | | } |
| | | private getMonitorPoint(mpointId: number) { |
| | | return this.monitorPoints.find( |
| | | mpoint => mpoint.id === mpointId |
| | | ); |
| | | } |
| | | configCoord(record: Device): void { |
| | | // 复制数据放在此处,放在后面,adress会被覆盖 |
| | |
| | | } |
| | | ); |
| | | } |
| | | public setOrgId(orgId) { |
| | | this.queryMap.orgId = orgId; |
| | | this.queryMap.mpointId = null; |
| | | // this.queryMap.devMacOrName = null; |
| | | this.monitorPointChange(); |
| | | this.load(); |
| | | } |
| | | public setMpointId(mpointId) { |
| | | this.queryMap.mpointId = mpointId; |
| | | this.load(); |
| | | } |
| | | orgSelectChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.organizationService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.orgOptions = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | monitorPointChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | const example = new ExampleService(); |
| | | const organizationId = !!this.queryMap.orgId ? this.queryMap.orgId : null; |
| | | const mpointName = !!text ? '%' + text + '%' : null; |
| | | example.or() |
| | | .andEqualTo({name: 'organizationId', value: organizationId }) |
| | | .andLike({name: 'name', value: mpointName }); |
| | | this.monitorPointService.getPageByExample(pageBean, example).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.monitorPoints = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | } |
| | |
| | | </nz-input> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | <div class="modal-footer"> |
| | | <span style="padding: 5px 10px;"> |
| | | 组织: |
| | | </span> |
| | | <nz-select style="width: 240px;" [(ngModel)]="configMap.orgId" (ngModelChange)="setOrgId($event)" [nzPlaceHolder]="'选择 组织(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="orgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | |
| | | <button nz-button type="button" (click)="close()">关闭</button> |
| | | <button nz-button [nzType]="'primary'" [nzLoading]="isSaving"> |
| | | <span> |
| | |
| | | </span> |
| | | </button> |
| | | </div> |
| | | </form> |
| | | |
| | |
| | | import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; |
| | | import { DeviceService } from '@business/services/http/device.service'; |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { Device} from '@business/entity/data'; |
| | | import { Device, MonitorPoint} from '@business/entity/data'; |
| | | import { _Validators } from '@delon/abc'; |
| | | import { PageBean, ResultBean } from '@business/entity/grid'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { environment } from '@env/environment'; |
| | | import { ExampleService } from '@business/services/util/example.service'; |
| | | import { Observable } from 'rxjs/Observable'; |
| | | import { OrganizationService } from '@business/services/http/organization.service'; |
| | | |
| | | @Component({ |
| | | selector: 'app-device-edit', |
| | |
| | | public deviceVersions: any [] = []; |
| | | public operateUsers: any [] = []; |
| | | public isSaving = false; |
| | | public configMap: {orgId?: number, mpointId?: number, mpoint?: MonitorPoint} = {orgId: null}; |
| | | public orgOptions = []; |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | private formBuilder: FormBuilder, |
| | |
| | | private versionService: VersionService, |
| | | private operateUserService: OperateUserService, |
| | | private deviceService: DeviceService, |
| | | private http: _HttpClient |
| | | private http: _HttpClient, |
| | | private organizationService: OrganizationService |
| | | ) { } |
| | | data: Device; |
| | | //原始数据记录 |
| | | // 原始数据记录 |
| | | originalData: Device = {}; |
| | | orgId: number = null; |
| | | validateForm: FormGroup; |
| | | ngOnInit() { |
| | | console.log(this.configMap); |
| | | if (!!this.data) { |
| | | Object.assign(this.originalData, this.data); |
| | | } |
| | |
| | | if (this.data.createTime == null) { |
| | | this.data.createTime = new Date().getTime(); |
| | | } |
| | | if (!!this.configMap.mpointId |
| | | && !!this.data.monitorPoint |
| | | && !data.longitude |
| | | && !data.latitude) { |
| | | data.longitude = this.data.monitorPoint.longitude; |
| | | data.latitude = this.data.monitorPoint.latitude; |
| | | } |
| | | data.monitorPointId = !!data.monitorPointId ? data.monitorPointId : this.configMap.mpointId; |
| | | const validates: Device = { |
| | | name: [data.name, [Validators.required]], |
| | | mac: [data.mac, [Validators.required], [this.macAsyncValidator]], |
| | |
| | | this.validateForm = this.formBuilder.group( |
| | | validates |
| | | ); |
| | | this.orgSelectChange(); |
| | | const control = this.validateForm.controls['monitorPointId']; |
| | | control.valueChanges.subscribe(value => { |
| | | const mpoint = ToolsService.getObjById<MonitorPoint>(value, this.monitorPoints); |
| | | this.resetCoor(mpoint); |
| | | }); |
| | | } |
| | | macAsyncValidator = (control: FormControl): any => { |
| | | return Observable.create(observer => { |
| | |
| | | exampleService.or().andEqualTo({name: 'mac', value: control.value}); |
| | | this.deviceService.countByExample(exampleService).subscribe( |
| | | res => { |
| | | debugger; |
| | | if (!!res.code && !!res.data) { |
| | | observer.next({ error: true, duplicated: true }); |
| | | } else { |
| | |
| | | } |
| | | ); |
| | | } |
| | | monitorPointChange(text) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.monitorPointService.getPagingList(pageBean, text).subscribe( |
| | | monitorPointChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 100}; |
| | | const orgId = this.configMap.orgId; |
| | | const example = new ExampleService(); |
| | | text = !!text && !!text.trim() ? text : null; |
| | | example.or() |
| | | .andEqualTo({name: 'organizationId', value: this.configMap.orgId}) |
| | | .andEqualTo({name: 'name', value: text}); |
| | | this.monitorPointService.getPageByExample(pageBean, example).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.monitorPoints = res.data; |
| | |
| | | } |
| | | ); |
| | | } |
| | | orgSelectChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.organizationService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.orgOptions = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | setOrgId(orgId: number) { |
| | | this.configMap.mpointId = null; |
| | | this.monitorPointChange(); |
| | | this.clearMpoint(); |
| | | } |
| | | clearMpoint() { |
| | | ToolsService.setValueToControl(this.validateForm, 'monitorPointId', null); |
| | | this.resetCoor(); |
| | | } |
| | | resetCoor(mpoint?: MonitorPoint) { |
| | | const longitude = !!mpoint ? mpoint.longitude : null; |
| | | const latitude = !!mpoint ? mpoint.latitude : null; |
| | | ToolsService.setValueToControl(this.validateForm, 'longitude', longitude); |
| | | ToolsService.setValueToControl(this.validateForm, 'latitude', latitude); |
| | | } |
| | | } |
| | |
| | | </div> |
| | | <div nz-form-control nz-col [nzSpan]="6" nzHasFeedback> |
| | | <nz-select formControlName="organizationId" [nzPlaceHolder]="'选择 组织(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="OrgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="orgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | |
| | | }) |
| | | export class MonitorPointEditComponent implements OnInit { |
| | | |
| | | orgOptions = []; |
| | | |
| | | orgOptions = []; |
| | | configMap: {organizationId: number}; |
| | | data: MonitorPoint; |
| | | isSaving = false; |
| | | validateForm: FormGroup; |
| | |
| | | value: data.areaCode |
| | | }; |
| | | } |
| | | this.OrgSelectChange(null); |
| | | this.orgSelectChange(null); |
| | | if (!!this.configMap.organizationId && !data.organizationId) { |
| | | data.organizationId = this.configMap.organizationId; |
| | | } |
| | | const validates: MonitorPoint|object = { |
| | | name: [data.name, [Validators.required] ], |
| | | organizationId: [data.organizationId, [Validators.required]], |
| | |
| | | }; |
| | | this.validateForm = this.formBuilder.group( |
| | | validates |
| | | ); |
| | | this.validateForm.controls['organizationId'].valueChanges.subscribe( |
| | | value => { |
| | | this.configMap.organizationId = value; |
| | | } |
| | | ); |
| | | } |
| | | close() { |
| | |
| | | this.data.townCode = codes[3]; |
| | | this.data.villageCode = codes[4]; |
| | | } |
| | | OrgSelectChange(text) { |
| | | orgSelectChange(text) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.organizationService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | |
| | | <pro-header [title]="grid.title"></pro-header> |
| | | <nz-card [nzBordered]="false"> |
| | | <div class="mb-md"> |
| | | <div nz-row class="mb-sm"> |
| | | <div nz-col [nzSpan]="6"> |
| | | <button nz-button (click)="addOrModify($event)" [nzType]="'primary'" [nzSize]="'large'"> |
| | | <i class="anticon anticon-plus"></i><span>新建</span> |
| | | </button> |
| | | <ng-container *ngIf="grid.selectedIndexs.length > 0"> |
| | | <button nz-button [nzSize]="'large'" (click)="deleteSelected()">批量删除</button> |
| | | </ng-container> |
| | | <nz-input [ngStyle]="{'width': '280px','float':'right'}" [(ngModel)]="queryMap.value" name="" [nzPlaceHolder]="queryMap.text" |
| | | (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> |
| | | </div> |
| | | <div nz-col style="text-align:right;padding: 5px 10px;" [nzSm]="6" [nzXs]="24"> |
| | | <label>组织:</label> |
| | | </div> |
| | | <div nz-col [nzSpan]="6"> |
| | | <nz-select style="width: 90%;" [(ngModel)]="queryMap.organizationId" (ngModelChange)="setOrganizationId($event)" [nzPlaceHolder]="'选择 组织(输入名称搜索)'" |
| | | nzAllowClear [nzFilter]="false" nzShowSearch (nzSearchChange)="orgSelectChange($event)" [nzNotFoundContent]="'无法找到'" > |
| | | <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> |
| | | </nz-option> |
| | | </nz-select> |
| | | </div> |
| | | <div nz-col [nzSpan]="6"> |
| | | <nz-input [(ngModel)]="queryMap.mpointName" name="" [nzPlaceHolder]="'请输入监控站名称'" |
| | | (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> |
| | | </div> |
| | | </div> |
| | | <div class="mb-md"> |
| | | <nz-alert *ngIf="grid.selectedIndexs.length > 0" [nzType]="'info'" [nzShowIcon]="true"> |
| | |
| | | import { MonitorPointEditComponent } from 'app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component'; |
| | | import { MonitorPointService } from '@business/services/http/monitor-point.service'; |
| | | import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component'; |
| | | import { OrganizationService } from '@business/services/http/organization.service'; |
| | | import { ExampleService } from '@business/services/util/example.service'; |
| | | |
| | | |
| | | @Component({ |
| | |
| | | }) |
| | | export class MonitorPointComponent implements OnInit { |
| | | |
| | | |
| | | public orgOptions = []; |
| | | private monitorPoint: MonitorPoint; |
| | | grid: Grid<MonitorPoint> = new Grid(null); |
| | | queryMap = { text: '请输入名称', value: '' }; |
| | | queryMap: { mpointName?: string, organizationId?: number } = { mpointName: null, organizationId: null }; |
| | | queryTextStream: Subject<string> = new Subject<string>(); |
| | | private initPage() { |
| | | this.monitorPoint = { |
| | |
| | | constructor( |
| | | private coorPickerService: CoorPickerService, |
| | | private monitorPointService: MonitorPointService, |
| | | |
| | | private confirmServ: NzModalService, |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private organizationService: OrganizationService |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | |
| | | .subscribe(queryText => { |
| | | this.load(); |
| | | }); |
| | | this.orgSelectChange(); |
| | | } |
| | | public setOrganizationId(orgId) { |
| | | this.queryMap.organizationId = orgId; |
| | | this.load(); |
| | | } |
| | | queryTextChanged($event) { |
| | | this.queryTextStream.next(this.queryMap.value); |
| | | this.queryTextStream.next(this.queryMap.mpointName); |
| | | } |
| | | load(reload: boolean = false) { |
| | | if (reload) { |
| | |
| | | setTimeout(() => { |
| | | this.grid.loading = true; |
| | | }, 1); |
| | | this.monitorPointService.getPagingList(this.grid, this.queryMap.value).subscribe( |
| | | const example = new ExampleService(); |
| | | const organizationId = !!this.queryMap.organizationId ? this.queryMap.organizationId : null; |
| | | const mpointName = !!this.queryMap.mpointName ? '%' + this.queryMap.mpointName + '%' : null; |
| | | example.or() |
| | | .andEqualTo({name: 'organizationId', value: organizationId }) |
| | | .andLike({name: 'name', value: mpointName }); |
| | | this.monitorPointService.getPageByExample(this.grid, example).subscribe( |
| | | (res: PageBean) => { |
| | | this.grid.loading = true; |
| | | if (res != null && res.data != null) { |
| | |
| | | if (d != null) { |
| | | Object.assign(data, d); |
| | | } |
| | | this.modalHelper.static(MonitorPointEditComponent, { data }).subscribe( |
| | | const configMap = this.queryMap; |
| | | this.modalHelper.static(MonitorPointEditComponent, { data, configMap }).subscribe( |
| | | (ret: { data: any, close: Function }) => { |
| | | // 修改状态 |
| | | if (ret.data['index'] != null) { |
| | |
| | | } |
| | | ); |
| | | } |
| | | orgSelectChange(text?: string) { |
| | | const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; |
| | | this.organizationService.getPagingList(pageBean, text).subscribe( |
| | | (res: PageBean) => { |
| | | if (res != null && res.data != null) { |
| | | this.orgOptions = res.data; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | } |
| | |
| | | import { DeviceVersion } from '@business/entity/data'; |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { NzMessageService, NzModalSubject } from 'ng-zorro-antd'; |
| | | import { FormGroup, FormBuilder, Validators } from '@angular/forms'; |
| | | |
| | | import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { ResultBean } from '@business/entity/grid'; |
| | | import { Observable } from 'rxjs/Observable'; |
| | | import { ToolsService } from '@business/services/util/tools.service'; |
| | | @Component({ |
| | | selector: 'app-version-edit', |
| | | templateUrl: './version-edit.component.html', |
| | |
| | | }) |
| | | export class VersionEditComponent implements OnInit { |
| | | |
| | | private originalData: DeviceVersion = {}; |
| | | cols: DeviceVersion; |
| | | |
| | | data: DeviceVersion; |
| | | isSaving = false; |
| | | validateForm: FormGroup; |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | private formBuilder: FormBuilder |
| | | private formBuilder: FormBuilder, |
| | | private http: _HttpClient |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | if (this.data.createTime == null) { |
| | | this.data.createTime = new Date().getTime(); |
| | | } |
| | | if (!this.data.version) { |
| | | this.setMaxVersionNo(); |
| | | } |
| | | const validates: DeviceVersion = { |
| | | name: [this.data.name, [Validators.required] ], |
| | | version: [this.data.version == null ? 1 : this.data.version, [Validators.required] ], |
| | | version: [this.data.version, [Validators.required], [this.versionAsyncValidator] ], |
| | | createTime: [this.data.createTime, [Validators.required] ], |
| | | description: [this.data.description] |
| | | }; |
| | | Object.assign(this.originalData, this.data); |
| | | this.validateForm = this.formBuilder.group( |
| | | validates |
| | | ); |
| | | } |
| | | private setMaxVersionNo() { |
| | | this.isSaving = true; |
| | | this.http.get('device-version/get-maxverno').subscribe( |
| | | (res: ResultBean<number>) => { |
| | | if (!!res.code && res.data) { |
| | | ToolsService.setValueToControl(this.validateForm, 'version', res.data + 1); |
| | | }else { |
| | | this.data.version = 1; |
| | | } |
| | | this.isSaving = false; |
| | | } |
| | | ); |
| | | } |
| | | close() { |
| | | this.subject.destroy(); |
| | |
| | | this.validate(); |
| | | } |
| | | } |
| | | versionAsyncValidator = (control: FormControl): any => { |
| | | return Observable.create(observer => { |
| | | if (!!control && !!control.value) { |
| | | // 编辑状态,version未改变 |
| | | if (!!this.originalData && this.originalData.version === control.value) { |
| | | observer.next(null); |
| | | observer.complete(); |
| | | } else { |
| | | this.isSaving = true; |
| | | this.http.get('device-version/get-byversion', {version: control.value} ).subscribe( |
| | | (res: ResultBean<any>) => { |
| | | if (!!res.code && !!res.data) { |
| | | observer.next({ error: true, duplicated: true }); |
| | | } else { |
| | | observer.next(null); |
| | | } |
| | | observer.complete(); |
| | | this.isSaving = false; |
| | | } |
| | | ); |
| | | } |
| | | }else { |
| | | observer.next(null); |
| | | observer.complete(); |
| | | } |
| | | }); |
| | | } |
| | | validate() { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[ i ].markAsDirty(); |
| | |
| | | import { NzModalSubject } from 'ng-zorro-antd'; |
| | | import { ReactiveFormsModule } from '@angular/forms'; |
| | | import { ViewEncapsulation, Component, ViewChild, ElementRef, NgZone } from '@angular/core'; |
| | | import { ViewEncapsulation, Component, ViewChild, ElementRef, NgZone, OnInit } from '@angular/core'; |
| | | import { MapOptions, Point, MarkerOptions, ControlAnchor, NavigationControlOptions, NavigationControlType, BMapInstance } from 'angular2-baidu-map'; |
| | | import { CoorPicker } from '@business/entity/data'; |
| | | import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; |
| | |
| | | templateUrl: './coordinates-picker.component.html', |
| | | styleUrls: [ './coordinates-picker.component.css' ], |
| | | }) |
| | | export class CoordinatesPickerComponent { |
| | | export class CoordinatesPickerComponent implements OnInit { |
| | | Default_LNG = 121; |
| | | Default_LAT = 31.4; |
| | | isSaving = false; |
| | |
| | | _BMap: any = null; |
| | | |
| | | constructor(private subject: NzModalSubject, private coorPickerService: CoorPickerService) { |
| | | |
| | | } |
| | | ngOnInit(): void { |
| | | this.data = this.coorPickerService.data; |
| | | let lng = this.data.longitude; |
| | | lng = lng === 0 || lng == null ? this.Default_LNG : lng; |
| | |
| | | width: -15 |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | private _marker: any = null; |
| | | loadMarker(marker) { |
| | | if (this._marker == null) { |
| | |
| | | this._map.addEventListener( |
| | | 'tilesloaded', |
| | | (type, fn) => { |
| | | this._map.clearOverlays(); |
| | | // this._map.clearOverlays(); |
| | | this._map.addOverlay(this._marker); |
| | | } |
| | | ); |