From 6efb2a0076a544b5714bccba214d81904264540d Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 12 Jun 2018 08:49:31 +0800
Subject: [PATCH] 报表展示 增加镇村选项
---
src/app/routes/devices/basic-info/basic-info.component.ts | 201 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 198 insertions(+), 3 deletions(-)
diff --git a/src/app/routes/devices/basic-info/basic-info.component.ts b/src/app/routes/devices/basic-info/basic-info.component.ts
index 434f272..526253c 100644
--- a/src/app/routes/devices/basic-info/basic-info.component.ts
+++ b/src/app/routes/devices/basic-info/basic-info.component.ts
@@ -1,4 +1,16 @@
-import { Component, OnInit } from '@angular/core';
+import { MonitorPointService } from '@business/services/http/monitor-point.service';
+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 { 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 { 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';
@Component({
selector: 'app-basic-info',
@@ -6,10 +18,193 @@
styles: []
})
export class BasicInfoComponent implements OnInit {
-
- constructor() { }
+ columns: SimpleTableColumn[] = [
+ { title: '������', index: 'id', type: 'checkbox' },
+ { title: '������', index: 'name' },
+ { title: 'mac', index: 'mac' },
+ { title: '������', index: 'deviceVersion.name' },
+ { title: '������������', index: 'monitorPoint.name' },
+ { title: '���������', index: 'operateUser.name' },
+ { title: '������������', width: '100px', type: 'date', index: 'createTime' },
+ { title: '������������', width: '100px', type: 'date', index: 'installTime' },
+ {
+ title: '���������',
+ buttons: [
+ {
+ text: '������',
+ type: 'none',
+ click: (record: any) => this.addOrModify(record)
+ },
+ {
+ text: '������',
+ type: 'del',
+ click: (record: any) => this.delete(record.id)
+ },
+ {
+ text: '������',
+ children: [
+ {
+ text: `���������������`,
+ type: 'static',
+ component: AdjustConfigComponent,
+ format: (record: any) => `<i class="anticon anticon-setting"></i>���������������`
+ },
+ {
+ text: `������������`,
+ type: 'none',
+ click: (record: any) => this.configCoord(record),
+ format: (record: any) => `<i class="anticon anticon-environment-o"></i>������������`
+ }
+ ]
+ }
+ ]
+ }
+ ];
+ queryTextStream: Subject<string> = new Subject<string>();
+ constructor(
+ private monitorPointService: MonitorPointService,
+ private deviceService: DeviceService,
+ private confirmServ: NzModalService,
+ public msgSrv: NzMessageService,
+ private modalHelper: ModalHelper,
+ private coorPickerService: CoorPickerService
+ ) { }
ngOnInit() {
+ this.queryTextStream
+ .debounceTime(900)
+ .distinctUntilChanged()
+ .subscribe(value => {
+ this.extraParams.queryParams = this.deviceService.getSqlParams(value);
+ this.load();
+ });
}
+ get listUrl() {
+ return this.deviceService.getListUrl();
+ }
+ extraParams = { queryParams: null };
+ queryText: string;
+ selectedRows: any[] = [];
+ checkboxChange(list: any[]) {
+ this.selectedRows = list;
+ }
+ deleteSelected() {
+ this.confirmServ.confirm({
+ title: '������������',
+ content: '������������������������������������������������',
+ okText: '������',
+ cancelText: '������'
+ }).on('onOk', () => {
+ if (this.selectedRows != null && this.selectedRows.length > 0) {
+ const ids = this.selectedRows.map(
+ (row: any) => {
+ return Number.parseInt(row.id);
+ }
+ );
+ this.delete(...ids);
+ }
+ });
+ }
+ load() {
+ this.selectedRows = [];
+ this.simpleTable.load();
+ }
+ delete(...id: number[]) {
+ this.deviceService.delete(...id).subscribe(
+ (res: any) => {
+ if (res.code === 1) {
+ this.load();
+ this.msgSrv.success('���������������');
+ }
+ }
+ );
+ }
+ @ViewChild('simpleTable') simpleTable: { load: Function };
+ queryTextChanged(event) {
+ this.queryTextStream.next(this.queryText);
+ }
+ addOrModify(d) {
+ const data = {};
+ if (d != null) {
+ Object.assign(data, d);
+ }
+ this.modalHelper.static(DeviceEditComponent, { data }).subscribe(
+ (ret: { data: any, close: Function }) => {
+ // ������������
+ if (ret.data['id'] != null) {
+ const origData = d;
+ const isModified = Object.keys(ret.data).some(
+ (key: string) => {
+ return ret.data[key] !== origData[key];
+ }
+ );
+ // ������������
+ if (!isModified) {
+ ret.close();
+ this.msgSrv.success('���������������������������');
+ return;
+ }
+ }
+ this.deviceService.save(ret.data).subscribe(
+ (res: any) => {
+ if (res.code === 1) {
+ this.load();
+ ret.close();
+ this.msgSrv.success('���������������������');
+ }
+ }
+ );
+ });
+ }
+ configCoord(record: Device): void {
+ // ������������������������������������������adress������������
+ Object.assign(this.coorPickerService.data, record);
+ this.coorPickerService.data['describe'] = '������������';
+ // ������ ��������������� ������������������
+ if ((!record.latitude || !record.longitude) && !!record.monitorPointId) {
+ this.monitorPointService.getEntity(record.monitorPointId).subscribe(
+ res => {
+ if (res != null && res.code === 1 && res.data != null) {
+ const areaNames = res.data.areaNames;
+ let adress = '';
+ if (areaNames != null) {
+ adress += !!areaNames.provinceName ? areaNames.provinceName : '';
+ adress += ' ';
+ adress += !!areaNames.cityName ? areaNames.cityName : '';
+ adress += ' ';
+ adress += !!areaNames.areaName ? areaNames.areaName : '';
+ adress += ' ';
+ adress += !!res.data.address ? res.data.address : '';
+ }
+ this.coorPickerService.data.address = adress;
+ this.openMap(record);
+ }
+ }
+ );
+ }else {
+ this.openMap(record);
+ }
+ }
+ private openMap(record: Device) {
+ const _data = this.coorPickerService.data;
+ this.modalHelper.static(CoordinatesPickerComponent).subscribe(
+ (staticComp) => {
+ const data: Device = {
+ id: record.id,
+ mac: record.mac,
+ longitude: _data.longitude,
+ latitude: _data.latitude,
+ };
+ this.deviceService.save(data).subscribe(
+ (resp: any) => {
+ if (resp.code === 1) {
+ this.load();
+ this.msgSrv.success('���������������������');
+ }
+ }
+ );
+ }
+ );
+ }
}
--
Gitblit v1.8.0